Search

9/30/2013

rainyday.js: a simple script for simulating raindrops falling on a glass surface

rainyday.js: a simple script for simulating raindrops falling on a glass surface

demo: http://maroslaw.github.io/rainyday.js/demo.html?imgur=rhnaa4G&youtube=MLBSAVcC1TA&preset=2

左心房肥大 竇性心搏過緩

左心房肥大 竇性心搏過緩

根據國外過去對運動員大規模的篩檢研究顯示, 運動員心電圖檢查異常比例約40%, 遠高於同年飛運動員. 運動員常見的心電圖異常項目包刮:左心室肥大, 竇性心搏過緩, 左/右心防擴大.

9/16/2013

清大彭明輝的部落格: 奴隸如何學會心甘情願地服從

清大彭明輝的部落格: 奴隸如何學會心甘情願地服從

前一篇舉出具體證據來證明:台灣居於統治地位的少數財團是靠剝削員工的薪水和賺取政府租稅補貼來增加財富,他們賺的是國人的錢,而韓國財團賺的是外國人的錢。因此,臺灣人遠比韓國人更像奴隸。但是,在21世紀怎麼還有可能維持這麼鮮明的剝削與奴隸? 傅科說:剝削從來不曾消失,只是技術愈來愈發達,愈來愈隱微難察而已。在21世紀,壟斷是以遠比20世紀更隱微難察的方式存在:它靠資本優勢來消滅競爭者(而資本優勢來自政商關係與公股銀行的超低利貸款,或者資本免稅以加速資本累積,或者資本不扣遺產稅來達到資本優勢的世襲),它靠租稅獎勵條例與科學園區的各種優惠制度來阻絕新興企業家的挑戰,它靠通路與廣告壟斷來阻絕新興商品的挑戰(而背後是靠資本優勢在維繫通路與廣告壟斷),它靠財務優勢來擊垮創新者的成本優勢(而財務優勢來自於公股銀行低利貸款,私人銀行小蝦米超低價吞掉公有銀行的大鯨魚),它靠智慧財產權來消滅競爭者,它靠立法來阻絕國外的競爭者,……。 奴隸制度可以維繫,還需要一整套論述讓被奴隸者心甘情願,同時讓壓榨別人的心安理得。 在中世紀,這一套論述叫做「君權神授」,販賣這套理論的教會吃得肥滋滋──在法國大革命之前,身為第一階級的高級僧侶人數不足人口的1%,卻占有全國20%的土地,連貴族都只能退居第二階級。工業革命之後這一套理論叫「社會達爾文主義」,資本家賣商品順便賣這一套理論,讓資本家理直氣壯地享受剝削,中產階級心安理得地享受廉價商品,工農階級自認不如人而甘願過著牛馬不如的生活。 在今天,這一套論理叫做「經濟學」,御用經濟學者們把資本壟斷叫做「規模經濟的必然優勢」,只強調規模經濟可以降低生產成本,而故意不去規模經濟可以提高壟斷程度,減少競爭者,並且在競爭者差距拉大而不足以造成威脅時開始靠默契聯合壟斷來哄抬物價,之後再壓低工資;然後,他們故意無視於壟斷造成利潤的上升與工資的下降,混淆視聽地用「完全競爭市場」的理論來捍衛高度壟斷的市場。 年輕人為什麼不去創業?當資本、公股銀行的低利貸款、通路、品牌、生產規模都穩定地被控制在少數財團手裡時,年輕人想要創業無異於以卵擊石。除非你是繼承家族企業與靠壟斷而維繫的競爭優勢,否則年輕人的創業機會侷限於大財團沒興趣的高風險新興市場。這就像是1%的人享有99%的市場,剩下99%的年輕人只能去競爭1%的市場。 被剝削、宰制、奴隸的人為何不抗?因為他們屬於99%的人,卻以為自己有機會進入1%的範圍。階級流動的管道非常地窄,但不是沒有,就像歐洲的中世紀,只要你夠賣命,就有機會累積戰功來封爵(雖然世襲的貴族不用戰功就可以封爵),或者帝制時期的中國儒生,可以靠功名而分享剝削、宰制、奴隸的好處,或者今天的大學教授,夠無恥或無知的話就可以入閣或當個不分區立委來幫助官商勾結的體制。只要甘願順從,即使沒有稱王封侯,起碼可以有優渥的收入,享受著廉價的商品,刻意遺忘廉價商品的背後是被刻意壓低的基本工資。 2012年,以名目所得計算的話,台灣的人均GDP 20,328元<22,055(希臘)<23,113(韓國)<26,389(賽普勒斯)<29,289(西班牙)<33,115(義大利)<36,667(香港)<38,589(英國)<41,141(法國)<41,513(德國)<45,888(愛爾蘭)<49,922(美國)。 但是以購買力計算的話,台灣的人均購買力 38,749元,接近德國(39,028)>37,883(比利時)>37,657(丹麥)>36,941(英國)>36,365(芬蘭)>36,266(日本)>35,548(法國)>32,272(韓國)>30,557(西班牙)>30,136(義大利)>29,730(紐西蘭)>24,505(希臘)。 我們的購買力為什麼那麼強,接近歐盟所有國家最憲幕的德國,甚至還超過丹麥、英國、日本、法國?社會底層的工資很低!我們是靠著剝削社會底層在享受超高的購買力,因此40%~60%的人對自己的生活享受很滿意,不願意看見被我們欺壓在腳底下那一大群困苦的人。他們在哪裡?非典就業的人口! 在加油站打工的,在 7-11打工的,在餐廳打工的,領基本工資的,靠行的計程車司機,人力派遣公司裡的各種人,……。當然,還有許許多多入不敷出的工人、自聘雇者。 管中閔為何要悍然拒絕調漲基本工資?因為它會動搖國本──少數財團財富累積是靠著剝削中產階級(上班族)的薪水,而中產階級會對現況滿意是靠壓榨更底層(工農)的勞動力,一旦調整基本工資就會摧毀這個奴隸制度的根基! 那麼,最底層的工農怎麼活下去?工人活在「只要夠努力,有天我也會出頭天」的夢想裡,農人呢?把少數人的農地變更成建地與商業用地,以便哄抬周邊地價。全省荒唐的徵地案之所以能得到一部份農民的支持,就是靠這把戲。 在21世紀奴隸制度如何可以維繫?靠代議政治的官商勾結,靠學者的為虎作倀,靠名嘴的歪曲事實,靠中產階級對既有秩序的支持、合作與故意不去知道事實,靠被奴隸者的認命與「只要夠努力,有天我也會出頭天」的想望。

