This file contains 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
import Foundation | |
public struct Vector: Equatable { | |
public let x: Double | |
public let y: Double | |
public var angle: Double { | |
return atan2(self.x, self.y) | |
} | |
This file contains 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
class 🌰 : CustomStringConvertible { | |
var 🖼 = "🌲" | |
func 🖌(🎊: String){ 🖼 += 🎊 } | |
var description: String { return 🖼 } | |
} | |
let 🌲🌲🌲 = [🌰(), 🌰(), 🌰()] | |
let 🌸 = "🌸" |
This file contains 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
// Find all of the square roots from 1 to 10 and log them to the console | |
function sqrt(x: number): number { | |
function square(x: number): number { | |
return x * x; | |
} | |
function average(x1: number, x2: number): number { | |
return (x1 + x2) / 2; | |
} |
This file contains 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
[ | |
{ | |
"name": "Device", | |
"id": "a1f11592-823b-11e2-8ae1-fd12a6ecbbf6" | |
}, | |
{ | |
"name": "Device", | |
"id": "0b527208-823f-11e2-983a-034c1dac2e33" | |
}, | |
{ |
This file contains 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
Class.constants.reject { |klass_name| !includes_toy_store?(klass_name) }.collect { |klass_name| Kernel.const_get(klass_name) } | |
def includes_toy_store?(klass_name) | |
klass = Kernel.const_get(klass_name) | |
return false unless klass.respond_to? :included_modules | |
klass.included_modules.include?(Toy::Store) | |
end |
This file contains 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 Huey | |
# An actual object for a bulb. | |
class Bulb | |
# ... | |
def self.find(identifier) | |
self.find_by_id(identifier) || self.find_by_name(identifier) | |
end |
This file contains 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
require 'redis' | |
require 'celluloid' | |
require 'json' | |
require 'pry' | |
class Ticker | |
attr_reader :redis | |
attr_reader :channel |
This file contains 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
require 'huey' | |
class Adapter::HueAdapter < Adapter::Base | |
creator "Nick Rowe" | |
adapts_to "Philips Hue Lighting System" | |
website "http://github.com/nixterrimus/hue-spirit-adapter" | |
implements :colorable_light |
This file contains 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
require 'huey' | |
class Adapter::HueAdapter < Adapter::Base | |
creator "Nick Rowe" | |
adapts_to "Philips Hue Lighting System" | |
website "http://github.com/nixterrimus/hue-spirit-adapter" | |
implements :colorable_light |
This file contains 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
require 'huey' | |
class Adapter::HueAdapter < Adapter::Base | |
creator "Nick Rowe" | |
adapts_to "Philips Hue Lighting System" | |
website "http://github.com/nixterrimus/hue-spirit-adapter" | |
implements :colorable_light |