Skip to content

Instantly share code, notes, and snippets.

View jwreagor's full-sized avatar

J R jwreagor

  • New Gillington, WI
View GitHub Profile
require 'rubygems'
require 'sinatra'
require 'pony_gmail' # the file that's linked above
post '/' do
Pony.mail(:to=>"someeamil@example.com",
:from => 'yourgmail@yourdomian.com',
:subject=> "SUBJECT",
:body => "BODY",
:via => :smtp, :smtp => {
require 'rubygems'
require 'dm-core'
require 'dm-types'
require 'bacon'
DataMapper.setup :default, :adapter => :in_memory
class User
include DataMapper::Resource
property :id, Serial
@actsasflinn
actsasflinn / msgpack_benchmark.rb
Created January 30, 2010 05:07
Message Pack vs similar utilities
=begin
Message Pack vs similar utilities
ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.0.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02
Packing
user system total real
pack: bert 18.320000 0.770000 19.090000 ( 19.101583)
pack: bson_ext 0.850000 0.030000 0.880000 ( 0.878398)
pack: json_ext 2.540000 0.040000 2.580000 ( 2.582495)
@pasviegas
pasviegas / mongodb
Created March 27, 2010 01:26
Simple monit script for mongodb
check host mongodb with address localhost
start program = "/usr/bin/sudo /opt/database/mongo/bin/mongod"
stop program = "/usr/bin/sudo /usr/bin/pkill -f mongod"
if failed port 28017 protocol HTTP
request /
with timeout 10 seconds
then start
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
'''
redis_search.py
Written by Josiah Carlson July 3, 2010
Released into the public domain.
This module implements a simple TF/IDF indexing and search algorithm using
Redis as a datastore server. The particular algorithm implemented uses the
"""
Script to convert a Xcode3 Color theme into a Xcode4 one.
Example:
bash# python xcode3_theme_to_xcode4.py Twilight.xcolortheme
It will write a new file: Twilight.dvtcolortheme into the same folder as the script is residing in.
"""
import plistlib,sys
""" Define boilerplate of the color theme """
defaultConfig = {
@lukeredpath
lukeredpath / process_finance_report.rb
Created July 28, 2010 15:14
A script for processing iTunes finance reports and importing to FreeAgent
#!/usr/bin/env ruby
### REQUIRED GEMS: restclient, activesupport, crack, mash, money, fastercsv
### USAGE
# fetch_finance_reports finance_report_1 finance_report_2 ... finance_report_x
### BEGIN CUSTOMIZATION
# I like to store this in a separate file in my home folder, ~/.freeagent
@dahlia
dahlia / lisp.rb
Created September 2, 2010 07:52
30 minutes Lisp in Ruby
# 30 minutes Lisp in Ruby
# Hong Minhee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
framework 'Cocoa'
framework 'WebKit'
class Cat
attr_accessor :name, :age
def initialize(name = 'kitty', age=42)
@name = name
@age = age
end