2014年12月5日 星期五

ImageMagick

http://www.imagemagick.org/discourse-server/viewtopic.php?t=23723
remove all horizontal or vertical black lines that are at least 30 pixels long

convert example_box_ocr.png ^
  -define morphology:compose=lighten ^
  -morphology Thicken ^
1x30+0+0^<:0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ^
  e.png

convert example_box_ocr.png ^
  -negate ^
  -define morphology:compose=darken ^
  -morphology Thinning Rectangle:1x30+0+0^< ^
  -negate ^
  e2.png


http://www.imagemagick.org/discourse-server/viewtopic.php?t=22338
convert billy.png -morphology close:2 "1x4: 0,1,1,0" result.png
 It is a morphological close (erode and dilate) attempt to remove two pixel tall horizontal black lines that have white above and below them.



-statistic median 7x7
-monochrome
-median
-morphology Smooth Octagon:1

2014年12月1日 星期一

驗證碼



http://www.verydemo.com/demo_c92_i75438.html
http://softwarerecs.stackexchange.com/questions/708/php-ocr-library

http://www.verydemo.com/demo_c92_i75438.html
http://blog.csdn.net/hongquan1991/article/details/8541415
https://code.google.com/p/tesseract-ocr/
http://www.oschina.net/news/40027/6-opensource-ocr-tools
http://blog.lyhdev.com/2011/04/groovy-tesseract-ocr.html

ImageMagick
http://www.imagemagick.org/Usage/


2014年11月3日 星期一

11月

密切注意股
2498 宏達電
2303 聯電
9906 寶成
2347 聯強
1319

機殼: 2354 鴻準, 5264 鎧勝
輪胎: 2105 正新

3454 晶睿
1103 開高, 尾盤收-0.5, 籌碼小小吃, 成交量2.6k
1104 大多時間在盤下, 尾盤翻紅, 籌碼續吃1xx, 成交量2k
1105 -2.5, 瑞士信貸續吃, 成交量 1.5k
1106 -4.5收最低, 瑞士信貸續吃, 成交量 2.5k
1107 +3.5收最高, 瑞士信貸續吃, 成交量 1.5k

3454 20141028 94.50 6.90% 1419404 1769558 .80x3
3454 MA5:94.04 MA20:91.78 MA60:94.22 84.90(20140818)-206.50(20140225)

3552 同致

2014年10月30日 星期四

十月

好久沒更新了....
這兩個月當中經歷了不少的心路歷程
10月底滿六個月, 到達我當初設定的目標
從11月再重新開始吧!!

本月強檔類股:
電信類股: 台灣大, 遠傳
運輸類股: 華航, 長榮航, 長榮海, 宅配通
防疫類股: 毛寶
安控類股: 奇偶 晶睿
銀行類股: 大眾銀 富邦金 國泰金
醫療類股: 杏昌
其他類股: 鴻準

飆股:
6259百徽: 9/29 漲停收12.9, 10/31 收20.1 (攻擊中)
6241易通展: 10/9漲停收23.75,  10/31 收30.6 (攻擊中)
1515力山: 10/7 收10, 10/31收11.65 (攻擊中)
1325恆大: 10/1收19.25, 10/17收23.4, 10/31收21
2482連宇: 9/1714.8, 10/31收22.5 (攻擊中)
3432台端: 9/19收18.2, 10/7收27.9, 10/31收22.3

短進短出:
3310佳穎
5225F-東科
9919康那香
3631晟楠

晶睿:
1028 跳空上漲, 籌碼吃貨(2xx)準備買進
1029 帶量(3k)跳空上漲, 買進, 籌碼續吃(2xx)
1030 帶量(4.8k)跳空上漲收漲停, 籌碼面連續三天吃貨(3xx), 成交量三個月最高
1031 平盤上下徘徊, 收平(3k)

2014年8月1日 星期五

八月

8/1
3206
1470(量小)
2020
*1906

8/2
3522 (7/24)
3030

8/4
3030

8/5
4739

8/7
3323

8/8
5215

8/12
6603


8/18
3682
1526

8/20
2612
2025
2609

8/21
1615
5014


2014年7月1日 星期二

七月口袋名單

7.1
3322
6/9(10.8)
今天12.4
虧轉盈, 預估EPS 1
6284(10/29)
5202(12/30, 2/7, 6/9 6/26, 6/30)
6/27(7.86)
8.99
虧轉盈, 預估EPS 0.0x
4130(6/12)
EPS翻倍
4513
第二波攻擊
休息四個月
基本面不佳
4905(6/27)
4138(6/18)

7.2
3428
3580(6/18)
4971(not so good)
4138(6/19)
5703 (0625)
5426(6/18)

7.3
3071(5/8, 6/11)
5426(6/18)
3061

7.4
2363

7.10
2712
3206

7.11
2901
3202(7/7)
4939(6/17)

7.14
1203
2701
2706 (7/7)
2901 (7/11)
3202(7/7)
1219(7/8)

7.16
1418(7/15)
1717(7/15)
3149
3582
4712
3073

7.17
2459
2024

7.18
6270
9937(6/4)
8277
3434(量小)

7.21
1217
4971
1203
1220
4141
3115
3511
1903

7.22
3669
6233
6215
3285

7.24
5392
1507

7.25
3308
8182(7/24)

7.28
6414
2401
2903
3511(7/21)

2014年6月28日 星期六

六月口袋名單

6/26
4905
5314(漲多)
5202
1721

6/27
3228 (6/15)
籌碼極度乾淨
6156
籌碼極度乾淨
8927(3/28 or 6/16)
3390(5/27)

5481(5/22)
最佳入手點5/21, 12.4, 目前12.5
籌碼極度乾淨

6/30
1721
最佳入手點3/18, 11.9, 目前12.9
(休息三個月)

5704
最佳入手點5/9, 24.9, 目前42.55
(一路上漲)

