Search

12/30/2011

關於「小確幸」的考察

關於「小確幸」的考察

據說它是村上春樹創造出來的詞,在google中鍵入此字,果然發現這個詞都跟村上兄連在一起。然而網路上大多只看能到幾句片段的話,比如:

...『如果沒有這種小確幸,人生只不過像乾巴巴的沙漠而已』-村上春樹《終於悲哀的外國語》
...「小確幸」就是生活中「微小但確切的幸福」的事,而「小確幸」的起源是來自村上春樹的一篇「小確幸」文章中,村上說他自己選購內褲,把洗滌過的潔淨內褲捲摺好然後整齊的放在抽屜中,就是一種微小而真確的幸福。
我想進一步看到這個詞彙完整的前後文,因此循著前面兩條線索,我推論應該是《終於悲哀的外國語》裡面有那麼一篇<小確幸>吧。然而當我到書店裡翻出《終於悲哀的外國語》,卻找不到這樣的標題,我猜想,可能是有人誤記了文章篇名,這種狀況下,我只能用「速讀掃描法」把整本書翻過一遍,然而卻怎樣也沒發現這個詞。

我拿起另外一本村上的散文集《尋找漩渦貓的方法》,因為它的封面跟《終於悲哀的外國語》滿相像,我猜想一定是有人搞混了,於是我再次用速讀掃描法搜尋「小確幸」,果然就讓我在<郵購的種種、快樂貓的、「吃飯睡覺遊戲」手錶>這篇文末找到了。

那一段的大意是說,喜愛蒐集唱片的村上,某天找到一張喜愛的唱片,但因價格太高而作罷,三年後,竟在不同的地方找到同一張唱片,價格意外很便宜,讓他感到很快樂。於是他就有了這一段結論:

「為了找出生活中個人的小確幸(雖然小,卻很確實的幸福),還是需要或多或少有類似自我節制的東西。例如忍耐著做完激烈運動之後,喝到冰冰的啤酒之類的時,會一個人閉上眼睛忍不住嘀咕道:『嗯,對了,就是這個』。那樣的興奮感慨,再怎麼說就是『小確幸』的真正妙味了。而且如果沒有這種小確幸,我認為人生只不過像乾巴巴的沙漠而已。」
那篇文章標題很長,但並不是<小確幸>。原本以為,果然是有人把篇名搞錯,根本沒有<小確幸>這篇文章,正待發作,沒想到又在網路上查到,原來在《蘭格漢斯島的午后》這本散文裡,的確就有一篇<小確幸>,談的是關於內褲的事。

我特地去圖書館翻了那篇,覺得反而沒有《尋找漩渦貓的方法》裡那段有意思。

小確幸就是「雖然微小,卻很確實的幸福」的縮寫。以這個定義來看,有很多事都可以稱為小確幸吧?比如:早晨起來看見陽光,好幸福喔;喝一杯自己煮的咖啡,好幸福喔;冬天裡鑽進暖和的被窩,好幸福喔;喝著啤酒,好幸福喔....。

然而真的是這樣嗎?
我們可不是每天起床看到陽光就會感到小確幸,也不是每次喝咖啡的時候都會感到小確幸,我們只有在某些特定的時刻,才會感到小確幸。換句話說,小確幸沒辦法列出一個清單,讓我們照著做就能得到幸福感。差別在哪裡?

這就是村上在《尋找漩渦貓的方法》裡那段提出來的,「小確幸的真正妙味」。
「為了找出個人生活中的小確幸,還是需要或多或少有類似自我節制的東西。例如忍耐著做完激烈運動之後,喝到冰冰的啤酒之類的。」

我想說得更清楚一點,那就是「飢餓感」。小確幸的前提,是飢餓感;或者根本所有的幸福之前提,就是飢餓感。因為滿足了小飢餓感,而得到小確幸,因為滿足了大飢餓感,而感到大幸福。

如果沒有經過那種微小的飢餓、等待、尋找的過程,即使每天早上都可以泡咖啡、下午可以喝啤酒、晚上可以欣賞摺疊好的內褲、聽聽自己喜愛的唱片,那大概也不會有什麼幸福感吧。想一想,喝冰涼啤酒會很幸福,也是在忍耐劇烈運動的燠熱之後;看著折疊好的內褲會很幸福,也是因為花了很多時間在重複無聊的動作之後呀。

因此,我們若想享受生活中的小幸福,一定要常常使自己有所不滿足,並且經歷那不滿足之苦,才會有滿足之甜。No pain no gain. 一樣的意思。


好,既然有所謂的小確幸,那麼有沒有「大」而「虛幻」的幸福呢?

噢,那不就是政治人物跟廣告商最擅長的事嗎?

12/26/2011

jquery essentials

http://speakerdeck.com/u/addyosmani/p/the-jquery-essentials-1


=jQuery Structure=
Core
CSS
Selectors
//attribute selector
$('input[name="attendeeName"]')

Ajax
Attributes
Effects
Properties
Deferred Object
Dimensions
Events
Manipulation
Plugins
Utilities

12/25/2011

健康食物

Sleep (or how to hack your brain) + Dustin Curtis

Sleep (or how to hack your brain) + Dustin Curtis
Non-24-hour sleep-wake syndrome - Wikipedia, the free encyclopedia

The most simple is the “Siesta” method, which includes just one nap in the day and then a huge chunk of sleep at night. Remarkably, adding just one nap during the day shaves an hour and forty minutes off your total sleep requirement.

cdto - Finder Toolbar app to open the current directory in the Terminal

cdto - Finder Toolbar app to open the current directory in the Terminal

Install

To install "> cd to ..." copy it to your Applications folder, and then from the applications folder drag it into the Finder toolbar.

Usage
To use just click on it in the Toolbar and it will open the terminal window

To use with iTerm or X11/xterm, using the finder contextual menu "show package contents" and exchange the plugins in the Plugin/Plugin Disabled folders respectively. Next time you run "cd to" it should open with the correct application.

movist - Movie Player for Mac OS X based on QuickTime & FFmpeg

movist - Movie Player for Mac OS X based on QuickTime & FFmpeg

可以載入多個字幕(最多三個)並且設定分別的顯示位置
可以設定字幕位置低於螢幕
可以設定字幕編碼
左右鍵可以向前後跳10秒
option+左右鍵可以向前後跳60秒

vlc player新版的沒辦法調整字型大小
via: VLC subtitles Preferencesparagon

enca -- detect and convert encoding of text files

enca -- detect and convert encoding of text files

brew install enca

檢查文件編碼
[~/dev/google.code/project/subutil] $ enca foo.srt
Traditional Chinese Industrial Standard; Big5
CRLF line terminators

