Skip to content

Instantly share code, notes, and snippets.

View pyrossh's full-sized avatar

Peter John pyrossh

View GitHub Profile
@klovadis
klovadis / gist:5170386
Created March 15, 2013 14:51
Lua script for redis to turn a dictionary table into a bulk reply
-- turns a dictionary table into a bulk reply table
local dict2bulk = function (dict)
local result = {}
for k, v in pairs(dict) do
table.insert(result, k)
table.insert(result, v)
end
return result
end
@avsej
avsej / test.rb
Created July 18, 2012 12:48
Two phase commit for Couchbase. Version 2 (improved version of https://gist.github.com/3135796)
require 'rubygems'
require 'couchbase'
def transfer(source, destination, amount)
cb = Couchbase.bucket
# prepare transaction document
id = cb.incr("transaction:counter", :create => true)
trans_id = "transaction:#{id}"
cb.set(trans_id, {"source" => source, "destination" => destination,
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as: