Search

6/28/2013

gett/mongojs

gett/mongojs - provides mongodb streaming api

Tailable cursors
# mycollection must by a capped collection
# http://docs.mongodb.org/manual/core/capped-collections/
var cursor = db.mycollection.find({}, {}, {tailable:true, timeout:false});

// since all cursors are streams we can just listen for data
cursor.on('data', function(doc) {
    console.log('new document', doc);
});

6/26/2013

http basic auth

https://gist.github.com/charlesdaniel/1686663

  1. server send 'WWW-Authenticate', 'Basic realm="Secure Area"' header
  2. get 'authorization' header from request
  3. base64 decode req.headers['authorization']
var http = require('http');
 
var server = http.createServer(function(req, res) {
        // console.log(req);   // debug dump the request
 
        // If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
 
        var auth = req.headers['authorization'];  // auth is in base64(username:password)  so we need to decode the base64
        console.log("Authorization Header is: ", auth);
 
        if(!auth) {     // No Authorization header was passed in so it's the first time the browser hit us
 
                // Sending a 401 will require authentication, we need to send the 'WWW-Authenticate' to tell them the sort of authentication to use
                // Basic auth is quite literally the easiest and least secure, it simply gives back  base64( username + ":" + password ) from the browser
                res.statusCode = 401;
                res.setHeader('WWW-Authenticate', 'Basic realm="Secure Area"');
 
                res.end('Need some creds son');
        }
 
        else if(auth) {    // The Authorization was passed in so now we validate it
 
                var tmp = auth.split(' ');   // Split on a space, the original auth looks like  "Basic Y2hhcmxlczoxMjM0NQ==" and we need the 2nd part
 
                var buf = new Buffer(tmp[1], 'base64'); // create a buffer and tell it the data coming in is base64
                var plain_auth = buf.toString();        // read it back out as a string
 
                console.log("Decoded Authorization ", plain_auth);
 
                // At this point plain_auth = "username:password"
 
                var creds = plain_auth.split(':');      // split on a ':'
                var username = creds[0];
                var password = creds[1];
 
                if((username == 'hack') && (password == 'thegibson')) {   // Is the username/password correct?
 
                        res.statusCode = 200;  // OK
                        res.end('Congratulations you just hax0rd teh Gibson!');
                }
                else {
                        res.statusCode = 401; // Force them to retry authentication
                        res.setHeader('WWW-Authenticate', 'Basic realm="Secure Area"');
 
                        // res.statusCode = 403;   // or alternatively just reject them altogether with a 403 Forbidden
 
                        res.end('You shall not pass');
                }
        }
});
 
 
server.listen(5000, function() { console.log("Server Listening on http://localhost:5000/"); });
or use http-auth npm module
or use express framework
app.use(express.basicAuth('username', 'password'));

6/24/2013

caolan/async

caolan/async

Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with node.js, it can also be used directly in the browser. Also supports component. Async provides around 20 functions that include the usual 'functional' suspects (map, reduce, filter, each…) as well as some common patterns for asynchronous control flow (parallel, series, waterfall…). All these functions assume you follow the node.js convention of providing a single callback as the last argument of your async function.
pow = (n, callback) ->
  setTimeout (->
    callback null, Math.pow(n, 5)
  ), Math.random()*10*1000

async.map([1, 2, 3], pow, (err, result) ->
  # log the result after all the async operation complete.
  console.log 'result', result
)

remy/nodemon

remy/nodemon - nodemon will watch the files in the directory that nodemon was started, and if they change, it will automatically restart your node application.

nodemon also supports running and monitoring coffee-script apps:
nodemon server.coffee

mikeal/request

mikeal/request -- Request -- Simplified HTTP request

  request.get(url, (error, rsp, body) ->
    songs = []
    $ = cheerio.load(body)
    songs = $('.track_list .song_name > a:first-child').map( ->
      $(this).attr('href').match(/\d+/)[0]
    )
    console.log('songs', songs)
    getMetaBySongId(songs[0])
  )