6130
含今天六根漲停板, 今天為最佳入手點, 55.7

6259(1/3, 2/25)
最佳入手點2/25, 10.3, 今天14
(橫盤三個月)

8927
最佳入手點6/16, 14.15, 今天16.6, 也算最佳入手點
籌碼極度乾淨

4106(6/13)



2014年5月27日 星期二

程式交易必讀

幣圖誌的文章砍掉了, 只能找中國網站...
http://blog.sina.com.cn/s/blog_02cf67f00101otor.html

为什么,很简单,其实多数人不想学,也看不懂。以为学会了均线黄金交叉怎么写之后,就能进市场赚钱,结果发现均线的绩效跟想像中有落差后,怎么写出下一个策略,或者怎么修改现在手上的策略,开始卡关,于是多数的人我认为,放弃了。

笔者一位在大陆教学操盘的老师告知,一般散户,学习操盘的循环最多两年,两年内没赚到钱,通常就会放弃。

完全命中我的心路歷程
當初以為用個K線去抓交叉跟爆量就能取得先機
誰知道false alarm太多, 根本無法篩選...

至少值得一提的是... 我撐過兩年了?

2014年5月10日 星期六

201404 阿太操作紀錄

0421
買 20.5 x 20: 四月開始三大法人都買, 0418主力吃15181張, 三年新高
元大經紀, 富邦大安, 元大藝文, 凱基台北

0422
買21.5 x 20: 3% 自動買進 (當天最高21.55)

0428
買20.2 x 10, 20.5 x 10, 20.9 x 10, 當日股價開19.3 -> 21.1 收漲停, 主力吃5557一年次高
東方匯理, 亞東, 群益金鼎

0429
買21.55 x 10, 當日最高21.9, 收最低20.8
元大經紀加碼

0512
台灣摩根史坦利 -3589, 股價-3.5%

0513
凱基台北 -1553, 股價-4.35%
摩根史坦利+550

0514
摩根史坦利+760
美商高盛每天持續-250張
依然在周線跟月線下方

0515
一路弱勢, 尾盤日盛大單拉回平盤
盤後消息: Q1 -0.85

0516
開跌停17.95, 收+2%
加碼18.55 x 10
籌碼面+5155, 一年內第三高: 4/18, 4/28
凱基經紀, 港商麥格理, 港商德意志, 東方匯理
站回五日線: 19.7 > 19.3
融資新低, 融券新高

0527
跌破19 (18.85)
港商德意志大賣

2014年3月20日 星期四

如何分辨arm mode or thumb mode?

可經由CPSR判斷

cpsr 60000010
-> 1100000000000000000000000010000
                                                       *
第六位是status bit
0: ARM mode , PC = +8
1: thumb mode, PC = +4

2014年3月8日 星期六

一類勞工與二類勞工

除了文中想講的點, 自己另外的想法是
當你有能力或是夢想的時候
其他人也很容易被你的魅力吸引而來

要當二類勞工不簡單


轉自http://winston-zh.attlin.com/2014/03/50.html

一類跟二類勞工

要了解高昂報酬背後的條件,讓我先先來打個比方。

假設你是村子裡面非常重要的,負責水源供給的勞工好了。這裡有兩種勞工類型:一類勞工,與二類勞工。

一類勞工會拎起一到兩個水桶,衝到水源旁邊,裝滿它們,把他們兩個挑回來,大概夠 20 個人喝吧,如此一來有水喝的村民就皆大歡喜了。這個勞工挑水的過程可能會喝掉一些水,然後回到村中,他可能可以分一些水回家作他的報酬。

二類勞工不太理所謂『公平分水』的概念,他會拿起一把鏟子,帶上一止水杯,然後忽然間就消失了。他跑到水源處,挖起一條可以通到村莊的小溪,希望可以把水源引過來。每當他拖著疲憊的身軀,拎著空杯子回到村莊的時候,總會引起一陣失望,但是不知道為什麼那村中的長老相信他,相信他在做的事情(還丟根骨頭給他啃,讓他不致餓肚子)。

某天,他直挺挺的站在村莊前面,他深後白涔涔地流躺著一條飲用水的小溪。這條小溪立刻把一類專門經營『水快遞』的勞工趕出市場,他們只好轉行,加入別的團隊。這個二類勞工呢,看他對這條小溪擁有多少的控制權,一般而言,他有小溪很大部分的擁有權。

後來村莊決定要把小溪整個買下來,整進整個村莊的供水系統,於是村莊拿了他們一部分的財產去換,比如說土地啊什麼的,這個二類勞工於是瞬間升級變成地主了。

村子裡面的媒體注意到村子給這個二類勞工的薪水奇高,別村的人根本挖不動他(他應該是有跟村子簽訂協議,比如要在村子裡留兩年,才能領完全額的報酬之類的),於是出了一篇報導,寫得好像別村出高價挖角,卻因為村子給的薪水太好,以致於這個二類勞工根本不會考慮。

這時候,一類勞工看了媒體報導,覺得村子虧待他們,同工不同酬(請看下面這個兩隻猴子同工不同酬的影片),心生不滿。

沙灘上的掘渠者

來說說一個真實的故事吧。

今年跨年的時候,我跑去 Monterey Bay 玩,沙灘上有個年輕人在挖洞,我饒有興致地站在高處看,我太太欣賞著沙灘美景,其他人根本不在意這個年輕人的舉動,沒有人理他。我指著他轉頭跟太太說:『你等著看,30分鐘以後,周遭的所有人都會加入,幫這個年輕人挖』

30 分鐘以後,他挖出了一條小渠道,從他沙灘上的城堡直挺挺的延伸到海邊有水的地方,希望把海水引入渠道,注入他的護城河。那渠道還不夠深,海水還進不來,於是年輕人忙著加深河道。又過了 5 分鐘,原本站在旁邊看熱鬧的小孩們開始加入,動手幫忙。10 分鐘以後,周遭的機個大人也開始挖掘。15 分鐘以後,一個靦腆的,拎著相機的外國人也投入幫忙。60 分鐘之內,這位二類勞工影響了 15 個一類勞工自願投入,一起把海水引入護城河。
文章開頭的照片就是我當時照的,永久地紀念我對個人力量的賭注。那個拿著紫色桶子的傢伙就是渠道的創始者,不過照片上看不出來就是了。

新聞報導總是很喜歡忽略很多真實的細節,這篇年薪 50 萬的報導就忽略掉『汗水並不等價』這個部分。二類勞工願意突破現狀,孤獨地,有時候可能還要挨餓一小段時間來引入村子賴以維生的水源,一類勞工則是用自己完成的工作與技能去交換薪水,兩者最主要的差異是冒險,而且不保證一定會回收。

村子裡有遠見的那群人可以說都是二類勞工(在 Goolge 裡面領高新的那群),他們篳路藍縷,以啟山林,連結了村莊的水源。這些拿很多股票的傢伙大概是下列其中一種:

  1. 在 Goolge 當初創立時,就已經負責創造其核心價值的那群人
  2. 自己業餘的時候玩玩自己的專案(side project),然後公司覺得超級有用,很有價值的那群人。[譯注:Gmaill 其實就是這樣從 Side Project 長成現在 Goolge 核心產品的。]
  3. 自己開新創公司,被 Google 買進來的
  4. (比較少拉)不知道為什麼有辦法成為某種核心科技或是技能的唯一提供者


除此之外,這種待遇大都是憑空想像出來的,用來賣很多很多 Business Insider 文章的這樣(以台灣的例子來說,就是商周,還有今週刊那些 XD)。

2014年3月4日 星期二

bump pointer

http://www.tuicool.com/articles/ma2yau

假设Java 堆中内存是绝对规整的,所有用过的内存都被放在一边,空闲的内存被放在另一边,中间放着一个指针作为分界点的指示器,那所分配内存就仅仅是把那个指针向空闲空间那边挪动一段与对象大小相等的距离,这种分配方式称为“指针碰撞”( Bump The Pointer )。如果 Java 堆中的内存并不是规整的,已被使用的内存和空闲的内存相互交错,那就没有办法简单的进行指针碰撞了,虚拟机就必须维护一个列表,记录上哪些内存块是可用的,在分配的时候从列表中找到一块足够大的空间划分给对象实例,并更新列表上的记录,这种分配方式称为“空闲列表”( Free List )。

2014年3月3日 星期一

聽懂話中的話

孩子愛抱怨,怎麼辦?
http://m.parenting.com.tw//article/article.action?id=5020348

小明跟媽媽抱怨:「老師都不公平,只疼女生,都聽她們的話。」

