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
# Assumes a DynamoDB table with a HashKeyElement of | |
# Id which is a Numeric. We have one record in this | |
# table: {"Id"=>12} | |
require "rubygems" | |
require "bundler" | |
require "benchmark" | |
Bundler.setup | |
require "jedlik" |
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
>> "{\"name\":\"John Pignata\",\"text\":\"\xF0\x9F\x8E\x83\"}".encode(Encoding::UTF_8) | |
=> "{\"name\":\"John Pignata\",\"text\":\"🎃\"}" |
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
source = new EventSource("/subscribe") | |
source.addEventListener "picture", (event) -> | |
data = JSON.parse(event.data) | |
$("body, input").trigger "changeBackground", [data.url, data.keyword] | |
jQuery -> | |
$("body").bind "changeBackground", (event, url, keyword) -> | |
$(this).css( | |
"background": "url(#{url}) no-repeat center center fixed" |
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 stream = new EventSource("/stream"); | |
stream.addEventListener("new-message", function (event) { | |
console.log(event.data); | |
}); |
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
class Collection | |
def initialize(items=[]) | |
@items = items | |
end | |
end |
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
# For more detail around IP addressing basics see TCP/IP | |
# Illustrated (Second Edition) pp. 31-43 | |
address = IPAddr.new("192.168.0.77") | |
# #<IPAddr: IPv4:192.168.0.77/255.255.255.255> | |
# To calculate an IP address' network address, each bit | |
# in the address is bitwise ANDed with each corresponding | |
# bit in the subnet mask. | |
address & IPAddr.new("255.255.255.248") |
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
# activesupport/lib/active_support/cache.rb:441 | |
protected | |
# activesupport/lib/active_support/cache.rb:461 | |
# Read an entry from the cache implementation. Subclasses must implement | |
# this method. | |
def read_entry(key, options) # :nodoc: | |
raise NotImplementedError.new |
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
class PostsController < ApplicationController | |
before_filter :authorize_user | |
def create | |
@post = blog.posts.build(post_parameters) | |
if @post.save | |
redirect_to action: :index, notice: "Post created." | |
else | |
render :new |
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
require_relative "backchannel/client" | |
require_relative "backchannel/window" | |
require_relative "backchannel/message" | |
class Backchannel | |
def self.start(handle) | |
client = Client.new(handle) | |
window = Window.new(client) | |
window.start |
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
>> Hash() | |
ArgumentError: wrong number of arguments (0 for 1) | |
from (irb):25:in `Hash' | |
from (irb):25 | |
from /Users/jp/.rvm/rubies/ruby-2.0.0-preview1/bin/irb:16:in `<main>' | |
>> Hash(1) | |
TypeError: can't convert Fixnum into Hash | |
from (irb):26:in `Hash' | |
from (irb):26 | |
from /Users/jp/.rvm/rubies/ruby-2.0.0-preview1/bin/irb:16:in `<main>' |