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
extension NSURL : StringLiteralConvertible { | |
public class func convertFromStringLiteral(value: String) -> Self { | |
return self(string: value) | |
} | |
public class func convertFromExtendedGraphemeClusterLiteral(value: String) -> Self { | |
return self(string: value) | |
} | |
} |
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
extension Array { | |
func each (block : (T) -> ()) { | |
for item in self { | |
block(item) | |
} | |
} | |
} | |
animals.each(println) |
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
var animals = ["cow", "dog", "pig"] | |
var emoji = ["🐮", "🐶", "🐷"] | |
for (animal, pic) in Zip2(animals, emoji) { | |
println("\(animal) \(pic)") | |
} |
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. |
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
# 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
# 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
(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
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
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 |