Skip to content

Instantly share code, notes, and snippets.

//
// UIImage+Dithering.m
//
#import "UIImage+Dithering.h"
typedef unsigned char PixelByte;
@implementation UIImage (Dithering)
iPad Default State
1. Broadcast iBeacon
a. advertisementData: name (e.g. "A", "B")
b. major: version number
c. minor: -
iPad A: Peer-to-Peer Update
1. iPad A has PDFs version number 2.0.0
2. iPad B has PDFs version number 1.0.0
3. iPad sees iPad B's version number is less than A's
@trungtran
trungtran / while.swift
Last active August 29, 2015 14:02
Custom While Loop in Swift
func customWhile(condition: (Void) -> Bool, body: (Void) -> Void) {
if condition() {
body()
customWhile(condition, body)
}
}
var number = 10
customWhile({number > 0}) {
println("number: \(number)")
-(void)zoomToFitMapAnnotations:(MKMapView*)mapView
{
if([mapView.annotations count] == 0)
return;
CLLocationCoordinate2D topLeftCoord;
topLeftCoord.latitude = -90;
topLeftCoord.longitude = 180;
CLLocationCoordinate2D bottomRightCoord;
@trungtran
trungtran / gist:8510445
Created January 19, 2014 20:16
1/19/14 We Kicked That Ball Press Release

We Kicked That Ball Falls Short in Shoot Out Against Homey Don't Kick That 14-24

Charlottesville, VA Short-handed We Kicked That Ball (WKTB) fell short Sunday afternoon against visiting Homey Don't Kick That (HDKT).

WKTB started out sluggish and confused following interim Captain Trung Tran's 45 minute speech on the importance of nutrition and fundamentals. In contrast, HDKT came out guns blazing scoring a quick seven runs in the first two inning.

Home team WKTB, however, did not go down so easily. Offensive specialist/catcher/right fielder Cassie Sharpe led a mid-game charge as the team whittled their deficit to 10-12. "The team just needed to get into their kicking groove", Sharpe said during the game. Pitcher Thomas Chen held HDKT defensively through the middle innings as WKTB rallied. Chen even stirred a few awes from the Umpire with his unyielding fastball.

Late into the newly extended game, WKTB's shorthanded lineup caught up to them defensively. Homey Don't Kick That surged again in the fin

@trungtran
trungtran / OS X Volume
Created October 18, 2013 13:41
Set volume of OS X from command line
# n = 0 to 7
osascript -e 'set volume <n>'
@trungtran
trungtran / gist:6975651
Created October 14, 2013 13:30
Git checkout remote branch
git checkout --track -b 1.1.0 origin/release/1.1.0
for (NSString *family in [UIFont familyNames])
{
NSLog(@"%@", [UIFont fontNamesForFamilyName:family]);
}
- [ shift-i - Search in file under cursor
- "il" + <query> - Search in file query
@trungtran
trungtran / Bash - Grep lib files for uniqueIdentifier
Created May 20, 2013 17:14
Bash command to search library.a files for uniqueIdentifier usage.
find . | grep -v .svn | grep "\.a" | grep -v "\.app" | xargs grep uniqueIdentifier