Skip to content

Instantly share code, notes, and snippets.

View gist:3711
Object.prototype.delegated = function(props) {
var f = function() { }
f.prototype = this
var r = new f()
for (var p in props)
if (props.hasOwnProperty(p))
r[p] = props[p]
return r
}
View jabber.rb
module Jabber
def self.read
size = $stdin.read(2).unpack("n").first
$stdin.read(size).split(':')
end
def self.write(success)
answer = success ? 1 : 0
token = [2, answer].pack("nn")
$stdout.write(token)
View gist:6857
module URI
def self.parse_with_options(uri_str, opts = {})
parsed_uri = self.parse(uri_str)
sing = (class << parsed_uri; self end)
sing.send :define_method, :options do
opts
end
parsed_uri
end
end
View gist:12667
module Gem
def self.activate(gem, *version_requirements)
options = version_requirements.last.is_a?(Hash) ? version_requirements.pop : {}
sources = options[:sources] || []
if version_requirements.empty? then
version_requirements = Gem::Requirement.default
end
unless gem.respond_to?(:name) and
View .emacs-fun.el
;; Emacs server
(server-start)
(add-hook 'server-switch-hook
(lambda nil
(let ((server-buf (current-buffer)))
(bury-buffer)
(switch-to-buffer-other-frame server-buf))))
(add-hook 'server-done-hook 'delete-frame)
(add-hook 'server-done-hook (lambda nil (kill-buffer nil)))
View eupathdb_ubiquity.js
CmdUtils.CreateCommand({
name: "plasmodb",
takes: {"plasmodb_id": noun_arb_text},
homepage: "http://gist.github.com/20872",
author: { name: "Ben J. Woodcroft", email: "b.woodcroft@pgrad.unimelb.edu.au"},
contributors: ["Ben J. Woodcroft"],
license: "GPL3",
description: "Go to a PlasmoDB Gene page in a new window",
preview: "Go to a PlasmoDB Gene page in a new window.",
View god.rb
rails_root = "/data/github/current"
20.times do |num|
God.watch do |w|
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
w.start = "rake -f #{rails_root}/Rakefile production jobs:work"
w.uid = 'git'
View weird-strings.rb
puts %. This is a statement.
puts %? This is a question?
puts %! This is an exclamation!
puts % These are tabs # but of course github converts tabs to spaces
# so you'll have to use your imagination
View fstring.hpp
/** Fast String - Voice Technology
* Simple char[] substitute with faster appender.
* Fernando Gregianin Testa <testa@voicetechnology.com.br>
* v0.1 - Usando no provider v2. 2007-02-22
*/
#ifndef FSTRING_
#define FSTRING_
#include <stdlib.h>
View gist:28743
def with_umask(mask)
previous = File.umask(mask)
yield
File.umask(previous)
end