將文件編碼轉換成utf-8
[~/dev/google.code/project/subutil] $ enca -x UTF-8 < foo.srt > foo.ut8.srt
enca: Iconv conversion error on `/tmp/encaWvyWlGJf': Illegal byte sequence

不一定會成功, 比較可行的方式是 check 編碼後直接在 vlc player 把預設字幕編碼改掉

12/19/2011

[遊戲介紹]唐人街Chinatown @ 桌遊地圖室 :: 痞客邦 PIXNET ::

[遊戲介紹]唐人街Chinatown @ 桌遊地圖室 :: 痞客邦 PIXNET ::

另外有90個商店版塊,共有十二種,上面印有數字3~6,代表商店最大的規模為多少。
例如海鮮店上面的數字為3,代表玩家把3間海鮮店的店鋪連在一起時可以獲得最大獲益,但也是海鮮店的極限。
原則上玩家要盡量透過交易地契或商店來讓自己相同的商店連在一起,
這樣自己每一回合結束都會有龐大的收入。

遊戲開始前玩家先拿取5萬元以及一組玩家標記,將商店版塊都放進布袋裡洗勻,
再將時間標記放在1965年的位置,遊戲總共進行六年(六回合)。

每回合流程如下:
1.抽取店鋪地契牌
依人數以及回合數不同,會分給每個玩家固定數量的地契牌,然後玩家決定要保留哪些。
棄掉的地契牌會放回牌堆,下一回合會再洗勻一次。
然後玩家依照自己保留的地契牌上的數字,放置自己的標記在圖版上。

3人遊戲:7/5;6/4;6/4;6/4;6/4;6/4
4人遊戲:6/4:5/3:5/3:5/3:5/3:5/3
5人遊戲:5/3:5/3:5/3;4/2;4/2;4/2

以三人遊戲為例,第一回合抽七張留五張,第二回合抽六張留四張,依此類推。

2.抽取商店版塊
根據玩家人數和回合數,從布袋中抽取固定數量的商店版塊。
第一回合是抽取步驟1中較大的數字,之後的回合都是抽取較小的數字。
同樣以三人遊戲為例,第一回合抽七個商店版塊,之後都是抽四個。

3.交易
玩家可以就任意東西作交易,金錢、商店版塊或地契。
但已經蓋好的商店不可以移動或移除。
若是用地契或蓋好的商店作交易,則必須改變上面的玩家標記。
要注意的是未來的承諾並無任何約束力,只有當前的交易才有約束力。
另外如果有人說我用一杯多多綠跟你換兩個商店版塊和一個地契時,其他人可以圍毆他(誤),
請勿用遊戲外的東西來交易。

4.蓋商店
由起始玩家開始依順時針方向,決定要蓋多少商店版塊在未開發的土地上,也可以都不蓋,留到下回合。

5.收入
玩家蓋好的商店會有收入。每個相同種類又相連的商店視為同一群。
商店版塊上的數字代表它必須要幾個屬於自己的相同商店相連才算完整的商店群。
若相連的商店版塊數量超過其數字,則當作兩群來計算。

不完整:1個10k;2個20k;3個40k;4個60k;5個80k
完整:3個50k;4個80k;5個110k;6個140k

以數字4的水族館為例,若是只有兩個版塊相鄰則收入是20k,
如果能湊滿四個成為完整商店群的話則收入暴增為80k。
若五個相鄰則收入為80k加10k。

11/17/2011

guard/guard - GitHub

guard/guard - GitHub

Guard is a command line tool to easily handle events on file system modifications (FSEvent / Inotify / Polling support).


tag: git hub watch guard

11/11/2011

s3fs

如果 brew install s3fs 不會過的話,
手動安裝fuse4x 之後再執行 brew intsall s3fs.

11/10/2011

HTTP cookie - Wikipedia, the free encyclopedia

HTTP cookie - Wikipedia, the free encyclopedia

Setting a cookie
Transfer of Web pages follows the HyperText Transfer Protocol (HTTP). Regardless of cookies, browsers request a page from web servers by sending them a usually short text called HTTP request. For example, to access the page http://www.example.org/index.html, browsers connect to the server www.example.org sending it a request that looks like the following one:


GET /index.html HTTP/1.1
Host: www.example.org

browser
-------→
server

The server replies by sending the requested page preceded by a similar packet of text, called 'HTTP response'. This packet may contain lines requesting the browser to store cookies:

HTTP/1.1 200 OK
Content-type: text/html
Set-Cookie: name=value
Set-Cookie: name2=value2; Expires=Wed, 09 Jun 2021 10:18:14 GMT
 
(content of page)

browser
←-------
server


(content of page)
browser
←-------
server
The server sends lines of Set-Cookie only if the server wishes the browser to store cookies. Set-Cookie is a directive for the browser to store the cookie and send it back in future requests to the server (subject to expiration time or other cookie attributes), if the browser supports cookies and cookies are enabled. For example, the browser requests the page http://www.example.org/spec.html by sending the server www.example.org a request like the following:
GET /spec.html HTTP/1.1
Host: www.example.org
Cookie: name=value; name2=value2
Accept: */*

browser
-------→
server
This is a request for another page from the same server, and differs from the first one above because it contains the string that the server has previously sent to the browser. This way, the server knows that this request is related to the previous one. The server answers by sending the requested page, possibly adding other cookies as well.
The value of a cookie can be modified by the server by sending a new Set-Cookie: name=newvalue line in response of a page request. The browser then replaces the old value with the new one.
The term "cookie crumb" is sometimes used to refer to the name-value pair.[23] This is not the same as breadcrumb web navigation, which is the technique of showing in each page the list of pages the user has previously visited; this technique, however, may be implemented using cookies.
Cookies can also be set by JavaScript or similar scripts running within the browser. In JavaScript, the object document.cookie is used for this purpose. For example, the instruction document.cookie = "temperature=20" creates a cookie of name temperature and value 20.[24]
[edit]

HttpOnly cookie

設定cookie時可以指定為 HttpOnly Cookie, 這個 cookie 無法被 javascript 讀出來 (ex: document.cookie)

The Will Will Web | 設定 Cookie 時可善用 HttpOnly 特性減低網站安全風險(XSS)

Cookie hijacking 是個很常見的 XSS 攻擊手法,大多是利用網站既有的 XSS 漏洞並透過 JavaScript 取得 documnet.cookie 資料,而 documnet.cookie 就包含所有你在該網頁所有可用的 Cookie 資料,但若你的網站程式在設定 Cookie 的時候有特別加上 HttpOnly 屬性,就可以進一步避免該頁的 Cookie 被 JavaScript 存取,也可保護使用者的 Cookie 不會偷走。


[Security] HTTP-only cookies
Vidar wrote an interesting article pointing me to HTTPOnly-cookies. Microsoft created this extension to the cookie standard, to allow servers to issue cookies with a special HttpOnly-flag. This flag makes the cookie inaccessible to javascript in supported browsers (currently only newer versions of IE supports this feature fully).

The set-cookie header looks like this:
Set-Cookie: USER=123; expires=Wednesday, 09-Nov-99 23:12:40 GMT; HttpOnly


HttpOnly - OWASP

HTML5 Canvas的Origin-Clean安全原則 - 黑暗執行緒

HTML5 Canvas的Origin-Clean安全原則 - 黑暗執行緒

前幾天介紹了如何利用toDataURL()將canvas繪製結果轉為圖檔的做法,但實際應用時,卻發現常常會冒出奇怪的錯誤:

在IE, Chrome或Safari上出現: SECURITY_ERR: DOM Exception 18
在FireFox則是冒出: 0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)
原來,跟Cross-Site Scripting的限制一樣,HTML canvas也有其安全原則! 簡單來說,可想成每個canvas有個origin-clean旗標,一開始預設為true,一旦有下列任一情況發生時,origin-clean旗標即被設為false:

drawImage()時,使用與document不同來源(origin,跟瀏覽器跨網域議題裡網域的概念差不多)的image或video作為材料
drawImage()時,使用orgin-clean=false的canvas作為材料
fillStyle使用其他來源的image或video作為pattern
fillStyle使用其他orgin-clean=false的canvas建立的pattern
strokeStyle使用其他來源的image或video作為pattern
strokeStyle使用其他orgin-clean=false的canvas建立的pattern
fillText()或strokeText()使用其他來源的字型
一旦canvas的orgin-clean旗標被設為false,此時若呼叫toDataURL()、getDataImage()或measureText()等方法,都會引發安全性錯誤[DOMException.SECURITY_ERR (18)]! 最簡單的例子,就是網站A網頁上的canvas,在drawImage時,引用了放在網站B的某個圖檔當作 src,則該canvas就無法再執行toDataURL()了!

新店步道

(美美美) 直潭山登山步道導覽圖
銀河洞越嶺步道 @ 我的赤腳旅行‧My Barefoot Travel :: 隨意窩 Xuite日誌
[台北新店].行啟紀念碑.屈尺道碣.礦工寮.和美山新步道.灣潭 (Tony的自然人文旅記第0807篇)
[新北市新店] .碧潭.和美山步道 (Tony的自然人文旅記第0832篇)

邪典電影 - 维基百科,自由的百科全书

邪典電影 - 维基百科,自由的百科全书

邪典電影(Cult Film)是指那些在小圈子內被支持者喜愛及推崇的電影,也可稱為非主流電影或另類電影。這種電影通常難以獲得小圈子外的大規模票房成功。它不是一種嚴格的電影類型,也不是一種電影風格。因為所處的地區不同,Cult Film的定義非常難下定論,例如香港的武俠片以及日本的特攝片尤其是怪獸系列,被歐美視為Cult Film,在當地則列入主流電影,廣範且成功得到商業利益。


Top Ten Cult Films, Then And Now - Santa Cruz News
1. THE BIG LEBOWSKI (1998) The movie that saved cult movies. Coming off hits Raising Arizona and Fargo, no one expected anything less than a slam dunk at the box office from the Coen brothers when Lebowski was released. But writer/directors the Coens had layered the movie so densely—packing it with circular dialogue, out-there characters and enough quotable lines for 10 movies—that audiences simply couldn’t digest it in one sitting in theaters.

The Big Lebowski disappeared quickly, and it wasn’t until movie geeks started watching the movie over and over that its sheer magnificence shone through. The Big Lebowski had such an effect on fans that in the early 2000s they started dressing in robes like The Dude and going to midnight screenings (full disclosure: I was one of them). Viewings were accompanied by White Russians and sometimes bowling (never on Shabbas).

Eventually, four duderinos started the now-legendary Lebowski Fests, wrote a book about it called I’m a Lebowski, You’re a Lebowski where they extensively quoted the movie’s cultists (full disclosure: I was one of them), and finally brought the original cast back together in New York for a reunion this month.

2. DONNIE DARKO (2001) The fact that this film flopped can’t be blamed entirely on the fact that it was released right after 9/11, or even that final cut was taken away from director Richard Kelly, resulting in a theatrical version that didn’t make sense. Even after the director’s cut restored the film’s logic with extensive backstory, people realized that this movie was just un-freakin’-believably weird.

But Donnie Darko’s creepy vision of a teenager either losing his mind or trapped in a time-travel nightmare hooked fans on home video. (Kelly is adamant that the sci-fi stuff in the film should be taken as real, and the director’s cut makes this way more obvious, but after many viewings of both I actually prefer the greater ambiguity of the theatrical version.) Jake Gyllenhaal’s performance as the title character is perfectly twisted, and Kelly’s use of the soundtrack is genius. The film’s current level of cult fame was best summed up in Campbell electro group the Limousines’ song “Very Busy People”: “That Donnie Darko DVD has been repeating for a week, and we know every single word.”

3. ANCHORMAN (2004) Loved by many, loathed by some, this first collaboration from producer Judd Apatow, director Adam McKay and star Will Ferrell eventually paved the way for their megahit Talladega Nights. But at the time, the mainstream found Anchorman puzzling, and audiences never gave it a chance.

It had that stupid Ron Jeremy–parodying subtitle “The Legend of Ron Burgundy,” and was filled with highly improvised, absurd and even nonsensical humor, not to mention an unrecognizable Paul Rudd (I still forget it’s him). What’s more, it is the kind of movie that makes you laugh maybe three or four times on first viewing, a little more often the second time through, and so on until it can have fans rolling in sheer anticipation of lines and news-anchor gang fights to come. Steve Carell recently named über-dolt Brick Tamland as his favorite character he’s ever played. He also loves lamp.

4. FIGHT CLUB (1999) In his great tell-all What Just Happened? , producer Art Linson remembers that Fox executives completely freaked out when they first saw the movie they had paid David Fincher to make out of Chuck Palahniuk’s book. The way he tells it, they were downright scared of the film and its Molotov cocktail of anti-consumerism, violence, anarchy and man boobs, and made it their mission to sabotage the success of their own movie.

But it quickly found an audience on DVD, with a whole generation of disaffected suburban white kids turning “I am Jack’s (fill in the blank)” into their own punk manifesto. Most fascinating to me is Fincher’s obsession with putting bizarre suicide attempts at the end of his films (he also did it in Se7en and The Game). His recurring message seems to be: In order to be free in the modern world, you have to be willing to give up everything, including your life. In any case, the finale, set to the Pixies’ “Where Is My Mind?,” is one of the most subversive and lyrical of any film ever.


5. AUDITION (1999) Japanese director Takashi Miike is a cult-movie machine. Ichi the Killer, Visitor Q and Gozu all have their followings, but Audition is the film that made movie geeks sit up and take notice. Ironically, it’s also his most simple and straightforward film.

The first hour is deceptively mundane, telling the story of a Japanese widower who is convinced to audition girls to be his new wife (using a nonexistent film role as cover). He picks the one who seems to be the sweetest and most submissive of all, Asami.

Of course, this is all a set-up for one of the nastiest third acts in the history of horror, and the film quickly became a favorite of both gorehounds and art-movie types with a strong stomach. Everybody else walked out (I first saw it at a mall in L.A. where most of the small audience really did). The last decade has seen a return to extreme filmmaking—from junk like August Underground to the incredible French film Inside—but nothing has had the power of Miike’s movie.


6. THE ROOM (2003) A brief history of The Room: Rejected by the studios, director Tommy Wiseau spends $6 million financing his own film, of which he is also the star. Critics barely even have time to rip it to shreds before it disappears from theaters.

Then, like so many cult films before it, it gets booked as a midnight movie. For six years, it plays once a month in L.A., and word of mouth spreads about this latest contender in the “worst film of all time” sweepstakes, a barely comprehensible melodrama driven not so much by its love-triangle plot as by non sequiturs and unintentionally hilarious dialogue.
Wiseau suddenly claims the unintentional humor was intentional. No one believes him. The movie goes on the road to sold-out screenings, beginning in New York. The two most famous WTF scenes—a rooftop conversation (“I did not hit her, I did not … Oh, hi Mark!”) and a scene where the guys throw around a football in tuxedos, go viral on YouTube, drawing even more barely suspecting victims to its midnight screenings.

Fans begin throwing plastic spoons at the screen (a reference to a framed picture of a spoon that Wiseau fixates on for no reason), inviting comparisons to the rabid cult of Rocky Horror Picture Show 30 years earlier. Wiseau’s performance alone—he comes across like a malfunctioning Christopher Walken android with a heavy, impossible to place accent—guarantees this will be a cult favorite for years to come.

7. MULHOLLAND DRIVE (2001) Throughout his career, David Lynch has basically made one cult film after another, his dream-state logic and hallucinogenic imagery never fully connecting with mainstream audiences. Whether it’s Eraserhead, Blue Velvet, TV’s Twin Peaks or Wild at Heart, his films were pretty much surefire cult stuff until the ’90s, when the Twin Peaks movie, some failed TV shows and Lost Highway turned even movie geeks off.

His comeback was this film, originally filmed as a TV movie, then reworked extensively to be a feature film after ABC execs rejected it. (Its history can be traced even further back, as Lynch has said it was born out of his ideas for a third season of Twin Peaks that never came about.) In retrospect, it’s easy to see that Lost Highway was basically a failed dry run for Mulholland Drive—it uses identical plot devices like characters with two different identities and nonlinear structures.

But with Mulholland Drive, possibly his best film, Lynch was able to prop up his mysterious storyline with an actual narrative solution, which was so subtly embedded in the film that most viewers didn’t catch it until the second or third viewings (anyone who never figured it out or wrote the movie off as nonsensical should google Lynch’s own 10 clues).

Of course, it’s not all about the destination—the journey through the world of Mulholland Drive is one of the most fascinating Lynch has ever devised, with Naomi Watts’ intense performance grounding the surreal surroundings.


8. WET HOT AMERICAN SUMMER (2001) The people behind this movie claim it’s based on their actual experiences. If that’s even remotely true, summer camp may quickly replace drugs and gangs as the number-one threat to the youth of America.

In reality, this movie is an absurdist twist on the early-’80s films that tried to cash in on the success of Animal House by setting their teen hi-jinx at camp. (Yes, Meatballs, but also the much lesser-known Gorp, which like this movie is set at a Jewish summer camp).

Wet Hot American Summer throws in black comedy, Monty Python–type scenes like the most awesomely funny motorcycle chase ever, and insane plot threads like a talking can of vegetables and the threat of Skylab falling on Camp Firewood. Most critics and audiences didn’t get it, and despite a cast featuring Janeane Garofalo, David Hyde Pierce, Paul Rudd, Elizabeth Banks and Amy Poehler (not to mention the screen debut of The Hangover’s Bradley Cooper), it flopped big time. But it found a cult following on video and within a few years was making the midnight movie rounds.

9. HAROLD & KUMAR GO TO WHITE CASTLE (2004) The little stoner movie that could. Written off by the uninitiated as braindead on arrival, those who actually gave this movie a chance were surprised to discover it’s actually a pretty sharp piece of social satire. Stars John Cho and Kal Penn deserve a lot of the credit for playing Harold and Kumar with charm and a certain innocence.

The other smart thing about Harold & Kumar Go to White Castle is that unlike bad stoner movies like Pineapple Express, it doesn’t overcomplicate things with unnecessary plot. This movie is, on a story level at least, about nothing but Harold and Kumar trying to find a White Castle. What they encounter along the way, like Neil Patrick Harris in the cameo that made him cool, is what makes the movie.

The cult for this got so big that there was a 2008 sequel, Harold & Kumar Escape From Guatanamo Bay, with a slightly bigger budget and a slightly bigger take at the box office. It satisfied cultists, leading to the upcoming A Very Harold & Kumar Christmas.

10. BLACK DYNAMITE (2009) The blaxploitation genre was deserted by the masses long ago; even Quentin Tarantino couldn’t do much for it with his tribute, Jackie Brown. Along comes musclebound actor Michael Jai White (best known for bits parts in Universal Soldier and The Dark Knight, and for starring in Spawn), who had an idea in 2006 for the ultimate blaxploitation badass, making a $500 trailer and co-writing a script with director Scott Sanders and co-star Byron Minns.

The humor is so deadpan and the attention to detail so perfect that it’s almost too easy to call Black Dynamite a spoof or even an homage—it’s more like an honest-to-god blaxploitation film with every element pushed to the point of absurdity. White’s portrayal of the Vietnam vet/ex-CIA title character is almost freakishly spot on, and the movie follows in the footsteps of Rudy Ray Moore’s Dolemite with its vision of an oversexed, superbad African American alpha male on a rampage.

The lines are endlessly quotable (“Why, Black Dynamite? Why?”), and even the little soul songs that describe the plot throughout the film are note-perfect. The movie was finally released in 2009, but only played in theaters for two weeks; it found a following at midnight screenings and on DVD. You can bet Tarantino has two copies.



TOP TEN CLASSIC CULT FILMS

1. BLADE RUNNER (1982) In three decades, the reputation of Ridley Scott’s best film has swung slowly from “unlovable big-budget sci-fi flop” to “the pinnacle of cinematic achievement.” No kidding, this is now the movie that every geek on the Internet seems to use to prove they have good taste in movies—the ultimate insult in a movie-related flame war goes something along the lines of “Well, I watch movies like Blade Runner and The Big Lebowski, you probably like Twilight.”

That’s a far cry from what people were saying in 1982, when it failed to be the blockbuster hit that everyone expected from the director of Alien and a leading man who had just played Han Solo and Indiana Jones. But critics and audiences found Scott’s vision of epic future-fail too dark, and Harrison Ford too cold and distant as android hunter Rick Deckard.
On home video though, there was time to watch every incredible detail of Scott’s dystopian Los Angeles in 2019 (it could still happen, people!) over and over. And now we know that Ford played the character that way to suggest that Deckard was himself an android (don’t argue, just give in to the red-eye and unicorn clues).

After exhausting the five-disc “Ultimate Collector’s” DVD (with all three cuts of the movie) and reading the making-of book, I can safely say there’s nothing about the story of this movie that hasn’t been told by now. And yet, there’s a mystical, more-than-the-sum-of-its parts quality to the film that continues to promise the revelation of new secrets with each repeat viewing. In other words, it is the ultimate cult movie.

2. THE ROCKY HORROR PICTURE SHOW (1975) This ranking doesn’t have much to do with the quality of the film: it is neither as life-alteringly amazing as its die-hard fans claim, or as abysmally awful as its critics say. It’s a fun, campy and, for its time, pretty edgy little genre mash-up that manages to pay tribute to musicals, monster movies and science fiction double features at the same time that it subverts their button-down moralizing. (Tim Curry as the cross-dressing Dr. Frank-N-Furter is the highlight of every scene he’s in.)
The simple truth is: There wouldn’t be cult films as we know them today without Rocky Horror Picture Show. It started the midnight movie craze and still brings out hordes of dressed-up, line-spewing, toast-chucking fanatics wherever and whenever it’s shown.


3. THIS IS SPINAL TAP (1984) There’s a reason why this is the most quoted cult film of all time. First-time viewers will latch on to the most obvious jokes—“these go to 11,” “none more black.”

But getting sucked into this mother of all mockumentaries is like going down the rabbit hole. By the third or fourth viewing, more subtle stuff like “mime is money” is starting to jump out, and by the 10th, completely buried jokes like the one about Boston: “I wouldn’t worry about it, though, it’s not a big college town.” To think that most of this dialogue was improvised is mind-blowing, although I was lucky enough to interview Michael McKean in character as David St. Hubbins, and I can attest that his improvised answers were as funny as anything in the film.

It’s also hard to believe it took so long to find an audience on video, although director Rob Reiner has said that the movie went over the heads of many people who thought Spinal Tap was a real band. Ironically, they did become one, with McKean and co-stars Christopher Guest and Harry Shearer “getting the band back together” for albums in 1992 and 2009, and touring.


4. NIGHT OF THE LIVING DEAD (1968) Every installment of Romero’s original zombie trilogy is an important cult film, but this one takes the cake because without it, we wouldn’t have the modern zombie movie. Before this, zombies were the stuff of quaint voodoo flicks, but Night of the Living Dead changed everything. It used the idea of the dead coming back to life to eat the living as a blank slate onto which the whole world could project its fears.

Endless big-brain theories sprung up to explain the film: Did the undead symbolize the oppressed proletariat? The revenge of the third world? And all this over a little black-and-white drive-in movie made for $140,000. Romero’s most brilliant move was making the zombies slow, lurching ghouls who overwhelm their prey with sheer numbers and relentless onslaught—they literally “crowd out” most of their victims. The ending is one of the most shocking in movie history, although I’ve never believed the official line that its racial overtones were unintentional. The scene may have, as Romero says, been written before African American Duane Jones was cast as Ben, but I guarantee everyone involved knew the message they were sending when they shot it.

5. MONTY PYTHON AND THE HOLY GRAIL (1975) There’s a long-running debate among Monty Python fans as to which is their best film, Holy Grail or Life of Brian. But really, there’s no contest: Holy Grail is perfect, from the many scenes that could have been skits in their earlier TV series (“Bring out your dead,” the Bridge of Death, etc.) to the funny throwaway lines like “Someday, all this will be yours”… “What, the curtains?”

What’s most ingenious about it all is that, rather than trying to hide the absurdity of a poorly financed comedy troupe trying to pull off a medieval period piece, the Pythons play it up whenever possible. The characters don’t ride horses, they skip along while banging coconuts together to sound like hooves, and the epic moment of their discovery of Camelot is undercut by the dismissive “It’s only a model.” Graham Chapman is perfect as the beleagured King Arthur, who has to put up with mouthy peasants, rude French soldiers and a Black Knight who doesn’t know when to call it a day.


6. REPO MAN (1984) Though it’s now one of the iconic cult films of the ’80s, writer-director Alex Cox’s debut studio film came this close—more than once—to never being released at all. Cox, a UCLA film student at the time, wasn’t about to languish in development hell, however, and he gained his first real notoriety when he took out an ad in Variety daring Universal to make his movie. Still, he told me his midnight-movie favorite never would have seen the light of day if it hadn’t been for one man named Kelly Neal, who believed in it so much he kept shuttling it from one college campus to the next until it finally caught on. Neal lost his job at Universal because of it, but cult film fans got Emilio Estevez—pretty in punk before Pretty in Pink—as a young misfit who falls in with Harry Dean Stanton and a bunch of crazy repo men. They’re all on the trail of a mysterious 1964 Chevy Malibu that could be carrying aliens, a neutron bomb or time-machine technology. Along the way, Estevez learns the repo code, discovers the secret of air fresheners and sings classic punk tunes. It’s not as weird as it sounds, though. It’s much, much weirder.


7. PINK FLAMINGOS (1972) Chicken sex. Semen injections. Girl-on-girl vomit. Turd eating. Edith Massey. Those are just a few of the things that make Pink Flamingos the kind of movie that makes you want to take a shower after watching it.

The story of transvestite Divine’s quest to be “the filthiest person alive,” it’s got to be the most revolting film ever made. But its hour-and-a-half-long wallow in perversity and bad taste is exactly what made it so notorious, putting director John Waters on the map. When I interviewed him a few years ago, Waters marveled at how much things have changed since then, with Pink Flamingos playing on TV: “How can that be?” he pondered. “I mean, cable, but still.”

8. THE TEXAS CHAINSAW MASSACRE (1974) It’s hard to imagine now what it was like for audiences to see TCM when it came out. Wes Craven told me that when he saw it in a theater shortly after it was released, he found it so shocking and insane that he thought it might have been made by some sick cult somewhere.

He wasn’t that far off, as the production of director Tobe Hooper’s meat-versus-steel nightmare was as terrifying as the film itself (Edwin Neal, who plays the hitchhiker, said after filming wrapped: “If I see Tobe Hooper again, I’ll kill him”).

Though John Carpenter’s Halloween gets all the credit/blame for starting the slasher-movie cycle, Hooper’s film had most of the key elements of the formula in place: a masked killer, a group of teens being picked off one by one in a series of bizarre murders and, most importantly, the “Final Girl” element that would come to be mandatory.

Perhaps it doesn’t get the recognition it deserves as a trendsetter because it’s so weird and surreal that it’s hard to group it in with other movies; there hasn’t been one quite like it before or since.


9. TAXI DRIVER (1976) When the people responsible for making one of the most important films of all time are on record publicly questioning whether it ever should have been made in the first place, you know you’re talking about a film that transcends the normal considerations of what makes a movie “good” or “bad.”

Nor is there any notion of good or bad to be found in Martin Scorsese’s film, a reflection of the murky moral universe Americans felt themselves adrift in during the post-Watergate years of the mid-1970s. Taxi Driver never loses its power to disturb because it has no exterior moral universe whatsoever; the only codes of behavior on the table come out of the inner workings of Travis Bickle’s brain, and it’s pretty spooky in there. Robert De Niro allegedly studied both taxi drivers and mental illness to prepare for the role; the movie ends up being about both and neither.


10. ERASERHEAD (1977) To paraphrase Laurence Fishburne in The Matrix: No one can be told what Eraserhead is. You have to see it for yourself. Made for $10,000 over five years of on-again, off-again production, David Lynch’s debut film is as unsettling now as it was three decades ago. Not since Luis Buñuel and Salvador Dali collaborated on Un Chien Andalou in 1929 had there been a film whose surreal imagery tapped so directly into the viewer’s subconscious.

Eraserhead is uncomfortable viewing, and its most disturbing scenes (with the “baby,” for instance) are now the stuff of legend. But nothing is more revealing about this movie than the fact that the dream sequences are no weirder than those the characters experience in waking life. In Lynch’s world, there’s no such divide.

11/03/2011

iTerm2

iTerm2

iTerm2 is a terminal emulator for Mac OS X that does amazing things.

iTerm2新手应知特色功能
一种是用鼠标,在iterm2中,选中某个路径或者某个词汇,那么,iterm2就自动复制了。
在新Tab中自动使用前一Tab路径
command+d:垂直屏幕切割;
command+shift+d:水平屏幕切割
command+enter进入与返回全屏模式
保存当前快照 Window > Save Window Arrangement.
恢复快照: Window > Restore Window Arrangement
可以在Preferences > General > Open saved window arrangement.设置自动恢复快照
cmd+i can rename a tab

利口酒

利口酒 - 维基百科,自由的百科全书

利口酒,即餐後甜酒,譯自法語名稱Liqueur,還曾轉音為「利喬酒」或「力嬌酒」。它是用白蘭地為基酒,加入果汁和糖漿再浸泡各種水果或香料植物製成。所以利口酒氣味芬芳,口味甘美,適合餐前飯後單獨飲用。利口酒比重較大,所以特別適合用以調配各種色彩層次的雞尾酒。
目前利口酒也有用威士忌作基酒的,或用葡萄酒作基酒,用葡萄酒作基酒的利口酒已經和苦艾酒很相似了,不過比苦艾酒甘甜。

11/02/2011

Check if gzip is enabled

Check if gzip is enabled

curl -I -H "Accept-Encoding: gzip,deflate" "$URL" --silent | grep -i "Content-Encoding:"

# OR
curl -H "Accept-Encoding: gzip,deflate" "$URL" --silent --write-out "%{size_download}" --output /dev/null
curl "$URL" --silent --write-out "%{size_download}" --output /dev/null
# 2nd must be greater the 1st


function check_compression {
local unzipped=`curl "$1" --silent --write-out "%{size_download}" --output /dev/null`
local zipped=`curl -H "Accept-Encoding: gzip,deflate" "$1" --silent --write-out "%{size_download}" --output /dev/null`
echo "unzipped size: $unzipped, zipped size: $zipped"
}


telnet l.yimg.com 80
GET /f/a/tw/js/flash_general_20090213.js HTTP/1.1
HOST: l.yimg.com

response:
function yad_ad_090213(e,q,t,o,g,m,l,s,h,d,a){var f=window.location.href;if(e&&q&&t&&o&&g&&m&&l&&s&&h&&d&&a){if(typeof(this["yad_plugin_flash"+d])=="undefined"){var b=(navigator.appVersion.indexOf("MSIE")!=-1)?true:false;var c=(navigator.appVersion.toLowerCase().indexOf("win")!=-1)?true:false;var p=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;yad_ControlVersion=function(){var v=-1,w,u;try{w=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.8");v=w.GetVariable("$version")}catch(u){}return v};yad_GetSwfVer=function(){var B=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){var y=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";var x=navigator.plugins["Shockwave Flash"+y].description;var w=x.split(" ");var v=w[2].split(".");var A=v[0];var u=v[1];if(w[3]!=""){yad_tempArrayMinor=w[3].split("r")}else{yad_tempArrayMinor=w[4].split("r")}var z=yad_tempArrayMinor[1]>0?yad_tempArrayMinor[1]:0;var B=A+"."+u+"."+z}}else{if(b&&c&&!p){B=yad_ControlVersion()}}return B};yad_getVerNum=function(v){if(v==-1){return v}else{if(v!=0){if(b&&c&&!p){yad_tempArray=v.split(" ");yad_tempString=yad_tempArray[1];yad_versionArray=yad_tempString.split(",")}else{yad_versionArray=v.split(".")}var x=yad_versionArray[0];var u=yad_versionArray[1];var w=yad_versionArray[2];return x}else{return -1}}};var k=yad_GetSwfVer(),n=yad_getVerNum(k);this["yad_plugin_flash"+d]=false;if(n>=d){this["yad_plugin_flash"+d]=true}}var r="",j="clickTAG";for(i=0;i<e.length;i++){i==0?r+=j+"="+encodeURIComponent(e[i])+"&yad_time="+h+"&yad_page="+encodeURIComponent(f)+"&":r+=j+i+"="+encodeURIComponent(e[i])+"&yad_time="+h+"&yad_page="+encodeURIComponent(f)+"&"}this["yad_plugin_flash"+d]?document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+m+'" height="'+l+'" id="adbn_swf_'+g+'" ><param name="movie" value="'+q+'" /><param name="wmode" value="'+s+'" /><param name="loop" value="true" /><param name="quality" value="high" /><param name="allowScriptAccess" value="'+a+'" /><param name="flashvars" value="'+r+'" /><embed src="'+q+'" loop="true" wmode="'+s+'" quality="high" name="adbn_swf_'+g+'" width="'+m+'" height="'+l+'" flashvars="'+r+'" type="application/x-shockwave-flash" allowScriptAccess="'+a+'"></embed></object>'):document.write('<a href="'+t+'" target="_blank"><img src="'+o+'" width="'+m+'" height="'+l+'" border="0" /></a>')}}function yad_showAd_090213(){if(yad_pos.lastIndexOf("%")!=-1){yad_pos="yad"}if(yad_url&&yad_swf&&yad_aurl&&yad_aimg&&yad_pos&&yad_w&&yad_h&&yad_wmode&&yad_time&&yad_ver&&yad_allowscript){yad_ad_090213(yad_url,yad_swf,yad_aurl,yad_aimg,yad_pos,yad_w,yad_h,yad_wmode,yad_time,yad_ver,yad_allowscript)}}yad_showAd_090213();var yad_flash_lib_loaded_090213=true;

telnet l.yimg.com 80
GET /f/a/tw/js/flash_general_20090213.js HTTP/1.1
HOST: l.yimg.com
Accept-Encoding: gzip, deflate

response:
HTTP/1.1 200 OK
Date: Wed, 26 Oct 2011 15:27:01 GMT
Cache-Control: max-age=31536000
Expires: Thu, 25 Oct 2012 15:27:01 GMT
Last-Modified: Fri, 13 Feb 2009 06:26:17 GMT
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Type: application/x-javascript
Content-Encoding: gzip
Age: 594506
Content-Length: 1180
Connection: keep-alive
Server: YTS/1.20.4

?Vko?6?+
?1D;v^k?Ё?dE?u??`-QIT?W\W$%?;m??׹????屓1????c?fR?2đ?"??E?ZD.Y???(?n ?7d?I!|?0??C?CAB?B@?B(?%&[&??!`?(?$?}Ͻ???ݙ?1?c?z,?.?)،I?|?q?%I?TK;??g?Ϗ?w?:?u???<?t?d?wd3?/??!)5??&??;??mEyJ?اq??|H? d??7<??5A7k?
i?g?????w<?x`h???n̾}?1?j???g?^=?y{?5,p??DA`/g]???`???,?k7MB&?o?L???Y??mvǸ??fz??i?bWN?fG?
ӎ??؎r{????,???V?????Ȫ???k?]?V?????^U??[?&?{'?YS{'??a??k?ܬ:?????3޹t??b?Q????q?N??a?Z}??O????NȜ?ǟ????d?7dW???Cf?2A?????l??Mc??????ox??X6:?N?̲?g???Y&ħ??<%Z/?4W?G???N?]
?Q????nj8?2WE????nn'?w????m??w????ɇ????????yO??dn`plG?10?? S?P-?2?.?yZz?c?W{??1QE?` s??^?dSF??-Lzr??!*?{?????^?A??tD???ۍ???-9@??*?i??5R??RF??i???4ƵV5Ƽ??wC??dm?zQH%????{?䵓???S????p????D; Ǻ<F??`?r???8J&ӔD?K??|??Y?`??F????悞? ??U?m?ä??x???SW8??Y?f????湱jN??j๐_j???? Yoiq=?b?????Y??????g??5?*??ײ&߼??????a?c???D-#?[??:"?`վ??<d?yȉK[?n???o??L?

Connection closed by foreign host.


SSL:
openssl s_client -connect www.example.com:443 -state


GET /foo/javascripts/bar.js?0.0.26 HTTP/1.1
HOST:www.example.com
Accept-Encoding: gzip,deflate

curl -H "Accept-Encoding: gzip,deflate" https://www.htctouch.com/personalize/javascripts/htc-scenebuilder.js?0.0.26

How to Change the Default Email Client on Mac OS X

How to Change the Default Email Client on Mac OS X

1. Launch Apple Mail (Mail.app).
If you've not set up Mail, set up a dummy POP, IMAP, or Exchange account (it will try and verify, get an error, but still allow you to continue). Keep filling in information and hitting continue until you can get to the next step:
2. Go to Mail > Preferences in the menu.
3. Click on "General" tab.
4. In the "Default Email Reader" pull-down menu, choose Select, browse to the email client application you want to use, highlight it and click "Select".
5. Close the Preferences dialog box.

10/28/2011

困境與抉擇 清大動機所彭明輝教授

困境與抉擇 清大動機所彭明輝教授

人生最艱難的事,恐怕莫過於面對困境而不氣餒,以及面對艱難的抉擇時,能夠心平氣和地做出清晰而明智的決定。但是,這兩件事之所以艱難,其實完全只是因為我們誇大了人生偶然際遇的重要性。假如我們可以清楚地看到人生的真相,從來不會因為生命裡偶然的際遇而有重大的改變,面對困境與抉擇的能力,將會簡單到不可思臆的程度。

有次清華電台訪問我:「老師,你如何面對人生中的困境?」我當場愣在那裡,許久都想不出我這一生什麼時候有過困境!這是怎麼一回事?我的兩個孩子國中成績都沒有到「就算失常也穩考得上」的程度,但是我和兩個孩子卻都不曾在聯考前夕真正地焦慮過。這又是怎麼做到的?在這篇文章裡提供你幾個秘訣。

許多同學應該都還記得聯考前夕的焦慮:差一分可能就要掉好幾個志願,甚至於一生的命運從此改觀!到了大四,這種焦慮可能更強烈而複雜:到底要先當兵、就業,還是先考研究所?我就經常碰到學生充滿焦慮地問我這些問題。可是,這些焦慮實在是莫需有的!

生命是一種長期而持續的累積過程,絕不會因為單一的事件而毀了一個人的一生,也不會因為單一的事件而救了一個人的一生。屬於我們該得的,遲早會得;屬於我們不該得的,即使僥倖巧取也不可能長久保有。如果我們看得清這個事實。許多所謂「人生的重大抉擇」就可以淡然處之,根本無需焦慮。而所謂「人生的困境」,也往往當下就變得無足掛齒。

以聯考為例:一向不被看好的甲不小心猜對十分,而進了建國中學;一向穩上建國的乙不小心丟了廿分,而到附中。放榜日一家人志得意滿,另一家人愁雲慘霧,好像甲、乙兩人命運從此篤定。可是,聯考真的意味著什麼?建國中學最後錄取的那一百人,真的有把握一定比附中前一百名前景好嗎?僥倖考上的人畢竟仍舊只是僥倖考上,一時失閃的人也不會因為單一的事件而前功盡棄。一個人在聯考前所累積的實力,絕不會因放榜時的排名而有所增減。因為,生命是一種長期而持續累積的過程!所以,三年後乙順利地考上台大,而甲卻跑到成大去。這時回首高中聯考放榜的時刻,甲有什麼好得意?而乙又有什麼好傷心?同樣的,今天唸清大動機系的人當年聯考分數都比今天唸成大機械的人高,可是誰有把握考研究所時一定比成大機械的人考得好?仔細比較甲和乙的際遇,再重新想想這句話:「生命是一種長期而持續的累積過程,不會因一時的際遇而中止或增減」。聯考排名只不過是個表象。有何可喜、可憂、可懼?

我常和大學的同學談生涯規劃,問他們三十歲以後希望在社會上扮演什麼樣的角色。可是,到現在沒有人真的能回答我這個問題,他們能想到的只有下一步到底是當兵還是考研究所。聯考制度已經把我們對生命的延續感徹底瓦解掉,剩下的只有片斷的「際遇」,更可悲的甚至只活在放榜的那個(光榮或悲哀的)時刻!但是,容許我不厭其煩地再重複一次:生命的真相是一種長期而持續的累積過程,該得的遲早會得到,不該得的不可能長久保有。我們唯一該關切的是自己真實的累積過程(這是偶發的際遇所無法剝奪的),而不是一時順逆的際遇。如果我們能看清楚這個事實,生命的過程就真是「功不唐捐」,沒什麼好貪求,也沒什麼好焦慮的了!剩下來,我們所需要做的無非只是想清楚自己要從人生獲得什麼,然後安安穩穩,勤勤懇懇地去累積就是了。

我自己就是一個活生生的例子。從一進大學就決定不再唸研究所,所以,大學四年的時間多半在唸人文科學的東西。畢業後工作了兩年,才決定要唸研究所。碩士畢業後,立下決心:從此不再為文憑而唸書。誰知道,世事難料,當了五年講師後,我又被時勢所迫,卅四歲才整裝出國唸博士。出國時,一位大學同學笑我:全班最晚唸博士的都要回國了,你現在才要出去?兩年後我從劍橋回來,眼裡看著別人欣羨敬佩的眼光,心裡卻只覺得人生際遇無常,莫此為甚:一個從大一就決定再也不鑽營學位的人,竟然連碩士和博士都拿到了!屬於我們該得的,那樣曾經少過?而人生中該得與不該得的究竟有多少,我們又何曾知曉?從此我對際遇一事不能不更加淡然。

當講師期間,有些態度較極端的學生曾當面表現出他們的不屑;剛從劍橋回來時,卻被學生當做傳奇性的人物看待。這種表面上的大起大落,其實都只是好事者之言,完全看不到事實的真相。從表面上看來,兩年就拿到劍橋博士,這好像很了不起。但是,在這「兩年」之前我已花整整一年,將研究主題有關的論文全部看完,並找出研究方向;而之前更已花三年時間做控制方面的研究,並且在國際著名的學術期刊上發表過數篇論文。而從碩士畢業到拿博士,其間七年的時間我從未停止過研究與自修。所以,這個博士其實是累積了七年的成果(或者,只算我花在控制學門的時間,也至少有五年),根本也沒什麼好驚訝的。常人不從長期而持續的累積過程來看待生命因積蓄而有的成果,老愛在表象上以斷裂而孤立的事件誇大議論,因此每每在平淡無奇的事件上強作悲喜。可是對我來講,當講師期間被學生瞧不起,以及劍橋剛回來時被同學誇大本事,都只是表象。事實是:我只在乎每天廿四小時點點滴滴的累積。拿碩士或博士只是特定時刻裡這些成果累積的外在展示而已,人生命中真實的累積從不曾因這些事件而中止或加添。

常有學生滿懷憂慮地問我:「老師,我很想先當完兵,工作一兩年再考研究所。這樣好嗎?」「很好!這樣子有機會先用實務來印證學理,你唸研究所時會比別人更瞭解自己要的是什麼。」「可是,我怕當完兵又工作後,會失去鬥志,因此考不上研究所。」「那你就先考研究所好了。」「可是,假如我先唸研究所,我怕自己又會像唸大學時一樣茫然,因此唸得不甘不願的。」「那你還是先去工作好了!」「可是....」我完全可以體會到他們的焦慮,可是卻無法壓抑住對於這種對話的感慨。其實,說穿了他所需要的就是兩年研究所加兩年工作,以便加深知識的深廣度和獲取實務經驗。先工作或先升學,表面上大相逕廷,其實骨子裡的差別根本可以忽略。在「朝三暮四」這個成語故事裡,主人原本餵養猴子的橡實是「早上四顆下午三顆」,後來改為「朝三暮四」,猴子就不高興而堅持要改回到「朝四暮三」。先工作或先升學,其間差異就有如「朝四暮三」與「朝三暮四」,原不值得計較。但是,我們經常看不到這種生命過程中長遠而持續的累積,老愛將一時際遇中的小差別誇大到攸關生死的地步。

最諷刺的是:當我們面對兩個可能的方案,而焦慮得不知何所抉擇時,通常表示這兩個方案或者一樣好,或者一樣壞,因而實際上選擇那個都一樣,惟一的差別只是先後之序而已。而且,愈是讓我們焦慮得厲害的,其實差別愈小,越不值得焦慮。反而真正有明顯的好壞差別時,我們輕易的就知道該怎麼做了。可是我們卻經常看不到長遠的將來,短視地盯著兩案短期內的得失:想選甲案,就捨不得乙案的好處;想選乙案,又捨不得甲案的好處。如果看得夠遠,人生長則八、九十,短則五、六十年,先做那一件事又有什麼關係?甚至當完兵又工作後,再花一整年準備考研究所,又有什麼了不起?

當然,有些人還是會憂慮道:「我當完兵又工作後,會不會因為家累或記憶力衰退而比較難考上研究所?」我只能這樣回答:「一個人考不上研究所,只有兩種可能:或者他不夠聰明,或者他的確夠聰明。不夠聰明而考不上,那也沒什麼好抱怨的。假如你夠聰明,還考不上研究所,那只能說你的決心不夠強。假如你是決心不夠強,就表示你生命中還有其它的可能性,其重要程度並不下於碩士學位,而你捨不得丟下它。既然如此,考不上研究所也無需感到遺憾。不是嗎?」人生的路那麼多,為什麼要老斤斤計較著一個可能性?我高中最要好的朋友,一生背運:高中考兩次,高一唸兩次,大學又考兩次,甚至連機車駕照都考兩次。畢業後,他告訴自己:我沒有人脈,也沒有學歷,只能靠加倍的誠懇和努力。現在,他自己擁有一家公司,年收入數千萬。一個人在升學過程中不順利,而在事業上順利,這是常見的事。有才華的人,不會因為被名校拒絕而連帶失去他的才華,只不過要另外找適合他表現的場所而已。反過來,一個人在升學過程中太順利,也難免因而放不下身段去創業,而只能乖乖領薪水過活。福禍如何,誰能全面知曉?我們又有什麼好得意?又有什麼好憂慮?

人生的得與失,有時候怎麼說也不清楚,有時候卻再簡單也不過了:我們得到平日努力累積的成果,而失去我們所不曾努力累積的!所以重要的不是和別人比成就,而是努力去做自己想做的。功不唐捐,最後該得的不白少你一分,不該得的也不白多你一分。好像是前年的時候,我在往藝術中心的路上碰到一位高中同學。他在南加大當電機系的副教授,被清華電機聘回來給短期課程。從高中時代他就很用功,以第一志願上台大電機後,四年都拿書卷獎,相信他在專業的研究上也已卓然有成。回想高中入學時,我們兩人的智力測驗成績分居全學年第一、第二名。可是從高一起我就不曾放棄過自己喜歡的文學、音樂、書法、藝術、和哲學,而他卻始終不曾分心去涉獵任何課外的知識,因此兩個人在學術上的差距只會愈來愈遠。反過來說,這十幾二十年來我在人文領域所獲得的滿足,恐怕已遠非他所能理解的了。我太太問過我,如果我肯全心專注於一個研究領域,是不是至少會趕上這位同學的成就?我不這樣想,兩個不同性情的人,註定要走兩條不同的路。不該得的東西,我們註定是得不到的,隨隨便便拿兩個人來比,只看到他所得到的,卻看不到他所失去的,這有什麼意義?

從高中時代閔始,我就不曾仔細算計外在的得失,只安心地做自己想做的事:我不喜歡鬼混,願意花精神把自己份內的事做好;我不能放棄對人文科學的關懷,會持續一生去探討。事實單單純純地只是:我只在乎每天廿四小時生命中真實的累積,而不在乎別人能不能看到我的成果。有人問找,既然遲早要唸博士,當年唸完碩士就出國,今天不是可以更早升教授?我從不這樣想。老是斤斤計較著幾年拿博士,幾年升等,這實在很無聊,完全未脫學生時代「應屆考取」的稚氣心態!人生長得很,值得發展的東西又多,何必在乎那三、五年?反過來說,有些學生覺得我「多才多藝」,生活「多采多姿」,好像很值得羨慕。可是,為了兼顧理工和人文的研究,我平時要比別人多花一倍心力,這卻又是大部份學生看不到,也不想學的。

有次清華電台訪問找:「老師,你如何面對你人生中的困境?」我當場愣在那裡,怎麼樣都想不出我這一生什麼時候有過困境!後來仔細回想,才發現:我不是沒有過困境,而是被常人當做「困境」的境遇,我都只當做一時的際遇,不曾在意過而已。剛服完役時,長子已出生卻還找不到工作。我曾焦慮過,卻又覺得遲早會有工作,報酬也不致於低得離譜,就不曾太放在心上。唸碩士期間,家計全靠太太的薪水,省吃儉用,但對我而言又算不上困境。一來,精神上我過得很充實,二來我知道這一切是為了讓自己有機會轉行去教書(做自己想做的事)。三十二歲才要出國,而大學同學正要回同一個系上任副教授,我很緊張(不知道劍橋的要求有多嚴),卻不曾為此喪氣。因為,我知道自己過去一直很努力,也有很滿意的心得和成果,只不過別人看不到而已。

我沒有過困境,因為我從不在乎外在的得失,也不武斷地和別人比高下,而只在乎自己內在真實的累積。我沒有過困境,因為我確實瞭解到:生命是一種長期而持續的累積過程,絕不會因為單一的事件而有劇烈的起伏。同時我也相信:屬於我們該得的,遲早會得到;屬於我們不該得的,即使一分也不可能長久持有。假如你可以分享這些信念,那麼人生於你也將會是寬廣而長遠,沒有什麼了不得的「困境」,也沒有什麼好焦慮的了。

10/24/2011

Bootstrapping hashtagify pro: How I doubled my workweek productivity

Bootstrapping hashtagify pro: How I doubled my workweek productivity

But a week ago I read a comment on HN (edit: thanks to raju in the comments for pointing me to the exact link) that inspired me to rethink how I’m organizing myself , and with one simple change I doubled my productivity on workdays. How? Instead of working on hashtagify at nights, after getting home from my day job, I’m starting my day two hours earlier, and doing 2 hours of programming in the morning, before going to work.

I’m usually a night person, and have always been very productive at nights, since when I was just a student. But after eight hours of work, it is difficult to have that kind of focus that you need to program, and the two (or two and a half) hours in the morning have been much more productive than the equivalent time in the evening.

After coming home I still do some lighter work, and don’t go to bed without having scheduled a task to do the next morning; this way when I wake up I don’t have to think what to do and I can be immediately productive.


http://news.ycombinator.com/item?id=3110632
yeah, my brain works really well after the run because it's full of fresh blood and oxygen. Seriously mate, 20 minutes of work in the morning after a run is better than 2 hours of work in the evening when I'm tired ... no exaggeration.
I hate running and exercise in general, but I promised myself I would do anything to get my company going, and anything includes things I dont want to do, so I force myself :)
Bonus points: Since I started running 6 or so months ago I have lost 28kg!


Try to get to bed at 9pm :) +- 30 mins
reply

