yllan

Nowhere differentiable curve

0 notes

過年明明沒有覺得吃很多,結果……

整天躺在床上真的是太可怕啦~~

過年明明沒有覺得吃很多,結果……

整天躺在床上真的是太可怕啦~~

1 note

Another possible catch about NSIndexPath

Since NSIndexPath is not unique and shared, we cannot test the equality using ==. However, according to someone’s experience, using isEqual: to test the equality of two NSIndexPaths may be wrong due to a bug which had been fixed in iOS 5.

That is, if you want to target old system, you’d better not invoke isEqual: or use NSIndexPath as a key in NSSet or NSDictionary.

I didn’t encounter this situation in iOS 4.3/5 but I don’t know in which version Apple had fixed this bug. Anyone can confirm that if this bug only exists in iOS beta version?

2 notes

我也是個見過風浪的男兒

最近有件事被同事當作笑柄,事情是這樣的:

因為姊姊今年生日意義重大,家人間我平常都沒在送什麼生日禮物的,想說這次就送個比較特別的禮物紀念一下。想起他之前去看過愛馬仕工匠展之後大為讚賞,就想說買個愛馬仕的東西送他好了。對於這個只在「電車男」裡聽過的品牌,我實在沒什麼概念,所以在我姊生日前一天,下班後就和平常一樣穿著短褲和拖鞋,闖進貴婦百貨 Bellavita 的 Hermes 專櫃。

當我和小姐說明,我想買禮物送人,預算是 X 萬,他居然這麼說:「那您可以看看鑰匙圈零錢包,這是我們這裡比較便宜的東西喔!」

我的天啊!五位數只夠買鑰匙圈和零錢包!!!這就是與我遙不可及的貴婦世界!!!!也許見慣大人物的櫃台小姐看到我這個邋遢的窮酸小子還以為我是來大冒險的呢!

總之,就在一陣胡搞瞎搞後,我獲得了「在 Hermes 買東西」的成就。(不要看我這樣,其實我滿厲害的呢!居然還解開過「在 Yahoo 2011 年度十大正妹相簿中出現」成就!)

不過據說 sffish 的朋友(無論去哪家店都會變成 VIP 的人)完全不覺得好笑,可能是因為這種事情對他們的圈子來說是基本常識。很好,為了顯示我也是個見過風浪的男兒,我決定 2012 年拿到達美樂和髒髒巷碗粿的 VIP。貴婦團們,我可是不會輸的!

0 notes

LOL

「Android手機打fuck居然會自動幫你校正成duck 哪門子的設計啊?」

「Duck Typing。」

0 notes

NSIndexPath gotcha!

Although it’s documented like this,

NSIndexPath objects are uniqued and shared. If an index path containing the specified index or indexes already exists, that object is returned instead of a new instance.

Test equality of two NSIndexPaths with == is SO WRONG. The uniqueness is not guaranteed. Sometimes, there will be two distinct NSIndexPath objects with the same index.

0 notes

請放心 hypo 不賣保護殼

Steven Levy talk about Steve Jobs

When I pulled out my iPod—I was using it as a recording device—he was horrified to see that it was covered by a plastic case, something that he considered an abomination. He urged me to discard it. “I think the stainless steel looks beautiful when it wears,” he told me. “Probably it’s like us. I mean, I’m going to be 50 next year, so I’m like a scratched-up iPod myself.”

既然 Steve Jobs 和老闆都這麼說了,當然是來附和一下。

「都幾歲的人了,難道還要像處男一樣用包皮包住你的小機機?當然裸機使用才是王道!殼上的彈孔,是你出生入死冒險過的象徵,是成熟粗獷的魅力,是硬漢的勳章,千萬不要傻傻換一個新的。」

0 notes

Phantom Types

Phantom Types 是一種 parameterized type (例如 java/C++ 中的 generic ),但傳進來的 type 和真正的資料並沒有關係。

例如

這個例子裡,Biography 和 Comic 只是一種 metadata,來標示 Book 物件的狀態或特性。我們可以利用 compiler 作 type checking,來設計出不易出錯的 API。

本例中,若是讓 Marvel 出版 Isaacson 寫的 Steve Jobs 傳就會發生 compile error。

當然,讓 ComicBiography 繼承 Book 就好了,同樣也可以達到目的,用 Phantom Types 的好處在哪裡呢?

Phantom types 的好處是他可以用多個 parametric type 組合出更複雜的標示。例如我可以製造出 Book<BookType, Language> 限定某 API 只能處理日文的漫畫書。

(但這邊用 Java 不算是個好例子,只要我 Book b = isaacWrite("Steve Jobs"); 就會把 b 所帶的 Type 資訊給洗掉。)