Skip to content

Instantly share code, notes, and snippets.

Jiang Jiang jjgod

Block or report user

Report or block jjgod

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:2366
import time, threading, processing
for cls in [threading.Thread, processing.Process]:
start = time.time()
for _ in range(1000):
child = cls(target=lambda: None)
child.start()
child.join()
print 'Spawning 100 children with %s took %.2fs' % (
cls.__name__, time.time() - start)
View gist:2639
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSLog(@"documentsDirectory: %@", resourcePath);
NSString *fontPath = [NSString stringWithFormat: @"%@/MinionPro-Regular.otf", resourcePath];
NSURL *fontURL = [NSURL fileURLWithPath: fontPath isDirectory: NO];
fontProvider = CGDataProviderCreateWithURL((CFURLRef) fontURL);
NSLog(@"%@, fontProvider = %p", fontURL, fontProvider);
mainFont = CGFontCreateWithDataProvider(fontProvider);
View gist:2640
if [ "${ARCHS}" = "armv6" ]; then
CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate codesign -s "Jjgod Jiang" -f ${TARGET_BUILD_DIR}/${EXECUTABLE_FOLDER_PATH}/${EXECUTABLE_NAME}
fi
View gist:3882
Thread 7 Crashed:
0 com.apple.JavaScriptCore 0x946f2940 WTF::fastRealloc(void*, unsigned long) + 3680
1 com.apple.JavaScriptCore 0x9476a2f2 KJS::ArrayInstance::put(KJS::ExecState*, unsigned int, KJS::JSValue*) + 1346
2 com.apple.JavaScriptCore 0x9470a827 KJS::stringProtoFuncSplit(KJS::ExecState*, KJS::JSObject*, KJS::List const&) + 1559
3 com.apple.JavaScriptCore 0x947c85a5 KJS::Machine::privateExecute(KJS::Machine::ExecutionFlag, KJS::ExecState*, KJS::RegisterFile*, KJS::Register*, KJS::ScopeChainNode*, KJS::CodeBlock*, KJS::JSValue**) + 28501
4 com.apple.JavaScriptCore 0x947c9098 KJS::Machine::execute(KJS::FunctionBodyNode*, KJS::ExecState*, KJS::FunctionImp*, KJS::JSObject*, KJS::List const&, KJS::RegisterFileStack*, KJS::ScopeChainNode*, KJS::JSValue**) + 760
5 com.apple.JavaScriptCore 0x947061ef KJS::FunctionImp::callAsFunction(KJS::ExecState*, KJS::JSObject*, KJS::List const&) + 127
6 com.apple.JavaScriptCore 0x94730af7 KJS::JSObject::call(K
View Calculate text width on iPhone
NSString *message = [NSString stringWithUTF8String: "Hello"];
int count = [message length];
UniChar *characters = (UniChar *) malloc(count * sizeof(UniChar));
CGGlyph *glyphs = (CGGlyph *) malloc(count * sizeof(CGGlyph));
int *advances = (int *) malloc(count * sizeof(int ));
CGSize *cgAdvances = (CGSize *) malloc(count * sizeof(CGSize));
/* Get the characters, glyphs and advances and calculate aStringWidth. */
[message getCharacters: characters];
View gist:62615
#!/usr/bin/env python
import sys, urllib
url = urllib.unquote(sys.argv[1])
def plus13(c):
i = ord(c)
if i >= ord('a') and i <= ord('z'):
i += 13
View gist:81031
$ ./ias.py
2009-03-18 18:01:29 URL:http://att.newsmth.net/att.php?p.874.1114207.284.JPG [395576/395576] -> "MyPhoto/IMG_0270.JPG" [1]
2009-03-18 18:01:29 URL:http://att.newsmth.net/att.php?p.874.1114219.298.png [432163/432163] -> "MyPhoto/1.png" [1]
2009-03-18 18:01:30 URL:http://att.newsmth.net/att.php?p.874.1114178.425.jpg [167389/167389] -> "MyPhoto/post_xin9.jpg" [1]
2009-03-18 18:01:31 URL:http://att.newsmth.net/att.php?p.179.710172.531.jpg [275847/275847] -> "DSLR/风车3.jpg" [1]
2009-03-18 18:01:32 URL:http://att.newsmth.net/att.php?p.179.710174.240.jpg [129165/129165] -> "DSLR/IMG_2383-20.jpg" [1]
2009-03-18 18:01:33 URL:http://att.newsmth.net/att.php?p.179.710152.441.jpg [135363/135363] -> "DSLR/chinon135.2.8.jpg" [1]
...
View gist:81040
#!/usr/bin/env python
# coding: utf-8
import ConfigParser, urllib, codecs, os, time
config = ConfigParser.ConfigParser()
config.read('ias.cfg')
board_url = "http://www.newsmth.net/bbsdoc.php?board=%s"
board_page_url = "http://www.newsmth.net/bbsdoc.php?board=%s&&page=%d"
post_url = "http://www.newsmth.net/bbscon.php?bid=%d&id=%d"
View gist:81042
[MyPhoto]
lastcheck = 1237371285
[DSLR]
lastcheck = 1237371323
[basic]
boards = MyPhoto, DSLR
View gist:95703
>>> Connecting
>>> debug is [5]
>>> host is [gmail.com]
>>> account is [dhxygroup]
>>> resource is [conference]
DEBUG: stream init called
>>> Logging in
DEBUG: jabberpy connect called
DEBUG: client connect called to gmail.com 5223 type 2
DEBUG: Attempting to create ssl socket
You can’t perform that action at this time.