Skip to content

Instantly share code, notes, and snippets.

window.onkeydown = function(event){
keyboard.press(event.keyCode);
}
}());
var $panes = $(".waypoint").length-1;
var $currentPane = $(".waypoint").first();
var keyboard = {
press:function(keycode){
console.log(keycode);
@motionbug
motionbug / gist:3085136
Created July 10, 2012 17:55 — forked from jamesez/gist:3085058
Build Chrome dmg
#!/bin/bash -ex
# Mount disk image on temp space
mountpoint=`hdiutil attach -mountrandom /tmp -nobrowse googlechrome.dmg | awk '/private\/tmp/ { print $3 } '`
echo Mounted on $mountpoint
# Determine version number
version=`defaults read "$mountpoint/Google Chrome.app/Contents/Info.plist" CFBundleShortVersionString`
echo Google Chrome version $version
@jboner
jboner / latency.txt
Last active May 15, 2025 07:53
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@zbowling
zbowling / gist:2356293
Created April 11, 2012 01:48
WWDC dates
Year Days Announcement Day Start of WWDC Venue
2012 ?? ????????? ??? 11-Jun-12??? Moscone West
2011 70 28-Mar-11 Mon 06-Jun-11 Moscone West
2010 40 28-Apr-10 Wed 07-Jun-10 Moscone West
2009 74 26-Mar-09 Thu 08-Jun-09 Moscone West
2008 88 13-Mar-08 Thu 09-Jun-08 Moscone West
2007 126 05-Feb-07 Mon 11-Jun-07 Moscone West
2006 153 07-Mar-06 Tue 07-Aug-06 Moscone West
2005 111 15-Feb-05 Tue 06-Jun-05 Moscone West
2004 123 26-Feb-04 Thu 28-Jun-04 Moscone West
@blakewatters
blakewatters / gist:1994289
Created March 7, 2012 16:44
iOS 5 Interface Builder, View Controller and ARC Best Practices

Now that the GateGuru team has been developing on the iOS 5 SDK for awhile, I thought I'd pull together some lessons learned.

  • Declare your IBOutlet and IBActions within the private category within your implementation file. This makes them visible to interface builder without cluttering up the external interfaces and leaking implementation details.
  • Declare your IBOutlet properties as (nonatomic, weak). The weak reference implies a non-owning reference and ARC will nil it as necessary.
  • Delegate properties should be (nonatomic, weak) as well.
  • The designated initializer for UIView's is initWithFrame: when initialized programmatically. When loaded from a Storyboard or custom Nib, it is initWithCoder:
  • The designated initializer for UIViewController's is initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil when initialized programmatically. It is initWithCoder: when loaded from a Storyboard or Nib.
@wess
wess / gist:1949952
Created March 1, 2012 13:53
Macro for Singleton with GCD
#define SINGLETON(classname) \
+(classname *)instance { \
static dispatch_once_t onetime; \
static classname *shared = nil; \
dispatch_once(&onetime, ^{ \
shared = [[classname alloc] init]; \
}); \
return shared; \
}
@mrsidique
mrsidique / gist:1867937
Created February 20, 2012 05:00
Infinite Scroll
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
[_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];
fetchingMoreMessages = NO;
if(self.tableView.contentOffset.y<0){
//it means table view is pulled down like refresh
return;
}
@nielsbot
nielsbot / UIImage+JPEG2000.h
Created February 19, 2012 00:43
Decoding JPEG 2000 files to UIImage
#import <Foundation/Foundation.h>
extern UIImage * UIImageWithJPEG2000Data( NSData * data ) ;
@codeswimmer
codeswimmer / ios_IPAddress.c
Created January 15, 2012 16:49
iOS: Get Current IP Address
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
@carlosmcevilly
carlosmcevilly / doc-methods
Created October 25, 2011 16:27
destructively filter the paste buffer to find objective-c methods
#!/bin/bash
# doc-methods
# no arguments
#
# usage: load the docs for an obj-c protocol, select all, copy, then run this.
#
# on osx, takes the contents of the paste buffer and replaces it with
# only the lines from the paste buffer that look like obj-c methods,
# based on a really simple heuristic