Skip to content

Instantly share code, notes, and snippets.

View twerth's full-sized avatar

Todd Werth twerth

View GitHub Profile
@twerth
twerth / gist:d39028cdc4c0b4811d15
Last active August 29, 2015 14:02
Some styles
def pbi(st)
st.frame = 'a0:j8'
st.background_color = color.pbi
st.z_position = 1
st.hidden = true
st.clips_to_bounds = true
end
def instruction_image(st)
st.frame = 'a11:j15'
@twerth
twerth / gist:848c9484ad63781ed60d
Last active August 29, 2015 14:17
TOL about new layout method and find_or_append feature for RMQ/RedPotion
class MainScreen < PM::Screen
title "My Screen"
layout MyLayout
stylesheet MainScreenStylesheet
def on_load
stylesheet.layout
set_state user_logged_in: false, first_name: "n/a", last_name: "n/a"
end
#!/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
@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
@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: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 / 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
#
>> class Foo
>> def bar
>> puts 'in bar'
>> end
>> end
=> nil
>> class Foo2 < Foo
>> def bar
>> super
>> puts 'in bar in foo2'
@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
#!/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']