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
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
// 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
NSArray *albums = @[[Album albumWithName:@"Random Access Memories" price:9.99f], | |
[Album albumWithName:@"Clarity" price:6.99f], | |
[Album albumWithName:@"Weekend in America" price:7.99f], | |
[Album albumWithName:@"Weekend in America" price:7.90f], | |
[Album albumWithName:@"Bangarang EP" price:2.99f]]; | |
// Reversing an Array | |
__unused NSArray *reversed = albums.reverseObjectEnumerator.allObjects; | |
// PREDICATES |
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
defmodule Example do | |
def my_puts str do | |
IO.puts str | |
end | |
end | |
Example.my_puts "Hello, World!" |
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
(module example racket | |
(define (my_print str) | |
(print str))) | |
(my_print "Hello, World!") |
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
# example of incrementing all elements across a list | |
Enum.map [1,2,3], fn(x) -> x + 1 end | |
Enum.map [1,2,3], &1 + 1 |
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
# TOP SECRET | |
# CodeNight CodeKnight Answer Key!!! | |
# Problem 0 | |
# Use Enumerable.each to print out a string for each knight in the format of "Jason prefers a sword" | |
knights.each {|knight| puts "#{knight.name} prefers a #{knight.preferred_weapon}"} | |
# Problem 1 | |
# Use Enumerable.find_all to find all knights with 50 or more health |
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
# 1) open irb | |
# 2) `load "code_knight.rb"` | |
# 3) `knights = Marshal::load(Marshal::dump($knights))` | |
# 4) do the problems using your variable `knights` | |
# armor types - :light, :medium, :heavy | |
# ethical_alignment - :chaotic, :neutral, :lawful | |
# moral_alignment - :good, :neutral, :evil | |
class CodeKnight |
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
My stuff is all based off the Xcode keymap—it helps you start with a little bit of familiarity. | |
Run is weird in appcode, cause it doesn't hit the breakpoints like Xcode's run does. What you want is Debug. | |
I have mapped Debug to ⌘+R, and Debug... to ⌘+⇧+R (Debug... is awesome!) (Also if you hold shift when you are in the Debug... menu you can run instead of debug) | |
I have remapped ⌘+T to Class... Effectively this allows me to open new tabs a la Sublime style where you hit command t for a new tab, and then enter the class name you want to open in that tab. | |
I don't like a lot of the ⌘+1 through ⌘+9 windows the way they are. I picked the ones I like and then remapped them to the lower keys for the ones I like to use a lot. I also hid all the tool window bars. |