Skip to content

Instantly share code, notes, and snippets.

View slyphon's full-sized avatar

Jonathan Simms slyphon

View GitHub Profile
(ns hiredman.beans)
(defn -it [& _]
[[] (ref {})])
(defn setter [tis nam tat]
(dosync
(commute (.state tis)
assoc nam tat)))
(use '[clojure.contrib [str-utils :only (re-gsub)]])
(use '[clojure.contrib [java-utils :only (as-str)]])
(defn #^String upcase
"upcases the initial character in s"
[s]
(let [string (as-str s)]
(apply str (Character/toUpperCase (first string)) (rest string))))
(defn #^String camelize [s]
@slyphon
slyphon / gist:401391
Created May 14, 2010 17:17 — forked from tobowers/gist:397354
zookeeper barrier implementation
require 'rubygems'
gem 'zookeeper'
require 'zookeeper'
REQUIRED_NUMBER_OF_PROCESSES = 2
class EventHandler
import org.apache.zookeeper.Watcher
@slyphon
slyphon / snippet.txt
Created May 25, 2011 03:49 — forked from lsegal/snippet.txt
yardoc --help output
$ yardoc --help
Usage: yard doc [options] [source_files [- extra_files]]
(if a list of source files is omitted,
{lib,app}/**/*.rb ext/**/*.c is used.)
Example: yardoc -o documentation/ - FAQ LICENSE
The above example outputs documentation for files in
lib/**/*.rb to documentation/ including the extra files
FAQ and LICENSE.
@slyphon
slyphon / em-irb-console.rb
Created June 11, 2011 00:25 — forked from tmm1/em-irb-console.rb
networked irb server/client in EM
require 'rubygems'
require 'eventmachine'
module Console
PROMPT = "\n>> ".freeze
def post_init
send_data PROMPT
send_data "\0"
end
@slyphon
slyphon / socksproxy.js
Created August 15, 2011 23:16 — forked from telamon/socksproxy.js
Socks5 proxy implementation in Node.JS
// http://www.ietf.org/rfc/rfc1928.txt
// Tested with: curl http://www.google.se/ --socks5 1080 --proxy-user foo:bar
var States = {
CONNECTED:0,
VERIFYING:1,
READY:2,
PROXY: 3
};
@slyphon
slyphon / uri_demo.rb
Created November 5, 2011 02:12 — forked from djberg96/uri_demo.rb
Appending a path to a URI
require 'uri'
s1 = "http://storage.blah.com/auth28173"
s2 = "/container/path/to/object"
u = URI.parse(s1)
ary = s2.split('/')
ary.shift if ary[0].empty?
@slyphon
slyphon / gist:1407253
Created November 30, 2011 00:01 — forked from alexo/gist:1406271
Yammer moving away from Scala
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@slyphon
slyphon / gist:2578260
Created May 2, 2012 17:06 — forked from jhosteny/gist:2578253
FuseFS with celluloid
require 'fusefs'
paxosdir = DCell::Paxos::PaxosDir.new(DCell.registry.globals.root)
FuseFS.set_root(paxosdir)
# Mount under a directory given on the command line.
FuseFS.mount_under "/tmp/foobar"
FuseFS.run
#
# Ideas stolen from lograge and brought to Rails 2.3
# https://github.com/mattmatt/lograge/blob/master/lib/lograge/log_subscriber.rb
#
module ImprovedControllerLogging
def self.included(base)
base.alias_method_chain :log_processing, :fixup
base.inject_alias_method_chain :perform_action,
:perform_action_with_benchmark,