媽媽:「一定是你們男生比較調皮不聽話,老師當然比較喜歡聽話的人。」
小明:「誰說的,老師明明就是愛女生,偏心鬼。」
媽媽:「如果你用這樣的口氣跟老師說話,老師才不想聽。」
小明:「才怪,好好講老師也不會聽啦。」
媽媽:「不要再說了,都不檢討自己,只會說別人的錯。」
小英跟媽媽說:「你都只疼妹妹,不疼我。」
媽媽:「有嗎?」
小英:「有啊,因為你都只照顧妹妹。」
媽媽:「妹妹還小嘛,你忘記我們以前也都只陪你一個。」
小英:「有嗎?你看你盛給我那麼多飯,卻只給妹妹一點點,你最愛妹妹。」
媽媽正在怨嘆怎麼做都不對,而來不及回話時,換妹妹抱怨了:「為什麼姊姊零用錢那麼多?」
媽媽耐著性子說:「因為姊姊比較大,等你長大就會跟姊姊一樣多。」
妹妹:「為什麼姊姊可以自己走路上學,我都不行。」,「為什麼姊姊可以……我都不行……」
最後媽媽終於氣炸了:「可不可以不要再抱怨了……」
上述對話,相信很多家長都能感同身受這種苦楚,甚至對於這些抱怨,有時也有著相當的抱怨(為什麼孩子一直抱怨呢)。我們常常在孩子抱怨時跟他講道理,卻慘遭碰壁。
其實「抱怨」是情緒表達的一種,就需要從情緒著手。抱怨不像生氣、開心、難過那麼容易辨別,而是經過很多層情緒的包裝,可能內裹著不同的情緒,包括生氣、挫折、傷心、焦慮等等。因此要回應「抱怨」並不簡單,加上我們對「抱怨」的某些情感與認知,都會影響我們如何回應孩子的抱怨。
了解孩子抱怨背後的需求
要了解孩子抱怨背後的感情,可以先回想我們曾經抱怨的事件:
抱怨老公是「工作狂」,其實要說的可能是「我需要你的陪伴」;跟老公抱怨「孩子不好管」,是想表達「我需要你的幫忙,或不要怪我管不好孩子」;抱怨「公婆不好相處」,要傳達的是,「我希望情況可以改善,或自覺委屈,想得到安慰」。
可見抱怨背後總有說不出來的需要。情緒心理學提到每種情緒都有正、反兩面的功能,而情緒會往正功能或負功能發展與認知系統有很大的關係,其中影響最大的是人如何解釋所發生的事情,有些人會賦予負向的歸因稱為「黑暗想法」;有些賦予正向的歸因稱為「陽光想法」,黑暗想法易阻礙我們回應孩子的真正需求,而陽光想法則比較容易產生力量,帶領孩子走出抱怨的陰霾。
如果父母親能運用「陽光想法」,將孩子的成長責任還給他們,相信就不需要承擔孩子的所有責任而倍感壓力。從心理學角度而言,當人的需求沒有得到滿足時就可能產生抱怨,即使個人需求不合理,甚至過分,但只要他人沒有給予適當的回應,事後就可能產生更多抱怨。
美國加州大學洛杉磯分校(UCLA)一群科學家,在實驗室中引發三十名受試者的情緒反應,並觀察他們的腦部活動變化後,發表最新的研究發現:「將自己的模糊感覺用精確文字表達出來後,有助於調節腦部控制情緒的中樞(杏仁核 amygdala)及右前額頁皮質的活動。」
情緒穩定是解決問題的重要因素,父母親面對孩子的抱怨,最重要的是幫助他了解自己的情感,能以適當的言語來安定自己的情緒。當孩子情緒穩定,就能有較多的能量去面對自己抱怨的事情,並擔負起責任。
區辨孩子的抱怨類型有助於父母正確回應孩子的需求。一般而言孩子抱怨大約有以下的類型:
純發洩型:當父母提供很多解決辦法,卻遭到孩子忽視或拒絕時,父母可以想一想,孩子是不是只想發洩情緒。或許他們想要有人聽他們說說話,父母可以問:「你希望我們聽聽就好,還是需要幫你解決問題。」通常孩子會告訴我們答案。如果孩子只是想發洩,或許可以每天約定一段時間聽孩子說說自己的情緒,讓情緒不要累積。
表達需求型:有些孩子經常說「為什麼誰都可以?」,「誰也在做,為什麼我不行?」等等,這樣的孩子其實是很辛苦的,他們不容易提出自己的需求,只能搭別人的順風車。父母可以支持孩子的權利,鼓勵他們說:「你可以跟媽媽說你也要,這樣我們就了解了。」讓孩子明白說出需求,感受到「說出來有效果」,將有助減少抱怨。
尋求協助型:有些孩子會說「都沒有人理我」、「沒人選我當模範生」、「大家都欺負我」,這類孩子的情感是受傷的,父母需要先關心他們的心情:「你一定很難過」、「辛苦你了」、「你很希望被肯定」。他們的想法通常比較負面,因此父母應從正向來引導:「全班有多少人,有幾個人不理你」,拓展孩子的眼界:「不是所有人都不理我」,再來才問:「發生什麼事情」。
從裡面找出孩子可以提升的社交技巧,例如,主動跟同學說「我也想玩」等等。至於想當模範生卻落空,家長可以問孩子,同學提什麼能力的人當模範生;問孩子已經具備哪些能力,鼓勵他已經有這麼多能力,只要再努力一點點就可以了,肯定孩子的同時也給予成長的方向。
試水溫(風向球)型:孩子可能會抱怨「誰的零用錢都很多」、「誰都可以打電動」、「誰現在就有手機」,來試探父母的反應如何?此時父母應先回應孩子的內在需求:「好像你想要更多錢、更多玩的時間」,再問孩子「你想要買哪些東西?想玩多久?」聽聽看內容合不合理,如果合理就調整;如果不合理就明白提出看法:「我最多可以給多少零用錢。電動開放最多的時間是多少」。若因比較下產生的匱乏感,試著跟孩子說:「同學有那麼多,真的讓人很羨慕,但我們也把最好的給你啊」。
要求關心型:有些小孩發現抱怨會引起父母的注意及關心,可能會不斷的抱怨或製造一些小事情,好讓父母的焦點可以持續在自己身上,像這樣的孩子要的就是陪伴及關心。所以最好每天固定安排時間,陪孩子玩他們喜歡玩的遊戲,充分享受親子的歡樂時光。
防火牆型:有些孩子會抱怨「老師功課出好多」、「都是同學惹我」、「沒有時間玩」,這類孩子很怕別人說那是他的責任,或是他又錯了,所以會試圖畫出一道防火牆表達:「我已經盡力了,不要再說了」。父母親通常要這樣安慰孩子:「我知道你盡力了,需要幫忙時,記得跟我說喔」,同時安慰孩子,「慢慢來,沒關係」。
要求重視被看見:有些孩子會跟父母抱怨其他兄弟姊妹的事蹟,有時是為了得到誇獎、重視:「你看,我做得很好,○○都沒有」。此時父母要記得常常肯定及讚賞孩子的表現:「你做得很好」,同時卸下孩子的教養權:「我也很希望○○可以這樣,教育○○是我的工作。」鼓勵孩子做好自己分內工作就好,免得增加手足的衝突。
雖然小朋友抱怨的內容可能相同,但每個人內在需求可能不一樣。家長可以每個內在需求都試試看,就能找到孩子的心理需求。當你對孩子做了一些事情後,他比較少抱怨時,就代表你成功的滿足及抓住孩子的內在需求。抱怨的確載著許多負向能量,然而家長有兩個很棒的法寶,就是「陽光想法」及「情感滿足」。經常善用這兩個法寶,將抱怨當成禮物,讓孩子學會正向思考,陪伴孩子一路成長。

2014年3月2日 星期日

NEXUS root

http://www.wugfresh.com/nrt/

[STUDY] vim

Ctrl + f : page down
Ctrl + b : page up
Ctrl + d : 1/2 page down
Ctrl + u : 1/2 page up

G : move to end of the file
gg : move to start of the file

/ : search key word, like /test
? : search key work, like ?test

n : repeat last command, use / then n, n, n,
N : revert last command, use / then N, N, N


[STUDY] makefile

http://www.cnblogs.com/aoyihuashao/archive/2010/01/18/1650865.html

2014年2月14日 星期五

[STUDY] Linux Shell Scripting Tutorial v2.0

P.19
Bash and Command Types
The bash shell understands the following types of commands:
‧ Aliases such as ll
‧ Keywords such as if
‧ Functions (user defined functions such as genpasswd)
‧ Built in such as pwd
‧ Files such as /bin/date
The type command can be used find out a command type.