台灣人比韓國人更像奴隸 by 彭明輝 - 政治新聞八卦版 - WeTalk 論壇 - 台灣最大的新聞論壇!

台灣人比韓國人更像奴隸 by 彭明輝 - 政治新聞八卦版 - WeTalk 論壇 - 台灣最大的新聞論壇!

加拿大的紀錄片《Generation Jobless》(無業世代),非常震撼!加拿大的大學畢業生失業和低度就業的問題也很嚴重:很多大學生畢業後到餐廳端盤子,看不到未來;還有大學生為了卡位,開始到公司上班,職稱是「實習生」,薪資「零」,而且這樣的工作還有人搶破頭。我的震撼是因為想起跟孫女兒的一段對話。 孫女兒曾經問我英國的奴隸販賣史,我怕她不知道何謂「奴隸」,就先問她:「你知道什麼叫奴隸嗎」?她說:「知道,老師有解釋過,奴隸就是要工作,但是沒有工資。」 比起來,無薪的「實習生」比奴隸還不如──奴隸雖然也沒有工資,但是至少老闆要負責他們的飲食起居和醫藥;而無薪的「實習生」卻一切要自理。 你可以說:無薪的「實習生」是自願工作,而奴隸是被迫工作,所以不可以把無薪的「實習生」跟奴隸並比。但是,林肯剛解放黑奴的時候,南方黑奴也是生怕找不到工作,而寧可「自願」去當奴隸啊!我們需要有分析「奴隸制」的新概念架構。 一個經濟系的教授跟我解釋:無薪的「實習生」是自由意志下的交易行為,屬於自由市場機制,政府不該干預,否則只會讓局勢更加惡化;而奴隸制度並非出於自由意志,所以政府應該要干預,以便用市場機制調度資源的有效運用。 我很想叫他去讀一讀馬克思的《資本論》,甚至只要讀一篇簡介的文章他就會知道什麼叫做經濟學角度下的「自由意志」和「自由交易」。 馬克思的很多預言都失效了,這不表示他說的每一句話都錯了。馬克思清楚地看到資本主義的核心問題:只要資本家壟斷了生產工具,工人就只好為了競爭工作機會而彼此削價,降低工作條件,而工人的付出就會有愈來愈大的比例變成資本家的「利潤」──這是有別於殖民主義時代的奴隸制,但仍舊是奴隸制。而 Stiglitz 也很清楚地告訴我們:壟斷是不勞而獲最根本的方法,因為在完全競爭市場裡面利潤等於零。這兩個核心概念是我們洞視今日經濟問題的關鍵。 最極端的市場有兩種:完全競爭市場和完全壟斷市場,前者利潤等於零而工資極大化;後者工資極小化而利潤極大化;前者是亞當史密、古典經濟學和新古典經濟學的夢想國度(經濟意義下最自由而平等的國家),後者是經濟上的奴隸制度。所以,從經濟學的角度看,每一個國家都應該向「完全競爭市場」邁進,以便發揮所有資源的最有效應用;也同時達到經濟權的完全自由與平等(每一個人的所得等於他對社會提供的服務,Not more, nor less)。 奴隸制度的核心就是經濟上的剝削,其他的剝削根本是附屬的、次要的。因此,我們也可以從利潤與工資的比值來衡量一個國家距離經濟上的完全平等(或奴隸制)有多遠。所以,讓我們來看看台灣和韓國哪一個國家比較民主,哪一個國家比較像經濟上的奴隸制。 根據 Deloitte 會技師事務所與美國競爭力委員會的《2013全球製造業競爭力指標》報告第4頁圖一的數據,台灣的人均產值比韓國多出17%,但是每小時工資卻只有韓國的52%!也就是說,假如韓國是一個完全競爭市場(利潤等於零),台灣的勞工至少有一半的應得工資被老板拿去當利潤!台灣遠比韓國更像一個奴隸制下的國家。 如果你把稅負因素再加進去,問題更嚴重。政府窮、人民窮,但是炒房炒股新增的十七兆財富,幾乎不需繳稅。根據美國保守派智庫 Heritage Foundation 的統計,台灣的稅負僅及韓國的三分之一,但是低稅負的好處全部給了富人,薪水階級和傳統產業絲毫不覺得稅負低。 乍看起來,在台灣當老闆真好?千萬別一概而論。事實應該是:可以跟行政院長開會的老闆很爽,不能跟院長開會的老闆很苦;在科學園區的老闆光靠政府補貼就賺得肥滋滋,在工業區內的廠商就等著倒閉──合法的不公平競爭,只有少數人受惠,這就叫做壟斷與「官商勾結」!難怪大家都想進園區。 我們以為自己有投票權,可以自由找工作,就不再是奴隸了?沒有經濟上的平等,其他一切的平等都是遮掩「剝削」與「奴隸」的糖衣! 臺灣人跟美國百年來的黑人處境相去其實不遠:我們可以投票給爛人當總統和立委(社會上最不受尊敬,最被看不起的一群人,因為他們沒有在做我們要他們作的事,而是整天在幫財團的剝削機制合法化),可以自由地找工作,只不過我們的工資至少有一半會被老板拿去當利潤。而這個壟斷的機制是靠我們繳的稅和我們賦予政府的權力在維繫的。 奴隸制度怎麼有可能在21世紀繼續生存?靠我們這些被剝削者的無知:我們被剝削,卻自以為是自由的。我們怎麼會那麼笨?因為有一大堆御用學者整天以「學術」之名在未我們洗腦,其中許多政治系和經濟系的學者、論述正是政府維繫奴隸制度最重要的幫兇。 代議政治呢?只不過官商勾結的白手套,愈來愚弄百姓,讓他們在被剝削的過程中找不到任何反對的理由。代議政治本質上就是將壟斷合法化的機制! 我們怎麼辦?公民運動是唯一的出路。很難,但我想不出更好的辦法。

