Skip to content

Instantly share code, notes, and snippets.

#
# This monkeypatch will tell IRB completion to ignore methods that also
# happen to be in the "Object" class as most of the time I don't care
# about these. This hack only steps in when you've entered something like
# "foo." or "Foo." or "Foo::", otherwise you'll be working with the
# full list of methods, including the ones from Object. k?
#
Readline.completion_proc = proc do |input|
IRB::InputCompletor::CompletionProc.call(input).reject do |o|
#!/bin/bash
#
# sendkey.sh: Helps proliferate your SSH public key to hosts.
#
# Rick Branson <rick@diodeware.com>
# This code is released into the public domain.
#
if [ "$#" -lt 1 ]; then
echo "sendkey.sh: Sends id_rsa.pub as authorized_keys to remote host (over SSH)"
#!/usr/bin/ruby
#
# This benchmark test implements a simple threaded message queue writer backed
# by an SQLite3 database. It is modeled after a Twitter-like queue-per-destination
# message system which has N number of actors, each with a queue. The idea
# is to demonstrate a safe, disk-backed queueing system with a large number of
# queues. All of the queues are stored in a separate table in the database file.
#
# In 2009, by Rick Branson, Released into Public Domain.
#
/* omg -- a C program to average things -- by Rick Branson -- public domain 'n shit */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define BUFSZ 1024 * 32
#define ARRAY_ALLOC_SZ 1024 * 32
int main(int argc, char **argv)
#!/usr/bin/ruby
#
# benshee.rb: A multi-connection HTTP request generator
# (C) 2009 Rick Branson -- actually it's public domain.
#
require "rubygems"
require "eventmachine"
require "uri"
/******************************************************************************
* $Id: mapshape.c 8755 2009-03-10 13:35:19Z jlacroix $
*
* Project: MapServer
* Purpose: Implements support for shapefile access.
* Authors: Steve Lime and Frank Warmerdam
*
* Note:
* This code is entirely based on the previous work of Frank Warmerdam. It is
* essentially shapelib 1.1.5. However, there were enough changes that it was
// a little teaser
var libc = new FFI.DynamicLibrary("libc.dylib", FFI.DynamicLibrary.FLAGS.RTLD_NOW);
assertInstanceof(libc, FFI.DynamicLibrary);
var atofPtr = libc.get("atof");
assertInstanceof(atofPtr, FFI.Pointer);
assertFalse(atofPtr.isNull());
var atof = FFI.Internal.methodFactory(atofPtr, "double", [ "string" ]);
//
// prototype-scriptaculous-hint-text.js | by Rick Branson -- Released into the public domain.
//
// Adds placeholder text above an input. Fades in and out. Is sexy. No kids. Not tested in IE (yet).
//
// $(element).hintText("string", {
// hiddenOpacity: the opacity of the placeholder text when it's hidden. (0.0 to 1.0)
// shownOpacity: the opacity of the placeholder text when it's shown. (0.0 to 1.0)
// effectDuration: the length (in seconds) of the fading effect, 0 turns it off.
// textPadding: the amount of text padding to use if none is explicitly set on
#
# To use this, drop it into your lib directory and add a require to an initializer
# in config/initializers.
#
# This little extension to Mongoid allows belongs_to_related associations to
# have an "in" option, which will traverse the object graph to find the
# collection that will contain the related model object.
#
# The goal is to allow relations to be created that reference objects embedded
# in documents, instead of only objects that are contained within collections.
@rbranson
rbranson / run-node.sh
Created October 21, 2010 16:16
start-stop-daemon friendly script to start node and log to a file
#!/bin/sh
#
# Runs node.js against script, logging to a logfile. We have to do
# this because there's no way to call node directly and have start-stop-daemon
# redirect stdout to a logfile.
#
LOGFILE=/var/log/node/node-application.log
NODE=/usr/local/bin/node
JAVASCRIPT=/var/apps/node-application/app.js