List of command bash keywords and built in commands
‧ JOB_SPEC & ‧ (( expression )) ‧ . filename ‧ [[:]]    ‧ [ arg... ] ‧ expression ‧ alias
‧ bg         ‧ bind             ‧ builtin    ‧ caller   ‧ case       ‧ command    ‧ compgen
‧ complete   ‧ continue         ‧ declare    ‧ dirs     ‧ disown     ‧ echo       ‧ enable
‧ eval       ‧ exec             ‧ exit       ‧ export   ‧ false      ‧ fc         ‧ fg
‧ for        ‧ getopts          ‧ hash       ‧ help     ‧ history    ‧ if         ‧ jobs
‧ kill       ‧ let              ‧ local      ‧ logout   ‧ popd       ‧ printf     ‧ pushd
‧ pwd        ‧ read             ‧ readonly   ‧ return   ‧ select     ‧ set        ‧ shift
‧ shopt      ‧ source           ‧ suspend    ‧ test     ‧ time       ‧ times      ‧ trap
‧ true       ‧ type             ‧ typeset    ‧ ulimit   ‧ umask      ‧ unalias    ‧ unset
‧ until      ‧ variables        ‧ while

P.22
bashrc, etc/profile.d

P39
Use of builtin command
set -x
set -v
set -n

P44
echo "$PATH" can print out the default path

P45(P38)
Assign values to shell variables

P47
THe := syntax (default value)

P48
variable name must with alphanumeric character or underscore character (_)
variable names are case-sensitive

Don't put spaces on equal
ex. no=10 (O)
    no = 10 (X)

P51
printf format directives

P53
Quoting (single / double), backslash
in single quote, the variable won't show the value

P54
backslash escaped characters

P56
export statement
use export command to export variables and functions to child processes

P59
IFS: Internal Field Separator
shell 預設所使用的內部欄位分隔符號

P62
mathematical operators and order

P63
create an integer variable: use the declare command
(why we need this?)

P66
bash hell environment
How to view / export local variable / enviroment variables

P68
Common Environment Variables
Home / PATH  / PWD

P73
Wildcards: base supports the following three simple wildcards
1. *   Matches any string, including the null string
2. ?   Matches any single (one) character.
3. ... Matches any one of the enclosed characters.

P75
alias, modify ~/.bashrc to make it permanently

P76
the tilde expansion (~)

P77
startup scripts related info
script execution order

P88
using aliases: edit bashrc to add alias

CH4
P93
test command (if it's useful?)

P94
if structures to execure code based on a condition

if condition
then
  xxx
  ooo

fi

P96
if command
then
    xxxx

else
    oooo

fi

P100
Multilevel if then else

if condition
then
     oooo
     xxxx
elif condition1
then
     oooo
     xxxx

elif condition2
then
     oooo
     xxxx
...
...
fi

P102
exit status is
0: OK
1: minor problems
2: serious trouble

P104
rm /tmp/filename && echo "File deleted."
The echo command will only run if rm exits successfully with a status of zero

P105
cat /etc/shadow 2>/dev/null || echo "Failed to open file"
'Failed to open file' will be displayed cat command failed to open the
file.

combine both logical operators
cat /etc/shadow 2>/dev/null && echo "File successfully opened." || echo
"Failed to open file."

P108
Codition expression using [
It's used for:
File arrtibutes comparisions
Perform string comparisions
Arithmetic comparisons
[ condition ]
[ ! condition ]
[ condition ] && true-command
[ condition ] || false-command
[ condition ] && true-command || false-command

P109
Numeric comparison
eq: equal
ge: greater than or equal to
gt: greater than
le: less than or equal to
lt: less than
ne: not equal to

P111
String comparison
equal:
STRING1 = STRING2
not equal:
STRING1 != STRING2
The length of STRING is zero (useful to see if variable is empty or not)
-z STRING

P112
File attributes comparisons
-a file
True if file exists.

-b file
True if file exists and is a block special file. (what is block special file?)

-c file
True if file exists and is a character special file.

-d dir
True if file exists and is a directory.

-e file
True if file exists.

-f file
True if file exists and is a regular file.

-g file
True if file exists and is set-group-id.

-h file
True if file exists and is a symbolic link.

-k file
True if file exists and its ‘‘sticky’’ bit is set.

-p file
True if file exists and is a named pipe (FIFO).

-r file
True if file exists and is readable.

-s file
True if file exists and has a size greater than zero.

-t fd
True if file descriptor fd is open and refers to a terminal.

-u file
True if file exists and its set-user-id bit is set.

-w file
True if file exists and is writable.

-x file
True if file exists and is executable.

-O file
True if file exists and is owned by the effective user id.

-G file
True if file exists and is owned by the effective group id.

-L file
True if file exists and is a symbolic link.

-S file
True if file exists and is a socket.

-N file
True if file exists and has been modified since it was last read.

P120
A Note About $@ and $*
$@ expanded as "$1" "$2" "$3" ... "$n"
$* expanded as "$1y$2y$3y...$n", where y is the value of $IFS variable

P121
Parameters set by the shell
All command line parameters or arguments can be accessed via $1, $2, $3,..., $9.
$* holds all command line parameters or arguments.
$# holds the number of positional parameters.
$- holds flags supplied to the shell.
$? holds the return value set by the previously executed command.
$$ holds the process number of the shell (current shell).
$! hold the process number of the last background command.

P122
Add usage functionality to the script

P126
case $variable-name in
     pattern1)
         xxxx
         xxxx
         ;;
     pattern2)
         xxxx
         xxxx
         ;;
     *)
esac
       
case $variable-name in
     pattern1|pattern2|pattern3)
         xxxx
     ;;
esac

P130
Dealing with case sensitive pattern
1. use: tr '[:upper:]' '[:lower:]' to convert a pattern to lowercase
2. Use regex with case patterns
3. Turn on nocasematch

---------- CH5 for loop ----------