9/12/2013

ctrlp.vim 專案開發時開檔案的好幫手

ctrlp.vim 專案開發時開檔案的好幫手

那我只要輸入類似這種的路徑: as/j/u.id 就可以找到需要的檔案(當然要看有沒有其他檔案有類似的組成) 找到以後有幾種開啟方法: enter: 可以在目前 window 中打開(如果已存在其他 tab 中會跳過去) C-t: 會開新的 tab C-v: 把目前的 window 做垂直切割開啟 installation: 其他一些指令可以參考 :help ctrlp-mappings 剛裝完 ctrlp 的時候可能會覺得他啟動有點慢,在 OSX/Linux 底下的話可以設定用 git ls-files 或 find 來做檔案列表的建立,速度會有明顯的改善,在 ~/.vimrc 裡面加入
  let g:ctrlp_user_command = {
    \ 'types': {
      \ 1: ['.git', 'cd %s && git ls-files -c -o'],
      \ 2: ['.hg', 'hg --cwd %s locate -I .'],
      \ },
    \ 'fallback': 'find %s -type f'
    \ }
installation: http://kien.github.io/ctrlp.vim/#installation

API | User Tests HOWTO - Browserscope

API | User Tests HOWTO - Browserscope

Browserscope wants to help you store and aggregate your browser test data. Storing your data in our system gives you the benefit of not having to write a complex, scaling backend with a user agent parser built in. You can download all of your data for offline processing, and we provide a stats table widget that you can embed on your page which shows the median results for your tests.

HTML5 Video Preload | High Performance Web Sites

HTML5 Video Preload | High Performance Web Sites