10/22/2011

名律師挑最棘手的先做 從容管好兩岸200位律師

名律師挑最棘手的先做 從容管好兩岸200位律師

這樣日理萬機的人,大概不難想像其案牘勞形的樣子。但這些公事,都阻礙不了他愛玩、愛旅遊的一顆心;每週還固定撥出時間練瑜伽、寫書法,這半年來也開始學起太極拳;不禁讓人好奇,面對這麼多繁複工作及多重角色,還可以兼顧生活品質與休閒活動,黃日燦究竟是怎麼做到的?

原因,黃日燦一言以蔽之:「最棘手、最麻煩的事情最先做。」他說,「三十多年下來,這對我可能是幫助最大的,如果沒有這麼做,我不可能做到今天。」他半開玩笑的說,照他的工作內容,彷彿已經活了一百五十歲,說明了這個習慣幫他增加工作效率,快速體驗人生。


除了時間的緊迫性之外,事情的「多樣性」更是挑戰。黃日燦形容,做律師的就像開雜貨店、理髮店一樣,永遠不知道什麼人要進來,也永遠不確定明天的生活會是怎樣,「那個時候,遇到比較麻煩的事情,會想說明天再做,但明天又有新的事。事情放越久就越煩,煩了以後就更不想碰它。」

其實,這種反應和大多數人一樣,喜歡讓自己的心情停留在一個舒適圈,讓心情保持愉快,卻忽略了這對事情的解決完全是背道而馳。

