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 'rubygems' | |
require 'aws/s3' | |
# Change the access key and secret to your amazon credentials | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => 'ACCESS_KEY_ID', | |
:secret_access_key => 'SECRET' | |
) | |
# Change this to your S3 bucket name | |
WEBSITE_BUCKET_NAME = "YOUR_BUCKET_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
class ApplicationController < ActionController::Base | |
around_filter :set_white_label | |
private | |
def set_white_label | |
subdomains = request.subdomains - RESERVED_SUBDOMAINS | |
if subdomains.empty? | |
yield | |
return |
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 Banana < ActiveRecord::Base; end | |
banana = Banana.new | |
banana.valid? #=> true | |
banana.singleton_class.validates_presence_of :name | |
banana.valid? #=> true - why did the validation not work? | |
banana.class.validates_presence_of :name | |
banana.valid? #=> false - as we'd expect...but now... |
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
# Shamelessly stolen from https://gist.github.com/ileitch/1459987 | |
module InterruptibleSleep | |
def interruptible_sleep(seconds) | |
@sleep_check, @sleep_interrupt = IO.pipe | |
IO.select([@sleep_check], nil, nil, seconds) | |
end | |
def interrupt_sleep | |
@sleep_interrupt.close if @sleep_interrupt |
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
From a034498e36c02715b9201646d4ce1ddcddf118c3 Mon Sep 17 00:00:00 2001 | |
From: Shugo Maeda <shugo@ruby-lang.org> | |
Date: Wed, 29 Apr 2015 09:14:15 +0900 | |
Subject: [PATCH] support ES6-like hash literals. | |
--- | |
parse.y | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------- | |
1 file changed, 72 insertions(+), 17 deletions(-) | |
diff --git a/parse.y b/parse.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
When /^I reload the page$/ do | |
page.evaluate_script("window.location.reload()"); | |
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
@interface BananaBox : NSObject | |
- (id)objectAtIndexedSubscript:(NSUInteger)idx; | |
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx; | |
@end | |
@implementation AppleCart | |
NSMutableArray *_bananas; | |
-(id) init { | |
self = [self init] |
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
@interface Banana : NSObject | |
- (id)objectForKeyedSubscript:(id)key; | |
- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; | |
@end | |
@implementation Banana | |
NSMutableDictionary *_attributes; | |
-(id) init { | |
self = [self init]; |
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
// To add array style subscripting: | |
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx; // setter | |
- (id)objectAtIndexedSubscript:(NSUInteger)idx; // getter | |
// To add dictionary style subscripting | |
- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; // setter | |
- (id)objectForKeyedSubscript:(id)key; // getter |
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
NSArray *anArray = @[a,b,c]; | |
NSDictionary *aDictionary @{ a : a1, b : b1}; | |
// New subscripting format | |
anArray[0]; // => returns a | |
aDictionary[a] // => returns a1 |
NewerOlder