Observation #1: Mobile devices don’t preload anything. The VIDEO spec calls the preload values “hints”, so it makes sense that mobile browsers would choose not to preload anything in order to save on data costs. Instead, the video doesn’t start downloading until the user initiates playback. When I saw this I decided to add a test for the AUTOPLAY attribute. As shown, that also does not cause any video download on mobile devices. Observation #2: The amount of video preloaded varies across the major desktop browsers. Luckily, preload='none' has consistent behavior across all browsers: nothing is buffered. But all other values of PRELOAD vary in how much video data is downloaded. Chrome is aggressive about preloading, going so far as to buffer 25 seconds of video for preload='metadata'. However, it is less aggressive for preload='auto', stopping at 25 seconds while the other desktop browsers download the entire 52 seconds. Firefox 19 and IE 10 are generally less aggressive, buffering zero seconds for three of five preload states. Observation #3: Browsers preload too much by default. Developers are most likely not going to specify any value for PRELOAD. As shown in Table 1, this situation results in IE 9 buffering 2 seconds of video, Opera 12 buffers 10 seconds, Chrome 26 buffers 25 seconds, and Safari 6 buffers the entire 52 seconds. The entire video is 4.2MB, so the amount of data downloaded is 0.2MB for IE9, 0.8MB for Opera 12, 2.0MB for Chrome 26, and the entire 4.2MB for Safari 6. http://www.browserscope.org/user/tests/table/agt1YS1wcm9maWxlcnINCxIEVGVzdBioyaYUDA?v=1&layout=simple

mdfind

mdfind(1) Mac OS X Manual Page

SYNOPSIS mdfind [-live] [-count] [-onlyin directory] [-name fileName] query -onlyin dir Limit the scope of the search to the directory specified. -name fileName Searches for matching file names only.\ -0 Prints an ASCII NUL character after each result path. This is useful when used in conjunction with xargs -0. mdfind javascript mdfind -onlyin ~/Dropbox/ebook -name javascript


via: 5 Unix Commands I Wish I’d Discovered Years Earlier
This one is specific to mac, as there are other *nix equivalents. It has similar functionality to find but uses the Spotlight index. It allows you to search your entire filesystem in seconds. You can also use it to give you live updates when new files that match your query appear. I use it most often when I’m trying to find the obscure location that an application stores some critical file.
mdfind -onlyin . -name url -0 | xargs -0 rm
mdfind -onlyin . -name url -0 | xargs -0 -J % rm -rf %
mdfind -onlyin . -name url -0 | xargs -0 -J % cp % /tmp // -J % 可以把 % 當做送進來的參數
如果是用find
find . -type f -name *.js -print0 | xargs -0 rm

Momentum Scrolling on iOS Overflow Elements

Momentum Scrolling on iOS Overflow Elements

Web pages on iOS by default have a "momentum" style scrolling where a flick of the finger sends the web page scrolling and it keeps going until eventually slowing down and stopping as if friction is slowing it down. Like if you were to push a hockey puck across the ice or something. You might think that any element with scrolling would have this behavior as well, but it doesn't. You can add it back with a special property.
-webkit-overflow-scrolling: touch;

分手快樂!在 Google 上班就像交了一個很帥的男友,但我一點都不快樂 | TechOrange《 專訪與人物 |

分手快樂!在 Google 上班就像交了一個很帥的男友,但我一點都不快樂 | TechOrange《 專訪與人物 |