MatthewMueller/cheerio

MatthewMueller/cheerio - a lightweight html parser with jquery like syntax (find, parent, parents, closest, next, nextAll, prev, prevAll, slice, each, map, filter, first, last, eq)

  request.get(url, (error, rsp, body) ->
    songs = []
    $ = cheerio.load(body)
    songs = $('.track_list .song_name > a:first-child').map( ->
      $(this).attr('href').match(/\d+/)[0]
    )
    console.log('songs', songs)
    getMetaBySongId(songs[0])
  )

via: parsing - HTML-parser on nodejs - Stack Overflow

6/17/2013

bestiejs/platform.js · GitHub

bestiejs/platform.js · GitHub

// on IE10 x86 platform preview running in IE7 compatibility mode on Windows 7 64 bit edition
platform.name; // 'IE'
platform.version; // '10.0'
platform.layout; // 'Trident'
platform.os; // 'Windows Server 2008 R2 / 7 x64'
platform.description; // 'IE 10.0 x86 (platform preview; running in IE 7 mode) on Windows Server 2008 R2 / 7 x64'

// or on an iPad
platform.name; // 'Safari'
platform.version; // '5.1'
platform.product; // 'iPad'
platform.manufacturer; // 'Apple'
platform.layout; // 'WebKit'
platform.os; // 'iOS 5.0'
platform.description; // 'Safari 5.1 on Apple iPad (iOS 5.0)'

// or parsing a given UA string
var info = platform.parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7.2; en; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 11.52');
info.name; // 'Opera'
info.version; // '11.52'
info.layout; // 'Presto'
info.os; // 'Mac OS X 10.7.2'
info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2'

A 75-Year Harvard Study Finds What It Takes To Live A Happy Life Read more: http://www.theatlantic.com/magazine/archive/2013/05/thanks-mom/309287/#ixzz2WRxoxY4w

A 75-Year Harvard Study Finds What It Takes To Live A Happy Life

