Skip to content

Instantly share code, notes, and snippets.

View twerth's full-sized avatar

Todd Werth twerth

View GitHub Profile
#!/usr/bin/env ruby -wKU
#
require 'rexml/document'
xml = `curl -s "http://www.google.com/ig/api?weather=94123"`
doc = REXML::Document.new(xml)
condition = doc.root.elements["weather/current_conditions/condition"].attributes['data']
wind_condition = doc.root.elements["weather/current_conditions/wind_condition"].attributes['data']
wind_condition = wind_condition.match(/\d+/).to_s
temp_f = doc.root.elements["weather/current_conditions/temp_f"].attributes['data']
@twerth
twerth / sphinx.rb
Created May 18, 2012 15:55 — forked from assimovt/sphinx.rb
Mac homebrew Sphinx 0.9.9 formula
require 'formula'
class Libstemmer < Formula
# upstream is constantly changing the tarball,
# so doing checksum verification here would require
# constant, rapid updates to this formula.
head 'http://snowball.tartarus.org/dist/libstemmer_c.tgz'
homepage 'http://snowball.tartarus.org/'
end
>> class Foo
>> def bar
>> puts 'in bar'
>> end
>> end
=> nil
>> class Foo2 < Foo
>> def bar
>> super
>> puts 'in bar in foo2'
@twerth
twerth / gist:1717529
Created February 1, 2012 15:27
Spin setup
# Spin
#
# Install:
# > gem install spin
# > gem install kicker -s http://gemcutter.org
#
# You need 2 processes going, to run:
# > spin
# > spin_kicker
#
@twerth
twerth / gist:1712534
Created January 31, 2012 19:49
Sample CSS style
body { color: #666663; background-color: #3e3e3e; font-size: 16px; }
h1, h2, h3, h4 { margin-bottom: 10px; font-weight: bold; }
h1 { font-size: 28px; font-weight: bold; margin-bottom: 15px; }
h2 { font-size: 20px; }
h3 { font-size: 18px; margin-bottom: 5px; }
h4 { }
ol { list-style-position: inside; list-style-type: decimal; margin-bottom: 10px; }
ul { list-style-position: inside; list-style-type: none; margin-bottom: 10px; }
li { padding: 0; margin: 0; }
@twerth
twerth / colors
Created July 22, 2011 15:47
List colors in shell
#!/bin/bash
echo -e "\033[0mCOLOR_NC (No color)"
echo -e "\033[1;37mCOLOR_WHITE\t\033[0;30mCOLOR_BLACK"
echo -e "\033[0;34mCOLOR_BLUE\t\033[1;34mCOLOR_LIGHT_BLUE"
echo -e "\033[0;32mCOLOR_GREEN\t\033[1;32mCOLOR_LIGHT_GREEN"
echo -e "\033[0;36mCOLOR_CYAN\t\033[1;36mCOLOR_LIGHT_CYAN"
echo -e "\033[0;31mCOLOR_RED\t\033[1;31mCOLOR_LIGHT_RED"
echo -e "\033[0;35mCOLOR_PURPLE\t\033[1;35mCOLOR_LIGHT_PURPLE"
echo -e "\033[0;33mCOLOR_YELLOW\t\033[1;33mCOLOR_LIGHT_YELLOW"
@twerth
twerth / publish_static_site.rb
Created November 26, 2010 16:59
Converts a dynamic rails (could be any site really) site into static files and rsyncs them up to the server
#!/usr/bin/env ruby
require 'fileutils'
require 'net/http'
URL = 'http://localhost:3000'
OUT_DIR = 'static_output'
SSH_PORT = 2222
SSH_URL = 'your_user@www.your_server.com:/your_folder/on_server/'
@twerth
twerth / gist:510424
Created August 5, 2010 21:40
Skeleton for bash completion ruby script
#!/usr/bin/env ruby
# To use, put this in your bashrc:
# complete -C path/to/script -o default your_command_or_commands_here
# example, to complete the foo and bar commands with the foo.rb script: complete -C ~/bin/foo.rb -o default foo bar
prefix = ARGV[1]
words = `some command here, or just any array`.split.uniq
words = words.select {|w| /^#{Regexp.escape prefix}/ =~ w} if prefix
#!/bin/bash
# Monitors your workstation's network, then reports anytime a GA event is tracked
# on any web page
# You must install ngrep to use. On OSX: sudo port install ngrep
# Change 'en0' to the device you want to to monitor ('en0' is the first ethernet card).
# Use 'ifconfig' to see what devices you have