Skip to content

Instantly share code, notes, and snippets.

@lwu
lwu / nutritional-composition.tsv
Created February 23, 2014 03:19
Appendix 3b: Nutritional composition of Balance of Good Health indicators [from Nutrient profiles: Options for definitions for use in relation to food promotion and children’s diets]
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 11 columns, instead of 2. in line 7.
Category Food Food Energy (kJ per 100g) Saturated fat (g per 100g) NME sugar (g per 100g) Sodium (mg per 100g) Calcium (mg per 100g) Iron (mg per 100g) n-3 fatty acids (g per 100g) Fruit and vegetable content* * Fruit and vegetable content has been estimated due to lack of recipe information. The foods in the database were assigned one of the following five values:
Bread, other cereals and potatoes French fries 1174 5.8 1.3 310 14 1 0 10 10% Between 0 and 20% fruit and vegetables (by weight)
Bread, other cereals and potatoes Corn flakes 1601 0.2 8.2 1000 5 7.9 0 10 30% Between 20 and 40%
Bread, other cereals and potatoes Cream crackers 1746 5.4 0 610 110 1.7 0 10 50% Between 40 and 60%
Bread, other cereals and potatoes Crispbread 1312 0.1 3.2 220 45 3.5 0 10 70% Between 60 and 80%
Bread, other cereals and potatoes Crunchy nut corn flakes 1721 0.7 37.7 600 15 7.9 0 10 90% Between 80 and 100%
Bread, other cereals and potatoes Currant buns 1185 1.9 16 317 110 1.9 0 10
Bread, other cereals and potatoes Malt lo
@lwu
lwu / serve.rb
Created February 13, 2015 02:32
serve.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
set :public_folder, 'public'
get '/' do
"Serve.rb"
end
128.12.16.0/255 Stanford.Res.Mirrielees
128.12.21.0/255 Stanford.Res.Manzanita.Lantana
128.12.22.0/255 Stanford.Res.Manzanita.KimballRF
128.12.23.0/255 Stanford.Res.Manzanita.Kimball
128.12.42.0/255 Stanford.Res.Fraternity.KappaAlphaTheta
128.12.43.0/255 Stanford.Res.Sorority.DeltaDeltaDelta
128.12.45.0/255 Stanford.Res.Wilbur.Soto
128.12.47.0/255 Stanford.Res.Wilbur.Otero
128.12.48.0/255 Stanford.Res.Wilbur.Okada
128.12.49.0/255 Stanford.Res.Wilbur.Junipero
@lwu
lwu / .emacs.lisp
Created August 15, 2008 00:42
my .emacs cfg
;; lwu .emacs 2008 (CarbonEmacs)
;; paths and directories
(add-to-list 'load-path "~/src/elisp")
(custom-set-variables)
(custom-set-faces)
; (require 'tramp)
(setq tramp-default-method "ssh")
// This class implements a simple way of displaying point-based data in Mapnik
// (It has yet to be tested as Mapnik r729's memory_featureset is commented out now.)
//
class point_datasource : public mapnik::memory_datasource {
public:
point_datasource() : feat_id(0) {}
void add_point(double x, double y, const char* key, const char* value);
int type() const { return mapnik::datasource::Raster; }
private:
@lwu
lwu / debug_shoes.rb
Created August 26, 2008 03:20
DebugShoes, a quick sketch of a class that adds informative debug interactions to a Shoes app
# Shoes got you down? DebugShoes won't fail silently on ya...
#
class DebugShoes < Shoes
def self.app(*args, &blk)
super(*args) do
begin
self.instance_eval(&blk)
rescue => e
error(e) # log the error and inform the user!
@err_bar = flow :width => 1.0, :height => 32, :top => self.height-32, :left => 0 do
My first Shoes app! Shoes is a "Tiny Toolkit" for informal graphics and windowing:
http://code.whytheluckystiff.net/shoes/
I wanted to be able to easily edit Mapnik stylesheets, hit render, and see the result
right away. While this isn't a great solution -- the prototype shells out to a C++ binary to
re-render the map -- it works for the time being.
A screenshot of the resulting application can be seen here:
http://farm4.static.flickr.com/3095/2801694916_1a051349b4_b.jpg
(http://flickr.com/photos/wu_135/2801694916/sizes/l/)
@lwu
lwu / README
Created September 4, 2008 02:21
This Python code snippet demonstrates basic use of the proposed "PointDatasource"
object exposed by the Mapnik patch attached here: http://trac.mapnik.org/ticket/113
To run this code, you will need to grab a copy of Mapnik from trunk, apply this patch,
and also download the style.xml file below.
@lwu
lwu / shapefly.rb
Created February 4, 2009 01:04
Get the shapefile for a query string using Yahoo/Flickr webservices
#!/usr/bin/env ruby
%w[open-uri hpricot].each {|lib| require lib }
YAHOO_APP_ID = "[yourappidhere]"
FLICKR_KEY = "[yourapikeyhere]"
raise "alarms" if YAHOO_APP_ID =~ /here/
raise "no query arg specified" if ARGV.empty?
# command line query => Y! where query => Flickr getInfo query => wget shapefile => ogr2ogr to KML
@lwu
lwu / osm_bbox.rb
Created February 4, 2009 19:16
Download the OSM XML that contains a given KML (bounding box)
#!/usr/bin/env ruby
%w[open-uri hpricot].each {|lib| require lib }
# get KML bbox and grab OSM XML
raise "no query arg specified" if ARGV.empty?
kml_filename = ARGV[0]
doc = Hpricot(open(kml_filename))
coords = (doc/"coordinates")[0].inner_html.split.map { |x| x.split(',').map {|s| s.to_f } }
longs = coords.transpose[0]