Skip to content

Instantly share code, notes, and snippets.

@lwu
lwu / pfly09.rb
Created March 29, 2009 10:57
= AllisonF + Brianna + Constance + Emily + Lucy + RKelly + Wushu
#!/usr/bin/env ruby
# primary source data: zteam car manifests :)
santabar = %w(AllisonF AnnieW Becky Brianna Brittany Chips Constance Dex
Emily Firebelly Frogger Galen LeslieR Lolo Lucy Marielle Marisa
RKelly Rosalie Scout Sparky Skiddo Tajah Tank Wushu)
davis = %w(AllisonF AnnieW Annika Ariana Brianna Chips Constance Emily
Firebelly Gina Izzy Laurel Lucy RKelly RachelL Rosalie SarahC
#!/usr/bin/env ruby
require 'open-uri'
days = []
(1..15).each do |pg|
query = 'days+ago+whendidyoujointwitter'
s = open("http://search.twitter.com/search.json?q=#{query}&rpp=100&page=#{pg}")
days << s.read.scan(/(\d+) days ago/).flatten.map { |st| st.to_i }
end
This ruby script takes in a TSV of type co-occurrence probabilities,
does some simple filtering, and prints the output.
The filtered text file is suitable for node-link diagram visualization.
@lwu
lwu / geo_test.rb
Created July 28, 2009 02:25
Experiment with Wikipedia opensearch
#!/usr/bin/ruby
#!/usr/bin/env ruby # MacPorts 1.87
air = {
:input => ["JFK", "LGA", "EWR"],
:expected => ["JFK Airport", "LaGuardia Airport", "Newark Liberty International Airport"]
}
# Note that opensearch "Mount Whitney NGS" returns empty, but the Wikipedia on-site search tries to return something!
@lwu
lwu / PKSimple.rb
Created September 11, 2009 18:36
Pressure-sensitive keyboard IO in Ruby (experimental MSFT hw!)
#!/usr/bin/env ruby
#
# Pressure-sensitive keyboard IO in Ruby (experimental MSFT hw!)
%w(rubygems serialport).each { |lib| require lib } # sudo gem install serialport pls
ser = SerialPort.new("/dev/tty.usbserial-A6007kA6", 115200, 8, 1, SerialPort::NONE)
ser.write("q") # initiate continuous ASCII mode
while true
@lwu
lwu / url.txt
Created April 13, 2012 20:51
URLs
http://a.espncdn.com/combiner/i?img=/photo/2012/0306/ncb_u_barkleysmile_134.jpg
http://a.espncdn.com/combiner/i?img=/photo/2012/0326/grant_g_crawford_gb1_134.jpg
http://a.espncdn.com/i/columnists/reilly_rick_80fp.png
http://a.espncdn.com/i/columnists/simmons_bill_80fp.png
http://a.espncdn.com/i/ncb/ncaatourney12/fp_check_bracket.gif
http://a.espncdn.com/media/motion/2012/0325/dm_120325_nfl_ontheclock_robertgriffinIII_thumdnail_wbig.jpg
http://a.espncdn.com/media/motion/2012/0327/dm_120327_nfl_schefter_payton_parcells_thumdnail_wbig.jpg
http://a.espncdn.com/photo/2012/0326/as_zoom_134.jpg
http://a.espncdn.com/photo/2012/0326/mlb_g_suzuki_gb1_110.jpg
http://a.espncdn.com/photo/2012/0327/nba_a_dirky_cr_110.jpg
@lwu
lwu / 1+1
Created September 6, 2012 06:08
Gist defect?
0
@lwu
lwu / poe.rb
Created November 13, 2013 00:15
code poetry 2013
#!/usr/bin/env ruby
require 'rubygems' # gratitude
require 'nokogiri' # arigato
h=Nokogiri::HTML(`curl http://www.biblegateway.com/passage/?search=Psalm+23&version=KJV&interface=print`).css(".text").text.split(/\W/)
%w(Zarvox Princess Cellos).each{|v|`say -v #{v} #{[9,7,9,123,9,42,55,118,104,108,6,7,100,10,95,96,86,76,120,72,106,107,63,32,42].map {|i|h[i]}.join(' ')}`}
@lwu
lwu / slam.el
Created November 21, 2013 04:19
Poetry Code Slam 2013 #performance
(fset 'copy-character-from-other-buffer
[?\C-x ?5 ?o ?\C- right escape ?w ?\C-x ?5 ?o ?\C-y])
(global-set-key [(a)] 'copy-character-from-other-buffer)
(global-set-key [(s)] 'copy-character-from-other-buffer)
(global-set-key [(d)] 'copy-character-from-other-buffer)
(global-set-key [(f)] 'copy-character-from-other-buffer)
(global-set-key [(g)] 'copy-character-from-other-buffer)
(global-set-key [(h)] 'copy-character-from-other-buffer)
(global-set-key [(j)] 'copy-character-from-other-buffer)
@lwu
lwu / menustat-search-results-1385156374.csv
Created November 22, 2013 22:08
CSV Export from @nycHealthy MenuStat.org website
We can't make this file beautiful and searchable because it's too large.
"Restaurant ","Food Category ","Item_Name ","Item Description 2013 ","Servings Per Item 2013 ","Serving Size 2013 ","Serving Size Unit 2013 ","Servings Size Text 2013 ","Calories 2013 ","Total Fat (g) 2013 ","Saturated Fat (g) 2013 ","Trans Fat (g) 2013 ","Cholesterol (mg) 2013 ","Sodium (mg) 2013 ","Potassium (mg) 2013 ","Carbohydrates (g) 2013 ","Fiber (g) 2013 ","Sugar (g) 2013 ","Protein (g) 2013 "
Applebee's,"Appetizers & Sides","Appetizer Sampler","Appetizer Sampler, Appetizers, As Served",,"=""-""","=""-""",,"=""2300-2460""","=""143-160""","=""43-47""","=""2-2.5""","=""-""","=""5440-6150""","=""-""","=""157-183""",13,"=""-""","=""89-91"""
Applebee's,"Appetizers & Sides","Applesauce, Kids","Applesauce, Side, Kids",,"=""-""","=""-""",,90,0,0,0,"=""-""",5,"=""-""",23,2,"=""-""",0
Applebee's,"Appetizers & Sides","Baked Potato","Baked Potato, Steaks & Toppers or Soups, Salads & Sides",,"=""-""","=""-""",,330,18,11,0,"=""-""",170,"=""-""",41,3,"=""-""",6
Applebee's,"Appetizers & Sides","Boneless Wings, Class