In June 2009, The Atlantic published a cover story on the Grant Study, one of the longest-running longitudinal studies of human development. The project, which began in 1938, has followed 268 Harvard undergraduate men for 75 years, measuring an astonishing range of psychological, anthropological, and physical traits—from personality type to IQ to drinking habits to family relationships to “hanging length of his scrotum”—in an effort to determine what factors contribute most strongly to human flourishing. Recently, George Vaillant, who directed the study for more than three decades, published Triumphs of Experience, a summation of the insights the study has yielded. Among them: “Alcoholism is a disorder of great destructive power.” Alcoholism was the main cause of divorce between the Grant Study men and their wives; it was strongly correlated with neurosis and depression (which tended to follow alcohol abuse, rather than precede it); and—together with associated cigarette smoking—it was the single greatest contributor to their early morbidity and death. Above a certain level, intelligence doesn’t matter. - 不酗酒抽煙 There was no significant difference in maximum income earned by men with IQs in the 110–115 range and men with IQs higher than 150. Aging liberals have more sex. Political ideology had no bearing on life satisfaction—but the most-conservative men ceased sexual relations at an average age of 68, while the most-liberal men had active sex lives into their 80s. “I have consulted urologists about this,” Vaillant writes. “They have no idea why it might be so.” But the factor Vaillant returns to most insistently is the powerful correlation between the warmth of your relationships and your health and happiness in old age. After The Atlantic’s 2009 article was published, critics questioned the strength of this correlation. Vaillant revisited the data he had been studying since the 1960s for his book, an experience that further convinced him that what matters most in life are relationships. For instance, the 58 men who scored highest on measurements of “warm relationships” earned an average of $141,000 a year more at their peak salaries (usually between ages 55 and 60) than the 31 men who scored lowest; the former were also three times more likely to have achieved professional success worthy of inclusion in Who’s Who. And, in a conclusion that surely would have pleased Freud, the findings suggest that the warmth of your relationship with Mommy matters long into adulthood. Specifically: * Men who had “warm” childhood relationships with their mothers earned an average of $87,000 more a year than men whose mothers were uncaring. * Men who had poor childhood relationships with their mothers were much more likely to develop dementia when old. * Late in their professional lives, the men’s boyhood relationships with their mothers—but not with their fathers—were associated with effectiveness at work. *On the other hand, warm childhood relations with fathers correlated with lower rates of adult anxiety, greater enjoyment of vacations, and increased “life satisfaction” at age 75—whereas the warmth of childhood relationships with mothers had no significant bearing on life satisfaction at 75. Vaillant’s key takeaway, in his own words: “The seventy-five years and twenty million dollars expended on the Grant Study points … to a straightforward five-word conclusion: ‘Happiness is love. Full stop.’ ”
https://news.ycombinator.com/item?id=5721653
Paul Tough's book, "How Children Succeed" [1] has a great section on how mothering style has a large effect on offspring throughout their lives: "Parents and other caregivers who are able to form close, nurturing relationships with their children can foster resilience in them that protects them from many of the worst effects of a harsh early environment. This message can sound a bit warm and fuzzy, but it is rooted in cold, hard science. The effect of good parenting is not just emotional or psychological, the neuroscientists say; it is biochemical. The researcher who has done the most to expand our understanding of the relationship between parenting and stress is a neuroscientist at McGill University named Michael Meaney. Like many in the field, Meaney does much of his research with rats, as rats and humans have similar brain architecture. At any given time, the Meaney lab houses hundreds of rats. They live in Plexiglas cages, and usually each cage holds a mother rat, called a dam, and her small brood of baby rats, called pups. Scientists in rat labs are always picking up baby rats to examine them or weigh them, and one day about ten years ago, researchers in Meaney’s lab noticed a curious thing: When they put the pups back in the cages after handling them, some dams would scurry over and spend a few minutes licking and grooming their pups. Others would just ignore them. When the researchers examined the rat pups, they discovered that this seemingly insignificant practice had a distinct physiological effect. When a lab assistant handled a rat pup, researchers found, it produced anxiety, a flood of stress hormones, in the pup. The dam’s licking and grooming counteracted that anxiety and calmed down that surge of hormones. Meaney and his researchers were intrigued, and they wanted to learn more about how licking and grooming worked and what kind of effect it had on the pups. So they kept watching the rats, spending long days and nights with their faces pressed up against the Plexiglas, and after many weeks of careful observation, they made an additional discovery: different mother rats had different patterns of licking and grooming, even in the absence of their pups' being handled. So Meaney’s team undertook a new experiment, with a new set of dams, to try to quantify these patterns. This time, they didn’t handle any of the pups. They just closely observed each cage, an hour at a time, eight sessions a day, for the first ten days of the pups' lives. Researchers counted every instance of maternal licking and grooming. And after ten days, they divided the dams into two categories: the ones that licked and groomed a lot, which they labeled high LG, and the ones that licked and groomed a little, which they labeled low LG. ... The researchers ran test after test, and on each one, the high-LG offspring excelled: They were better at mazes. They were more social. They were more curious. They were less aggressive. They had more self-control. They were healthier. They lived longer. Meaney and his researchers were astounded. What seemed like a tiny variation in early mothering style, so small that decades of researchers hadn’t noticed it, created huge behavioral differences in mature rats, months after the licking and grooming had taken place. And the effect wasn't just behavioral; it was biological too. When Meaney’s researchers examined the brains of the adult rats, they found significant differences in the stress-response systems of the high—LG and low-LG rats, including big variations in the size and shape and complexity of the parts of the brain that regulated stress." [1] http://www.amazon.com/How-Children-Succeed-Curiosity-Charact... -----

6/09/2013

