Skip to content

Instantly share code, notes, and snippets.

@yllan
yllan / gist:1018779
Created June 10, 2011 12:51
thumbnail with compression rate
find . -name "*.jpg" -exec sips -Z 1200 -s formatOptions 50 "{}" ";"
# convert file format
sips -Z 1200 -s format jpeg -formatOptions 50 originFilePath --out newFilePath
# change name from png to jpg recursively
for X in `find . -name "*.png"`
do
echo $X ${X/.png/.jpg}
done
@yllan
yllan / gist:1047853
Created June 26, 2011 18:51
Step support two directions
void (^((^step)(CGFloat, CGFloat, CGFloat)))(void (^)(CGFloat)) = ^(CGFloat begin, CGFloat end, CGFloat delta) {
if (begin <= end) {
return (void (^)(void (^)(CGFloat)))[[^(void (^block)(CGFloat)) {
for (CGFloat v = begin; v < end; v += delta) {
block(v);
}
} copy] autorelease];
} else {
return (void (^)(void (^)(CGFloat)))[[^(void (^block)(CGFloat)) {
for (CGFloat v = begin; v >= end; v -= delta) {
@yllan
yllan / gist:1111164
Created July 28, 2011 07:41
白爛電影
失落之地
難兄難弟
冰刀雙人組
銘謝吸煙 Thank You for Smoking http://app.atmovies.com.tw/movie/movie.cfm?action=filmdata&film_id=ften00427944
@yllan
yllan / gist:1113367
Created July 29, 2011 07:22
How could this leak?
// How could this leaking?
// self.request is a ASIHttpRequest
[self.request setDataReceivedBlock: ^(NSData *receivedData) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[intermediateData appendData: receivedData];
if (CFAbsoluteTimeGetCurrent() - lastUpdateTime >= updateThreshold) {
CGImageSourceUpdateData(partialImageSource, (CFDataRef)intermediateData, false);
CGImageRef partialImage = NULL;
partialImage = CGImageSourceCreateImageAtIndex(partialImageSource, 0, NULL); // Instruments say this line leaks,
@yllan
yllan / gist:1116829
Created July 31, 2011 14:29
Japan Travel
近畿鐵道周遊券
http://catdodo.pixnet.net/blog/post/29468292
妖怪市集
http://machadango.pixnet.net/blog/post/34604833
@yllan
yllan / gist:1180450
Created August 30, 2011 08:17
台大醫院八卦備份
作者: AAATP (我兒子超可愛!) 看板: medstudent
標題: [感想] 有個夢很詭異,說給大家聽,聽完請忘記~~
時間: Tue Aug 30 11:05:08 2011
早上摸你咪挺完,心情不知該開心還是難過,一個好消息和一個壞消息,先說壞消
息吧,之前開了一個93歲的PPU,本來術後還不錯的,結果今天leak了....主治醫師還
虧我,病人沒出院就在facebook上報喜炫燿,現在怎麼就打臉了XD至於好消息....
-------此為白日夢分格線-------------------禁止轉錄或延伸聯想----------------
@yllan
yllan / gist:1290892
Created October 16, 2011 13:46
hypo 疑難排除

執行 Rails 程式之前

env RAILS_ENV="production"

生 pdf

  • 12SQ / ticket 用 bin/runpdf.rb run sale_id
One time when Steve had contracted a tenacious pneumonia his doctor forbid everything — even ice. We were in a standard I.C.U. unit. Steve, who generally disliked cutting in line or dropping his own name, confessed that this once, he’d like to be treated a little specially.
I told him: Steve, this is special treatment.
He leaned over to me, and said: “I want it to be a little more special.”
Intubated, when he couldn’t talk, he asked for a notepad. He sketched devices to hold an iPad in a hospital bed. He designed new fluid monitors and x-ray equipment. He redrew that not-quite-special-enough hospital unit. And every time his wife walked into the room, I watched his smile remake itself on his face.
For the really big, big things, you have to trust me, he wrote on his sketchpad. He looked up. You have to.
勇勇不一樣
@yllan
yllan / gist:1390622
Created November 24, 2011 04:33
Phantom Type Java
class Book<P> {
String title;
public Book(String s) {
title = s;
}
}
interface Biography {}
interface Comic {}