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:5419104
Created April 19, 2013 09:07
Run GHUnit iOS Simulator 6.x
int main(int argc, char *argv[])
{
@autoreleasepool {
CFMessagePortCreateLocal(NULL, (CFStringRef) @"PurpleWorkspacePort", NULL, NULL, NULL);
return UIApplicationMain(argc, argv, nil, @"GHUnitIOSAppDelegate");
}
}
@implementation UIWindow (Private)
if [ "${CONFIGURATION}" = "Release" ]; then
echo Do something really release-like
fi
@seiji
seiji / gist:4481012
Created January 8, 2013 03:50
whatismyIP
curl http://ifconfig.me
curl http://ifconfig.me/ip
@seiji
seiji / gist:4173637
Created November 30, 2012 03:38
runningProcesses
#include <sys/sysctl.h>
- (NSArray *)runningProcesses {
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
size_t miblen = 4;
size_t size;
int st = sysctl(mib, miblen, NULL, &size, NULL, 0);
@seiji
seiji / gist:4167028
Created November 29, 2012 05:38
usleep.c
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc <= 1)
usleep(1);
else
usleep(atol(argv[1]));
return 0;
}
@seiji
seiji / gist:4166563
Created November 29, 2012 03:16
raise memorywarning
[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)];
@seiji
seiji / gist:4138187
Created November 24, 2012 02:57
create binary plist
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *err = nil;
NSData *plist;
NSDictionary *dict;
char *payload = "This is the payload";
dict = [NSDictionary dictionaryWithObjectsAndKeys:
@"Hello world", @"greeting",
@seiji
seiji / main.m
Created November 20, 2012 23:53
main.m
//
// main.m
// Insects
//
//
#import <UIKit/UIKit.h>
#pragma mark - ViewController
#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 / 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++) {