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 | |
import XCTest | |
class Ref { | |
var success = false | |
} | |
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 UIKit | |
let attr = NSAttributedString(string: "Hello, playground", attributes: [NSBackgroundColorAttributeName:UIColor.redColor()]) | |
var shouldBeOne = 1 | |
attr.enumerateAttribute(NSBackgroundColorAttributeName, inRange: NSMakeRange(0, attr.length), options:[]) { (value, range, stop) -> Void in | |
shouldBeOne += 1 | |
} | |
print(shouldBeOne) //<- prints "1" |
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 UIKit | |
class AsyncOperation : NSOperation{ | |
enum State{ | |
case Waiting, Executing, Finished | |
} | |
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 | |
class StateMachine<P:StateMachineDelegateProtocol>{ | |
private unowned let delegate:P | |
private var _state:P.StateType{ | |
didSet{ | |
delegate.didTransitionFrom(oldValue, to:_state) | |
} | |
} |
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
func returning<T>(object:T, block:(_:T)->Void)->T{ | |
block(object) | |
return object | |
} |
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
(ns reverb.lighttable | |
(:require lt.object) | |
(:require-macros lt.macros)) | |
(lt.object/object* ::my-template-name :tags [:my-tag-name] :some-nebulous-state [], :other-state-like-thing {}) | |
(lt.object/->def ::my-template-name) | |
(lt.object/create ::my-template-name) | |
(lt.object/instances-by-type ::my-template-name) |
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
def self.with_memory_db | |
old_db_config = ActiveRecord::Base.connection_config | |
ActiveRecord::Base.establish_connection :adapter=>"sqlite3", :database=>":memory:" | |
yield(ActiveRecord::Base.connection) if block_given? | |
ensure | |
ActiveRecord::Base.establish_connection old_db_config | |
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 'bundler/setup' | |
Bundler.require(:default) | |
module Fred; module Barny; module Wilma; def self.betty; "hello, bedrock!" end end end end | |
app = proc do |env| [200, { 'Content-Type' => 'text/html' }, Fred::Barny::Wilma.betty()]; end | |
run app |
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 Foo | |
module Bar | |
class Baz | |
def self.quux | |
puts "hello, world" end end end end | |
Foo::Bar::Baz.quux() | |
module Fred |
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
-(IBAction)show:(id)sender{ | |
CGRect frame = [aView frame]; | |
frame.origin.y = [[self view] bounds].size.height; | |
[aView setFrame:frame]; | |
[[self view] addSubview:aView]; | |
[UIView beginAnimations:@"slide up" context:NULL]; | |
frame.origin.y = [[self view] bounds].size.height - frame.size.height; | |
[aView setFrame:frame]; | |
[UIView commitAnimations]; |