Skip to content

Instantly share code, notes, and snippets.

View jinthagerman's full-sized avatar

Jin Budelmann jinthagerman

View GitHub Profile
@jinthagerman
jinthagerman / UIColor+Addition.m
Created May 16, 2012 05:26
UIColor from hex
// http://stackoverflow.com/questions/1560081/how-can-i-create-a-uicolor-from-a-hex-string
+ (UIColor *) colorWithHex:(int)hex {
return [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0
green:((float)((hex & 0xFF00) >> 8))/255.0
blue:((float)(hex & 0xFF))/255.0 alpha:1.0];
}
@jinthagerman
jinthagerman / IMDB250TallyDirectors.py
Created August 3, 2012 05:03
Find the directors with the most movies in the IMDB top 250
#!/usr/bin/env python
# encoding: utf-8
"""
IMDB250TallyDirectors.py
Created by Jin Budelmann on 2012-08-03.
"""
import sys
import os
@jinthagerman
jinthagerman / IMDB250TallyDirectors.py
Created August 3, 2012 05:04
Find the directors with the most movies in the IMDB top 250
#!/usr/bin/env python
# encoding: utf-8
"""
IMDB250TallyDirectors.py
Created by Jin Budelmann on 2012-08-03.
"""
import sys
import os
@jinthagerman
jinthagerman / gist:3815780
Created October 2, 2012 02:13
Singletons
@implementation MySingleton
+ (MySingleton*)singleton {
static MySingleton* __singleton = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
__singleton = [[MySingleton alloc] init];
});
return __singleton;
}
@jinthagerman
jinthagerman / APMacros.h
Created November 22, 2012 22:49
Simply create associated property with one line of code using a reusable preproc macro
#import <objc/runtime.h>
#define ASSOCIATIVE_PROPERTY(GET_NAME, SET_NAME, TYPE, ASSOCIATION_POLICY) \
static char GET_NAME##Key; \
- (TYPE) GET_NAME \
{ \
return objc_getAssociatedObject(self, & GET_NAME##Key); \
} \
\
- (void) SET_NAME:(TYPE)value\
@jinthagerman
jinthagerman / gist:4133720
Created November 23, 2012 02:15
Simplify ratio
int n1 = 320;
int n2 = 480;
simplifyRatio(&n1, &n2);
printf("%d %d", &n1, &n2);
int highestCommonFactor(int n1, int n2) {
int remainder = n1%n2;
@jinthagerman
jinthagerman / gist:4209797
Created December 4, 2012 22:49
Atrocity
//receive loop(timeout=1000ms)
long long starttime = [self currentTimeMillis];
while(true){
//timeout check
long long readTimeout = SEND_RESPONSE_TIMEOUT - ([self currentTimeMillis] - starttime);
if(readTimeout < 0){
break;
}
Pod::Spec.new do |s|
s.name = 'ZBarSDK'
s.version = '1.3.1'
s.platform = :ios
s.license = 'GNU LGPL 2.1'
s.summary = 'QR and barcode scan library.'
s.homepage = 'http://zbar.sourceforge.net/'
s.author = { 'Jeff Brown' => 'spadix@users.sourceforge.net' }
s.source = { :git => 'https://github.com/ZBar/ZBar.git', :tag => 'iPhoneSDK-1.3.1' }
@jinthagerman
jinthagerman / Death To iTunes
Last active December 12, 2015 03:08
Death to iTunes
sudo killall iTunes
sudo rm -rf /Applications/iTunes.app/
osascript -e 'tell application "System Events" to delete login item "iTunesHelper"'
@jinthagerman
jinthagerman / gist:6278682
Created August 20, 2013 08:28
Solarized Dark - Customized.dvtcolortheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.727544 0.222335 0 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.443313 0.509062 0.518274 1</string>