This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.tutorialspoint.com/ruby/ruby_sending_email.htm | |
# http://www.devco.net/archives/2009/10/27/using_ruby_netimap_with_plain_auth.php | |
require 'net/smtp' | |
require 'net/imap' | |
message = <<MESSAGE_END | |
From: Private Person <[email protected]> | |
To: A Test User <[email protected]> | |
MIME-Version: 1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code adds an instance method called "transact" to all Moneta stores. | |
# You pass it a key and a block, and it pipes in the value for that key in the | |
# store. Whatever gets returned by the block gets saved over the value in the | |
# store. | |
module Moneta | |
module Expires | |
def transact(key, &blk); self[key] = yield(self[key]) end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple event dispatcher implementation | |
module Evented | |
class Dispatcher < Array | |
def call *args; self.each do |e|; e.call *args end end | |
end | |
class Dispatchers < Hash | |
def call name, *args; self[name].call(*args) if self[name] end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// contents of matchUrl code are a slightly modified version of the matchRequest code found | |
// in the nerve library for node.js http://github.com/gjritter/nerve/blob/master/lib/nerve.js | |
function matchUrl(matcher, req) { | |
if(typeof matcher === 'string') return(matcher === req.url); | |
else if(matcher.constructor === RegExp) return req.url.match(matcher); | |
else return req.url.match(matcher.apply(req)); | |
} | |
exports.route = function(servlets, req, res) { | |
for(var i = 0; i < servlets.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# removes hidden svn files. | |
# run it like so: | |
# rm_svn . | |
# based off of code found at http://niquimerret.com/?p=116 | |
function rm_svn { | |
find $1 -name ".svn" | xargs rm -Rf | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# text streaming example ported from JavaScript | |
# http://blog.new-bamboo.co.uk/2009/12/7/real-time-online-activity-monitor- | |
# example-with-node-js-and-websocket | |
process.mixin require 'sys' | |
filename: process.ARGV[2] | |
return puts "Usage: coffee watcher.coffee filename" unless filename |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
class SdlGfx <Formula | |
url 'http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-2.0.20.tar.gz' | |
homepage 'http://www.ferzkopp.net/joomla/content/view/19/14/' | |
md5 '8a787e538a8e4d80d4927535be5af083' | |
depends_on 'sdl' | |
def install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First attempt at a bullet physics formula. | |
require 'formula' | |
class Bullet <Formula | |
head 'http://bullet.googlecode.com/svn/trunk' | |
homepage 'http://code.google.com/p/bullet/' | |
depends_on 'cmake' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://griffin.oobleyboo.com/archive/ruby_rfc2822/ | |
class Time | |
def rfc2822 | |
sprintf( | |
"%.3s, %02d %.3s %04d %02d:%02d:%02d %s", Date::DAYNAMES[self.wday], self.day, | |
Date::MONTHNAMES[self.mon], self.year, self.hour, self.min, self.sec, self.zone | |
) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# http://gist.github.com/348262 | |
# Incomplete evented Redis implementation specifically made for | |
# the new PubSub features in Redis. | |
require 'stringio' | |
require 'rubygems' | |
require 'eventmachine' |