Skip to content

Instantly share code, notes, and snippets.

View seiji's full-sized avatar
🏠
Working from home

Seiji Toyama seiji

🏠
Working from home
View GitHub Profile
@seiji
seiji / gist:3915599
Created October 19, 2012 00:36
Control iOS Simulator
#!/Library/Frameworks/LuaCocoa.framework/Versions/Current/Tools/luacocoa
--[[
Controll iOS Simulator
--]]
LuaCocoa.import("ScriptingBridge")
local system_events = SBApplication:applicationWithBundleIdentifier_("com.apple.systemevents")
local ios_sim_process = nil
@seiji
seiji / gist:3915641
Created October 19, 2012 00:50
Reload Current Tab of MobileSafari
tell application "System Events"
tell process "iPhone Simulator"
click button "Reload" of window 1
end tell
end tell
@seiji
seiji / gist:3929710
Created October 22, 2012 04:57
Build spidermonkey
wget ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
tar -zxf js-1.7.0.tar.gz
cd js/src
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
make -f Makefile.ref
sudo JS_DIST=/usr/local/js make -f Makefile.ref export
@seiji
seiji / gist:3929920
Created October 22, 2012 05:59
Insert Private Feed of Github
$ mongo
> use github
> db.createCollection('feed', { capped: true, size: 100000 })
# require jsawk (with spidermonkey)
curl https://github.com/$username.private.json?token=$token | jsawk "this.entry" | mongoimport --jsonArray --upsert -d github -c feed
@seiji
seiji / gist:3930237
Last active April 18, 2017 20:24
Append NSAttributedString
NSAttributedString *subjectString =
[[NSAttributedString alloc] initWithString:@"git"
attributes:@{
NSForegroundColorAttributeName : [UIColor blueColor],
NSFontAttributeName : [UIFont boldSystemFontOfSize:20]
}];
NSAttributedString *verbString = [[NSAttributedString alloc] initWithString:@" push -u "];
NSAttributedString *objectString =
[[NSAttributedString alloc] initWithString:@"origin master"
@seiji
seiji / gist:3930680
Created October 22, 2012 09:49
ios6 error
*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time!
Clear this association before associating this view with
@seiji
seiji / gist:3935968
Created October 23, 2012 00:50
display view hierarchy
NSLog(@"%@", [view performSelector:@selector(recursiveDescription)]);
@seiji
seiji / gist:4022535
Created November 6, 2012 04:22
utf8mb4
#import "NSString+Unicode.h"
@implementation NSString (Unicode)
- (NSUInteger)utf8mb4length {
const char *bytes= [self UTF8String];
unsigned int length = [self lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
unsigned int calc = 0;
for (int i=0; i<length; i++) {
#pragma D option quiet
self int level;
objc$target:::entry
{
printf("%*s[tid=%lld][%s %s]\n",
self->level * 2, " ->",
(long long)tid, probemod, probefunc);
@seiji
seiji / main.m
Created November 20, 2012 23:53
main.m
//
// main.m
// Insects
//
//
#import <UIKit/UIKit.h>
#pragma mark - ViewController