Font sizing with rem - Snook.ca

Font sizing with rem - Snook.ca

Sizing with rem CSS3 introduces a few new units, including the rem unit, which stands for "root em". If this hasn't put you to sleep yet, then let's look at how rem works. The em unit is relative to the font-size of the parent, which causes the compounding issue. The rem unit is relative to the root—or the html—element. That means that we can define a single font size on the html element and define all rem units to be a percentage of that.
html { font-size: 62.5%; }  /* =10px */
body { font-size: 1.4rem; } /* =14px */
h1   { font-size: 2.4rem; } /* =24px */
I'm defining a base font-size of 62.5% to have the convenience of sizing rems in a way that is similar to using px. But what pitiful browser support do we have to worry about? You might be surprised to find that browser support is surprisingly decent: Safari 5, Chrome, Firefox 3.6+, and even Internet Explorer 9 have support for this. The nice part is that IE9 supports resizing text when defined using rems. (Alas, poor Opera (up to 11.10, at least) hasn't implemented rem units yet.) What do we do for browsers that don't support rem units? We can specify the fall-back using px, if you don't mind users of older versions of Internet Explorer still being unable to resize the text (well, there's still page zoom in IE7 and IE8). To do so, we specify the font-size using px units first and then define it again using rem units.
html { font-size: 62.5%; } 
body { font-size: 14px; font-size: 1.4rem; } /* =14px */
h1   { font-size: 24px; font-size: 2.4rem; } /* =24px */
And voila, we now have consistent and predictable sizing in all browsers, and resizable text in the current versions of all major browsers.

6/08/2013

PanSci 泛科學 | Blog | 80分女孩沒人愛?

PanSci 泛科學 | Blog | 80分女孩沒人愛?

「你看過這篇文章嗎?我在想,我是不是他所說的80分女孩。更正確地說,我應該算是80分老女人了,都快35歲了,戀愛經驗還掛蛋。」臉書右下角傳來她的訊息。 這已經是我第三次在塗鴉牆上看到這篇文章了,從不同的朋友、不同的女孩(人?)、不同的地方轉過來。 一開始我以為,這篇文章在某種程度上同理剩女的悲哀,後來才發現,許多推論都只是推測,許多推測也沒有根據。例如「八十分女生雖然普遍條件很好,可是在成長過程中可能從來沒有想過自己是否有具備「讓男人感到安心」的特質(或手腕)」、或是「中等美女多有幾個特色:安全、善體人意、不會給人極大壓力、溫柔婉約、善於傾聽,也因此,男人越是願意跟她們發展長期關係甚至結婚。」等等。 真正的事實是,不存在一組「穩定的特質」可以描述80分女孩,就算有,也跟有沒有人要無關。從認識、交往、結婚、到長久的婚姻關係,中間需要經過的決策歷程是複雜、甚至有些是不可控的[1],特質只在初始吸引時有效果。 圖片來源:Brandon Christopher Warren 100%的女孩 好,那是什麼樣的「特質」決定一開始的吸引呢? 這個問題很簡單,當一個臭男生對他的哥兒們說:「嘿,我最近認識一個妹」的時候,通常這些哥們會問的第一個題是:「長怎樣?」、「有沒有照片(伸)」、或是「沒圖沒真相」,因為外貌吸引力在一開始真的扮演很重要的角色[2],對於男性尤甚,女性則還會考慮收入、社會地位等等[3]。 但是,男性並非真的這麼膚淺(而已),通常之後也會接著問「她是個怎樣的人?」(如果不是只想要一夜情的話)。事實上,在長遠的關係中,我們更重視伴侶的個性[4]──這也是為什麼,分手原因的冠軍寶座常是「個性不合」,而不是「她長太醜」[5]。 (1) 外貌:娃娃臉、低腰臀比(有一說是0.7)[6, 7]、低BMI[8]、胸部稍大。 (2) 個性:是事實上不論男女,大家都在找同一個人──謹慎可靠好相處,開放外向情緒穩[9],台灣的研究也得到相仿的結果[4]。 我這邊想補充強調一點是(應該是說反省一點),過去我們都太過強調女性的外貌了。沒錯,大量的研究指出男女都愛看正妹,但是個性也會影響我們對一個人的知覺。Swami等人曾請2157個男大生評斷,怎樣的照片是他們心目中的女神[10]。結果顯示,雖然大部分的男生都喜歡中等偏瘦的女生(underweight, BMI=15 − 18.5 kg / m2),但是若受試者知道她的個性不錯,對「美的身材」的接受度(Range)也比較廣──相反的,如果知道她個性差,這些男性就會她的身材比較挑剔。 好相處的女孩沒人要? 「我想,可能是我太強勢了吧。你們男生不都是喜歡百依百順的女孩?」 「難道事業成功也是一種錯?工作穩定也不好?我不明白,我薪水也還算不錯,也很有想法,甚至常常提供他一些新的想法和建議,可是他最後竟然看上那種女人……」很多時候我們會納悶,是否女強人=敗犬?事業成功就注定情感成空? 如果你也曾經抱持這樣的想法,我的理解是,讓妳成空的不是妳的能力太好,而是妳的語氣或脾氣不好。Swami等人的研究中發現幾個讓人反感的特質,包括神經質、不可靠、和不好相處: (1) 不好相處(Disagreeable):愛批評(Critical)、不合作(uncooperative)、凡事只想到自己(self-interest)。 (2) 神經質(Neurotic):太敏感(touchy)、太情緒化(moody)、容易焦慮(anxious)。 (3) 不可靠(Unconscientious):三分鐘熱度、生活一團亂(massy)、不可信賴(unreliable)成就動機又低(lack ambition)。 上述的三項特質,對男性的吸引力(Desirability)都低於2.5分(滿分是7分)。當然,這篇文章也指出,好相處反而讓妳找不到歸宿,很可惜,這個假設是錯的──事實是,大家都歡溫柔、好相處、善解人意的女孩(Agreeable)。 常態配對的謬誤 不少(偽?)兩性科學,會利用常態分配的方式解釋婚配市場,這樣的解釋方式雖然易於理解,但是(至少)有兩個問題: (1) 特質只是開始,相處才是重點多年人際關係的研究共同指出一件事情是:兩人的互動永遠比一開始的樣子重要。因為一段好的關係裡,我們會共同形塑彼此的樣子[11, 12];而真正影響彼此關係好壞的,是相處時的狀況──她願不願意傾聽、她願不願意回應[13]?她能不能在你需要的時候給予支持?能不能跟你分享生活瑣事[14]?能不能為這段關係做一點犧牲[15]。這些無法從常態分佈鐘形曲線上看出來的,才是決定幸福的關鍵因子。所以,擇偶只看那顆鐘,幸福永遠不會中。 (2)你以為,你可以自己做決定嗎? 總而言之,吸引和結婚,其實從來不存在因果關係,甚至連相關都很微弱。你可能被一個人吸引,但可能不會附諸行動;你可能開始追求,但不見得會到手;就算追到手,半年內還是有4成的人會分手;就算沒分手,對於結婚,家人和親戚的意見也無法不納入考慮[16],畢竟結婚是兩個家庭的結合,身邊的重要她人都會影響我們的決定! 圖片來源:Makena G 你真的知道,自己想要的是什麼嗎? 不過,在一切的阻撓與複雜前,我們還是有件事情可以做──問問自己:「我真的知道自己要的是什麼嗎[9]?我想遇見怎樣的人?我要怎麼樣的一段關係?」,你可以試著列出十個擇偶條件,然後回顧你過去的感情,或許就可以看清:為什麼一直以來,你都遇不到對的人?有時候長期單身不是沒人要,也不是目標太高,而是錯把吸引自己的人,當成適合自己的人。畢竟每個人都想跟更好的人在一起,但最後只能跟「願意跟你在一起」的人,在一起。 註解: 詳情請參閱此文:「算出」你的命中註定?六個交友網站不能說的祕密 詳情請參閱此文:愛情弔詭。一個網友muki問:吸引自己 & 適合自己的人差在哪裡?其實,甚至不需要「自己」這個詞。也就是說,應該是「吸引人」的人,與適合自己的人是不一樣的。沒錯,所有的人都喜歡好相處、情緒穩定、可靠的人,但是如果希望認識之後衝突小一些,磨合少一些,價值觀的相似(與自己相似)是一個可以考慮的點,而「價值觀相似」(value similarity)這件事,某種程度上就會讓適合自己的人=/=吸引自己的人。可是我還是老梗地說,合不合很大的部分是得靠相處,這也是為什麼我說初始條件無法決定一段幸福的愛戀。也還好一段好的感情需要靠相處,因為得來不易的幸福才更有溫度。 詳情請參閱此文:爆乳战术为何屡试不爽? 詳情請參閱此文:人帥真好?有關外貌吸引力的十個如果 一般來說,追求行為=對方吸引力×到手可能性,如果幾乎不可能到手,就不會有追求。詳情請期待敝熊不才的新書:《在怦然之後:愛情的十六堂課》 詳細操作方式,請見此書末:《一個人的愛情療癒:一個人、兩個人或三個人的關係,如何走出來?》。作者發現,原來,一直以來他的感情屢戰屢敗,是因為他只看臉蛋。 不過,這篇文章也說對了一件事情,就是男生有時候需要的是一種安全感,或者應該說,不論男女,我們「都需要」安全感。 我覺得不平的是:為什麼只有「剩女」,而沒有「剩男」呢?我想,或許是大家對於女性的年齡要求比較嚴苛的緣故。而且隨著年齡的增長,男性越來越無法接受比自己大的女人[17]。 倉促成稿,若有疏漏,歡迎指教,謝謝各位科友!

6/04/2013

Paul Irish on Web Application Development Workflow

Paul Irish on Web Application Development Workflow

dot files - https://github.com/paulirish/dotfiles (check bash_prompt) snap a photo after commit - brew install imagesnap - post-commit hook #!/usr/bin/env ruby file="~/.gitshots/#{Time.now.to_i}.jpg" puts "Taking capture into #{file}" system "imagesnap -q -w 3 #{file}" exit 0 ssh config Host dev HostName dev.example.com port 22000 User foley Generators - Generators scaffold out entire projects, or argument existing ones - Flexible: . remotely pulling and filtering dependencies . wiring, so boilerplate minimization++ . sub-generators for creating new models, views etc. - Default generators: Ember, Backbone, Angular, Mocha, Jasmine…

z - jump around

z - jump around - brew install z

NAME z - jump around SYNOPSIS z [-chlrtx] [regex1 regex2 ... regexn] AVAILABILITY bash, zsh DESCRIPTION Tracks your most used directories, based on 'frecency'. After a short learning phase, z will take you to the most 'frecent' directory that matches ALL of the regexes given on the command line. OPTIONS -c restrict matches to subdirectories of the current directory -h show a brief help message -l list only -r match by rank only -t match by recent access only -x remove the current directory from the datafile EXAMPLES z foo cd to most frecent dir matching foo z foo bar cd to most frecent dir matching foo and bar z -r foo cd to highest ranked dir matching foo z -t foo cd to most recently accessed dir matching foo z -l foo list all dirs matching foo (by frecency) NOTES Installation: Put something like this in your $HOME/.bashrc or $HOME/.zshrc: . /path/to/z.sh cd around for a while to build up the db. PROFIT!! Optionally: Set $_Z_CMD to change the command name (default z). Set $_Z_DATA to change the datafile (default $HOME/.z). Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution. Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your- self. Set $_Z_EXCLUDE_DIRS to an array of directories to exclude. (These settings should go in .bashrc/.zshrc before the lines added above.) Install the provided man page z.1 somewhere like /usr/local/man/man1. Aging: The rank of directories maintained by z undergoes aging based on a sim- ple formula. The rank of each entry is incremented every time it is accessed. When the sum of ranks is greater than 6000, all ranks are multiplied by 0.99. Entries with a rank lower than 1 are forgotten. Frecency: Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted rank that depends on how often and how recently something occurred. As far as I know, Mozilla came up with the term. To z, a directory that has low ranking but has been accessed recently will quickly have higher rank than a directory accessed frequently a long time ago. Frecency is determined at runtime. Common: When multiple directories match all queries, and they all have a common prefix, z will cd to the shortest matching directory, without regard to priority. This has been in effect, if undocumented, for quite some time, but should probably be configurable or reconsidered. Tab Completion: z supports tab completion. After any number of arguments, press TAB to complete on directories that match each argument. Due to limitations of the completion implementations, only the last argument will be com- pleted in the shell. Internally, z decides you've requested a completion if the last argu- ment passed is an absolute path to an existing directory. This may cause unexpected behavior if the last argument to z begins with /. ENVIRONMENT A function _z() is defined. The contents of the variable $_Z_CMD is aliased to _z 2>&1. If not set, $_Z_CMD defaults to z. The environment variable $_Z_DATA can be used to control the datafile location. If it is not defined, the location defaults to $HOME/.z. The environment variable $_Z_NO_RESOLVE_SYMLINKS can be set to prevent resolving of symlinks. If it is not set, symbolic links will be resolved when added to the datafile. In bash, z prepends a command to the PROMPT_COMMAND environment vari- able to maintain its database. In zsh, z appends a function _z_precmd to the precmd_functions array. The environment variable $_Z_NO_PROMPT_COMMAND can be set if you want to handle PROMPT_COMMAND or precmd yourself. The environment variable $_Z_EXCLUDE_DIRS can be set to an array of directories to exclude from tracking. $HOME is always excluded. Direc- tories must be full paths without trailing slashes. FILES Data is stored in $HOME/.z. This can be overridden by setting the $_Z_DATA environment variable. When initialized, z will raise an error if this path is a directory, and not function correctly. A man page (z.1) is provided. SEE ALSO regex(7), pushd, popd, autojump, cdargs Please file bugs at https://github.com/rupa/z/

localtunnel

localtunnel

The easiest way to share localhost web servers to the rest of the world{ $ gem install localtunnel $ localtunnel 8000 share this url: http://xyz.localtunnel.com

6/03/2013

I had a revelation one day when I realized I didn't have to read everything I found on the Internet.

I had a revelation one day when I realized I didn't have to read everything I found on the Internet.

I say no more often and now I actually have weekends to myself to do things I want to do, like hiking in the Marin Headlands, running 16.6 miles to catch sunset on the beach, getting brunch on Sundays and running into Sir Jony Ive, taking photos or just relaxing. It's pretty neat. I sold or tossed a ton of stuff I didn't need, use or wear. I stopped wearing all those free startup shirts I gathered over the years and moved on to button-ups. I use Laundry Locker to deal with ironing them so I don't spend my Sundays doing this. I buy toothpaste, shampoo and the like in bulk on Amazon so I don't have to remember to make monthly errands. I moved to a slimmer wallet and carry less stuff with me everywhere. I cancelled unnecessary monthly billed services so there's less to think about when I see my statements. I removed apps I didn't use daily from my phone's home screen and deleted ones I didn't use at least once a week. I stopped checking into places on foursquare 10 times a day. I got into a regular workout routine and ran 102 miles this month alone... I would have never had the time or patience to do that if I felt guilty I wasn't working. I've pushed everything else out of the way so I can focus on what I'm doing right now, living life.

6/01/2013

看对的书 (Part 1 - Tribal Leadership)

看对的书 (Part 1 - Tribal Leadership)

部落的 5 个阶段对应的话语都很有特色,所以要鉴别一个部落处于哪个阶段并不难: 「人生就是个悲剧」——第 1 阶段的人认为没有谁的生活是好过的。 「我就是个悲剧」——第 2 阶段的人看得到别人生活美好的一面,只是觉得自己的生活很糟糕。 「我很牛,但你不是」——第 3 阶段的人觉得自己的生活不错,因为自己很牛,但觉得自己身边的人都不如自己牛,也不愿意给予自己更多支持,因此自己没办法完成更大的目标。 「我们很牛,但你们不是」——第 4 阶段的人觉得自己的部落很牛,而且竞争对手都不如自己。 「世界很美好」——第 5 阶段的人只专注于做一些很崇高的事业,无视竞争对手的存在。 就美国而言,有一半的人处于第 3 阶段的部落,而且绝大多数都是专业化的知识工作者,例如医生、律师,当然也包括工程师。由于现代教育体系奖励很牛的小朋友,而不是奖励很会跟别人合作的小朋友,所以大多数专业人士到达第 3 阶段后就难以获得突破,除非他们能够获得顿悟。顿悟的来源通常有两种:要么是明白到自己想要追求的目标实在是太大,无论自己有多牛都不可能实现,所以必须放弃单干的幻想,学会通过支持别人来换取自己的目标得以实现;要么是觉得自己足够牛了,获取更多的个人成就已经变得没意思了,那还不如帮助别人实现他们的目标。只有在不看重个人成就高低的前提下,部落才可能进入第 4 阶段。 此外,美国还有四分之一的人处于第 2 阶段。他们往往有一个处于第 3 阶段的老板,这些老板为了保证自己能够获得最好的职业发展而只雇佣能力比自己低的第 2 或第 3 阶段下属。第 2 阶段的人往往就在这样的老板手下痛苦挣扎,看着老板的生活很好,同时感觉自己生活很悲催,因此发誓将来成为老板的话一定不能这样子。但是,等第 2 阶段的人成为老板并且过上好生活后,他们会进入第 3 阶段,成为他们过去痛恨的老板。这时候,他们就不想放弃晋升带来的冲劲了,希望能够更好地证明自己也是很牛的,同时迅速往上爬。 这背后的道理是,人的行为变更是不可能跨越阶段进行的。书中甚至把每一个阶段分成了 3 个子阶段——初期、中期、末期。你不能指望一个人在脱离第 2 阶段后能够立即拥有第 4 阶段的意识,放弃个人成长优势而去帮助他人。因此,如果你想要成为一个部落领袖的话,你需要能够鉴别部落所处的阶段,同时你自己要能穿梭于不同的阶段,去到部落所处的阶段然后把部落带到更高级的阶段。至于每一个子阶段的特征是什么,以及如何能够帮助部落迁移到更高的阶段,我在这里就不详细解释了,大家去看书中的内容吧。如果不愿意看书,到 Tribal Leader 官网上下载有声读物也可以,而且还是免费的,只不过需要注册一下。如果买书的话,我推荐买 Kindle 版,因为看起来方便,不用想方设法把一本进口书弄回国内。 我之所以选择推荐这本书,是因为我很认同里面所说的部落阶段划分。我经历过不少第 3 阶段的部落——名校、名企大多如此。我知道,自己再牛能做的事情也有限;但是,我不知道如何能够突破。这本书解释清楚了一个问题——个人要突破,必须先放下职业发展的得失。然后还要推动整个部落突破,这需要部落拥有核心价值观和高尚的目标,同时制定达成高尚目标的战略。我相信国内也会有很多优秀的工程师卡在第 3 阶段找不到突破口,所以我建议大家读读这本书看看有什么启发。