Skip to content

Instantly share code, notes, and snippets.

# To test this out, call:
# (206) 357-6220 x33684 or
# sip:2063576220@vox4.cloudvox.com x33684
default {
if calleridname != 'Not available'
name = calleridname
end
text = "Hello #{name}, I think you're calling from #{callerid}"
# From Edge Rails
class Object
unless public_method_defined?(:present?)
def present?
!blank?
end
end
end
# Parallel map
# Originally from http://project.ioni.st/post/2332#snippet_2332
class Array
def pmap
threads = []
0.upto(size - 1) do |n|
threads << Thread.new do
yield(at(n))
end
end
@eric
eric / twitter_word_count.rb
Created August 8, 2008 21:49
Making it simple to provide input for http://wordle.net/create
#
# Created by Eric Lindvall <eric@5stops.com>
#
# Making it simple to provide input for http://wordle.net/create
#
#
require 'rubygems'
gem 'mechanize'
require 'mechanize'
require 'open-uri'
require 'hpricot'
class Gistr
def initialize(gist_id)
@gist_id = gist_id
end
def post(email, password, title)
post_to_tumblr(email, password, title, gist_code)
class CreditCardType < ActiveRecord::Base
acts_as_enumeration :lookup_name
column :name
def initialize(attributes = nil)
super
self.lookup_name ||= name.to_s.gsub(/[^A-Za-z0-9-]/, '').underscore
end
create :id => 1, :name => 'Visa'
@eric
eric / dialplan.rb
Created September 22, 2008 21:17
Example tutorial for collecting DTMF keypad digits while using text-to-speech
# Example tutorial for collecting DTMF keypad digits while using
# text-to-speech (TTS). Tested on Cloudvox via AGI (Asterisk's
# phone call API) and Adhearsion Ruby library.
default {
execute 'swift', "%p" % "Please enter a number and we will tell you what it is when we are done talking."
# See if our talking was interrupted by DTMF, and if so, grab the digit
nums = variable('SWIFT_DTMF')
@eric
eric / dialplan.rb
Created September 24, 2008 02:36
Adhearsion example that demonstrates the basics of click-to-call
# Example of a simple click-to-call script. Includes a trick showing how to
# create a module for dialplan helpers. Tested on Cloudvox via AGI (Asterisk's
# phone call API) and Adhearsion Ruby library.
local_config = YAML::load(File.read(File.dirname(__FILE__) + '/local_config.yml')) rescue {}
module DialplanHelper
attr_accessor :default_swift_voice
attr_accessor :default_outgoing_context
@eric
eric / gist:20526
Created October 28, 2008 21:36
My ~/.autotest
# My current ~/.autotest
require 'autotest/redgreen'
require 'autotest/restart'
# Images from http://blog.ardes.com/2008/5/23/leopard-autotest-growl-and-bob-the-builder
AUTOTEST_IMAGE_ROOT = File.expand_path(File.join(ENV['HOME'], 'Pictures', 'autotest'))
module Autotest::Growl
def self.growl(title, msg, img, pri=0)