在不知道下一步是什麼,就決定離開 Google 大約六個月前,我決定辭掉眾人羨慕的 Google 工作,去探索生活的另一種可能性,其實也沒有太周詳的計畫。不過離開是因為沒辦法留下,當初也說不出所以然,只知道不能再繼續走下去,因為強烈感覺到目前在走的路,並不會帶我到想要去的地方,所以我得離開那裏。 越留下來,我越是覺得不安,甚至是憤恨。我本來可以等自己找到出路的時候再辭職,但我知道待的時間越長就會越難離開,況且我可能永遠也找不到那個正確的出路,我也知道沒有人會告訴我正確出路是什麼。我想過,也許我會有個很棒的丈夫、可愛的小孩和身為媽媽的奉獻精神 ; 也想過就此錯過好好思考人生的機會,總之我終於在 2013 年 1 月急轉彎離開 Google。 每次有人問起離開 Google 的感覺,我都說,這像是和大學男朋友分手。 他很帥、很棒、每個人都愛他,我也愛過他,但他就不是那個真命天子。我花很久的時間才認清自己必須離開他,最後才鐵了心做了令雙方都傷心的決定,我不確定自己以後還會不會遇到像他這麼好的人,但離開他讓我的視野更開闊。 之後我也覺得那是我生命中最關鍵的選擇。我花了幾年時間決定離開 Google,我幾乎沒辦法想像放棄薪水、放棄家人般的主管和朋友般的同事會是什麼感覺,我那麼努力得來的一切,即使過得不開心,我也無法說放就放。 社會認同下的安全感、榮譽感,是無法離開 Google 的主因 我曾經認真思考自己在猶豫什麼,我發現最主要的原因是,我不願意離開 Google 給我的聲譽和安全感,說來可恥,別人的認同變成驅動我的主力。 從幼稚園開始我就成為全班最聰明的學生,我身邊的朋友都有這段經歷,因此這一路上都走著大家認同的路:進國小榮譽榜、進私立高中、進前五大文理學院、在大學得獎、在 Google 工作,但我接下來想做的事情卻不是大家讚賞的那些事,我還沒有準備好面對大家的失落和失望。 害怕輿論的不安,讓我不敢面對真實的自己 那種不安不像進 Google 第一年的緊張不安,當時的生活就像旋風一樣,根本沒辦法停下來思考自己在做什麼,整個腦子裡就是第一份薪水、新進課程、訓練和實戰經驗,我那時徹底愛上 Google,也愛上我的同事們,所以我幾乎沒有時間好好想人生的問題。 最後一次升遷的時候我才發覺有些事情真的結束了,我在工作上的成就和我的快樂不成正比,升遷只讓我覺得自己在為不確定的目標費盡心力,反而更不快樂,有更多錢沒錯,但錢也沒有改變我的生活,我當時覺得很有罪惡感,我會問自己:「Google 員工不是人人稱羨的工作嗎?不是應該好好珍惜百萬年薪、免費食物、免費按摩等等嗎?」 我是真的感恩在心,但我其實一點成就感都沒有,而且我不敢告訴任何人。 我期望心中的聲音會告訴自己:「嘿,雖然 Google 還會做很多有趣的事情,但你應該要離開了」。可是當時內心卻是一直想著:「嘿,每個人都渴望這份工作,你也應該要喜歡,想想辦法吧!努力一點吧!不要再抱怨了」,所以我繼續努力工作、到東京出差 3 個月、執行各種專案、訓練新成員。 我可以說是在 Google 長大的,在那裏我學會做好事情,那就是我的 MBA 訓練,只是我的心已經不在那了,可是我還是無法離開,我有能力改變我的人生但我卻不願意改變,害怕失敗、害怕輿論的恐懼讓我留下來,這種恐懼從早到晚跟著我,有時候甚至會跑進我的夢裡。那幾年我常常做惡夢,夢裡我被某樣東西追逐,我不斷跳過窗戶和門,但始終擺脫不了它,在現實生活中,我常常問自己為什麼在這裡?我在做什麼?我總覺得我在欺騙自己。 我的不安感到 2012 年末達到巔峰,所以我決定休息一個月,看看不工作個幾天會不會讓自己更明瞭,我就待在舊金山的家裡「好好生活」,大家對於我沒去歐洲大放一假感到很訝異,我早上就去上芭蕾課,我逛雜貨店、買東西自己煮來吃(對 Google 的人來說,煮東西自己吃是很新奇的想法),我又開始烘焙、開始閱讀、跑步、玩吉他、忽略每一封 email,我就是很簡單地享受工作時無法擁有的快樂,我過得很開心,但對於我工作上的不安感卻一點幫助都沒有。 突然瞭解自己,並決定離職的轉捩點 假期的最後,我一時興起跟大學好友一群人到 Joshua Tree 國家公園。某天晚上我們圍在營火旁,有個朋友開始問起我的背景,當時在場所有人幾乎都是藝術工作者,所以我怯怯然說到我在大科技公司上班,這就好像承認自己是在國稅局上班一樣尷尬。 後來交代一些在公司做的事情和我的年資,那位朋友竟然回答「那妳一定是很喜歡妳的工作才可以待這麼久」,我當時覺得有些問題很令人困擾,好像自己被試探一樣,但我還是說了一些工作的優點,那次是我第一次動搖、第一次不相信自己。 話題結束後,我逕自遠離營火到附近看星星,我周遭一片荒蕪,身邊沒有任何人,只覺得了然萬物那樣地自由。 那瞬間我才真正覺得自己可以做任何想做的事,所有的一切都掌握在我自己的手裡,這是我的生活,所以不必在意別人怎麼想,如果我想烘焙,我就烘焙;我想寫作,我就寫作;我想開公司,我就開公司;我想什麼都不做,我就什麼都不做;我想搞砸一次,那就搞砸一次;就離開營火的那幾分鐘時間,對我而言卻像永恆,我突然就這樣在一片荒蕪之中想開了,才發現原來這些年來我都在欺騙自己,只是一直不願意承認。 回公司上班的第一天,我隨即交出我的辭呈,我辭職的理由(開發新興趣、做些新專案、多些時間烘焙)讓大家困惑不已,但他們依然很支持我,又諷刺又神奇地,回去的那天,我桌上竟然擺著「最有可能在五年內創立公司」的獎座。 五個月後,依舊對未來不確定,但學會對自己誠實 幾個月過去了,我的家人、朋友、以前的同事或陌生人都問我現在的生活如何,其實有時候這生活很迷人,但大部分的時候(計算剩下多少存款可以用的時候)不怎麼迷人。 事實上,離開軌道到完全未知的生活是一件很恐怖又孤單的事情,有時候我幾乎被「自己什麼事都沒辦法做」的想法困住,但有件事情很重要,終於我的人生、我的身分第一次不是 100 % 跟我的成就連在一起,我比較不在乎別人怎麼想,也花比較多時間做感覺對的事情,我還學著聽自己內心的聲音,學著誠實和自己對話。 那些對話讓我學會拒絕,學會平衡自己的社會責任,好有多一些時間跟自己相處。 這也讓我搬到小威尼斯,去實現我想要有個寬敞單人公寓的夢想(舊金山的租金貴得不堪負荷),每天到海邊跑步,放慢之前那種舊金山「不工作則死」的生活步調。離開我最好的朋友和那人人稱羨的工作固然很難,但當我走在夏天暖暖的海灘上,看夕陽落入 Santa Monica 的山群裡,我才真正回到家。 雖然我對未來還是模模糊糊,沒方向,至少我不用再找正確的出路,多虧自己一輩子努力念書、5 年工作存錢,才有機會和餘裕享受這短暫的休息,但我認為每個人都有權利和義務去一趟自己的 Joshua Tree,每個人都可以放掉一切,最難的是真正聽見你心裡的聲音並去實現它。