於是,日積月累下,黃日燦發現,已經很努力的自己,每天的事情還是做不完,桌面文件總是堆積如山。「除非我不做這行業,不然永遠都是事情比時間多。」而且,困難或麻煩之事若放著不處理,即使先處理別的事,心還是懸在那裡,影響了做其他事的心情和狀態。黃日燦終於體悟到:「遲早要做,與其遲,不如早。」

舉例來說,有時候律師在看案子時會出現盲點,這時多數人通常會想說「等下再想」,但黃日燦認為,「等下再想」這件事情已經造成心理負擔,「我的經驗是,現在想不出來,擺兩個鐘頭就想得出來,這種事發生的機率是有,但非常小。」

幾次嘗試後發現,先做完最棘手的事會有種「輕舟已過萬重山」的感覺,接下來就很順手,因為感覺上再沒有更難的事了。「當你知道這麼做是有利的,並實際享受它帶來的好處,你就可以持續下去。」

快速提綱挈領,收信五分鐘就回

能抓出最重要的事情來,對於處理事情的輕重緩急,心中也早有了排序。他說:「最難的事都能先處理,簡單的事情就更沒什麼好拖的。」這麼做,除了可避免負面效應外,更能帶來正面回饋。

黃日燦用他常從事的網球運動來比喻:只要早半秒鐘到位,就從容很多;晚半秒鐘,注定永遠疲於奔命。