P134
for var in item1 item2 ... itemN
do
      command1
      command2
      ....

done

or
for var in list-of-values
for var in file1 file2 file3
for var in $fileNames
for var in (( EXP1; EXP2; EXP3 ))

P136
for loop, The lists or values are normally:
1. Strings
2. Numbers
3. Command line arguments
4. File names
5. Linux command output

P142 while loop
while [condition]
do
    command1
    command2
    ...
done

read from file
while IFS= read -r line
do
   command1
   command2
   ...
done < "/ptah/to/filename"

while IFS= read -r field1 field2 field3...
do
   command1
   command2
   ...
done < "/path/to dir/file name with space"

P143 Using ((expression)) Format With The While Loop
f the value of the expression is non-zero,
the return status is 0; otherwise the return status is 1.
while [ $n -le 5 ] = while (( $n <= 5 ))

P144
while IFS= read -r f1 f2
use IFS to separete f1, f2
input string: nameserver 127.0.0.1
f1: nameserver, f2:127.0.0.1

while IFS=: read -r user enpass uid gid desc home shell
do
   ....
   ....
done < "$file"
read file and separate different column

P146
Use of : to set infinite while loop
You can use : special command with while loop to tests or set an infinite loop or an endless loop

PS. : is command
if [xxxxxxx] ; then
     :
else
     :
fi
use : first, or it there is nothing if loop, it will fail

: ${var:=default}
if var is null, var will be default

: > 123.txt
clean out 123.txt

: can be comment line in .sh

P148
The until loop statement
Just like while loop, until loop is also based on a condition.

The while loop vs the until loop
1. The until loop executes until a nonzero status is returned.
2. The while command executes until a zero status is returned.
3. The until loop always executes at least once.

P150
The select loop statement
(not study)

P155
Using the break statement
Use the break statement to exit from within a FOR, WHILE or UNTIL loop

