This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// old way | |
- (NSMutableArray *)sections { | |
if (!_sections) { | |
_sections = [NSMutableArray new]; | |
} | |
return _sections; | |
} | |
// cool new way | |
- (NSMutableArray *)sections { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sieve = (n) -> | |
primes = (true for i in [3..n]) | |
for i in [2..n] | |
continue if Math.pow(i,i) > n | |
for j in [Math.pow(i,i)-3..n] by i | |
primes[j] = no | |
(index + 3 for primality, index in primes when primality) | |
console.log sieve(1000000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
require 'net/http' | |
require 'json' | |
STOPWORDS = %w( | |
a about above after again against all am an and any are aren't as at be because been before | |
being below between both but by can't cannot could couldn't did didn't do does doesn't doing | |
don't down during each few for from further had hadn't has hasn't have haven't having he he'd | |
he'll he's her here here's hers herself him himself his how how's i i'd i'll i'm i've if in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo = %w{cat dog dog cat cat cat dog cat dog dog cat cat dog dog} | |
bar = %w{yes no yes yes yes no no yes no yes no no yes yes} | |
puts "Foo: #{foo}" | |
puts "Bar: #{bar}" | |
histogram = foo.inject(Hash.new(0)) { |h,v| h[v] += 1; h } | |
puts histogram |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ % brew install netpbm | |
==> Downloading http://sourceforge.net/projects/netpbm/files/super_stable/10.35.86/netpbm-10.35.86.tgz | |
Already downloaded: /Library/Caches/Homebrew/netpbm-10.35.86.tgz | |
/usr/bin/tar xf /Library/Caches/Homebrew/netpbm-10.35.86.tgz | |
==> cp Makefile.config.in Makefile.config | |
cp Makefile.config.in Makefile.config | |
==> make | |
make | |
/private/tmp/brew-netpbm-10.35.86-LQva/netpbm-10.35.86/Makefile.common:560: Makefile.depend: No such file or directory | |
cat /dev/null >Makefile.depend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UISegmented control | |
UIImage *segSelected = [[UIImage imageNamed:@"sel.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)]; | |
UIImage *segUnselected = [[UIImage imageNamed:@"uns.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)]; | |
UIImage *segSelectedUnselected = [UIImage imageNamed:@"sel-uns"]; | |
UIImage *segUnselectedSelected = [UIImage imageNamed:@"uns-sel"]; | |
UIImage *segUnselectedUnselected = [UIImage imageNamed:@"uns-uns"]; | |
[[UISegmentedControl appearance] setBackgroundImage:segUnselected | |
forState:UIControlStateNormal | |
barMetrics:UIBarMetricsDefault]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[self.fullscreenButton customViewButtonWithImage:@"fullscreenButton" target:self action:@selector(toggleFullScreen:)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL *url = [NSURL URLWithString:@"pinit12://pin/create/bookmarklet/?media=http%3A%2F%2Fimages.apple.com%2Fhome%2Fimages%2Fipad_hero.jpg&url=http%3A%2F%2Fwww.apple.com%2F&title=Apple&is_video=false&description=Test"]; | |
[[UIApplication sharedApplication] openURL:url]; |