這樣的好習慣讓黃日燦在事業上很早取得成就,並不斷自我突破。一九九○年從美國回台灣時,他成為眾達全球唯一的華裔合夥人。在台灣二十一年來,陸續完成幾個轟動一時的案子,包括雅虎購併奇摩案、富邦金控購併荷商安泰人壽等等。

這個習慣隨著職位越做越高,事情越來越多,而變得難度更高,「但是它創造的價值也越來越高啊!」黃日燦說,他現在雖然不必事必躬親,但他若不發動,下面的人也動不了,「假如我一有遲疑,留在我手上,那事情還是我的,只會累死自己。」他在管理上一樣貫徹這個習慣的精神:「該交辦、授權、給指示的,一定要馬上給。」

Seashore - open source image editor for Mac OS X

Seashore - open source image editor for Mac OS X

Seashore is an open source image editor for Mac OS X's Cocoa framework. It features gradients, textures and anti-aliasing for both text and brush strokes. It supports multiple layers and alpha channel editing. It is based around the GIMP's technology and uses the same native file format.
However, unlike the GIMP, Seashore aims to serve the basic image editing needs of most computer users, not to provide a replacement for professional image editing products. Also, unlike GIMP, Seashore has an all-new Cocoa UI that will fit right in on Mac OS X.

活着的三个理由 - 阮一峰的网络日志

活着的三个理由 - 阮一峰的网络日志

罗素说,人活着有三个理由。

第一个理由是"追求爱情"(longing for love)。
因为爱情会带来"狂喜"(ecstasy),这是其他任何经历都做不到的;爱情能减轻孤独,让你对生活不再那么恐惧;爱情能创造最美好的人类生活,仿佛天堂的缩影。

第二个理由是"追求知识"(search for knowledge)。
因为知识能让我们理解人的内心,理解自然界,满足我们与生俱来的好奇心。

第三个理由是"同情心"(pity for the suffering)。
当你看到他人受苦、看到饥饿的孩子、看到被压迫的人民、看到被虐待的老人,看到人类的孤独、贫穷、痛苦,你的内心都会难以平静。我们活着,就是为了减轻一些这种苦难,不仅为了帮助他人,还因为我们自己也是这种苦难的受害者。

10/18/2011

Fw: [分享] 雙重等待 - 看板 GFonGuard - 批踢踢實業坊

Fw: [分享] 雙重等待 - 看板 GFonGuard - 批踢踢實業坊

並不是所有看似穩定的關係,最終都能走向紅地毯的底端;
並不是所有的規劃與期待,最終都可以如願共同達成;
並不是所有的約定與夢想,最終都能攜手一起走到。

那些曾經以為能夠長久維繫的愛,常常禁不起時間的摧殘
那些曾經以為能夠放下的釋懷,常常承受不住一些考驗與誤會
那些曾經以為能夠安撫的傷痛,常常在夜裡擁抱不到對方臂膀時開始搖動。

「當她哭著說她愛上別人的時候,我非常困難地壓抑住要爆發的情緒。
心裡有好多的問號湧現,我想問她什麼時候開始的?為什麼沒有先告訴我?
他究竟有哪裡比我好等等。可是我沒有問。
因為我知道,問得越多,也只會讓她離我更遠,場面越難堪而已…」

一位學長將香菸壓熄於鋼盆說著。

「直到很後來、很後來我才發現,那時我真的是太自私了。
人是很脆弱的動物阿,寂寞的時候會想要有人陪,孤單的時候會想要找人出去玩,
一群朋友聚在一起的時候,會談論八卦聊天等等…沒有誰有權力要求誰等待誰,
也沒誰生來就註定就應該要為誰站崗…如果今天換做是我在外面,
我難道就能保證自己的心永恆不變?與其說是她變心,
不如說,是她比我先找到了比我更適合的人。」

當兵與站崗是種「雙重等待」(Double Waiting)的過程,沒有哪一方「一定」比較辛苦。
在營的光頭不懂站崗的難耐,營外的等待也無法完全理解部隊裡的悲哀。
關係中的雙方都預設了一些期待,在等待某個幸福的到來。
只是,這兩個人常常不知道這樣的期待是否對等?
對方是否把自己看做是生命中同等重要的人?
自己對於未來又有多少信心?對方是否有同樣的信心?
又願意為關係的維持付出多少努力?
這些不對等與不確定性,都讓關係蒙上了一些陰影
(J. J. Cameron & Ross, 2007; Knobloch, 2005; Lydon, Pierce, & Oregan, 1997;
Solomon & Knobloch, 2004),也使得等待變得漫長而煎熬。

換言之,真正讓人感到焦慮的,並不是等待本身,
而是自己在等的,究竟是不是對的那個人。

對於站崗的女人而言,心理上的壓力並不亞於部隊裡那顆光頭。
她們一方面必須承擔社會期許的壓力,人際界限的顧慮,
另一方面還要為自己逐漸增加的年齡與逐漸減少的吸引力默哀
(Morry, Kito, & Ortiz, 2011; Singh, 2011),
並掙扎於其他的追求者(alternative)與道德考量之間(Lydon, et al., 1997)。

「我想說的是,女人的心其實是很柔軟的。當一個人對妳真的很好,
當妳在需要的時候,有一個人總是能及時的出現,聽妳說說話,陪妳走路散散心,
真的很難不放入感情。當平常在妳身邊的那個人不再能常常見面之後,
你自然會需要靠別的東西來填補這個空缺,很可能是新的活動,新的團體,
或認識新的朋友。」一位朋友在男友退伍前幾天跟他提分手,
幾個死黨到現在還對這件事情耿耿於懷,
覺得她太過狠心了,難道就不能再多等個兩三天嗎?

但我的這些死黨們可能把事情想得太簡單了。
沒有一段感情,可以透過「拖延」的方式延長一兩天,

若真能延長,可能再也不能用同樣多的心力去愛對方了。

畢竟,那些糾葛殘破問題始終沒有解決,

而且大多在很早以前,就已經種下導致兩人分開的危險因子
(Brehm, Miller, & Perlmam, 2010)。

劇情發展到這個時候,往往已經是「孤臣無力可回天」了。

最新的研究也顯示,在關係裡如果只有一方付出了100%的努力與愛,是無法幸福美滿的。

當雙方各付出了「同等」的感情、承諾與依託,不論是50%,50%,或是90%,90%,
都比只有一個人努力挽回來得有效。
(Oria, Collins, Simpson, Salvatore, & Kim, in press)

人類是很需要分享(Sharing)的。

透過自我接露,我們與世界建立連結,感受到其他人是在乎我們的,
因此聊聊彼此的心情,看法與生活,很容易增進雙方的親密感
(Shelton, Trail, West, & Bergsieker, 2010)。


這也是為什麼你剛認識一個人的時候,如果跟他徹夜長談,會有一種相見恨晚的感覺。
只是這種分享的效果是有限的。
首先,要對方對你印象不壞或是被你吸引[4];
再來,是你所談論的話題必須是他有興趣或有辦法回應的(Response),
沒有人會喜歡聽一大段聽不懂的東西,或是無止盡的自怨自艾
(J. Cameron, Holmes, & Vorauer, 2009; Canevello & Crocker, 2010)。

當然話題本身也很重要。

距離與軍旅所造成的最大隔閡,就是減少了共通話題(Common Topic)。
伴侶間的共通話題,是讓一段關係可以持續運作不乏味的重要調味料
(Furma, Brown, & Feiring, 2010)。

從前就算她不打魔獸,你也可以跟她聊聊明星的八卦,吃遍各種美食;
從前你就算不用蘭蔻,也可以陪她一起看電影或韓劇。
你們關心一些共同的朋友,擁有一些相仿的興趣,
可是現在你擁有了一個特別的世界,
一個充斥著好多男人與汗臭味、奇怪的規定與公約、還有各種特殊術語的社會;
她也認識了一些你不熟悉的朋友。如果不能有效地溝通交流彼此關心的事情,
或是關心「對方所關心的事情」,共通話題很容易就用罄,然後在電話機前冷場。

