Skip to content

Instantly share code, notes, and snippets.

@jpignata
jpignata / results.txt
Created September 5, 2012 17:56
DynamoDB Test
# 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"
>> "{\"name\":\"John Pignata\",\"text\":\"\xF0\x9F\x8E\x83\"}".encode(Encoding::UTF_8)
=> "{\"name\":\"John Pignata\",\"text\":\"🎃\"}"
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"
var stream = new EventSource("/stream");
stream.addEventListener("new-message", function (event) {
console.log(event.data);
});
class Collection
def initialize(items=[])
@items = items
end
end
# 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")
# 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
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
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
>> 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>'