https://segmentfault.com/a/1190000016179093
菲律賓
朋友實際情況
1、飯店房間:永遠都會有蟑螂(小隻、大隻),旁邊可能有火車、有快速道路吵
2、水電很貴:吹冷氣的話,一個月八九千上下吧
3、網路超爛:公司網路用都會有回應變慢情況,有時手機網路還比公司網路好,手機吃到飽的網路,到一定額度就會變慢速
4、外食:一個月花到1萬,公司有補助的話,會降低費用
=========
70k是20百分比
90k是35%
100k以上好像是45%
这个个人薪资纳税比例
这就是为啥很多公司办理签证的合约都写35000peso的原因 因为这样个人纳税就是5000多peso左右
======
大陽城
鳳凰城
TC Gaming
1、飯店房間:永遠都會有蟑螂(小隻、大隻),旁邊可能有火車、有快速道路吵
2、水電很貴:吹冷氣的話,一個月八九千上下吧
3、網路超爛:公司網路用都會有回應變慢情況,有時手機網路還比公司網路好,手機吃到飽的網路,到一定額度就會變慢速
4、外食:一個月花到1萬,公司有補助的話,會降低費用
=========
- 有賭牌?
- 9g工簽?
- 領美金?
- 包機票?
- 年假?
- 宿舍住到爽?
- 薪水稅後?
- 醫保?
70k是20百分比
90k是35%
100k以上好像是45%
这个个人薪资纳税比例
这就是为啥很多公司办理签证的合约都写35000peso的原因 因为这样个人纳税就是5000多peso左右
======
大陽城
鳳凰城
TC Gaming
Struct to Map by Tag
telegram Gopher 台灣
@winampmaker
https://play.golang.org/p/RObzlfjZSRi
============================
@winampmaker
https://play.golang.org/p/RObzlfjZSRi
func struct2Map(model interface{}, tagName string) map[string]interface{} {
m := make(map[string]interface{})
r := reflect.ValueOf(model)
total := r.NumField()
for i := 0; i < total; i++ {
m[r.Type().Field(i).Tag.Get(tagName)] = r.Field(i).Interface()
}
return m
}
============================
"github.com/fatih/structs"
func StructtoMapbyTag(tr interface{}, tag string) map[string]interface{} {
t := make(map[string]interface{}) //儲存處理過的m
s := structs.New(tr)
m := s.Map() //先轉成map[string]interface{}
for key, value := range m {
t[s.Field(key).Tag(tag)] = value.(string)
}
return t
}
font size conversion px em
https://websemantics.uk/tools/convert-pixel-point-em-rem-percent/
https://websemantics.uk/articles/font-size-conversion/
Point Pixel Em Percent Keyword Default sans-serif
6pt 8px 0.5em 50% Sample
7pt 9px 0.55em 55% Sample
7.5pt 10px 0.625em 62.5% x-small Sample
8pt 11px 0.7em 70% Sample
9pt 12px 0.75em 75% Sample
10pt 13px 0.8em 80% small Sample
10.5pt 14px 0.875em 87.5% Sample
11pt 15px 0.95em 95% Sample
12pt 16px 1em 100% medium Sample
13pt 17px 1.05em 105% Sample
13.5pt 18px 1.125em 112.5% large Sample
14pt 19px 1.2em 120% Sample
14.5pt 20px 1.25em 125% Sample
15pt 21px 1.3em 130% Sample
16pt 22px 1.4em 140% Sample
17pt 23px 1.45em 145% Sample
18pt 24px 1.5em 150% x-large Sample
20pt 26px 1.6em 160% Sample
22pt 29px 1.8em 180% Sample
24pt 32px 2em 200% xx-large Sample
26pt 35px 2.2em 220% Sample
27pt 36px 2.25em 225% Sample
28pt 37px 2.3em 230% Sample
29pt 38px 2.35em 235% Sample
30pt 40px 2.45em 245% Sample
32pt 42px 2.55em 255% Sample
34pt 45px 2.75em 275% Sample
36pt 48px 3em 300% Sample
https://websemantics.uk/articles/font-size-conversion/
Point Pixel Em Percent Keyword Default sans-serif
6pt 8px 0.5em 50% Sample
7pt 9px 0.55em 55% Sample
7.5pt 10px 0.625em 62.5% x-small Sample
8pt 11px 0.7em 70% Sample
9pt 12px 0.75em 75% Sample
10pt 13px 0.8em 80% small Sample
10.5pt 14px 0.875em 87.5% Sample
11pt 15px 0.95em 95% Sample
12pt 16px 1em 100% medium Sample
13pt 17px 1.05em 105% Sample
13.5pt 18px 1.125em 112.5% large Sample
14pt 19px 1.2em 120% Sample
14.5pt 20px 1.25em 125% Sample
15pt 21px 1.3em 130% Sample
16pt 22px 1.4em 140% Sample
17pt 23px 1.45em 145% Sample
18pt 24px 1.5em 150% x-large Sample
20pt 26px 1.6em 160% Sample
22pt 29px 1.8em 180% Sample
24pt 32px 2em 200% xx-large Sample
26pt 35px 2.2em 220% Sample
27pt 36px 2.25em 225% Sample
28pt 37px 2.3em 230% Sample
29pt 38px 2.35em 235% Sample
30pt 40px 2.45em 245% Sample
32pt 42px 2.55em 255% Sample
34pt 45px 2.75em 275% Sample
36pt 48px 3em 300% Sample
Header golang client get
Usually how to tech is
BUT Have problem inside. So.... use this
More Safe.
req, err := http.NewRequest("GET", "http://example.com", nil)
req.Header.Add("Authorize", "dswxswsxw")
resp, err := client.Do(req)
BUT Have problem inside. So.... use this
headers := http.Header{
"Accept-Encoding": []string{"gzip, deflate"},
}
req, err := http.NewRequest("GET", url, nil)
req.Header = headers
client := &http.Client{}
resp, err = client.Do(req)
More Safe.
ffmpeg hls 2~3秒 rtmp
.2秒
ffmpeg -i rtmp://xxx/live/A1 -tune zerolatency -preset faster -vcodec libx264 -b:v 400k -s 720x450 -r 15 -acodec mp3 -g 2 -f ssegment -segment_format mpegts -segment_time 2 -segment_list playlist.m3u8 out%03d.ts
-r 15 帧速率
-s 720x450 分辨率
-b 500k 比特率
-gop 2
-segment_time 2
压缩快慢
-preset ultrafast,superfast, veryfast, faster, fast, medium, slow, slower, veryslow
.3秒
ffmpeg -i rtmp://xxxx/live/A1 -tune zerolatency -preset faster -vcodec libx264 -b:v 400k -s 720x450 -r 15 -acodec mp3 -g 1.5 -f hls -hls_list_size 2 -hls_time 1.5 -hls_wrap 4 playlist.m3u8
-hls_time n:
-hls_list_size n:设置播放列表保存的最多条目
-hls_wrap n:设置多少片之后开始覆盖
ffmpeg -i rtmp://xxx/live/A1 -tune zerolatency -preset faster -vcodec libx264 -b:v 400k -s 720x450 -r 15 -acodec mp3 -g 2 -f ssegment -segment_format mpegts -segment_time 2 -segment_list playlist.m3u8 out%03d.ts
-r 15 帧速率
-s 720x450 分辨率
-b 500k 比特率
-gop 2
-segment_time 2
压缩快慢
-preset ultrafast,superfast, veryfast, faster, fast, medium, slow, slower, veryslow
.3秒
ffmpeg -i rtmp://xxxx/live/A1 -tune zerolatency -preset faster -vcodec libx264 -b:v 400k -s 720x450 -r 15 -acodec mp3 -g 1.5 -f hls -hls_list_size 2 -hls_time 1.5 -hls_wrap 4 playlist.m3u8
-hls_time n:
-hls_list_size n:设置播放列表保存的最多条目
-hls_wrap n:设置多少片之后开始覆盖
GraphQL golang
GraphQL
https://www.thepolyglotdeveloper.com/2018/05/getting-started-graphql-golang/
https://www.thepolyglotdeveloper.com/2018/05/maintain-data-relationships-resolvers-graphql-golang-application/
https://www.thepolyglotdeveloper.com/2018/07/jwt-authorization-graphql-api-using-golang/
https://www.thepolyglotdeveloper.com/2018/05/getting-started-graphql-golang/
https://www.thepolyglotdeveloper.com/2018/05/maintain-data-relationships-resolvers-graphql-golang-application/
https://www.thepolyglotdeveloper.com/2018/07/jwt-authorization-graphql-api-using-golang/
[轉]車 神單業務
https://www.mobile01.com/topicdetail.php?f=618&t=5517840&p=4#40
分享一下自已遇到的二個神單業務,基本上自已換車都直接找他,可以信任也不怕比價!
1、在業界到少15年以上,但就是不接大主管職(專心經營自已的客戶及小團隊)。
2、每年上台領獎,不是全國前三,也至少是全國銷售全國十名內,換過車廠也一樣。
3、三年內一定換業務車,通常是公司獎勵車(我還沒看過他們二年沒換車的)
4、開出來的單不怕比價,通常比過三家營業或朋友介紹的業務還是他最便宜,(開單後幾乎不需要追蹤)
5、不推特仕車或領牌車(除非客人要求),單上外加的配件也全部都是原廠配件,保固期內有問題原廠出單保固換新(增加客戶信認)
6、保險一定退傭金,15%起跳(看險種及保額,第一年通常超過20%),保險一次列出三家的保險內容及費用給我比內容比價,汽車想整理出險一句話,原廠內整理到好(原廠櫃臺出明細表),也可以換大美或鍍膜。
7、保養約時間幾乎都搞的定,農曆年前1個禮拜內的原廠保養或檢修,一個月約都OK,
8、接電話一定馬上叫出客戶的名子
9、到家服務,車子的保養自已沒空跑的話,寫車子的保險單,都可以到家幫我接送車
10、車子有任何問題或事故,在附近的話一定有小團隊的人前來幫忙處理,在遠處的話也會積極處理(事故只需要打第一通給業務的電話,後面業務會幫忙處理並主動告知)。
11、不限自營品牌,沒有適合的車款不硬推,例如小團隊內自已做國產某牌、老公做進口高級某牌、團隊其他業務也有經營其他品牌。
12、服務不斷線,例如公司招待出國旅遊時,電話一定轉接其他小團隊內的業務。
為啥人家可以做到這樣還可以開出神單?
因為人家有固定的客戶群經營出信任感,回頭率高,介紹率高~
因為人家可以有信心每年可以簡單拿到最基本100臺以上的獎金,獎金和競賽獎金都有計算退入訂單內了~
因為人家訂單不怕比價,也不用外廠劣質零件,訂單簡單,簽約快速(不用煩客人客人比完價就知道最便宜了,還要談什麼?),還有別的業務報副廠零件一堆更便宜也不用攻擊,因為客戶是聰明人出保時就知道了。
因為人家經營好(勢力好),就是有辦法交車、保養、出保、出險排前面,
因為人家配合多,大品牌頂級隔熱紙不想在原廠貼沒關係,介紹一樣的品牌門市面大,服務好,技術好價格又便宜,
人脈=錢脈啊~~
[轉]Building a single binary containing templates
https://github.com/gin-gonic/gin/blob/master/examples/assets-in-binary/README.md
gin-jwt
1. Authenticator 回傳的 data
2. data 會丟入到 PayloadFunc
3. PayloadFunc 整理資料寫入 MapClaims
4. Authorizator 再拿 MapClaims 資料出來判斷
新版和舊版有地方不同
type xxxxx struct{
claims := jwt.ExtractClaims(c)
id := claims["aaaaaaa"].(string)
2. data 會丟入到 PayloadFunc
3. PayloadFunc 整理資料寫入 MapClaims
4. Authorizator 再拿 MapClaims 資料出來判斷
新版和舊版有地方不同
type xxxxx struct{
aaaaaaa:string
}
1、
Authenticator: func(userId string, password string, c *gin.Context) (interface{}, bool) {
if v, ok := data.(xxxxx); ok {
id = data.(xxxxx).aaaaaaa
}
1、
Authenticator: func(userId string, password string, c *gin.Context) (interface{}, bool) {
return xxxxx{aaaaaaa: ooooxxxx} or string
2、
PayloadFunc: func(data interface{}) jwt.MapClaims {if v, ok := data.(xxxxx); ok {
id = data.(xxxxx).aaaaaaa
}
return jwt.MapClaims{"aaaaaaa": ooooxxxx, "bbbbbbb": ooooxxxx}
3、
Authorizator: func(data interface{}, c *gin.Context) bool {id := claims["aaaaaaa"].(string)
!注意! Here data is string fmt.Println(reflect.TypeOf(data))
黑蘋果 Hackintosh
https://www.youtube.com/watch?v=h0rl1NpWgIw&index=8&list=PL_kqm4nEkYPsyJEqagiYK9G6uMoeayEM4&t=0s
[轉]為小米路由器3換個靈魂(Padavan)
http://www.badbuta.com/2018/06/02/%E7%82%BA%E5%B0%8F%E7%B1%B3%E8%B7%AF%E7%94%B1%E5%99%A83%E6%8F%9B%E5%80%8B%E9%9D%88%E9%AD%82%EF%BC%88padavan%EF%BC%89/
[轉]別說電玩害了你兒子:經過設計的電玩世界,和你親手幫兒子設計的人生有何不同?
https://buzzorange.com/techorange/2018/06/22/why-game-producers-son-is-not-addicted/
flutter
https://www.youtube.com/watch?v=GLSG_Wh_YWc
Stateless vs Stateful
https://youtu.be/GLSG_Wh_YWc?t=8840
https://youtu.be/GpLb2XvKv20?t=946
https://medium.com/@matthew.smith_66715/why-we-chose-flutter-and-how-its-changed-our-company-for-the-better-271ddd25da60
State
https://www.jianshu.com/p/ed9c3378e9cc
https://tw.saowen.com/a/cff1432eff1eb306314bd241f231b4d693eaaa5aaa5310df9015fc7a0e53c134
androdi 電視盒
有人推 h96 pro +
https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-18274100013.15.335b2dd2ok2ztM&id=551825429534
android 7.1的另一款
https://item.taobao.com/item.htm?spm=2013.1.w4004-18274100020.24.22d870be3f3Rmc&id=560351004511
還有RAM 4G +32G
https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-18274100013.17.602444dcuODOhi&id=563255815946
https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-18274100013.15.335b2dd2ok2ztM&id=551825429534
android 7.1的另一款
https://item.taobao.com/item.htm?spm=2013.1.w4004-18274100020.24.22d870be3f3Rmc&id=560351004511
還有RAM 4G +32G
https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-18274100013.17.602444dcuODOhi&id=563255815946
旗艦 評價
https://www.mobile01.com/topicdetail.php?f=588&t=5469913&p=2#18
崩壞+傳說問我就對了
我崩壞之神
賣過兩個花費超過40萬水晶帳戶全角色2S大畢業全武器大緊繃,現在退休玩兩隻小號
傳說A牌
堅持尋找真裡的玩家也是我
花費超過三個月時間錄影+上傳youtube驗證U11觸控亂跳問題 堪比HTC外包QC
我用過
ZENPHONE 3隻
HTC 5隻
小米2隻
三星6隻
現在用的IPHONE 8 +
以上都買旗艦
主要需求長時間打GAME
會打到機子燒到需要開冷氣和風扇直吹 繼續打的那種
其次聽音樂、FB、看新聞
給你我的評價
HTCM7 神
M8神
M9垃圾
M9+垃圾
E9+垃圾
HTC10 遊戲神+毛病多(幹裡老換完電池觸控斷點,這隻他媽超級燙)
U11超大神+毛病多(超長2年保固螢幕觸控亂跳已解決,和IPHONE8+遊戲玩起來根本一樣 所以給超大神)
三星 I9100 神 刷機後開起威能
note 4 神+毛病多 (大螢幕遊戲神+WIFI
S6 浮誇神 (造型主觀浮誇小啟智哈味,效能神但毛病小多)
S8 浮誇神 (造型主觀浮誇小啟智哈味,效能神但毛病小多)
S9 神神(錢很多可以考慮 效能神毛病小多小卡小延遲)
Zenphone 2 CP小神(剛出玩遊戲夠用,各種浮誇內建APP)
Zenphone 3 遊戲小神+毛病多(螢幕背光+APP各種小問題+組裝品質)
Zenphone 4 遊戲神+毛病多(自家APP好用但毛病多+遊戲神)
紅米note 5
小米5 評價和ASUS旗艦差不多 CP取勝 但毛病以安卓來說比HTC還多
賈伯斯的遺囑 8+ 用到現在覺得和安卓差異極小,而且人會變智障 下次會換回安卓
結論
崩壞三+傳說+照相
IPHONE8+>S9>U11
U11玩遊戲拍照雖然神,但各種毛病 我只能慘讓給三星
起碼三星品質真的穩,沒有HTC毛病這多
Zenphone5 不在同一起跑點 只能場外休息
以上不是浮誇 而是誠心建議
async await Promise.all
async getaaa()
async getbbb()
async getccc()
=======new way=======
async refreshall(){
await Promise.all( xxxxxx.map(async (value, index) =>{
aaa = await getaaa()
}))
await Promise.all( xxxxxx.map(async (value, index) =>{
bbb = await getbbb()
}))
=======old way=======
async refreshall(){
await Promise.all( xxxxxx.map(async (value, index) =>{
aaa = await getaaa()
bbb = await getbbb()
ccc = await getccc()
}))
}
1. map usually return something, here just throw
2. if use foreach(), get error. Like foreach is not function, can't async await.
old way aaa order is good, but bbb ccc order is bad.
new way all aaa bbb ccc order is ok.
async getbbb()
async getccc()
=======new way=======
async refreshall(){
await Promise.all( xxxxxx.map(async (value, index) =>{
aaa = await getaaa()
}))
await Promise.all( xxxxxx.map(async (value, index) =>{
bbb = await getbbb()
}))
await Promise.all( xxxxxx.map(async (value, index) =>{
ccc = await getccc()
}))
}
=======old way=======
async refreshall(){
await Promise.all( xxxxxx.map(async (value, index) =>{
aaa = await getaaa()
bbb = await getbbb()
ccc = await getccc()
}))
}
1. map usually return something, here just throw
2. if use foreach(), get error. Like foreach is not function, can't async await.
old way aaa order is good, but bbb ccc order is bad.
new way all aaa bbb ccc order is ok.
call by value call by reference object array push
Problem:
array A
A.push(item)
item is object from for or map or foreach....etc
show A all add item is same.......
Solve:
var txxxxx = [] // xxxx is any word
=====loop start=====
txxxx[index] = item //index is from for or map or foreach...etc
ot = {
xxxx: txxxx[index]
}
A.push(ot)
=====loop end=====
array A
A.push(item)
item is object from for or map or foreach....etc
show A all add item is same.......
Solve:
var txxxxx = [] // xxxx is any word
=====loop start=====
txxxx[index] = item //index is from for or map or foreach...etc
ot = {
xxxx: txxxx[index]
}
A.push(ot)
=====loop end=====
vue watch v-for
Very easy things, but need some way to pass this difficult.
Problme is async await if your problem is this, now see how to do
1. template or web html
.any input v-model="filter_keywork"
.<p v-for="r in results"> {{r.aaa}} {{r.bbb}} </p>
2. var app data:{
filer_keywork: '',
resuls: [],
}
3. methods:{
getrows(){
this.axios or any http get
},
async filteredRows(){
this.results = await this.getrows()
}
}
4.watch: {
filter_keywork: function(){
this.filteredRows()
}
}
Watch filter_keywork changed to call method this.fileredRows().
This time methods can us async await get back resuls => this.results Then vue render. No async await .... vue sleep.
Problme is async await if your problem is this, now see how to do
1. template or web html
.any input v-model="filter_keywork"
.<p v-for="r in results"> {{r.aaa}} {{r.bbb}} </p>
2. var app data:{
filer_keywork: '',
resuls: [],
}
3. methods:{
getrows(){
this.axios or any http get
},
async filteredRows(){
this.results = await this.getrows()
}
}
4.watch: {
filter_keywork: function(){
this.filteredRows()
}
}
Watch filter_keywork changed to call method this.fileredRows().
This time methods can us async await get back resuls => this.results Then vue render. No async await .... vue sleep.
[轉]區塊鍊 blockshain bitcoin ethereum
非常好的說明 Block
https://www.youtube.com/watch?v=_160oMzblY8
https://anders.com/blockchain/
https://www.inside.com.tw/2018/05/16/monero-hard-fork-success
[轉]Golang 交叉编译跨平台的可执行程序 (Mac、Linux、Windows )
https://www.jisec.com/application-development/753.html
go env
Mac 下编译 Linux 和 Windows 64位可执行程序
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go
Linux 下编译 Mac 和 Windows 64位可执行程序
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go
Windows 下编译 Mac 和 Linux 64位可执行程序
SET CGO_ENABLED=0
SET GOOS=darwin
SET GOARCH=amd64
go build main.go
SET CGO_ENABLED=0
SET GOOS=linux
SET GOARCH=amd64
go build main.go
OS ARCH OS version
linux 386 / amd64 / arm >= Linux 2.6
darwin 386 / amd64 OS X (Snow Leopard + Lion)
freebsd 386 / amd64 >= FreeBSD 7
windows 386 / amd64 >= Windows 2000
go env
Mac 下编译 Linux 和 Windows 64位可执行程序
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go
Linux 下编译 Mac 和 Windows 64位可执行程序
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go
Windows 下编译 Mac 和 Linux 64位可执行程序
SET CGO_ENABLED=0
SET GOOS=darwin
SET GOARCH=amd64
go build main.go
SET CGO_ENABLED=0
SET GOOS=linux
SET GOARCH=amd64
go build main.go
golang []map[string]interface{} sqlx BUT
Golang often us []interface{} or map[string]interface{}
sqlx.Queryx Alternate Scan Types
rows, err := db.Queryx("SELECT * FROM place")
for rows.Next() {
// cols is an []interface{} of all of the column results
cols, err := rows.SliceScan()
}
rows, err := db.Queryx("SELECT * FROM place")
for rows.Next() {
results := make(map[string]interface{})
err = rows.MapScan(results)
}
So
func Sqlselectall(db1 *sqlx.DB, table string) []map[string]interface{} {
rows, err := db1.Queryx("SELECT * FROM " + table)
if err != nil { }
results := []map[string]interface{}{}
for rows.Next() {
result := make(map[string]interface{})
err = rows.MapScan(result)
results = append(results, result)
}
return results
}
BUT results to json use c.JSON(http.StatusOK, results) get warning value
https://stackoverflow.com/questions/39391437/merge-two-or-more-mapstringinterface-types-into-one-in-golang
sqlx.Queryx Alternate Scan Types
rows, err := db.Queryx("SELECT * FROM place")
for rows.Next() {
// cols is an []interface{} of all of the column results
cols, err := rows.SliceScan()
}
rows, err := db.Queryx("SELECT * FROM place")
for rows.Next() {
results := make(map[string]interface{})
err = rows.MapScan(results)
}
So
func Sqlselectall(db1 *sqlx.DB, table string) []map[string]interface{} {
rows, err := db1.Queryx("SELECT * FROM " + table)
if err != nil { }
results := []map[string]interface{}{}
for rows.Next() {
result := make(map[string]interface{})
err = rows.MapScan(result)
results = append(results, result)
}
return results
}
BUT results to json use c.JSON(http.StatusOK, results) get warning value
https://stackoverflow.com/questions/39391437/merge-two-or-more-mapstringinterface-types-into-one-in-golang
法人
http://stockresearchsociety.blogspot.tw/2018/05/57-1400.html
專業的機構,因為他們夠專業所以他們會創造很多名辭及指標去快速判斷公司是否如他們所預期的方向前進,
對於公司產品的競爭力外資群會看毛利率,
對於公司領導人管理能力外資群會看營利率,
對於公司財務長的能力外資會看業外收入,
很多人都會看財報,但他們就是判斷不出來什麼是好,什麼是不好,為什麼判斷不出來?因為他們不會去以某一個基準點去比較,這種感覺就像甲問乙說你老婆長的怎樣,乙回答說長的很漂亮,此時甲判斷出乙老婆長怎樣嗎?應該不行吧,因為
沒有一個基準去比較
,而且甲也不知道乙的品味是怎樣,所以甲無從得知乙的老婆長怎樣。
看完以上的故事後,我們得到一個結論,那就是
1、要嘛就是乙給甲一個比較的基準
2、要嘛就是甲經由平常的觀察去了解乙的品味
我們把這個故事平移到分析財報上面來,
1、要嘛就是我找一個基準點去比較這一季的財報
2、要嘛就是我平常去觀察外資群及法人對某種財報接受的程度以及會做出的反應
很多人分析財報會輸給我,其實你們是輸在第二點,你們不會觀察外資群及法人對某種財報的接受程度及會做出的反應,這也就是我常說的法人心理面。
宏碁第一季的毛利率是10.5%,營利率是1%,奇怪第一季不是淡季嗎?也不用促銷,正常來說毛利率應該要比去年第四季還要好,怎麼會比去年第四季差嗎?
看完以上的故事後,我們得到一個結論,那就是
1、要嘛就是乙給甲一個比較的基準
2、要嘛就是甲經由平常的觀察去了解乙的品味
我們把這個故事平移到分析財報上面來,
1、要嘛就是我找一個基準點去比較這一季的財報
2、要嘛就是我平常去觀察外資群及法人對某種財報接受的程度以及會做出的反應
很多人分析財報會輸給我,其實你們是輸在第二點,你們不會觀察外資群及法人對某種財報的接受程度及會做出的反應,這也就是我常說的法人心理面。
宏碁第一季的毛利率是10.5%,營利率是1%,奇怪第一季不是淡季嗎?也不用促銷,正常來說毛利率應該要比去年第四季還要好,怎麼會比去年第四季差嗎?
去年第一季營收為560億,營業費用為49.97億,
今年第一季營收為548億,營業費用為52.32億,
疑~為什麼今年第一季營收比去年少,營業費用要比去年高呢?目前我們沒有看到整份的財報,但是
若是給外資群來看,他會下的結論就是
產品爭競力是不是變差了,所以毛利率才下降,
是不是管理不夠好,所以才會造成營收比較少,但營業費用卻上升。
札實的投資能力
札實的投資能力不是一天兩能可以達成,除了閱讀再閱讀,親身經歷一些股市的漲跌,投資沒有捷徑,沒有上帝指標,股市比的就是誰犯的錯少,誰的股市常識、知識足,要在股市中生存下來難度很高要學的東西很多如
1、基本面(財報,看出合理價格)=>每一季閱讀財報
2、籌碼面(看出三大法人心理及散戶心態)=>每天追蹤籌碼
3、技術面(投資人的均價,弱點在哪)
4、資金配置(修正錯誤)
5、風險管控(不融資,不過度放大槓桿)
6、三大法人,散戶心理面
7、自我心理面(強化本身的人性弱點)=>這三本書可以幫助你"投資心理學,金融心理學—驅動股市的真正力量,投資人的大腦革命"
8、了解領導者的能力,風格,誠信
看到這,也許有很多小散戶會說,哪來的這麼多美國時間去研究這個,最好是給我技術圖形,給我進出點,給我指標,給我價格,我簡簡單單的就能低買高賣,但是如果股市這麼簡單,就不會是10個投資人9個輸,投資本來就是不容易的事,就像當醫生要讀醫學院,當律師要讀法學院,當工程師要念工學院,這些職業賺到的錢都沒有在股市中多(如果你資金夠大的話),那憑什麼你什麼都不學就想輕易的在股市獲利?
1、基本面(財報,看出合理價格)=>每一季閱讀財報
2、籌碼面(看出三大法人心理及散戶心態)=>每天追蹤籌碼
3、技術面(投資人的均價,弱點在哪)
4、資金配置(修正錯誤)
5、風險管控(不融資,不過度放大槓桿)
6、三大法人,散戶心理面
7、自我心理面(強化本身的人性弱點)=>這三本書可以幫助你"投資心理學,金融心理學—驅動股市的真正力量,投資人的大腦革命"
8、了解領導者的能力,風格,誠信
看到這,也許有很多小散戶會說,哪來的這麼多美國時間去研究這個,最好是給我技術圖形,給我進出點,給我指標,給我價格,我簡簡單單的就能低買高賣,但是如果股市這麼簡單,就不會是10個投資人9個輸,投資本來就是不容易的事,就像當醫生要讀醫學院,當律師要讀法學院,當工程師要念工學院,這些職業賺到的錢都沒有在股市中多(如果你資金夠大的話),那憑什麼你什麼都不學就想輕易的在股市獲利?
cpu scaling freq cpufreq powersave
apt install cpufrequtils
more /etc/init.d/cpufrequtils
cpufreq-set -g powersave
cpufreq-info
=====
lscpu
cat /proc/cpuinfo | grep -i 'mhz'
grep -E '^model name|^cpu MHz' /proc/cpuinfo
cat /sys/devices/system/cpu/cpufreq/policy7/scaling_governor
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
**performance
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -f $CPUFREQ ] || continue; echo -n performance > $CPUFREQ; done
**powersave
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -f $CPUFREQ ] || continue; echo -n powersave > $CPUFREQ; done
echo "powersave" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
=====
more /etc/init.d/cpufrequtils
cpufreq-set -g powersave
cpufreq-info
=====
lscpu
cat /proc/cpuinfo | grep -i 'mhz'
grep -E '^model name|^cpu MHz' /proc/cpuinfo
cat /sys/devices/system/cpu/cpufreq/policy7/scaling_governor
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
**performance
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -f $CPUFREQ ] || continue; echo -n performance > $CPUFREQ; done
**powersave
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -f $CPUFREQ ] || continue; echo -n powersave > $CPUFREQ; done
echo "powersave" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
=====
資源 成本
公司對內部人員陛升還有外部人員空降這件事,可以決定主管的態度是把人當資源還是成本
資源會成長
成本要控制
不相信人是資源的人,內部的人資系統不太會有培訓的機制,寧願花大錢買不懂你文化的人進來
setio.sh
https://raw.githubusercontent.com/centminmod/centminmod/123.09beta01/tools/setio.sh
https://community.centminmod.com/threads/centmin-mod-09-beta-branch-testing.4128/page-13#post-25695
https://community.centminmod.com/threads/centmin-mod-09-beta-branch-testing.4128/page-13#post-25695
年線 財報 價格
真的想投資宏碁的人,如果你現在空手,且你非常看好宏碁未來優化的能力,請嚴守資金配置,儘量花一年來怖局,把你的成本怖在半年線及年線,怖在半年線,至少宏碁開過兩次財報,讓市場驗證過半年這股價是不是有效,怖在年線,至少你看過四次財報,而且這價格經市場驗證過一年是有效的,有人說,半年線?現在不是19.2元嗎?難道要怖在19.2元嗎?當然不是,接下來的半年如果宏碁股價有本事一直維持在28~30之間,那半年線就會在28~30之間,這半年你至少要看到兩次的財報,如果兩次財報開完,宏碁還有本事站在28~30,那代表市場認同這價格,上次宏碁開第三季財報0.48元,市場驗證後,是從16漲到22然後在20.x產生穩態一個月,剩下的價格都還沒有經過財報的考驗,所以千萬不天真的覺得看到33.75,宏碁就值33.75, 現在27.x元,宏碁就值27.x元,等到2018/3/31和2018/5/15開完那次財報,大家等一個月,那時呈現出來的股價能是有意義的,真正有經過財報及市場的考驗
一周一次的集保股權階怖出爐了
2018/1/27 12:42
之前宏碁在上漲時,1~10張的打死都不會增加,現在主力拉了一個錨點33.75元然後跌下來到27.6元,這些散戶突然間就覺得宏碁好便宜啊,
之前同事在20,22時一直求我賣,他說你賣個3張也好啦,都從14漲到22了,都漲8元了,不可能這樣一直漲上去啦,我沒有理他,結果股價從22.x跌到20.x後,他就說,你看吧,跌了吧,股價漲上去你沒有賣都是假的啦,我也沒有理會他。直到宏碁一直漲,狂漲到33.75元後,跌到30.x元,他說他要買了,我聽了差點沒有昏倒,為什麼22你叫我賣,30.x你卻要買?宏碁基本面有改變嗎?似乎沒有,所以他這症狀就是大部散戶的症狀,中了錨定效和加一點後悔效應,覺得宏碁從14漲到33.75一路漲沒賺到,心理一直一直很恨,結果33.75跌到30,甚至是27.3元,他們就會覺得這是從天上掉下來的禮物,趕快加碼買進。
這周1~10張的散戶狂增9113人,買了股票24990張,算是非理性的買法,這就是成交量很大所會造成的現象,不要天真的以為什麼10萬張籌定籌碼可以避免這周從33.75跌到27.6,我說過,這叫做狗犬火車頭,不要以為火車是被你吠走的,這是市場的趨勢,必然會發生的事,這人性弱點叫"代表性原則錯誤",常常看我的文章,或聽到某個人說賣出,就以為整件事是因他而發生的,之前ptt有一個人賣了800張,結果ptt就一片拜神說,原來宏碁的大跌是他引發的。一位宏碁股東賣出了9xx張,他後來寫信來和我說對不起,覺得宏碁大跌是他引發的,有一些人就在怪罪別人賣了1張,2張拿錢出來買產品,所以引發宏碁大跌,也有人怪罪有人高檔調節,所以引發宏碁大跌…等,說真的,那就是"代表性原則錯誤",市場上會發生的事就是會發生,這周宏碁的成交量是974304張,意思就是這周每一天宏碁成交量是20萬張,你沒有看錯就是20萬張,區區的幾百,幾仟,一兩萬張,你以為火車頭真的是被狗吠走的,會因為別人做了一些調整後,覺得宏碁就是被那些人搞下來的,無知的程度可比古代人處理天狗食月的想法,"老百姓見月亮沒瞭,就拿起銅鑼、盆子、鍋蓋,紛紛跑出屋子,邊敲邊喊:天狗吃月瞭,快打快打呀 打死它,打死它,咱們要月亮!"
要看出市場怎麼走,你要研究、觀察、記錄出真實的情況,最終自已心理有所準備,難道我該睜著眼說瞎話的去記錄我看到的東西,這文章是我未來自已要看的,為什麼我要睜著眼說瞎話,記錄下錯的東西,單純要讓大家開心,這樣未來我回頭自已看的時候,看到的就是沒有意義的東西。如果覺得我寫的不喜歡,自已可以去研究,觀察,記錄嘛,然後一周後回頭看看,是不是和你推測的一樣,反正股市中我們有的是時間,一周開盤五次,自已慢慢驗證,如果自已寫了老半天,一周回頭看,和你自已寫的完全是不符合的,走勢和自已推測的也差很多時,你就會知道誰研究,記錄、觀察的才是對的,這不是很公平嗎?
之前宏碁在上漲時,1~10張的打死都不會增加,現在主力拉了一個錨點33.75元然後跌下來到27.6元,這些散戶突然間就覺得宏碁好便宜啊,
之前同事在20,22時一直求我賣,他說你賣個3張也好啦,都從14漲到22了,都漲8元了,不可能這樣一直漲上去啦,我沒有理他,結果股價從22.x跌到20.x後,他就說,你看吧,跌了吧,股價漲上去你沒有賣都是假的啦,我也沒有理會他。直到宏碁一直漲,狂漲到33.75元後,跌到30.x元,他說他要買了,我聽了差點沒有昏倒,為什麼22你叫我賣,30.x你卻要買?宏碁基本面有改變嗎?似乎沒有,所以他這症狀就是大部散戶的症狀,中了錨定效和加一點後悔效應,覺得宏碁從14漲到33.75一路漲沒賺到,心理一直一直很恨,結果33.75跌到30,甚至是27.3元,他們就會覺得這是從天上掉下來的禮物,趕快加碼買進。
這周1~10張的散戶狂增9113人,買了股票24990張,算是非理性的買法,這就是成交量很大所會造成的現象,不要天真的以為什麼10萬張籌定籌碼可以避免這周從33.75跌到27.6,我說過,這叫做狗犬火車頭,不要以為火車是被你吠走的,這是市場的趨勢,必然會發生的事,這人性弱點叫"代表性原則錯誤",常常看我的文章,或聽到某個人說賣出,就以為整件事是因他而發生的,之前ptt有一個人賣了800張,結果ptt就一片拜神說,原來宏碁的大跌是他引發的。一位宏碁股東賣出了9xx張,他後來寫信來和我說對不起,覺得宏碁大跌是他引發的,有一些人就在怪罪別人賣了1張,2張拿錢出來買產品,所以引發宏碁大跌,也有人怪罪有人高檔調節,所以引發宏碁大跌…等,說真的,那就是"代表性原則錯誤",市場上會發生的事就是會發生,這周宏碁的成交量是974304張,意思就是這周每一天宏碁成交量是20萬張,你沒有看錯就是20萬張,區區的幾百,幾仟,一兩萬張,你以為火車頭真的是被狗吠走的,會因為別人做了一些調整後,覺得宏碁就是被那些人搞下來的,無知的程度可比古代人處理天狗食月的想法,"老百姓見月亮沒瞭,就拿起銅鑼、盆子、鍋蓋,紛紛跑出屋子,邊敲邊喊:天狗吃月瞭,快打快打呀 打死它,打死它,咱們要月亮!"
要看出市場怎麼走,你要研究、觀察、記錄出真實的情況,最終自已心理有所準備,難道我該睜著眼說瞎話的去記錄我看到的東西,這文章是我未來自已要看的,為什麼我要睜著眼說瞎話,記錄下錯的東西,單純要讓大家開心,這樣未來我回頭自已看的時候,看到的就是沒有意義的東西。如果覺得我寫的不喜歡,自已可以去研究,觀察,記錄嘛,然後一周後回頭看看,是不是和你推測的一樣,反正股市中我們有的是時間,一周開盤五次,自已慢慢驗證,如果自已寫了老半天,一周回頭看,和你自已寫的完全是不符合的,走勢和自已推測的也差很多時,你就會知道誰研究,記錄、觀察的才是對的,這不是很公平嗎?
ffmpeg
https://sonnati.wordpress.com/2011/08/08/ffmpeg-%E2%80%93-the-swiss-army-knife-of-internet-streaming-%E2%80%93-part-ii/
python 3 pandas matplotlib.pyplot
寫程式這麼久,python真的有夠難寫的,網路上一堆範例都有語法上的錯誤或不完整的,後來經由大陸某教學網終於成功
https://morvanzhou.github.io/tutorials/data-manipulation/np-pd/3-8-pd-plot/
1、donwload python3 from python website
2、create aaa.py put context
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
print(ts)
ts.plot()
plt.show() //This is best important!!
3、python aaa.py then see error. Usually is package not install. So just pip install
import matplotlib.pyplot as plt # pip install matplotlib
import pandas as pd # pip install pandas
https://morvanzhou.github.io/tutorials/data-manipulation/np-pd/3-8-pd-plot/
1、donwload python3 from python website
2、create aaa.py put context
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
print(ts)
ts.plot()
plt.show() //This is best important!!
3、python aaa.py then see error. Usually is package not install. So just pip install
import matplotlib.pyplot as plt # pip install matplotlib
import pandas as pd # pip install pandas
see screen have notis, just follow install.
windows docker go
1、go
mkdir directory aaa
create file go_httpserver.go
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome to my Website!!!\n %s", r.URL.Path[1:])
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe("0.0.0.0:80", nil)
}
set GOARCH=amd64
FROM scratch
ADD go_httpserver /
ENTRYPOINT ["/go_httpserver"]
mkdir directory aaa
create file go_httpserver.go
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome to my Website!!!\n %s", r.URL.Path[1:])
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe("0.0.0.0:80", nil)
}
set GOOS=linux
go build go_httpserver.go => get linux go program
2、create docker image
2.1 install docker toolbox Link
2.2 run kitematic then see left-down DOCKER CLI , click it, then
2.2.1 create directory bbb
2.2.2 create Dockerfile
ADD go_httpserver /
ENTRYPOINT ["/go_httpserver"]
docker buid -t testdockergoweb:v1 .
2.2.3 use kitematic left-up +NEW -> My Images -> CREATE just crate image
2.2.4 now Containers list have testdockergoweb running. see right-up Settings
-> Hostname / Ports -> change
DOCKER PORT 80
PUBLISHED IP:PORT port->3111
SAVE
then
click PUBLISHED IP:PORT list have bule link.
3、export docker image
in DOCKER CLI -> docker export testdockergoweb > testdockergoweb.tar
眼光費
http://stockresearchsociety.blogspot.tw/2017/12/1211414.html
- 做短線、想做差價前,就下虛擬單 你寫下來進入點, 要出時寫下賣出點,十次實驗,對的機率有7成以上,可以做差價
- 如果你的公司值20元,一年能賺3元,目前股價60元,你能說,一年賺3元,本益比20倍,所以60元很便宜,說這種話,我聽了都覺得很好笑。一年能賺3元,公司值20元,你要年年賺3元賺13.x年才賺到到60元,結果你竟然在一季賺了0.75元,你就開始幻想這樣的賺法13年後你就回本。
- 巴非特之所以不敗,原因很簡單,公司值20元,他在股價打7折、8折時,14~16元然後看出這家公司體質改善了,未來會賺錢,走上正確的方向機率很大,巴非特就大力的買在那個價格,然後用時間去換報酬,這樣的投資才是最安全的,沒有被一些人拿走未來15年,20年的獲利當眼光費。
- 投資為什麼常常會賠錢?因為你沒有估價的能力,也沒有耐心,也不會為你的投資做長久的設想,所以很容易一時亂了手腳
- 眼光費
加回匯率因素,XXX淨值約19.7元,目前看一年能賺1~1.2元,我20投資XXX,我等一年,XXX賺1~1.2元,我等兩年XXX賺2~2.4元,兩年後,三年後XXX獲利穩定後,一般世俗的眼光費套在XXX上,大家再選一個氣氛很好,如財報很好或是大盤氣氛很好的時間點,隨隨便便也是一個很大的報酬率,除了本身公司獲利你穩賺的股息外,總是能等到別人給你10~15年獲利當眼光費的一天,一等到你就賺了10~15年的獲利了嗎?要最大化你在XXX最大的報酬,絕對不會是20,21,21元去賣掉覺得自已賺好多,你要最大化XXX的獲利,一定是在一年後,兩年後的某一天,而那一天只要XXX持續優化的情況下,一定會到來,那時才會是你得到最大報酬率的時候
Azure function
headers: {
'Content-Type': 'application/json'
},
body: {
ip: (
req.headers['x-forwarded-for'].split(":")[0]
//req.headers['x-forwarded-for'] //||
//req.connection.remoteAddress ||
//req.socket.remoteAddress //||
//req.connection.socket.remoteAddress
)
}
[轉]第一次在 GCP Storage 放置靜態網頁就上手
https://coder.tw/?p=7626
1. install gcloud
2. gcloud auth login `email` #login auth email, get rights for change 公開
2.1 gcloud auth revoke `email` #remove auth email
1. install gcloud
2. gcloud auth login `email` #login auth email, get rights for change 公開
2.1 gcloud auth revoke `email` #remove auth email
https://cloud.google.com/sdk/gcloud/reference/auth/login
設定 Bucket 新上傳的檔案預設公開,只能針對 Bucket 設定,不朔及既往
設定某資料夾(or Bucket)底下所有檔案、目錄為公開
設定 Bucket 新上傳的檔案預設公開,只能針對 Bucket 設定,不朔及既往
gsutil defacl set public-read gs://s.ntust.me
設定某資料夾(or Bucket)底下所有檔案、目錄為公開
gsutil acl set -r public-read gs://s.ntust.me/iatp
股
- 每季報告
- 第四季:因為明年3月才會公布財報,所以第三季公佈後到明年3月,近半年時間,是沒有任何依據,第3季公佈成績好,自然可以撐到明年3月,公佈成績不好,也是同樣不好到明年3月,除非有特殊情況,否則沒人看第四季的。
- 外資
- 在大洗盤,把散戶洗走:外資看好這支股票,為了增加獲利,壓低股價,嚇散戶自願出場,買下低成本股票,增加持有股數,等待最終獲利。
- 這段期間不可能讓成本上升,就算上升也會想盡辨法壓低,如果壓不下來,外資持有成本也同樣壓不下來,獲利就不能提高。
- 一般散戶受不了壓力,就直接出場,因為這是長時間,非短期操作。
- 要補單要在大盤情況也不好大跌跟補單
nginx proxy pass [ best practices ] 2 for sysctl tcp
.https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
http://www.queryadmin.com/1654/tuning-linux-kernel-tcp-parameters-sysctl/
https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
Don't USE
net.ipv4.tcp_tw_recycle=1
—don’t use it—it was already broken for users behind NAT, but if you upgrade your kernel, it will be broken for everyone.
net.ipv4.tcp_timestamps=0
—don’t disable them unless you know all side-effects and you are OK with them. For example, one of non-obvious side effects is that you will loose window scaling and SACK options on syncookies.
https://read01.com/zh-tw/KBgmj7.html
Don't USE
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_tw_reuse=1 /*Only you know, sometime can do*/
***********sysctl**************
net.ipv4.tcp_mtu_probing=1
# Increase number of max open-files
fs.file-max = 150000
# Increase max number of PIDs
kernel.pid_max = 4194303
# Increase range of ports that can be used
net.ipv4.ip_local_port_range = 1024 65535
# https://tweaked.io/guide/kernel/
# Forking servers, like PostgreSQL or Apache, scale to much higher levels of concurrent connections if this is made larger
kernel.sched_migration_cost_ns=5000000
# https://tweaked.io/guide/kernel/
# Various PostgreSQL users have reported (on the postgresql performance mailing list) gains up to 30% on highly concurrent workloads on multi-core systems
kernel.sched_autogroup_enabled = 0
# https://github.com/ton31337/tools/wiki/tcp_slow_start_after_idle---tcp_no_metrics_save-performance
# Avoid falling back to slow start after a connection goes idle
net.ipv4.tcp_slow_start_after_idle=0
net.ipv4.tcp_no_metrics_save=0
# https://github.com/ton31337/tools/wiki/Is-net.ipv4.tcp_abort_on_overflow-good-or-not%3F
net.ipv4.tcp_abort_on_overflow=0
# Enable TCP window scaling (enabled by default)
# https://en.wikipedia.org/wiki/TCP_window_scale_option
net.ipv4.tcp_window_scaling=1
# Enables fast recycling of TIME_WAIT sockets.
# (Use with caution according to the kernel documentation!)
#net.ipv4.tcp_tw_recycle = 1
# Allow reuse of sockets in TIME_WAIT state for new connections
# only when it is safe from the network stack’s perspective.
#net.ipv4.tcp_tw_reuse = 1
# Turn on SYN-flood protections
net.ipv4.tcp_syncookies=1
# Only retry creating TCP connections twice
# Minimize the time it takes for a connection attempt to fail
net.ipv4.tcp_syn_retries=2
net.ipv4.tcp_synack_retries=2
net.ipv4.tcp_orphan_retries=2
# How many retries TCP makes on data segments (default 15)
# Some guides suggest to reduce this value
net.ipv4.tcp_retries2=8
# Optimize connection queues
# https://www.linode.com/docs/web-servers/nginx/configure-nginx-for-optimized-performance
# Increase the number of packets that can be queued
net.core.netdev_max_backlog = 3240000
# Max number of "backlogged sockets" (connection requests that can be queued for any given listening socket)
net.core.somaxconn = 50000
# Increase max number of sockets allowed in TIME_WAIT
net.ipv4.tcp_max_tw_buckets = 1440000
# Number of packets to keep in the backlog before the kernel starts dropping them
# A sane value is net.ipv4.tcp_max_syn_backlog = 3240000
net.ipv4.tcp_max_syn_backlog = 3240000
# TCP memory tuning
# View memory TCP actually uses with: cat /proc/net/sockstat
# *** These values are auto-created based on your server specs ***
# *** Edit these parameters with caution because they will use more RAM ***
# Changes suggested by IBM on https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Welcome%20to%20High%20Performance%20Computing%20%28HPC%29%20Central/page/Linux%20System%20Tuning%20Recommendations
# Increase the default socket buffer read size (rmem_default) and write size (wmem_default)
# *** Maybe recommended only for high-RAM servers? ***
net.core.rmem_default=16777216
net.core.wmem_default=16777216
# Increase the max socket buffer size (optmem_max), max socket buffer read size (rmem_max), max socket buffer write size (wmem_max)
# 16MB per socket - which sounds like a lot, but will virtually never consume that much
# rmem_max over-rides tcp_rmem param, wmem_max over-rides tcp_wmem param and optmem_max over-rides tcp_mem param
net.core.optmem_max=16777216
net.core.rmem_max=16777216
net.core.wmem_max=16777216
# Configure the Min, Pressure, Max values (units are in page size)
# Useful mostly for very high-traffic websites that have a lot of RAM
# Consider that we already set the *_max values to 16777216
# So you may eventually comment these three lines
net.ipv4.tcp_mem=16777216 16777216 16777216
net.ipv4.tcp_wmem=4096 87380 16777216
net.ipv4.tcp_rmem=4096 87380 16777216
# Keepalive optimizations
# By default, the keepalive routines wait for two hours (7200 secs) before sending the first keepalive probe,
# and then resend it every 75 seconds. If no ACK response is received for 9 consecutive times, the connection is marked as broken.
# The default values are: tcp_keepalive_time = 7200, tcp_keepalive_intvl = 75, tcp_keepalive_probes = 9
# We would decrease the default values for tcp_keepalive_* params as follow:
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 9
# The TCP FIN timeout belays the amount of time a port must be inactive before it can reused for another connection.
# The default is often 60 seconds, but can normally be safely reduced to 30 or even 15 seconds
# https://www.linode.com/docs/web-servers/nginx/configure-nginx-for-optimized-performance
net.ipv4.tcp_fin_timeout = 7
***********sysctl**************
==PS==
.net.ipv4.tcp_slow_start_after_idle & net.ipv4.tcp_no_metrics_save
https://github.com/ton31337/tools/wiki/tcp_slow_start_after_idle---tcp_no_metrics_save-performance
http://www.queryadmin.com/1654/tuning-linux-kernel-tcp-parameters-sysctl/
https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
Don't USE
net.ipv4.tcp_tw_recycle=1
—don’t use it—it was already broken for users behind NAT, but if you upgrade your kernel, it will be broken for everyone.
net.ipv4.tcp_timestamps=0
—don’t disable them unless you know all side-effects and you are OK with them. For example, one of non-obvious side effects is that you will loose window scaling and SACK options on syncookies.
https://read01.com/zh-tw/KBgmj7.html
Don't USE
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_tw_reuse=1 /*Only you know, sometime can do*/
***********sysctl**************
net.ipv4.tcp_mtu_probing=1
# Increase number of max open-files
fs.file-max = 150000
# Increase max number of PIDs
kernel.pid_max = 4194303
# Increase range of ports that can be used
net.ipv4.ip_local_port_range = 1024 65535
# https://tweaked.io/guide/kernel/
# Forking servers, like PostgreSQL or Apache, scale to much higher levels of concurrent connections if this is made larger
kernel.sched_migration_cost_ns=5000000
# https://tweaked.io/guide/kernel/
# Various PostgreSQL users have reported (on the postgresql performance mailing list) gains up to 30% on highly concurrent workloads on multi-core systems
kernel.sched_autogroup_enabled = 0
# https://github.com/ton31337/tools/wiki/tcp_slow_start_after_idle---tcp_no_metrics_save-performance
# Avoid falling back to slow start after a connection goes idle
net.ipv4.tcp_slow_start_after_idle=0
net.ipv4.tcp_no_metrics_save=0
# https://github.com/ton31337/tools/wiki/Is-net.ipv4.tcp_abort_on_overflow-good-or-not%3F
net.ipv4.tcp_abort_on_overflow=0
# Enable TCP window scaling (enabled by default)
# https://en.wikipedia.org/wiki/TCP_window_scale_option
net.ipv4.tcp_window_scaling=1
# Enables fast recycling of TIME_WAIT sockets.
# (Use with caution according to the kernel documentation!)
#net.ipv4.tcp_tw_recycle = 1
# Allow reuse of sockets in TIME_WAIT state for new connections
# only when it is safe from the network stack’s perspective.
#net.ipv4.tcp_tw_reuse = 1
# Turn on SYN-flood protections
net.ipv4.tcp_syncookies=1
# Only retry creating TCP connections twice
# Minimize the time it takes for a connection attempt to fail
net.ipv4.tcp_syn_retries=2
net.ipv4.tcp_synack_retries=2
net.ipv4.tcp_orphan_retries=2
# How many retries TCP makes on data segments (default 15)
# Some guides suggest to reduce this value
net.ipv4.tcp_retries2=8
# Optimize connection queues
# https://www.linode.com/docs/web-servers/nginx/configure-nginx-for-optimized-performance
# Increase the number of packets that can be queued
net.core.netdev_max_backlog = 3240000
# Max number of "backlogged sockets" (connection requests that can be queued for any given listening socket)
net.core.somaxconn = 50000
# Increase max number of sockets allowed in TIME_WAIT
net.ipv4.tcp_max_tw_buckets = 1440000
# Number of packets to keep in the backlog before the kernel starts dropping them
# A sane value is net.ipv4.tcp_max_syn_backlog = 3240000
net.ipv4.tcp_max_syn_backlog = 3240000
# TCP memory tuning
# View memory TCP actually uses with: cat /proc/net/sockstat
# *** These values are auto-created based on your server specs ***
# *** Edit these parameters with caution because they will use more RAM ***
# Changes suggested by IBM on https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Welcome%20to%20High%20Performance%20Computing%20%28HPC%29%20Central/page/Linux%20System%20Tuning%20Recommendations
# Increase the default socket buffer read size (rmem_default) and write size (wmem_default)
# *** Maybe recommended only for high-RAM servers? ***
net.core.rmem_default=16777216
net.core.wmem_default=16777216
# Increase the max socket buffer size (optmem_max), max socket buffer read size (rmem_max), max socket buffer write size (wmem_max)
# 16MB per socket - which sounds like a lot, but will virtually never consume that much
# rmem_max over-rides tcp_rmem param, wmem_max over-rides tcp_wmem param and optmem_max over-rides tcp_mem param
net.core.optmem_max=16777216
net.core.rmem_max=16777216
net.core.wmem_max=16777216
# Configure the Min, Pressure, Max values (units are in page size)
# Useful mostly for very high-traffic websites that have a lot of RAM
# Consider that we already set the *_max values to 16777216
# So you may eventually comment these three lines
net.ipv4.tcp_mem=16777216 16777216 16777216
net.ipv4.tcp_wmem=4096 87380 16777216
net.ipv4.tcp_rmem=4096 87380 16777216
# Keepalive optimizations
# By default, the keepalive routines wait for two hours (7200 secs) before sending the first keepalive probe,
# and then resend it every 75 seconds. If no ACK response is received for 9 consecutive times, the connection is marked as broken.
# The default values are: tcp_keepalive_time = 7200, tcp_keepalive_intvl = 75, tcp_keepalive_probes = 9
# We would decrease the default values for tcp_keepalive_* params as follow:
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 9
# The TCP FIN timeout belays the amount of time a port must be inactive before it can reused for another connection.
# The default is often 60 seconds, but can normally be safely reduced to 30 or even 15 seconds
# https://www.linode.com/docs/web-servers/nginx/configure-nginx-for-optimized-performance
net.ipv4.tcp_fin_timeout = 7
***********sysctl**************
==PS==
.net.ipv4.tcp_slow_start_after_idle & net.ipv4.tcp_no_metrics_save
https://github.com/ton31337/tools/wiki/tcp_slow_start_after_idle---tcp_no_metrics_save-performance
bbr Kernel 4.9.51
aws linux 官方
https://aws.amazon.com/tw/amazon-linux-ami/2017.09-release-notes/
ubuntu
https://segmentfault.com/a/1190000008395823
https://farer.org/2017/05/18/build-kernel-with-bbr-on-ec2-amazon-linux/
修改/etc/sysctl.conf文件,加入如下两行:
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
檢查
cat /proc/sys/net/ipv4/tcp_congestion_control
https://aws.amazon.com/tw/amazon-linux-ami/2017.09-release-notes/
ubuntu
https://segmentfault.com/a/1190000008395823
https://farer.org/2017/05/18/build-kernel-with-bbr-on-ec2-amazon-linux/
修改/etc/sysctl.conf文件,加入如下两行:
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
檢查
cat /proc/sys/net/ipv4/tcp_congestion_control
move to ionic3
1、update every things to ionic3 uninstall, install , update npm....etc
2、use ionic 3, create new project, run, sure can run on android.
3、copy old config.xml data to new config.xml
4、change new project src -> src1, then copy old project src.
4.1、 code have any ionic-native change @ionic-native/xxxxxxxxx
4.2 、src/app/app.module.ts
.top add import { BrowserModule } from '@angular/platform-browser';
.import、providers same 4.1
4.3、copy new project src/index.html 、 src/service-worker.js
then try ionic cordova android --emulator
2、use ionic 3, create new project, run, sure can run on android.
3、copy old config.xml data to new config.xml
4、change new project src -> src1, then copy old project src.
4.1、 code have any ionic-native change @ionic-native/xxxxxxxxx
4.2 、src/app/app.module.ts
.top add import { BrowserModule } from '@angular/platform-browser';
.import、providers same 4.1
4.3、copy new project src/index.html 、 src/service-worker.js
then try ionic cordova android --emulator
[轉]在大陸來往近10年定居5年,而去年我回台灣了。
https://www.mobile01.com/topicdetail.php?f=651&t=5310046
https://www.mobile01.com/topicdetail.php?f=651&t=5310046#10
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=2#11
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=2#14
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=2#15
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=3#26
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=4#40
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=18#176
https://www.mobile01.com/topicdetail.php?f=651&t=5310046#10
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=2#11
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=2#14
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=2#15
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=3#26
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=4#40
https://www.mobile01.com/topicdetail.php?f=651&t=5310046&p=18#176
nginx proxy pass [ best practices ]
1、/etc/nginx/nginx.conf
worker_processes 1; #auto;
events {
worker_connections 3000; #786;
# multi_accept on;
}
http {
server_tokens off; #open this line
resolver 8.8.8.8 8.8.4.4 valid=300s; #resolver dns server
proxy_cache_path /var/cache/proxy-nginx levels=1:2 keys_zone=proxy-cache:10m max_size=3g inactive=1d use_temp_path=off;
log_format main '$remote_addr $status $request $body_bytes_sent [$time_local] $http_user_agent $http_referer $http_x_forwarded_for $upstream_addr $upstream_status $upstream_cache_status $upstream_response_time';
access_log /var/log/nginx/access.log main buffer=1m; #or maybe note # because disk space
log_format cache_status '[$time_local] "$request" $upstream_cache_status';
access_log /var/log/nginx/cache_access.log cache_status;
client_max_body_size 100M;
------------------
#slice 1m; # for slice_range
#try_files $uri $uri/ =404;
server {
set $ds_host_ip 'xxx.xxx.xxx.xxx';
set $ds_hostname 'ooo.ooo.ooo.ooo';
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
location /nginx_status {
stub_status on;
access_log off;
}
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
}
make clean; ./configure --with-file-aio --without-http_autoindex_module --without-http_browser_module --without-http_geo_module --without-http_empty_gif_module --without-http_map_module --without-http_memcached_module --without-http_userid_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_split_clients_module --without-http_uwsgi_module --without-http_scgi_module --without-http_referer_module --without-http_upstream_ip_hash_module && make && make install
----------------------------------------------
.https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
https://www.mobile01.com/topicdetail.php?f=506&t=5147355
--auto nginx mod CENTMIN MOD
https://centminmod.com/
.https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
https://cipherli.st/
On ssl_session_tickets dropbox & cipherli.st have different way............. maybe use cipherli.st
#ssl_session_timeout 1h;
#ssl_session_ticket_key /run/nginx-ephemeral/nginx_session_ticket_curr;
#ssl_session_ticket_key /run/nginx-ephemeral/nginx_session_ticket_prev;
#ssl_session_ticket_key /run/nginx-ephemeral/nginx_session_ticket_next;
http://fangpeishi.com/optimizing-tls-record-size.html
http://fangpeishi.com/optimizing-tls-record-size.html
.https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
ssl_ciphers '[ECDHE-ECDSA-AES128-GCM-SHA256|ECDHE-ECDSA-CHACHA20-POLY1305|ECDHE-RSA-AES128-GCM-SHA256|ECDHE-RSA-CHACHA20-POLY1305]:ECDHE+AES128:RSA+AES128:ECDHE+AES256:RSA+AES256:ECDHE+3DES:RSA+3DES';
ssl_prefer_server_ciphers on;
aio_write on;
http://www.infoq.com/cn/articles/thread-pools-boost-performance-9x
.https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
open_file_cache_min_uses 2;
open_file_cache_errors on;
http://blog.justwd.net/snippets/nginx/nginx-open-file-cache/
.auto nginx mod CENTMIN MOD
https://centminmod.com/
======clern cache=======
https://leokongwq.github.io/2016/11/25/nginx-cache.html
worker_processes 1; #auto;
events {
worker_connections 3000; #786;
# multi_accept on;
}
http {
server_tokens off; #open this line
resolver 8.8.8.8 8.8.4.4 valid=300s; #resolver dns server
proxy_cache_path /var/cache/proxy-nginx levels=1:2 keys_zone=proxy-cache:10m max_size=3g inactive=1d use_temp_path=off;
add_header X-Cache $upstream_cache_status; #讓Header顯示是否有Cache:HIT命中 MISS失敗 BYPASS略過
proxy_headers_hash_max_size 51200; #add this line
proxy_headers_hash_bucket_size 6400; #add this line
log_format main '$remote_addr $status $request $body_bytes_sent [$time_local] $http_user_agent $http_referer $http_x_forwarded_for $upstream_addr $upstream_status $upstream_cache_status $upstream_response_time';
access_log /var/log/nginx/access.log main buffer=1m; #or maybe note # because disk space
log_format cache_status '[$time_local] "$request" $upstream_cache_status';
access_log /var/log/nginx/cache_access.log cache_status;
gzip_proxied any; #open this line, because CDN
2、/etc/nginx/proxy_params put all or maybe find document for practices
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
client_max_body_size 100M;
client_body_buffer_size 1m;
proxy_intercept_errors on;
proxy_buffering on;
proxy_buffer_size 128k;
proxy_buffers 256 16k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_max_temp_file_size 0;
proxy_read_timeout 300;
------------------
#slice 1m; # for slice_range
proxy_cache_key $scheme$host$proxy_host$request_uri; # $slice_range
#proxy_cache_key "$scheme://$host$request_uri";
#proxy_cache_key $host:$server_port$uri$is_args$args; #通过key来hash,定义KEY的值
#proxy_cache_valid 15m;
proxy_cache_valid 200 301 302 304 1h; #206 -> slice_range
proxy_cache_valid 404 1m;
proxy_cache_valid any 1m;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
#proxy_set_header Range $slice_range; #for slice_range
proxy_cache_revalidate on;
# Set some good timeouts
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
#proxy_cache_key "$scheme://$host$request_uri";
#proxy_cache_key $host:$server_port$uri$is_args$args; #通过key来hash,定义KEY的值
#proxy_cache_valid 15m;
proxy_cache_valid 200 301 302 304 1h; #206 -> slice_range
proxy_cache_valid 404 1m;
proxy_cache_valid any 1m;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
#proxy_set_header Range $slice_range; #for slice_range
proxy_cache_revalidate on;
# Set some good timeouts
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
#proxy_cache_min_uses 3; #只要统一个url,在磁盘文件删除之前,总次数访问到达3次,就开始缓存。
proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment; # 如果任何一个参数值不为空,或者不等于0,nginx就不会查找缓存,直接进行代理转发
------------------
aio threads;
aio_write on;
------------------
open_file_cache_errors on;
2.1、SSL
./etc/nginx/snippets/ssl-example.com.conf
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; #crt
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; #key
./etc/nginx/snippets/ssl-params.conf
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
#resolver 8.8.8.8 8.8.4.4 valid=300s; #move to nginx.conf http
resolver_timeout 5s;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment; # 如果任何一个参数值不为空,或者不等于0,nginx就不会查找缓存,直接进行代理转发
------------------
aio threads;
aio_write on;
------------------
open_file_cache max=10000;
open_file_cache_min_uses 2;open_file_cache_errors on;
2.1、SSL
./etc/nginx/snippets/ssl-example.com.conf
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; #crt
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; #key
./etc/nginx/snippets/ssl-params.conf
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
#resolver 8.8.8.8 8.8.4.4 valid=300s; #move to nginx.conf http
resolver_timeout 5s;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
3、/etc/nginx/sites-available/default
# Default server configuration
#server1
server {
set $ds_host_ip 'xxx.xxx.xxx.xxx'; #destination host ip
set $ds_hostname 'ooo.ooo.ooo.ooo'; #destination hostname
set $ds_hostname 'ooo.ooo.ooo.ooo'; #destination hostname
listen 80 reuseport;
#listen [::]:80 default_server;
#root /var/www/html;
#index index.html index.htm index.nginx-debian.html;
#server_name _;
location / {
proxy_pass http://$ds_host_ip:$server_port;
proxy_pass http://$ds_hostname:$server_port;
proxy_pass http://$ds_hostname:$server_port;
include /etc/nginx/proxy_params;
#try_files $uri $uri/ =404;
}
location /nginx_status {
stub_status on;
access_log off;
}
}
server {
set $ds_host_ip 'xxx.xxx.xxx.xxx';
set $ds_hostname 'ooo.ooo.ooo.ooo';
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
location / {
proxy_pass http://$ds_host_ip:$server_port;
proxy_pass http://$ds_hostname:$server_port;
proxy_pass http://$ds_hostname:$server_port;
include /etc/nginx/proxy_params;
}location /nginx_status {
stub_status on;
access_log off;
}
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
}
#server2
server {
set $ds_host_ip 'xxx.xxx.xxx.xxx';
listen 8881 reuseport;
location / {
proxy_pass http://$ds_host_ip:$server_port;
include /etc/nginx/proxy_params;
}
}
#server3
server {
set $ds_host_ip 'xxx.xxx.xxx.xxx';
listen 3333 reuseport;
location / {
proxy_pass http://$ds_host_ip:$server_port;
include /etc/nginx/proxy_params;
}
}
server {
set $ds_host_ip 'xxx.xxx.xxx.xxx';
listen 81 reuseport;
location / {
proxy_pass http://$ds_host_ip:$server_port;
include /etc/nginx/proxy_params;
}
}
server {
set $ds_host_ip 'xxx.xxx.xxx.xxx';
listen 8080 reuseport;
location / {
proxy_pass http://$ds_host_ip:$server_port;
include /etc/nginx/proxy_params;
}
}
===== =====
/etc/security/limits.conf
* soft nproc 65535
===== =====
/etc/security/limits.conf
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
echo "net.core.somaxconn=1024" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
echo "net.ipv4.ip_forward=0" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
===== =====
#单个IP在60秒内只允许新建20个连接
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m state --state NEW -m recent --update --seconds 60 --hitcount 20 --name DEFAULT --rsource -j DROP
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m state --state NEW -m recent --set --name DEFAULT --rsource
#控制单个IP的最大并发连接数为20
-I INPUT -p tcp --dport 80 -m connlimit --connlimit-above 20 -j REJECT
#每个IP最多20个初始连接
-A INPUT -p tcp --syn -m connlimit --connlimit-above 20 -j DROP
http://seanlook.com/2015/05/17/nginx-location-rewrite/
http://xyz.cinc.biz/2016/06/nginx-if-and-host-get-variable.html
http://siwei.me/blog/posts/nginx-built-in-variables
https://www.52os.net/articles/nginx-anti-ddos-setting.html
https://www.52os.net/articles/nginx-anti-ddos-setting-2.html
https://gagor.pl/2016/01/optimize-nginx-for-performance/
------------------
https://gryzli.info/2017/05/09/nginx-configuring-reverse-proxy-caching/
https://www.nginx.com/blog/nginx-high-performance-caching/
https://guides.wp-bullet.com/how-to-configure-nginx-reverse-proxy-wordpress-cache-apache/
https://tweaked.io/guide/nginx-proxying/
http://www.jianshu.com/p/625c2b15dad5
http://phl.iteye.com/blog/2256857
https://gist.github.com/regadas/7381125
https://calomel.org/nginx.html
Building the Nginx Reverse Proxy example
echo "net.core.somaxconn=1024" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
echo "net.ipv4.ip_forward=0" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
===== =====
iptables限制tcp连接和频率
#单个IP在60秒内只允许新建20个连接
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m state --state NEW -m recent --update --seconds 60 --hitcount 20 --name DEFAULT --rsource -j DROP
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m state --state NEW -m recent --set --name DEFAULT --rsource
#控制单个IP的最大并发连接数为20
-I INPUT -p tcp --dport 80 -m connlimit --connlimit-above 20 -j REJECT
#每个IP最多20个初始连接
-A INPUT -p tcp --syn -m connlimit --connlimit-above 20 -j DROP
http://seanlook.com/2015/05/17/nginx-location-rewrite/
http://xyz.cinc.biz/2016/06/nginx-if-and-host-get-variable.html
http://siwei.me/blog/posts/nginx-built-in-variables
https://www.52os.net/articles/nginx-anti-ddos-setting.html
https://www.52os.net/articles/nginx-anti-ddos-setting-2.html
https://gagor.pl/2016/01/optimize-nginx-for-performance/
------------------
https://gryzli.info/2017/05/09/nginx-configuring-reverse-proxy-caching/
https://www.nginx.com/blog/nginx-high-performance-caching/
https://guides.wp-bullet.com/how-to-configure-nginx-reverse-proxy-wordpress-cache-apache/
https://tweaked.io/guide/nginx-proxying/
http://www.jianshu.com/p/625c2b15dad5
http://phl.iteye.com/blog/2256857
https://gist.github.com/regadas/7381125
https://calomel.org/nginx.html
Building the Nginx Reverse Proxy example
----------------------------------------------
.https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
Deploying Brotli for static contentcloudflare/ngx_brotli_module https://github.com/cloudflare/ngx_brotli_module
https://www.mobile01.com/topicdetail.php?f=506&t=5147355
--auto nginx mod CENTMIN MOD
https://centminmod.com/
.https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
https://cipherli.st/
On ssl_session_tickets dropbox & cipherli.st have different way............. maybe use cipherli.st
TLS#ssl_session_tickets on;
#ssl_session_timeout 1h;
#ssl_session_ticket_key /run/nginx-ephemeral/nginx_session_ticket_curr;
#ssl_session_ticket_key /run/nginx-ephemeral/nginx_session_ticket_prev;
#ssl_session_ticket_key /run/nginx-ephemeral/nginx_session_ticket_next;
http://fangpeishi.com/optimizing-tls-record-size.html
http://fangpeishi.com/optimizing-tls-record-size.html
.https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
ssl_ciphers '[ECDHE-ECDSA-AES128-GCM-SHA256|ECDHE-ECDSA-CHACHA20-POLY1305|ECDHE-RSA-AES128-GCM-SHA256|ECDHE-RSA-CHACHA20-POLY1305]:ECDHE+AES128:RSA+AES128:ECDHE+AES256:RSA+AES256:ECDHE+3DES:RSA+3DES';
ssl_prefer_server_ciphers on;
AIOaio threads;
aio_write on;
http://www.infoq.com/cn/articles/thread-pools-boost-performance-9x
.https://blogs.dropbox.com/tech/2017/09/optimizing-web-servers-for-high-throughput-and-low-latency/
Open file cacheopen_file_cache max=10000;
open_file_cache_min_uses 2;
open_file_cache_errors on;
http://blog.justwd.net/snippets/nginx/nginx-open-file-cache/
.auto nginx mod CENTMIN MOD
https://centminmod.com/
======clern cache=======
https://leokongwq.github.io/2016/11/25/nginx-cache.html
Port Forwarding Gateway via iptables on Linux On AWS
Better way is Amazon Linux and
Enhanced Networking on Linux C3、C4、M4
Enhanced Networking on Linux C3、C4、M4
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sriov-networking.html
I think is better for performace.
Port Forwarding Gateway via iptables on Linux
1、
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_NAT_Instance.html#NATSG
1.1、Create instance form ami :ami-vpc-nat-hvm choese best new
***NAT AMI***
1.2、
Check.IPv4 forwarding is enabled and ICMP redirects are disabled in /etc/sysctl.d/10-nat-settings.conf
2、
https://holtstrom.com/michael/blog/post/400/Port-Forwarding-Gateway-via-iptables-on-Linux.html
eth0 10.0.0.219 52.78.165.129
eth1 10.0.1.149
web server 10.0.1.249
iptables -vxnL --line-numbers
iptables -t nat -vxnL --line-numbers
watch -n 1 sudo iptables -vxnL --line-numbers
watch -n 1 sudo iptables -t nat -vxnL --line-numbers
===Start===
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 10.0.0.219 --dport 888 \
-j DNAT --to-destination 10.0.1.249:80
☆ iptables -t nat -A POSTROUTING -j MASQUERADE //key point, can't use out eth0
===抓封包===
tcpdump -i eth0 -p tcp and port 888 -n -v
===刪除===
iptables -D INPUT 2
iptables -t nat -D PREROUTING 2
iptables -t nat -D POSTROUTING 2
===無用===
iptables -A FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -d 10.0.1.249 -j ACCEPT
iptables -A FORWARD -d 10.0.1.249 -p tcp --dport 80 -j ACCEPT
iptables -t nat -A POSTROUTING -j SNAT --to-source 10.0.0.219
===無用===
===無用 這行解決 telnet localhost 888===
iptables -t nat -A OUTPUT -p tcp -o lo --dport 888 -j DNAT --to 10.0.1.249:80
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_NAT_Instance.html#NATSG
1.1、Create instance form ami :ami-vpc-nat-hvm choese best new
***NAT AMI***
1.2、
Check.IPv4 forwarding is enabled and ICMP redirects are disabled in /etc/sysctl.d/10-nat-settings.conf
IPv4 forwarding =1
Run.A script located at /usr/sbin/configure-pat.sh runs at startup and configures iptables IP masquerading.
Here have problem, so must delete POSTROUTING
Run.A script located at /usr/sbin/configure-pat.sh runs at startup and configures iptables IP masquerading.
Here have problem, so must delete POSTROUTING
sudo iptables -t nat -D POSTROUTING 1
2、
https://holtstrom.com/michael/blog/post/400/Port-Forwarding-Gateway-via-iptables-on-Linux.html
eth0 10.0.0.219 52.78.165.129
eth1 10.0.1.149
web server 10.0.1.249
iptables -vxnL --line-numbers
iptables -t nat -vxnL --line-numbers
watch -n 1 sudo iptables -vxnL --line-numbers
watch -n 1 sudo iptables -t nat -vxnL --line-numbers
===Start===
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 10.0.0.219 --dport 888 \
-j DNAT --to-destination 10.0.1.249:80
☆ iptables -t nat -A POSTROUTING -j MASQUERADE //key point, can't use out eth0
===抓封包===
tcpdump -i eth0 -p tcp and port 888 -n -v
===刪除===
iptables -D INPUT 2
iptables -t nat -D PREROUTING 2
iptables -t nat -D POSTROUTING 2
===無用===
iptables -A FORWARD -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -d 10.0.1.249 -j ACCEPT
iptables -A FORWARD -d 10.0.1.249 -p tcp --dport 80 -j ACCEPT
iptables -t nat -A POSTROUTING -j SNAT --to-source 10.0.0.219
===無用===
===無用 這行解決 telnet localhost 888===
iptables -t nat -A OUTPUT -p tcp -o lo --dport 888 -j DNAT --to 10.0.1.249:80
JSMpeg – MPEG1 Video & MP2 Audio Decoder in JavaScript for ios stream
First try this demo can play on ios
http://jsmpeg.com/
Second
https://github.com/phoboslab/jsmpeg#encoding-videoaudio-for-jsmpeg
view-stream.html (nodejs localhost:8080 maybe can see)
websocket-relay.js this is use node.js then get ws server
-re 參數表示以視頻實際播放速率解碼,不加這個參數一般會導致直播速率變得飛快
-re一定要加,代表按照帧率发送,否则ffmpeg会一股脑地按最高的效率发送数据。
http://jsmpeg.com/
Second
https://github.com/phoboslab/jsmpeg#encoding-videoaudio-for-jsmpeg
view-stream.html (nodejs localhost:8080 maybe can see)
Import !!
ffmpeg -re -i rtmp://xxx.xxx.xxx.xxx/live/ooo -f mpegts -codec:v mpeg1video -bf 0 -codec:a mp2 -s 640x360 -r 30 -q 4 -muxdelay 0.001 http://localhost:8081/password
-re 參數表示以視頻實際播放速率解碼,不加這個參數一般會導致直播速率變得飛快
-re一定要加,代表按照帧率发送,否则ffmpeg会一股脑地按最高的效率发送数据。
-muxdelay 0.001 reduce lag (maybe no use)
-q 4 Need test
-q 4 Need test
You're setting -q 1, which is the best possible quality. Try setting it to 4 or 8 instead.
compression_level (-q)
Set algorithm quality. Valid arguments are integers in the 0-9 range, with 0 meaning highest quality but slowest, and 9 meaning fastest while producing the worst quality. Can put more than 9.
compression_level (-q)
Set algorithm quality. Valid arguments are integers in the 0-9 range, with 0 meaning highest quality but slowest, and 9 meaning fastest while producing the worst quality. Can put more than 9.
mpegts this is see error, then find some guy say use mpegts.
Don't use mpeg1video
https://github.com/phoboslab/jsmpeg/issues/149
https://github.com/phoboslab/jsmpeg/issues/149
localhost:8081/password this is "node websocket-relay.js" screen have notify, just try
Example: node websocket-relay.js password 8081 8080
https://github.com/phoboslab/jsmpeg#example-setup-for-streaming-raspberry-pi-live-webcam
訂閱:
文章 (Atom)

























🤣⋯⋯