所以,一段戀情趨於平淡,並不一定是營外世界的勾引或部隊裡的貧瘠,
而是無法真正地分享彼此的感受,搞到最後打電話像例行公事,
不打怪怪的,打了又不知道要說什麼。

那麼,怎樣才能增加話題的豐富性呢?

許多溝通的書籍都談到如何開啟一段有趣的話題,茲舉幾個例子如下[5]:
(1)回憶你們的交往初期,並重新發現當初是什麼吸引了彼此
(2)計劃週末的旅行,想玩的景點,想吃的東西
(3)關心他的工作或課業與人際狀況,是否預到瓶頸或困境
(4)討論一些「如果的事」:
如果現在雙方可以放下手邊的事情,最想要做什麼?
如果世界末日到了,只能救十個人,那你會救誰?
如果可以變成某一種動物,你會想變成什麼?
(5)討論一個不可能做到的點子,然後在不可能上面建築更多不可能:
比方說在雲端蓋一個城堡,並討論那城堡裡的擺設,或者為你昨夜做的夢做接龍等等。

那麼,要怎樣知道自己守候的那個人,究竟是自己真的很愛很愛的,
還是只是因為害怕寂寞而把對方留住呢?

我想,實驗室學姐所說的一段話,某種程度上可以回答這個問題。
「很多人為了等待把自己當成蜘蛛,讓思念像網一樣越纏越緊,
勒死對方,也讓自己瀕臨窒息。
等待可以很辛苦,也可以變成更大的前進力量。
當你在陷落、疲憊的時候,腦子裡還是會浮現某個人的樣子…」

而這個人,往往就是你現在的心靈所停靠的那個港灣;
而這樣的思念,或許也能讓等待不再那麼遙遠沒有終點
(Le, Korn, Crockett, & Loving, 2011)。

9/26/2011

hello world

hello world says:

blah blah

Andrzej on Software: Rails is not MVC

Andrzej on Software: Rails is not MVC

OK, so what's the difference?

In short, we're talking about MVC when a model can notify (through the Observer pattern) the views about the changes. It's not possible in a classical Rails app (it's possible when you use WebSockets, Pusher or a similar technology, but it's not so popular yet.). MVC was popular in desktop apps.

On the other hand, Model2 is exactly what we do with Rails. We don't notify the views from the model, the controller simply passes the model data to the views and handles the html generation which is then sent to the browser.


There's an interesting pattern evolving recently that a Rails app simply serves as a backend for a mobile app and all it does is exposing a JSON/REST API. It's similar to Model2, but instead of generating HTML it generates JSON. Still, it's not MVC.

You can read more about UI architectures in this article by Martin Fowler



Model 2 - Wikipedia, the free encyclopedia

9/25/2011

On The Importance Of Playing

On The Importance Of Playing

But when it came time to do some research. I couldn't get to work. I was a little tired; I was not interested; I couldn't do research! ...

And then I thought to myself, "You know, what they think of you is so fantastic, it's impossible to live up to it. You have no responsibility to live up to it!"...

Then I had another thought; Physics disgusts me a little bit now, but I used to enjoy doing physics. Why did I enjoy it? I used to play with it. I used to do whatever I felt like doing - it didn't have to do with whether it was important for the development of nuclear physics...

So I get this new attitude ... I'm going to play with physics, whenever I want to, without worrying about any importance whatsoever.
Within a week I was in the cafeteria and some guy, fooling around, throws a plate in the air. ...

I had nothing to do, so I start to figure out the motion of the rotating plate...
And before I knew it (it was a very short time) I was "playing" - working, really - with the same old problem that I loved so much, that I had stopped working on when I went to Los Alamos; my thesis-type problems; all those old-fashioned wonderful things.
It was effortless. It was easy to play with these things. It was like uncorking a bottle: Everything flowed out effortlessly. ...

There was no importance to what I was doing, but ultimately there was. The diagrams and the whole business that I got the Nobel Prize for came from that piddling around with the wobbling plate.

MVC Architecture for JavaScript Applications

MVC Architecture for JavaScript Applications

Real MVC

In a nutshell the classic MVC architecture work like this. There is a model that is at the heart of the whole thing. If the model changes, it notifies its observers that a change occurred. The view is the stuff you can see and the view observes the model. When the view is notified that the model has changed, the view changes its appearance. The user can interact with the view (e.g. clicking stuff) but the view doesn’t know what to do. So the view tells the controller what the user did and assumes the controller knows what to do. The controller appropriately changes the model. And around and around it goes.

This description is probably a nice summary for those who already understand the MVC architecture but it is way too short for someone who doesn’t know it already. Describing all the ins and outs of MVC is a task I’m not going to attempt in full. I will do three things:

Recommend the books I found that explain MVC well.
Describe some tips about MVC for JavaScript web applications in particular that I have found helpful.
Provide a complete example.

9/17/2011

Changing the transparency of terminal in Mac OS Leopard

Changing the transparency of terminal in Mac OS Leopard

Go to Terminal -> Preferences, Window tab, Background Color and change the opacity to whatever you like. The window will change as you change the percentage of opacity.

9/14/2011

卡牌屋

[閒聊]第一屆卡牌屋桌遊教學王評審心得

最後推薦一下卡牌屋台北店的新店面,在Kmall 25樓,很舒適
有兩個四人桌和兩個可容納6人左右的沙發區,還有眾多遊戲可供選購



如果你坐在沙發區這邊,還可以順便遠眺台北的風景
聽說夜景很美,只是我沒等到晚上就先離開了
還有人起鬨說現在就要先把跨年的場地包起來了(因為看得到101煙火)XD

7 wonders (2.2)
Santiago (2.5)
Puerto Rico (3.3)
Caylus (3.8)
Small World (2.3)
Nuns on the run (2.1)
Power grid (3.3)
Dream Factory (2.1)
RA (2.4)
Cargo Noir (2.0) 這遊戲我沒聽過,是今年出的新遊戲......
Betrayal at the house on the hill (2.2)
Endeavor (2.9)
Factory Manager (3.0)
Ticket to Ride Europe (2.0)
Race for the Galaxy (2.9)
Tigers & Euphrates (3.6)
星杯傳說 (?)

隱藏版美食 ~榆小舖@景美

隱藏版美食 ~榆小舖@景美

16台北市文山區羅斯福路六段269號
02-2932-6377

9/12/2011

Master the Linux bash command line with these 10 shortcuts | TechRepublic

Master the Linux bash command line with these 10 shortcuts | TechRepublic

4. Use key shortcuts to efficiently edit the command line
bash supports anumber of keyboard shortcuts for command-line navigation and editing. The Ctrl-A key shortcutmoves the cursor to the beginning of the command line, while the Ctrl-E shortcutmoves the cursor to the end of the command line. The Ctrl-W shortcutdeletes the word immediately before the cursor, while the Ctrl-K shortcutdeletes everything immediately after the cursor. You can undo a deletion with Ctrl-Y.

8. Perform calculations
bash can performsimple arithmetic operations at the command prompt. To use this feature, simplytype in the arithmetic expression you wish to evaluate at the prompt withindouble parentheses, as illustrated below. bash will attemptto perform the calculation and return the answer.

bash> echo $((16/2))
8

Ask HN: I am wasting so much of time, what can I do?

StayFocusd - Chrome plugin


1. There's also a StayFocusd[1] plugin for Chrome which will block sites for you.
2. Also try Crackbook [1] for Chrome which delays pages instead of banning them. Works much better for me that Stayfocusd, which I just disable after a while. (Disclaimer: I am the author.)
3. Soundtracks from RTS games (ex: starcraft) can create a sort of Pavlovian Response, telling your brain "You are sitting at a computer carrying out a difficult task which takes a good deal of focus and mental exertion. This activity is fun and rewarding, and it is urgent that you do it as well and as quickly as possible."
4. ust use the headphones without music to only get the wins from this. It's not like anyone except you can tell the difference
5. Get a second device, like a tablet, which you use for surfing, reading, and leisure. Your laptop is no longer for that. It's exclusively for producing and for serious work.
6. Get rid of your TV if you have it. Completely. That's really just a senseless time-sucker and you won't miss it within a week.
7. Babysteps, babysteps, babysteps. Taken from today's Hacker News: "I can not emphasize how important baby steps are. They are the key to avoiding fatal frustration. I have a law that helps define the size of subtasks: DO NOT EVER LEAVE THE COMPUTER IF YOUR PROGRAM DOES NOT RUN." http://all-things-andy-gavin.com/2011/09/11/video-game-progr...


- Fighting your urge to "procrastinate" all day long leads to lots of decision fatigue that will make everything just worse: http://www.nytimes.com/2011/08/21/magazine/do-you-suffer-fro... . The best way around this is to create habits, as they will get you on autopilot through difficult procrastination situations within a month. Some great thoughts on this from Leo Babauta: http://zenhabits.net/will/ My personal take on this: The key is starting out VERY slow (one habit a month at the most) and keeping your expectations really low. The habit itself needs to survive through all times and is more important than the actual outcome. Example from me: I do exercises right before showering, but the least I do is 5 pushups. That sounds like nothing, and actually it isn't but I do them no matter what - drunk, late, sad, happy. Habits will eventually carry you through everything, but you just stick to them. Suggestions for you: Not reading e-mail after or before a certain time, turning of the computer completely at a certain time. Stuff like that.
- Building on that, affirmations and meditation are extremely powerful as a habit too. I've written an article on this if you're interested: http://www.growinup.org/?p=5
- Gym and sports definitely helps your willpower, as long as you don't discover another way of procrastination in there. It can happen ;-)
- Knowing what you really want. Maybe you know already (I certainly did), but you're too scared and unfocused to really take action. If you're too scared, watch this: http://www.youtube.com/watch?v=Lk0hSeQ5s_k If you're too unfocused, read this: http://focusmanifesto.com/ Anyway, know what you wanna do and where you're going.
- All these things helped me in a way, but the final piece for me comes here as promised. I've had a huge fight with my wife for all kinds of reasons related to my procrastination, and she told me something I've never forgot. I've distilled the essence of what she told me on a paper and I read it every night. Here it is, for you all to read:
"Every time I pray, I feel you falling down this black hole, but I cannot help you. Only YOU can do it. No amount of reading or games or [insert your timesucker here] can fill that emptiness inside of you. So don't do stuff out of an impulse. Do it conciously. Whatever you do, choose to do it and accept the consequences. Don't be guilty about anything anymore - just accept that you made your choice and be responsible. There's no need to lie to yourself. It's just ok. Live, breathe, be gentle. There is one and one way only out of the frustration, anger and depression: Accept your choices. Love yourself. Leave the guild behind and FOLLOW YOUR HEART".


Pomodoro Technique
1. Choose a task to be accomplished
2. Set the Pomodoro to 25 minutes (the Pomodoro is the timer)
3. Work on the task until the Pomodoro rings, then put a check on your sheet of paper
4. Take a short break (5 minutes is OK)
5. Every 4 Pomodoros take a longer break
Pomodoro Technique book


Org - an Emacs Mode for Notes, Project Planning, and Authoring


via: Ask HN: I am wasting so much of time, what can I do?

「好文分享」蔣勳:過得像個人,才能看到美 - 點石成金 文創志業 自費出版的領航者 - udn部落格

「好文分享」蔣勳:過得像個人,才能看到美 - 點石成金 文創志業 自費出版的領航者 - udn部落格

幾年來,幾乎所有的竹科企業我都去過了,和企業的人有所接觸後,我才知道我過去有「知識偏執」的狀況,但我並沒有真正認識30歲上下的職場工作人員。

竹科有一家上市公司的員工平均年齡是31.8歲,他們都是最優秀大學畢業的菁英。

在開始工作的前10年,是人生很重要的階段,但他們卻通常是11點以後才下班。要戀愛,可能沒有時間戀愛;要買房子,就用世俗的固定模式買房子,找一個大家認為有名的設計師;要結婚,但用很草率的方式結婚。我知道很多工程師經由輔導去娶烏克蘭新娘,他們可能連戀愛的時間、耐心都沒有。

真正的美,作假不得

我原來希望的藝術是能恢復人的品味和人的感覺,但他們接觸了這些東西卻沒有感覺,像有些企業會固定舉辦一些音樂會,但他們卻沒有辦法進入那個世界。所以我現在希望向大家說的是「人的原點」,當我們失去了人的原點,談所有的美都是假的。

我有一個朋友,住在信義路上億元的豪宅,找了日本最有名的設計師來裝潢,但有一次我去他家,發現他住了2年,可是廚房裡所有進口廚具的膠膜都沒撕掉。

他的房子只是一個showroom。可是家不是showroom,家是讓你可以放鬆自在、活得像人的地方,家是因為住在裡面的人有自己的渴望、自己的感覺,才會有自己的風格。

如果主人對這個家沒有意見、對自己的生活沒有看法,只想告訴別人買的是義大利最貴的床,那只是作假給別人看。

你可以在家裡放很多明式家具,很美;你喜歡家裡很空,也很美,但這裡面的難度是你到底要什麼,如果你不知道,你找再有名的建築師設計都是假的,你怎麼樣回來做自己,才是最難的功課。

我自己是住在淡水河邊,當時會在那裡買房子,是因為覺得淡水河口好漂亮,但是我房子的建商卻不知道善用那裡的美景,窗戶建得很小,我在房間裡就覺得好難過。

所以我找了一個學建築的學生,他幫我開了12個窗,而且全部是往外推的推窗,比拉窗更有靠近河邊的感覺,還架出一個小陽台,所以我可以坐在小欄杆上看河,和淡水河只有2公尺的距離。

