Skip to content

Instantly share code, notes, and snippets.

View pricees's full-sized avatar

Ted Price pricees

View GitHub Profile
@pricees
pricees / gist:3290077
Created August 7, 2012 22:31
Gist of REGEX notes
moby = <<EOL
Call me Ishmael. Some years ago - never mind how long precisely - having little
or no money in my purse, and nothing particular to interest me on shore, I
thought I would sail about a little and see the watery part of the world.
[Moby Dick - 1st paragraph]
EOL
#
# Passively store your match the old way: "$1"
#
@pricees
pricees / gist:3297892
Created August 8, 2012 19:28
traceroute for theslingshot.com
traceroute theslingshot.com
traceroute to theslingshot.com (173.245.61.159), 30 hops max, 60 byte packets
1 10.10.20.1 (10.10.20.1) 5.886 ms 7.314 ms 7.710 ms
2 74-92-190-118-Illinois.hfc.comcastbusiness.net (74.92.190.118) 13.226 ms 14.104 ms 14.397 ms
3 96.120.25.193 (96.120.25.193) 53.888 ms 54.198 ms 54.463 ms
4 te-1-8-ur13.area4.il.chicago.comcast.net (68.86.114.105) 31.096 ms 32.892 ms 33.477 ms
5 te-8-2-ur12.area4.il.chicago.comcast.net (68.87.231.25) 32.515 ms 33.003 ms 33.876 ms
6 te-2-2-0-2-ar01.area4.il.chicago.comcast.net (68.87.232.225) 34.667 ms 14.280 ms 25.691 ms
7 pos-3-6-0-0-cr01.350ecermak.il.ibone.comcast.net (68.86.95.9) 24.770 ms 25.194 ms 25.335 ms
8 be-12-pe03.350ecermak.il.ibone.comcast.net (68.86.84.190) 23.508 ms 24.095 ms 24.365 ms
@pricees
pricees / gist:3298890
Created August 8, 2012 21:23
A small note about nginx locations
http://wiki.nginx.org/NginxHttpCoreModule#location
Example:
location = / {
# matches the query / only.
[ configuration A ]
}
location / {
# matches any query, since all queries begin with /, but regular
@pricees
pricees / gist:3668404
Created September 7, 2012 18:30
Ss::PersistentJhash
#
# Public: This class uses Rubys native hash data type for immediate data manipulation. This serializes the data to JSON where it is stored into a Redis backend for persistence.
# It contains a namespace and a rd_key, it will store the data as JSON into "[namespace]:[key]"
#
# Assumes REDIS = Redis.new (redis connection)
#
# Examples
#
# foo = PersistentJhash.new
# foo.namespace
@pricees
pricees / gist:3668414
Created September 7, 2012 18:32
PersistentJhash Test (meh)
describe Ss::PersistentJhash do
before do
tmp = Ss::PersistentJhash.new
tmp.clear.save
assert tmp.send(:conn)
tmp.load_data.must_be :empty?
end
it "is a hash" do
@pricees
pricees / gist:3890415
Created October 15, 2012 01:44
Using Ivona TTS Saas service with Ruby
require 'digest/md5'
require 'savon'
require 'open-uri'
# Public: Various methods to get information from the Ivona cloud service
#
#
# Examples
#
# url = IvonaTts.synthesize(user: "[your user name]",
@pricees
pricees / gist:4062164
Created November 12, 2012 21:50
Redis Pubsub Subscriber Class
# Public: Subscriber class for digesting conn messages
#
# channel - Channel to subscribe to
# block - Block for digesting message (opt)
#
# Examples
#
# # With a block!
# Subscriber.new("test").start
# #=> "Subscribed to #test"
@pricees
pricees / gist:4062179
Created November 12, 2012 21:52
redis pubsub subscriber instance
Subscriber.new(channel) do |_, m|
begin
hsh = JSON.parse(m)
logger = ENV["RACK_ENV"] == "development" ? $stdout : $stderr
klass = hsh["class"]
method = hsh["method"]
args = hsh["args"]
@pricees
pricees / gist:4067982
Created November 13, 2012 19:54
RSS Feed processor class
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
require 'json'
# Class handles reading, processing RSS feeds
#
# Examples
#
# # GOOD
@pricees
pricees / gist:4142594
Created November 25, 2012 06:18
alarms table
create_table :alarms do
primary_key :id
Integer :local_day
Time :local_time
Integer :utc_day
Integer :utc_time_in_sec
Text :zone
end