PS.
use for loop to get file in the folder
for f in /etc/*

P157
Using the continue statement

for i in something
do
    [ condition ] && continue
    ....
    ....

done

while true
do
       [ condition1 ] && continue
       ......
       ......
       [ condition2 ] && break
done

P160
Command substitution
You can use the grave accent (`) to perform a command substitution. The syntax is:
`command-name` or $(command-name)




---------- CH6 Shell Redirection----------



P164
Before acommand is executed, its input and output may be redirected using a special notation interpreted
by the shell. For example, sending output of date command to a file instead of to the screen.
Changing the default path of input or output is called redirection.

In Linux everything is a file.
Your hardware is also a file:
‧ 0 - Input - Keyboard (stdin)
‧ 1 - Output - Screen (stdout)
‧ 2 - Error - Screen (stderr)

The above three numbers are standard POSIX numbers and also known as file descriptors (FD). Every Linux
command at least open the above streams to talk with users or other system programs.

P165
Standard input
< is input redirection symbol and syntax is: command < filename

Standard output
> is output redirection symbol and syntax is: command > output.file.name

Standard error
2> is input redirection symbol and syntax is:
command 2> errors.txt

P168
Empty file creation
To create empty file use the following syntax:
>newfile.name
> operator redirects output to a file. If no command given and if file doesn't exist it will create empty file.

P169
/ dev/ null discards unwanted output
All data written on a /dev/null or /dev/zero special file is discarded by the system.
Use /dev/null to send any unwanted output from program/command and syntax is:
command >/dev/null

This syntax redirects the command standard output messages to /dev/null where it is ignored by the shell. OR
command 2>/dev/null

This syntax redirects the command error output messages to /dev/null where it is ignored by the shell. OR
command &>/dev/null
This syntax redirects both standard output and error output messages to /dev/null where it is ignored by the shell.

grep vivek /etc/passwd >/dev/null && echo "Vivek found" || "Vivek not found"
to show only found or not found, do not print out the grep result

P171
Here documents
To create a here document use the following syntax:
command <<HERE
text1
text2
testN
$varName
HERE
(HERE can be replaced by other word)
ex.
wc -w <<EOF
> This is a test.
> Apple juice.
> 100% fruit juice and no added sugar, colour or preservative.
> EOF

This type of redirection tells the shell to read input from the current source (HERE) until a line containg
only word (HERE) is seen.


P173
Here strings
Here strings is just like here documents and syntax is:
command <<<$word
or
command arg1 <<<"$word"

it can use for grepping into a shell variable
grep "nor" <<<$var >/dev/null && echo "Found" || echo "Not found"
below is the same meaning
echo $var | grep -q "nor" && echo "Found" || echo "Not found"
However, here strings looks more logical and easy to read.

P175
Redirect Script Errors
You can redirect script error to a log file called scripts.err:
./script.sh 2>scripts.err

P177
Appending redirected output
You can append the output to the same file using >> operator
(> will overwrite original content)

Redirection of both standard error and output
redirect both stdout and stderr to file using the following syntax:
command-name &>filename
command-name >cmd.log 2>&1
command-name >/dev/null 2>&1

P178
Writing output to files
use the redirection symbol, >, to send data to a file.
Use the >> redirection symbols, to append to a file

P180
Assigns the file descriptor (fd) to file for output
assign a file descriptor to an output file with the following syntax:

exec fd> output.txt
where, fd >= 3

ex.
exec 3> /tmp/output.txt
echo "This is a test" >&3
# Close fd # 3
exec 3<&-


P181
Assigns the file descriptor (fd) to file for input

To assign a file descriptor to an input file use the following syntax:
exec fd< input.txt
where, fd >= 3.

ex.
exec 3< /etc/resolv.conf

# Close fd # 3
exec 3<&-

P182
To closes the file descriptor use the following syntax:
exec fd<&-
To close fd # 5, enter:
exec 5<&-

Opening the file descriptors for reading and writing
to open file for both reading and writing on file descriptor:
exec fd<>fileName
File descriptor 0 is used if fd is not specified.
If the file does not exist, it is created.
This syntax is useful to update file.

FILENAME="/tmp/out.txt"
exec 3<>$FILENAME
echo "Today is $(date)" >&3
# close fd # 3
exec 3>&-

P183
Reads from the file descriptor (fd)
read -u fd var1 var2 ... varN

while IFS= read -u fd -r line
do
  command1 on $line
  command2 on $line
done

P186
Executes commands and send output to the file descriptor (fd)
to run or execute commands and send output to the file descriptor:
command-name >& fd

#!/bin/bash
exec 4> /tmp/out.txt
free -m >&4

(did not understand this part too much)

---------- CH7 Pipes and Filters----------
Under bash you can create a sequence of one or more commands separated by one of the following operators:
;  Separates commands that are executed in sequence.
   date ; pwd
&  The shell executes the command in the background in a subshell.
   The shell does not wait for the command to finish, and the return status is 0.
   The & operator runs the command in background while freeing up your terminal for other work.
   find / -iname "*.pdf" >/tmp/output.txt &
&& command2 is executed if, and only if, command1 returns an exit status of zero
|| command2 is executed if and only if command1 returns a non-zero exit status
|  Linux shell pipes join the standard output of command1 to the standard input of command2.

P195 Putting jobs in background

You can use the following command to control the job:
fg - Place job in the foreground.
bg - Place job in the background.
jobs - Lists the active jobs on screen.

P196 How do I put commands in background?
command &
command arg1 arg2 &
command1 | command2 arg1 &
command1 | command2 arg1 > output &
The command which runs in background is called a job.

P197 Pipes
A shell pipe is a way to connect the output of one program to the input of another program without any temporary
file.

command1 | command2 | commandN
format_data_command > output.data.file
The vertical bar (|) is the pipe symbol.
The data path only works in one direction: command1 output -> commande2 input
(there are lots of useful example here)

P200
Input redirection in pipes
command1 < input.txt | command2

P203
Commonly used filter commands
awk
cut
grep
gzip
head
paste
perl
sed
sort
split
strings
tac
tail
tee
tr
uniq
wc

---------- CH8 Traps----------

P205 Signals
A signal is nothing but some sort of inter-process communication
(techniques for the exchanging data among multiple threads in one or more processes or commands)
A signal is sent to a process or command in order notify an event that occurred
For example, while running a command called 'ls -R /, you may hit CTRL+C (or Break) to cancel command
execution. As soon as you hit CTRL+C, a signals called SIGINT (2) sent to indicate interrupt from keyboard.
When, SIGINT is sent to ls command, Linux interrupts the process's normal flow of execution. In this example, ls
command get terminated.
You need to use the trap command to catch signals and handle errors under Linux shell scripts.

P206 Parent and Child Processes
A parent process is a Linux process that has created one or more child processes.
A process can fork a child i.e create a child process.
In UNIX, every process is created using fork and exec method. However, this model results in a waste of system
resources.
Under Linux, the fork method is implemented using copy-on-write pages, so the only penalty that it incurs is the
time and memory required to duplicate the parent's page tables, and to create a unique task structure for the child.

P207 Process States
The status of the process which can be one of the following:
1. D (uninterruptible sleep)
   Process is sleeping and cannot be bring back until an event such as I/O occurred.
   For example, process foo is a process waiting for keyboard interrupt.
2. R (running)
   Process is running or executing.
3. S (sleeping)
   Process is not running and is waiting for an event or a signal.
4. T (traced or stopped)
   Process is stopped by signals such as SIGINT or SIGSTOP.
5. Z (zombie or defunct)
   Processes marked <defunct> are dead processes (so-called "zombies") that remain because their parent has not
   destroyed them properly. These processes will be destroyed by init if the parent process exits.

P211 Sending signal to Processes
kill - send a signal to a process
Particularly useful signals include:
1. SIGHUP (1) - Hangup detected on controlling terminal or death of controlling process.
2. SIGINT (2) - Interrupt from keyboard.
3. SIGKILL (9) - Kill signal i.e. kill running process.
4. SIGSTOP (19) - Stop process.
5. SIGCONT (18) - Continue process if stopped.

To send a kill signal to PID # 1234 use:
kill -9 1234
kill -KILL 1234
kill -SIGKILL 1234

killall - kill processes by name
If no signal name is specified, SIGTERM is sent.
killall processName
killall firefox-bin
killall -s SIGKILL firefox-bin

pkill - kill process
The pkill command is another command with additional options to kill process by its name, user name, group name,
terminal, UID, EUID, and GID
(not study)

P213 Terminating Processes
To terminate unwanted background process use kill command with -9 signal
kill -TERM pid
kill -KILL pid

To stop (suspend) a foreground process hit CTRL+Z (hold down CTRL key and press z). To resume the
foreground process use the fg command, enter:
fg jobid
fg 1
fg %

P216 Shell signal values
Some signals can never be caught. For example, the signals SIGKILL (9) and SIGSTOP (19) cannot be caught,
blocked, or ignored.
(signal table here, very important!)

P217 The trap statement
the trap command captures an interrupt.

P219 How to clear trap
P221 Include trap statements in a script
P223 Use the trap statement to catch signals and handle errors
(not study trap related topic)

P227
What is a Subshell?
Use exec command to avoid subshell
The . (dot) Command and Subshell
Compound command
Exec command
(not study)


---------- CH9 Functions----------
P232
funcion() {......}
One line functions inside { ...; } must end with a semicolon

P233 Displaying functions
declare -f funciton_name

Removing functions
unset -f functionName

P235 Defining functions

function name {
   .....
   .....
}

or

function name() {
   .....
   .....
}

P238
Writing functions
All shell functions are treated as a command.
You must define a function at the start of a script.

A function must be created before calling.

P240
a full sample case

P244 Pass arguments into a function
Shell functions have their own command line argument.
Use variable $1, $2..$n to access argument passed to the function.

The syntax is as follows:
name() {
  arg1=$1
  arg2=$2
  command on $arg1
}

To invoke the the function use the following syntax:
name foo bar
Where,
1. name = function name.
2. foo = Argument # 1 passed to the function (positional parameter # 1).
3. bar = Argument # 2 passed to the function.

Function shell variables
‧ All function parameters or arguments can be accessed via $1, $2, $3,..., $N.
‧ $0 always point to the shell script name.
‧ $* or $@ holds all parameters or arguments passed to the function.
‧ $# holds the number of positional parameters passed to the function.

P247 Local variable
By default all variables are global.
Modifying a variable in a function changes it in the whole script.

You can create a local variables using the local command and syntax is:
local var=value
local varName

or

function name(){
local var=$1
command1 on $var
}


P250
Returning from a function

P255
Source command

P256
Recursive function
Recursive functions are slow under bash.
Avoid using recursive functions if possible.

P258
Putting functions in background

2014年2月8日 星期六

20140208 Lynia.com PS 筆記

CH0 Introduction
CH1 Strategies for Learning
CH2 bridge and mini bridge
press space to enter full screen preview or view-> full screen preview

in PS, press ctrl + alt + o to jump to bridge
in bridge, press ctrl + Alt + o to jump to PS

CH3 color settings and preferences
double click the hand tool icon will make image fit to window
double click the zoom tool icon will make image 100%
double click the image in zoom tool will make the point to center

in brush tool,
alt + right click + drag left / right will change brush size
alt + right click + drag up / down will change hardness

press f to change to full screen mode
shift + f to change it back

CH4 Foundations of Color Management

CH5 Getting Started with Photoshop
press key to change different tools
press shift + key to change sub tools
ex. b for brush tool
    shift b for brush tool / pencil tool / color replacement tool

in zoom tool, click directly to zoom in
alt + click to zoom out

h for hand tool
z for zoom tool

double click zoom tool to become 100%
double click hand tool to fit window

0502
f for full screen
right click on the background, it can choose background color

0503
ctrl + tab to switch different photo tab
window - arrange can show different photo tab at the same screen
(vertically / horizontal)
then use hand or zoom tool to show different part of photos

0504
ctrl + + to zoom in
ctrl + - to zomm out
image - Reveal all to extend the canves (if something if out of the canves, it will extend)
ctrl + s to save file
ctrl + w to close file

0505
edit - menu or window - workspace - keyboard shortcut and menu
here u can customize the shortcut key or remove/edit menu

CH6 Understanding Digital Images
alt + ctrl + i to adjust image size

CH7 Working in Camera Raw

6500k camera flash
5500k studio lights
3200k tungsten
1800k candle

0705
in crop tool,
press ctrl it will temporary become straighten tool
press shift to fix the ratio

0707:
black and white picture work flow:
1. first work with basic panel
2. invert to gray scale picture and adjust different color
3. use brush tool to local adjust

0708
when adjust sharp, alt + drag will show the affect region
radius is related to file resolution, the lower the resolution, the lower the radius
for people, u don't need too much detail, this should be zero
masking: black part won't be sharpening, whatever is white, it will be sharpening

work flow:
1. first work with basic panel, top to bottom
2. adjust other tab if necessary
3. last, go to detail panel, to get sharpen and reduce color noise

CH8 Utilizing Layers

0803
ctrl + j to duplicate the layer
shift + ctrl + n to create a new layer
or layer - new layer

text layer: choose text tool an input something
press ctrl + enter to finish

0806
show / hide layer: click then drag through layers
ctrl + g to create a layer group
alt + drag, it can sync effect from one layer  to another
alt + click can close/expand all the layer effect at once

0808
bottom of layer panel, there is a fx which can add layer effect (layer style)
alt + click will close all the layer style at once

0809 clipping mask
if some layer just apply to another layer, move mouse to the 2 layer and alt + click
it will change to apply as clipping mask

0810 move layer
3 different way to select layer
1. right or left click, then choose the layer
2. use the auto-select function in the menu bar
3. ctrl + alt + click to auto select the layer

CH9 Making Selections
during selection, press space key can move the selected area
after selecting, ctrl + j to copy the layer

when select something, shift + click to select more part
when want to deselect something, alt + click to deselect the part
ctrl + h to temporally hide the selected line

2014年1月29日 星期三

20140201 windows 8

符合高解析度程式:
Chrome
vmware

不符合:
potplayer
line
PS CS6 (adobe is still working on that)


mint:
http://rechtsgut.pixnet.net/blog/post/31644711-linux-mint-15,-16---cinnamon-%E5%90%84%E8%99%95%E5%AD%97%E5%9E%8B%E5%A4%A7%E5%B0%8F%E8%AA%BF%E6%95%B4
將文字及圖片放大後會好用很多

chrome:
在 chrome 的網址列 鍵入 chrome://flags
找到 HiDPI 支援 Windows 
把它設為 啟用

PSCS6
https://forums.adobe.com/thread/1323412?start=80&tstart=0

2014年1月5日 星期日

20140105 一月計劃

1. ACR study finish
2. 跑步時速9km/s 跑7km
3. shell script book1 study finish (3~5 pages / day)

*******************************
prepare:
1. PS6 study start (next month finish)
2. 跑步時速9km/s 跑9km
3. shell script book2

1. ACR & shell scipt on time
2. running is...... need to catch up

2014年1月4日 星期六

20140105 2014新年計劃

運動:
一日北高18hr
雙北15hr
瘋北宜200k 12hr
3P 4小時10分
北宜40分

生活:
0800起床
0900上班
1900下班

工作:
work smarter
shell script
make file

update:
EQ
native debug
stock ap
photoshop

等2014年底再回頭來笑吧