CodeMirror

CodeMirror

CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with a number of language modes and addons that implement more advanced editing functionaly.
Eloquent JavaScript, Second Edition (eloquentjavascript.net)
paulirish 5 hours ago | link Yes. Both Chrome DevTools and Safari's Inspector (separate projects these days) both use CodeMirror as their editor. reply

9/09/2013

addEventListener, handleEvent and passing objects | The CSS Ninja - All things CSS, JavaScript & HTML

addEventListener, handleEvent and passing objects | The CSS Ninja - All things CSS, JavaScript & HTML

Here’s a super awesome trick I had no idea about until someone pointed out you could do this. addEventListener can take an object as a second argument that will look for a method called handleEvent and call it! No need for binding “this” so it will pass around the context correctly, the context is the object you’ve just set as the event listener callback.
var obj = {
    handleEvent: function() {
        alert(this.dude);
    },
    dude: "holla"
};

element.addEventListener("click", obj, false);
var obj  =  {
    init: function() {
        document.getElementById("btn").addEventListener("click", this, false);
        document.getElementById("btn").addEventListener("touchstart", this, false);
    },
    handleEvent: function(e) {
        switch(e.type) {
            case "click":
                this.button();
                break;
            case "touchstart":
                this.button();
                break;
        }
    },
    dude: "holla",
    button: function() {
        alert(this.dude);
    }
};

obj.init();
As you can see our object has an init() method which binds all the events and just passes in “this” as the callback, handleEvent then delegates off to whatever method it needs based on the event being triggered, rad.

hacker news

all-time top links: http://lab.varun.io/hn_all_time_top_links/
hacker slide: http://www.hackerslide.com/
hnsearch: https://www.hnsearch.com/search#request/all&q=tesla+norway
Hacker News Daily
HackerWeb

9/04/2013

Understanding process.nextTick() - How To Node - NodeJS

Understanding process.nextTick() - How To Node - NodeJS

However, process.nextTick() is not just a simple alias to setTimeout(fn, 0) - it's far more efficient. More precisely, process.nextTick() defers the function until a completely new stack. You can call as many functions as you want in the current stack. The function that called nextTick has to return, as well as its parent, all the way up to the root of the stack. Then when the event loop is looking for a new event to execute, your nextTick'ed function will be there in the event queue and execute on a whole new stack. Interleaving execution of a CPU intensive task with other events Let's say we have a task compute() which needs to run almost continuously, and does some CPU intensive calculations. If we wanted to also handle other events, like serving HTTP requests in the same Node process, we can use process.nextTick() to interleave the execution of compute() with the processing of requests this way:
var http = require('http');

function compute() {
    // performs complicated calculations continuously
    // ...
    process.nextTick(compute);
}

http.createServer(function(req, res) {
     res.writeHead(200, {'Content-Type': 'text/plain'});
     res.end('Hello World');
}).listen(5000, '127.0.0.1');