我也不喜歡隔間,所以設計師幫我用高度界定出3個不同的區域。我家最高的地方是客廳,朋友來的時候坐在最高的地方喝茶;次高的地方是書房,我在那邊看書;再次高的地方是我的餐廳。我覺得這是我的房子、我的家,我是主人,我知道我要什麼。

在穿著上,我喜歡純棉、純麻,因為我覺得它們很溫暖,材料本身有觸覺上的記憶,在排汗、吸汗的過程也非常舒服。加上我喜歡爬山、喜歡躺在草地上、喜歡在海灘捲起褲腳踩水,我喜歡這樣的生活,所以我就有我服裝的特徵,名牌就不適合我,因為我喜歡自在。

找回人與人之間的感覺

我現在不問工程師有沒有去聽音樂、看展覽,反而是問他們:「你們在這裡工作5年了,有沒有人可以告訴我公司門口那一排是什麼樹?」但很少人能夠回答的出來。

事實上,他們公司門口那排小葉欖仁的葉子漂亮得不得了,綠色會在陽光裡發亮。後來我再去,就有一個員工和我說,「謝謝你告訴我這件事,我現在下班時會先看看小葉欖仁再回家,所以比較不會和太太吵架了。」

他也問我現在5歲的女兒將來該學鋼琴、還是小提琴,但我建議11點下班的他多抱抱女兒,比較重要。因為所有的藝術講的都是人的故事,一個孩子如果不記得父親的體溫,她將來看畫、聽音樂都沒有感動。如果沒有人的記憶,所有藝術對她而言都只是賣弄而已。

我們從年輕開始,就因為工作忙碌,忽略了人與人的感覺,但工作忙碌之餘,你還是一個人,你必須每分每秒提醒自己回來做人的部份。你看到了美,才會覺得這個世界是值得活下去的。如果你看到的只是品牌、只是假的美,你不見得快樂,那反而可能會是你憂鬱症的原因。

找回美的感覺其實很簡單,去觸摸一片葉子,去聞一下在很熱很熱的夏天、下完午後暴雨的氣味,那是都我們有記憶的感覺,那都會引發我們的感觸和感動。

現在美常常成為新的知識、新的壓力,博士可能毫無美感,但一個不識字的美濃農夫卻可以很美,他看得到月光的美、看得到稻浪翻飛的美。美是最大的財富,它不會因為你的學歷而不同,而是因為你人的部份完不完整而不同。

週休二日,回來做自己

現在台灣過週休二日,好像非要全家去吃一個餐廳、到哪裡去看薰衣草、喝咖啡,全部整套,然後全部的人塞車塞到一肚子氣。我們對休閒的定義是滿僵化的,好像一定要別人服務我們才算是休閒。

我自己假日的時候喜歡自己一個人做4菜1湯,因為我覺得做菜好快樂。我也很喜歡在週休二日洗我自己最喜歡的純棉的、純麻的襯衫,絕不丟給洗衣機,因為我覺得觸感好極了。看到它們晾在陽光裡、在風裡飄,白的好漂亮,我的週休二日就很快樂,因為我回來做自己。


在7、8月,民生東路六段有全台北最漂亮的大花紫薇,即使有車可開,那時候我也絕對要走路,這些是讓我最快樂的事,這才是人。如果我們吃得不像人,穿得不像人,生活都失去了人的意義,那談藝術太遙遠。

我談我的生活,並不希望別人學我。每個人是不一樣的,不要隨便相信價格、人云亦云,生活中的美學,應該是不按照別人安排的。每個人應該用自己的生命,去創造自己的生活美學出來。

蔣勳,60歲。學歷:文化大學史學系、文化大學藝術研究所、法國巴黎大學藝術研究所。經歷:曾任《雄獅美術》月刊主編,並先後執教於文化大學、輔仁大學與東海大學美術系,著有小說、散文、藝術史、美學論述作品數十種。現任:新竹IC之音電台《美的沈思》節目主持人



出處: 「好文分享」蔣勳:過得像個人,才能看到美 - 點石成金 文創志業 自費出版的領航者 - udn部落格 http://blog.udn.com/eastolga/5493256#ixzz1XjyMB4x1

9/05/2011

tl;dr

tl;dr

Said whenever a nerd makes a post that is too long to bother reading.
"omg you postwench. i can only say one thing in response - tl;dr"
"tl;dr...why dont you give up on your unabridged edition of War and Peace or at least stop posting it here?"


Too Long; Didn't Read

Literally translates to: That was too long to read.
Really translates to: I'm too lazy to read the entirety of what you said, but I still want to say something.

Now, instead of just dropping capitals the modern internet communicator

curl网站开发指南 - 阮一峰的网络日志

curl网站开发指南 - 阮一峰的网络日志


我一向以为,curl只是一个编程用的函数库。
最近才发现,这个命令本身,就是一个无比有用的网站开发工具,请看我整理的它的用法。
===================================
curl网站开发指南
阮一峰 整理

curl是一种命令行工具,作用是发出网络请求,然后得到和提取数据,显示在"标准输出"(stdout)上面。
它支持多种协议,下面举例讲解如何将它用于网站开发。
一、查看网页源码
直接在curl命令后加上网址,就可以看到网页源码。我们以网址www.sina.com为例(选择该网址,主要因为它的网页代码较短):
  curl www.sina.com
  
  
  301 Moved Permanently
  
  

Moved Permanently


  

The document has moved here.


  
如果要把这个网页保存下来,可以使用-o参数,这就相当于使用wget命令了。
  curl -o [文件名] www.sina.com
二、自动跳转
有的网址是自动跳转的。使用-L参数,curl就会跳转到新的网址。
  curl -L www.sina.com
键入上面的命令,结果就自动跳转为www.sina.com.cn。
三、显示头信息
-i参数可以显示http response的头信息,连同网页代码一起。
  curl -i www.sina.com
  HTTP/1.0 301 Moved Permanently
  Date: Sat, 03 Sep 2011 23:44:10 GMT
  Server: Apache/2.0.54 (Unix)
  Location: http://www.sina.com.cn/
  Cache-Control: max-age=3600
  Expires: Sun, 04 Sep 2011 00:44:10 GMT
  Vary: Accept-Encoding
  Content-Length: 231
  Content-Type: text/html; charset=iso-8859-1
  Age: 3239
  X-Cache: HIT from sh201-9.sina.com.cn
  Connection: close
  
  
  301 Moved Permanently
  
  

Moved Permanently


  

