Skip to content

Instantly share code, notes, and snippets.

View eric-wood's full-sized avatar
🥑
probably snacking

Eric Wood eric-wood

🥑
probably snacking
View GitHub Profile
@eric-wood
eric-wood / get_tweets.rb
Created March 26, 2012 15:03
Load real-time tweets into ActiveRecord (strips out location data)
#!/usr/bin/env ruby
require 'tweetstream'
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require APP_PATH
Rails.application.require_environment!
TweetStream.configure do |config|
config.consumer_key = 'redacted'
@eric-wood
eric-wood / term.rb
Created March 28, 2012 17:21
Write a line the full width of the terminal which updates as the terminal resizes
prev_cols = 0
loop do
cols = `tput cols`.chomp.to_i
if prev_cols != cols
print "\e[1A\e[2K"
puts "="*cols
end
sleep 0.5
prev_cols = cols
@eric-wood
eric-wood / now_playing.rb
Created March 28, 2012 18:45
iTunes track information in your terminal!
# Show iTunes information in real-time in the terminal
def status
cmd = "osascript -e 'tell application \"iTunes\" to player state'"
`#{cmd}`
end
def track_name
cmd = "osascript -e 'tell application \"iTunes\" to name of current track'"
`#{cmd}`
@eric-wood
eric-wood / tetris.rb
Created April 18, 2012 14:54
The beginnings of a tetris game made with curses
require 'curses'
require 'timeout'
include Curses
PIECE1 = <<PIECE
111100000000
111100000000
111111111111
111111111111
a = morse.split(/ /)
h = {
'.-' => 'A',
'-.' => 'N',
'-...' => 'B',
'---' => 'O',
'-.-.' => 'C',
'.--.' => 'P',
'-..' => 'D',
'--.-' => 'Q',
@eric-wood
eric-wood / index.html
Created August 16, 2012 20:46
A google-esque typeahead/autocomplete thingy...maybe I'll turn this into a full-blown extension widget thing eventually!
<input>
@eric-wood
eric-wood / index.html
Created August 19, 2012 15:43
Give it focus and it'll capture keyboard shortcuts kind of like the widgets you see in OS X apps. Useful for letting users set hotkeys. I should probably turn this into a jQuery plugin one day. Let me know if you have any suggestions or code critiques!
<h4>Click on the box and enter a new keyboard shortcut:</h4>
<input id="shortcut-box"><button id="clear-shortcut-box">clear</button>
@eric-wood
eric-wood / refresh_latex.rb
Created September 6, 2012 16:46
Automatic LaTeX re-rendererer
#!/usr/bin/env ruby
# refresh_latex
# Automagically re-render LaTeX files and open the result in a PDF reader.
# Using Skim we can do all of this without losing focus to the editor,
# although I provide code to somewhat accomplish this with Preview.app
#
# As of right now it only works in OS X since it uses the "open" command.
# Feel free to port it to any platform you want to
#
@eric-wood
eric-wood / gradiance.css
Created October 22, 2012 16:27
Userstyle for Gradiance (that silly website my compilers class uses for homework)
/*
* Userstyle for Gradiance (www.newgradiance.com)
*
* Goals:
* - use a sans-serif font (the author failed at CSS and screwed up font-family)
* - make the background color easier on the eyes (white and grey vs. blue and other crap)
* - remove annoying blue colors for the sake of consistency
*/
body {
@eric-wood
eric-wood / Exception.txt
Created November 30, 2012 18:12
GraffitiClient errors -- downloading public sketches
11-30 11:48:58.671: W/System.err(672): org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
11-30 11:48:58.671: W/System.err(672): at [Source: org.apache.http.conn.EofSensorInputStream@46009b68; line: 1, column: 2]
11-30 11:48:58.694: W/System.err(672): at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1432)
11-30 11:48:58.694: W/System.err(672): at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:385)
11-30 11:48:58.701: W/System.err(672): at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:306)
11-30 11:48:58.701: W/System.err(672): at org.codehaus.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:2084)
11-30 11:48:58.701: W/System.err(672): at org.codehaus.jackson.impl.Utf8StreamParser._nextTokenNotInObject(Utf8StreamParser.java:600)
11-30 11:48:58.701: W/System.err(6