compute();

panorama - google map

panorama - google map

10 Simple Things You Can Do Today That Will Make You Happier, Backed By Science

10 Simple Things You Can Do Today That Will Make You Happier, Backed By Science

1. Exercise more – 7 minutes might be enough Exercise has such a profound effect on our happiness and well-being that it’s actually been proven to be an effective strategy for overcoming depression. You don’t have to be depressed to gain benefit from exercise, though. It can help you to relax, increase your brain power and even improve your body image, even if you don’t lose any weight. A study in the Journal of Health Psychology found that people who exercised felt better about their bodies, even when they saw no physical changes: 2. Sleep more – you’ll be less sensitive to negative emotions The BPS Research Digest explores another study that proves sleep affects our sensitivity to negative emotions. Using a facial recognition task over the course of a day, the researchers studied how sensitive participants were to positive and negative emotions. Those who worked through the afternoon without taking a nap became more sensitive late in the day to negative emotions like fear and anger: Using a face recognition task, here we demonstrate an amplified reactivity to anger and fear emotions across the day, without sleep. However, an intervening nap blocked and even reversed this negative emotional reactivity to anger and fear while conversely enhancing ratings of positive (happy) expressions. 3. Move closer to work – a short commute is worth more than a big house ... Or as Harvard psychologist Daniel Gilbert put it, “Driving in traffic is a different kind of hell every day.” We tend to try to compensate for this by having a bigger house or a better job, but these compensations just don’t work: Two Swiss economists who studied the effect of commuting on happiness found that such factors could not make up for the misery created by a long commute. 4. Spend time with friends and family – don’t regret it on your deathbed Staying in touch with friends and family is one of the top five regrets of the dying. If you want more evidence that it’s beneficial for you, I’ve found some research that proves it can make you happier right now. Social time is highly valuable when it comes to improving our happiness, even for introverts. Several studies have found that time spent with friends and family makes a big difference to how happy we feel, generally. I love the way Harvard happiness expert Daniel Gilbert explains it: We are happy when we have family, we are happy when we have friends and almost all the other things we think make us happy are actually just ways of getting more family and friends. George Vaillant is the director of a 72-year study of the lives of 268 men: In an interview in the March 2008 newsletter to the Grant Study subjects, Vaillant was asked, “What have you learned from the Grant Study men?” Vaillant’s response: “That the only thing that really matters in life are your relationships to other people.” The Terman study, which is covered in The Longevity Project, found that relationships and how we help others were important factors in living long, happy lives: We figured that if a Terman participant sincerely felt that he or she had friends and relatives to count on when having a hard time then that person would be healthier. Those who felt very loved and cared for, we predicted, would live the longest. Surprise: our prediction was wrong… Beyond social network size, the clearest benefit of social relationships came from helping others. Those who helped their friends and neighbors, advising and caring for others, tended to live to old age. 5. Go outside – happiness is maximized at 13.9°C A UK study from the University of Sussex also found that being outdoors made people happier: Being outdoors, near the sea, on a warm, sunny weekend afternoon is the perfect spot for most. In fact, participants were found to be substantially happier outdoors in all natural environments than they were in urban environments. 6. Help others – 100 hours a year is the magical number One of the most counterintuitive pieces of advice I found is that to make yourself feel happier, you should help others. In fact, 100 hours per year (or two hours per week) is the optimal time we should dedicate to helping others in order to enrich our lives. So spending money on other people makes us happier than buying stuff for ourselves. What about spending our time on other people? A study of volunteering in Germany explored how volunteers were affected when their opportunities to help others were taken away: Shortly after the fall of the Berlin Wall but before the German reunion, the first wave of data of the GSOEP was collected in East Germany. Volunteering was still widespread. Due to the shock of the reunion, a large portion of the infrastructure of volunteering (e.g. sports clubs associated with firms) collapsed and people randomly lost their opportunities for volunteering. Based on a comparison of the change in subjective well-being of these people and of people from the control group who had no change in their volunteer status, the hypothesis is supported that volunteering is rewarding in terms of higher life satisfaction. In his book Flourish: A Visionary New Understanding of Happiness and Well-being, University of Pennsylvania professor Martin Seligman explains that helping others can improve our own lives: …we scientists have found that doing a kindness produces the single most reliable momentary increase in well-being of any exercise we have tested. 7. Practice smiling – it can alleviate pain A new study led by a Michigan State University business scholar suggests customer-service workers who fake smile throughout the day worsen their mood and withdraw from work, affecting productivity. But workers who smile as a result of cultivating positive thoughts – such as a tropical vacation or a child’s recital – improve their mood and withdraw less. A smile is also a good way to alleviate some of the pain we feel in troubling circumstances: Smiling is one way to reduce the distress caused by an upsetting situation. Psychologists call this the facial feedback hypothesis. Even forcing a smile when we don’t feel like it is enough to lift our mood slightly (this is one example of embodied cognition). 8. Plan a trip – but don’t take one A study published in the journal, Applied Research in Quality of Life showed that the highest spike in happiness came during the planning stage of a vacation as employees enjoyed the sense of anticipation: In the study, the effect of vacation anticipation boosted happiness for eight weeks. After the vacation, happiness quickly dropped back to baseline levels for most people. Shawn Achor has some info for us on this point, as well: One study found that people who just thought about watching their favorite movie actually raised their endorphin levels by 27 percent. If you can’t take the time for a vacation right now, or even a night out with friends, put something on the calendar—even if it’s a month or a year down the road. Then whenever you need a boost of happiness, remind yourself about it. 9. Meditate – rewire your brain for happiness In one study, a research team from Massachusetts General Hospital looked at the brain scans of 16 people before and after they participated in an eight-week course in mindfulness meditation. The study, published in the January issue of Psychiatry Research: Neuroimaging, concluded that after completing the course, parts of the participants’ brains associated with compassion and self-awareness grew, and parts associated with stress shrank. According to Shawn Achor, meditation can actually make you happier long-term: Studies show that in the minutes right after meditating, we experience feelings of calm and contentment, as well as heightened awareness and empathy. And, research even shows that regular meditation can permanently rewire the brain to raise levels of happiness. 10. Practice gratitude – increase both happiness and life satisfaction The Journal of Happiness studies published a study that used letters of gratitude to test how being grateful can affect our levels of happiness: Participants included 219 men and women who wrote three letters of gratitude over a 3 week period. Results indicated that writing letters of gratitude increased participants’ happiness and life satisfaction, while decreasing depressive symptoms. Quick last fact: Getting older will make yourself happier As a final point, it’s interesting to note that as we get older, particularly past middle age, we tend to grow happier naturally. There’s still some debate over why this happens, but scientists have got a few ideas: Researchers, including the authors, have found that older people shown pictures of faces or situations tend to focus on and remember the happier ones more and the negative ones less. Other studies have discovered that as people age, they seek out situations that will lift their moods — for instance, pruning social circles of friends or acquaintances who might bring them down. Still other work finds that older adults learn to let go of loss and disappointment over unachieved goals, and hew their goals toward greater wellbeing.