The document has moved here.


  
-I参数则是只显示http response的头信息。
四、显示通信过程
-v参数可以显示一次http通信的整个过程,包括端口连接和http request头信息。
  curl -v www.sina.com
  * About to connect() to www.sina.com port 80 (#0)
  * Trying 61.172.201.195... connected
  * Connected to www.sina.com (61.172.201.195) port 80 (#0)
  > GET / HTTP/1.1
  > User-Agent: curl/7.21.3 (i686-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
  > Host: www.sina.com
  > Accept: */*
  >
  * HTTP 1.0, assume close after body
  < HTTP/1.0 301 Moved Permanently
  < Date: Sun, 04 Sep 2011 00:42:39 GMT
  < Server: Apache/2.0.54 (Unix)
  < Location: http://www.sina.com.cn/
  < Cache-Control: max-age=3600
  < Expires: Sun, 04 Sep 2011 01:42:39 GMT
  < Vary: Accept-Encoding
  < Content-Length: 231
  < Content-Type: text/html; charset=iso-8859-1
  < X-Cache: MISS from sh201-19.sina.com.cn
  < Connection: close
  <
  
  
  301 Moved Permanently
  
  

Moved Permanently


  

The document has moved here.


  
  * Closing connection #0
如果你觉得上面的信息还不够,那么下面的命令可以查看更详细的通信过程。
  curl --trace output.txt www.sina.com
或者
  curl --trace-ascii output.txt www.sina.com
运行后,请打开output.txt文件查看。
五、发送表单信息
发送表单信息有GET和POST两种方法。GET方法相对简单,只要把数据附在网址后面就行。
  curl example.com/form.cgi?data=xxx
POST方法必须把数据和网址分开,curl就要用到--data参数。
  curl --data "data=xxx" example.com/form.cgi
如果你的数据没有经过表单编码,还可以让curl为你编码,参数是--data-urlencode。
  curl --data-urlencode "date=April 1" example.com/form.cgi
六、文件上传
假定文件上传的表单是下面这样:
  

    
    
  

你可以用curl这样上传文件:
  curl --form upload=@localfilename --form press=OK [URL]
七、Referer字段
有时你需要在http request头信息中,提供一个referer字段,表示你是从哪里跳转过来的。
  curl --referer http://www.example.com http://www.example.com
八、User Agent字段
这个字段是用来表示客户端的设备信息。服务器有时会根据这个字段,针对不同设备,返回不同格式的网页,比如手机版和桌面版。
iPhone4的User Agent是
  Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
curl可以这样模拟:
  curl --user-agent "[User Agent]" [URL]
九、cookie
使用--cookie参数,可以让curl发送cookie。
  curl --cookie "name=xxx" www.example.com
至于具体的cookie的值,可以从http response头信息的Set-Cookie字段中得到。
十、增加头信息
有时需要在http request之中,自行增加一个头信息。--header参数就可以起到这个作用。
  curl --header "xxx: xxxxxx" http://example.com
十一、HTTP认证
有些网域需要HTTP认证,这时curl需要用到--user参数。
  curl --user name:password example.com
【参考资料】
  * Using cURL to automate HTTP jobs
  * 教你学用CURL

8/29/2011

送給新鮮人的 7 項建議 – MMDays

送給新鮮人的 7 項建議 – MMDays


擁有正確的理財觀念
我一直很喜歡 Tim O’Reilly 的一句話: “Money is like gasoline during a road trip. You have to pay attention to money, but it shouldn’t be about the money. (金錢就像旅程中開車時的汽油一般,你需要注意金錢的狀況,但是整個旅程的意義本身跟金錢無關)”。擁有好的金錢價值觀可以讓你生活更舒適一點,這裡說的舒適不是說,你要住豪宅,開名車,而是指心靈跟生活上的輕鬆。也就是說你生活不需要特別憂慮明天有欠誰錢? 下一餐的著落在哪邊? 因此可以有時可以恣意地輕鬆地喝個下午茶,做做自己感興趣的東西。所以,你得學會控制住自己的慾望,並且瞭解到自己真正的渴望是什麼。如果不瞭解自己,那麼你可以先從記帳開始,透過每天的開銷來認識你自己。理財並不複雜,你只要記得最基本的原則: 永遠讓你的淨收入大於你的淨支出。其他的都是次要的。

當個怪人
在一個群體當中,最困難的事情就是維持獨立思考。因為你永遠不想當個團體中的異類,當大家要去唱 KTV 時,你也遷就著;當大家要去夜衝時,你也遷就著。於是你的時間就這麼蹉跎了,重點是,這個蹉跎的時間還不是為了你自己想要達成的夢想。當然,你會這麼做,正是因為你還沒搞清楚你想要做什麼。所以,常常會有這個狀況: 人家說你數學不好,你就拼命補數學;人家說你體育差,你是不是也跟人家一起去練習跑步? 不過,你可以選擇每天悠閒地慢跑,但是你知道你的目標不是為了田徑競賽,而是你喜歡那種有節奏的步伐,乘著微風的感覺;你知道你要學習數學,是因為你至少每天得用到基本的加減乘除,來解決生活上面所遇到的基本計算,這跟你的考試一點關係也沒有。瞭解到自己是多麼地與眾不同,總比盲目地跟隨著群體運動來得好多。

人生是一段單向道的旅程
你要理解這個樣子的事實,人生無論如何怎麼樣都不可能重來。你可能會犯錯,你可能會跌倒,不過那又怎麼樣? 重點是,你從你之前的人生中到底悟到了什麼! 多一步或是少一步,你都不可能是現在的你。所以,好好地接受你的過去,就代表你能好好地接受現在的你;這也代表著,你將能夠從你之前的經驗挖掘出寶貴的東西。如果你無法接受,甚至正視你自己,那麼寶箱在你前面,沒有開啟也是徒然。世界,是在你的腦裡面,不是在你的腦外面;瞭解到這一點,你的世界就很容易改變了。除此之外,為了讓你的人生不要可惜了、遺憾了,該做什麼的時候,就做什麼。緣分是很難得的,可以跟父母開開心心地聊上一個下午或晚上的時光會在單向道上消失的;可以跟好友一起瘋狂、一起努力的時光會在單向道上消失的;可以跟戀人一起擁抱、一起牽手的時光會在單向道上消失的。重點不是你失去了什麼、得到了什麼,重點是你怎麼樣經歷了這些什麼。人生難得,人生中最重要的事情就是人生,其它的,都是次要的。最後,如果可以的話,儘量讓你的單行道長一點,因為精彩的總是在後邊。

8/25/2011

scroll and fixed

網頁上常見的特效: 捲動到某個地方後, 頁面的 element 就會dock 在頁面的上方, 可以用在比較長的表單, 作法就是去算doucment.scrollTop 到了預設的地方之後把 element 設成 {poistion:fixed, top:0}
ex: less.org

知得過、不及處,就是中和。


王陽明-->傳習錄-->門人黃省曾錄

 【304】問:“良知原是中和的,如何卻有過、不及?”先生曰:“知得過、不及處,就是中和。”

8/22/2011

三個演講

1. 史帝夫.賈伯斯2005年史丹佛大学畢業演講 http://t.cn/anHwH8

2. J.K.羅琳2008年哈佛大學畢業演講 http://t.cn/aE4zuW

3. 蘭迪.鮑許教授的最後一次演講 http://t.cn/anHwke

How GitHub Works

How GitHub Works

Hours are bullshit
Hours are great ways to determine productivity in many industries, but not ours. Working in a startup is a much different experience than working in a factory. You can’t throw more time at a problem and expect it to get solved. Code is a creative endeavor. You need to be in the right mindset to create high-quality code.

Think back to the last time you were depressed or angry. How productive were you? Now think back to the last time you were truly productive. Code flying from your fingertips. Not just the sheer quantity- the sheer quality of that code. When you’re in the right mindset, your best day of coding can trump weeks of frustrated keyboard-tapping.

We want employees to be in the zone as often as possible. Mandating specific times they need to be in the office hurts the chances of that. Forcing me in the office at 9am will never, ever get me in the zone, but half of GitHub may very well work best in the morning.

By allowing for a more flexible work schedule, you create an atmosphere where employees can be excited about their work. Ultimately it should lead to more hours of work, with those hours being even more productive. Working weekends blur into working nights into working weekdays, since none of the work feels like work.

Be Asynchronous
GitHub didn’t have an office for the first two years. Chat rooms (in our case, Campfire) is where things got done. Today we’ve moved into our second office, and Campfire is still where we get things done.

NodeJS – The what, why, how and when | Xebia Blog

NodeJS – The what, why, how and when | Xebia Blog

What is NodeJS?

The NodeJS five-word sales pitch from their own website is “Evented I/O for V8 Javascript”. We’ll get to what that means exactly in the How. NodeJS, in a few more words, is a server-side application framework with a focus on high concurrent performance. Applications written for Node run in a single-threaded, event-based process.

Event-based programming approaches this in a different matter. When calling the blocking operation, you pass it an additional argument: a block of code to execute when the operation has completed. Instead of waiting for a reply from the user or the database, the application continues its execution.


Why
Why evented I/O? The short answer: Latency.

What does this mean? Effectively, it means that classic, blocking processes twiddle their thumbs for 41,000,000 CPU cycles while waiting for something from disk to load. Those processes can’t do anything else while they twiddle their thumbs, so in the case of a webserver, other requests get paused until the application has received its data.

The classic solution for this problem: Add moar processes. When one process twiddles its thumbs waiting for data, the other process can take over and handle the next request. With 200 processes available for handling requests, consumers never have to wait long in the queue for their request to be handled by the next freed process.

But it has its limits. Hard limits, even, which have been the source of many outages in the past. What if there’s a big delay on the network for whatever reason? What if there’s more new requests coming in per second than the database can process? The 200 processes each block once they reach the point where they retrieve data from the network, and once they’re all occupied, the webserver simply stops serving requests, users time out, and Twitter trends with messages like “IS #SOMESITE.COM DOWN? #FML”.

How does Node solve this? Well, to put it simply, it doesnt’t twiddle its thumbs. It goes ‘Alright underlying system, give me this information from the network. I’ll go do something useful, lemme know when you’re done aight? Aight.’ And then it proceeds to do something useful, like handle the next request.

It’s the ‘lemme know when you’re done’ that contains the core of NodeJS’s performance. Instead of waiting for something to be retrieved (blocking), it continues to run (non-blocking). No precious CPU cycles get wasted that way waiting.

Because it doesn’t block, there’s also a greatly reduced need for running multiple processes. It just keeps going, regardless of how many requests it has to handle. When it receives a bazillion requests, it doesn’t run out of processes or some other arbitrary limit, it just handles each one, one by one. It handles each event as it’s triggered, one at a time, and it does so very rapidly.

It’s like ordering food. You step up to the counter of your local fast food store, and order a hamburger. Classically, you stand there and wait until the chef is done and the person serving gives you your order, while others queue up neatly behind you. In the multi-threaded approach, the store hires more serving personnel and chefs that can each handle one customer at a time.

In the non-blocking approach, the servant smiles, says “Alright sir, please pick a seat, your order will be brought to you when it’s done. Next!”. And so it continues. The servant passes the order to the kitchen, the kitchen prepares your burger, and a pretty serving girl brings you your hamburger when it’s done. The queue passes the counter quickly, because everything the servant does is take the people’s order and pass it along.

If only fast food stores actually worked like this.

Why Javascript?

First, event handling, callbacks and asynchronous behavior are at its core. It’s been used in this fashion for years in its natural habitat, the browser. Opening a file or network resource and passing that method a callback isn’t that different from triggering an AJAX-call with a callback – in fact, it’s exactly the same. The browser is inherently asynchronous, as pretty much every piece of logic relies on user input, network I/O, or something simpler as a timed event – each of those would block the execution of the script if it was done with blocking operations, and that’s the last thing you want in a user-experience heavy application like a webbrowser.

Event handling is at the core of both Javascript as a language and as a way of thinking for Javascript developers, which is another important reasoning behind using Javascript: It’s familiar to many developers. Javascript is a bit of a ninja amongst programming languages – most people don realize it’s one of the most-used programming languages out there. Its popularity has boosted significantly over the last decade, with the rise of AJAX, highly interactive and responsive web applications, streaming updates, and big companies like Google pushing web applications as a primary platform for all kinds of applications.

Why single-threaded?
The advantages of a single-threaded application is that the processor doesn’t have the overhead of context switching (when one thread gets CPU time while the other’s paused). There’s no heap allocations or forks or startup sequences that need to be done when creating a new thread. Besides that, there’s of course the obvious advantage of not needing to program with concurrency in the back of your head. Less headache, less hard-to-track bugs, less specific knowledge and understanding needed, etc.

But what about modern-day hardware? The mainstream CPU builders don’t build single-core processors anymore, it’s all fancy dual-, quad-, hexa- and octacores these days, with even more cores and special-purpose components to be added in the nearby future.

Well, that’s not a problem. Whilst a Node program is single-threaded, there’s nothing stopping you from creating multiple Node processes and running them side-by-side, each using a single core. Put a loadbalancer or reverse proxy like nginx in front of it , either on the same server or externally, and you’re done. You could even use another Node process as a loadbalancer. Of course, you’d have to be using a back-end storage system that can handle concurrent requests (i.e. from multiple Node processes) in order to be able to do that.

But V8 can also run outside of the browser, and, being an open source project, has been extended to create NodeJS. Node adds a thread pool (using libeio), event loop (libevent), and fancy things like DNS resolving and cryptography.

On top of that are a bunch of Node bindings for I/O (sockets, HTTP, etc).

Finally, a standard library to do pretty much everything you need written in pure Javascript is built on top of that. Have a picture:


when
With that out of the way, here’s a few use cases Node can be used for and can excel at:

Generic web framework. It’s got all the things you need – server-side logic, connectors for back-end systems (like databases), file serving, template parsing (with a wide variety of template languages), authentication, you name it.
Highly concurrent websites – high-volume webservices, varying loads, etc.
Highly concurrent connections – for example, websockets with many clients sending and receiving data.
Back-end systems dealing with files. Example: GitHub’s Nodeload, which prepares Git repositories for download by compressing them into tarballs. It calls git archive, waits, then streams the result back to the user using Node’s stream API’s. (output I/O is also I/O and can benefit from evented I/O). See https://github.com/blog/900-nodeload2-downloads-reloaded

8/17/2011

tar

tar -zpcv -f /root/etc.tar.gz /etc

or

tar zcv etc > foo.tar.gz

8/15/2011

Targeting Screens from Web Apps | Android Developers

Targeting Screens from Web Apps | Android Developers
That's an example of just two viewport properties. The following syntax shows all of the supported viewport properties and the general types of values accepted by each one:


<meta name="viewport"
content="
height = [pixel_value | device-height] ,
width = [pixel_value | device-width ] ,
initial-scale = float_value ,
minimum-scale = float_value ,
maximum-scale = float_value ,
user-scalable = [yes | no] ,
target-densitydpi = [dpi_value | device-dpi |
high-dpi | medium-dpi | low-dpi]
" />

頭家爐主 Local chiefs and incense heads

頭家爐主 Local chiefs and incense heads

民間信仰中一種祭祀組織的形式。爐主代表地方社區居民負責一年當中的祭祀事宜,頭家則協助爐主分擔祭祀工作。通常是在神前擲茭(卜杯)的方式決定,聖杯最多者為下一年爐主。頭家人數不等,視社區人數多寡或地方慣例而定。頭家爐主通常是男性的戶長擔任,不過也有女性擔任爐主的情況。
爐主是因神明旨意而卜選出來,早期擔任爐主是莫大的榮譽,人們會認為是得到神明庇佑,才會被卜選成為爐主,因此通常都會用心服務。
爐主要負責收取祭祀費用,稱為「收丁口錢」,頭家則分攤收費的工作。爐主在神誕日要請戲團來表演,稱為「請戲」。在交通不便的年代,頭家還要「擔戲籠」,幫忙挑戲班的樂器與戲服等。近年來,由於收丁口錢的習俗逐漸淡薄,頭家爐主的需要性就沒有那麼高了。
現代廟宇有管理委員會或財團法人等組織負責廟務的經營與管理,但早期許多廟宇是以爐主制的方式進行管理;利用「爐主簿」記載歷年爐主與頭家的姓名、每年的收支明細、廟產記錄等。有些地方是有神無廟的情況,通常以每年由爐主輪流祭祀的方式維持神明的信奉,因此爐主可以把神明請到家中奉祀一整年,例如臺中縣新社鄉由九庄聯合祭祀媽祖,九庄媽堅持不立廟,是希望每年可以澤被爐主,親臨爐主家中受奉祀。
有神明便有香爐,有香爐便有爐主,所以神明的信眾便稱為「爐腳弟子」。廟宇祀神有爐主,神明會也有爐主。每年神誕新舊爐主頭家交接時,會舉行「新交舊」,新、舊任爐主頭家一起共宴。

8/12/2011

Daring Fireball Linked List: Android's 'Density-Independent Pixel'

Daring Fireball Linked List: Android's 'Density-Independent Pixel'

Android devices have wildly-varying pixel-per-inch resolutions. To aid developers, the OS offers a “density-independent pixel” unit of measurement:

A virtual pixel unit that applications can use in defining their UI, to express layout dimensions or position in a density-independent way.

The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, the baseline density assumed by the platform (as described later in this document). At run time, the platform transparently handles any scaling of the dip units needed, based on the actual density of the screen in use. The conversion of dip units to screen pixels is simple: pixels = dips * (density / 160). For example, on 240 dpi screen, 1 dip would equal 1.5 physical pixels. Using dip units to define your application’s UI is highly recommended, as a way of ensuring proper display of your UI on different screens.

I suspect Apple will do something similar, except that by going straight from 480 × 320 to 960 × 640, everything just doubles in terms of pixels and nothing works out to a non-integer scaling factor.

Philosophical Games: Customize Android Browser Scaling with target-densityDpi

Philosophical Games: Customize Android Browser Scaling with target-densityDpi

Add dpi support for WebView.

In the "viewport" meta tag, you can specify "target-densityDpi".
If it is not specified, it uses the default, 160dpi as of today.
Then the 1.0 scale factor specified in the viewport tag means 100%
on G1 and 150% on Sholes. If you set "target-densityDpi" to
"device-dpi", then the 1.0 scale factor means 100% on both G1 and Sholes.

Implemented Safari's window.devicePixelRatio and css media query
device-pixel-ratio.

So if you use "device-dpi" and modify the css for font-size and image
src depending on window.devicePixelRatio, you can get a better page on
Sholes/Passion.

Here is a list of options for "target-densityDpi".

device-dpi: Use the device's native dpi as target dpi.
low-dpi: 120dpi
medium-dpi: 160dpi, which is also the default as of today
high-dpi: 240dpi
: We take any number between 70 and 400 as a valid target dpi.

Fix http://b/issue?id=2071943



A pixel is not a pixel is not a pixel - QuirksBlog

node-optimist /

node-optimist

optimist is a node.js library for option parsing for people who hate option parsing. More specifically, this module is for people who like all the --bells and -whistlz of program usage but think optstrings are a waste of time.

With optimist, option parsing doesn't have to suck (as much).


var argv = require('optimist').argv;

if (argv.rif - 5 * argv.xup > 7.138) {
console.log('Buy more riffiwobbles');
}
else {
console.log('Sell the xupptumblers');
}


$ ./xup.js --rif=55 --xup=9.52
Buy more riffiwobbles

$ ./xup.js --rif 12 --xup 8.1
Sell the xupptumblers


And non-hypenated options too! Just use argv._!

var argv = require('optimist').argv;
console.log('(%d,%d)', argv.x, argv.y);
console.log(argv._);


$ ./nonopt.js -x 6.82 -y 3.35 moo
(6.82,3.35)
[ 'moo' ]

$ ./nonopt.js foo -x 0.54 bar -y 1.12 baz
(0.54,1.12)
[ 'foo', 'bar', 'baz' ]


example: https://github.com/substack/node-browserify/blob/master/bin/cli.js


var argv = require('optimist').usage('Usage: $0 [entry files] {OPTIONS}').wrap(80).option('outfile', {
alias: 'o',
desc: 'Write the browserify bundle to this file.\n' + 'If unspecified, browserify prints to stdout.',
}).option('require', {
alias: 'r',
desc: 'A module name or file to bundle.require()\n' + 'Optionally use a colon separator to set the target.',
}).option('entry', {
alias: 'e',
desc: 'An entry point of your app'
}).option('alias', {
alias: 'a',
desc: 'Register an alias with a colon separator: "to:from"\n' + "Example: --alias 'jquery:jquery-browserify'",
}).option('plugin', {
alias: 'p',
desc: 'Use a plugin. Use a colon separator to specify additional ' + 'plugin arguments as a JSON string.\n' + 'Example: --plugin \'fileify:["files","."]\''
}).option('help', {
alias: 'h',
desc: 'Show this message'
}).check(function (argv) {
if (argv.help) throw ''
if (process.argv.length <= 2) throw 'Specify a parameter.'
}).argv;