The Scientific 7-Minute Workout

The Scientific 7-Minute Workout

http://www.7-min.com/ http://well.blogs.nytimes.com/2013/05/09/the-scientific-7-minute-workout/?_r=1& An article in the May-June issue of the American College of Sports Medicine’s Health & Fitness Journal does just that. In 12 exercises deploying only body weight, a chair and a wall, it fulfills the latest mandates for high-intensity effort, which essentially combines a long run and a visit to the weight room into about seven minutes of steady discomfort — all of it based on science. “There’s very good evidence” that high-intensity interval training provides “many of the fitness benefits of prolonged endurance training but in much less time,” says Chris Jordan, the director of exercise physiology at the Human Performance Institute in Orlando, Fla., and co-author of the new article. Work by scientists at McMaster University in Hamilton, Ontario, and other institutions shows, for instance, that even a few minutes of training at an intensity approaching your maximum capacity produces molecular changes within muscles comparable to those of several hours of running or bike riding. Interval training, though, requires intervals; the extremely intense activity must be intermingled with brief periods of recovery. In the program outlined by Mr. Jordan and his colleagues, this recovery is provided in part by a 10-second rest between exercises. But even more, he says, it’s accomplished by alternating an exercise that emphasizes the large muscles in the upper body with those in the lower body. During the intermezzo, the unexercised muscles have a moment to, metaphorically, catch their breath, which makes the order of the exercises important. The exercises should be performed in rapid succession, allowing 30 seconds for each, while, throughout, the intensity hovers at about an 8 on a discomfort scale of 1 to 10, Mr. Jordan says. Those seven minutes should be, in a word, unpleasant. The upside is, after seven minutes, you’re done.

9/02/2013

polarmobile/coffeescript-style-guide

polarmobile/coffeescript-style-guide Style Guide Corrections ;) from jashkenas

browser bug: Element disappearing during transition in Chrome

Element disappearing during transition in Chrome

Hi, This is Chrome bug that sometimes appears for some reason. All absolute-positioned elements inside hardware-accelerated container (e.g. slides) must have rsAbsoluteEl class, or such css styles: .rsWebkit3d .your-absolute-positoned-elements-selector { -webkit-backface-visibility: hidden; -webkit-transform: translateZ(0); } Dmitry