Skip to content

Instantly share code, notes, and snippets.

desc "build docs"
task :docs do
require 'rdiscount'
require 'erb'
license = File.open('LICENSE.txt','r').read
mdown = RDiscount.new(ERB.new(File.open('doc/doc.markdown','r').read).result(binding), :smart).to_html
wrapper = File.open('doc/doc_wrapper.erb','r').read
mdown = File.open('index.html','w+') do |f|
f.write ERB.new(wrapper).result(binding)
end
desc "generate gh-pages"
task :gh_pages do
`rake docs`
`git branch` =~ /^\* (.+)?\n/
current_branch = $1
`git commit -am "docs"`
`git checkout gh-pages`
`git merge #{current_branch}`
def minify_css(css)
# take out new lines
css.gsub!(/\n/,'')
# take out spaces between selectors and rule blocks
css.gsub!(/([\.a-zA-Z_\-\#]+?)\s*\{\s*([^\{\}\s])?/,'\1{\2')
# take out spaces between rule block endings and selectors
css.gsub!(/\}\s*([\.a-zA-Z_\-\#]+?)/,'}\1')
var TimelineSetter = window.TimelineSetter = (window.TimelineSetter || {});
var Timeline = TimelineSetter.Timeline = function(){...};
Timeline.boot = function(){
$(function(){
...
});
%w[css html].each do |lang|
it "should compress #{lang}" do
k = Kompress.const_get("#{lang.upcase}").new(Kernel.const_get("BIG_#{lang.upcase}"))
k.send(lang).should eql Kernel.const_get("SMALL_#{lang.upcase}")
end
end
#!/usr/bin/env bash
WD=`pwd`
tiger_em () {
directory=$WD/$1
shift
until [ -z "$1" ]
do
get_em $directory "ftp://ftp2.census.gov/geo/tiger/TIGER2010/"$1
shift
(function() {
var Geocoder = function(address, cb) {
this.address = address;
this.geocoder = new google.maps.Geocoder();
this.geocode(cb);
};
Geocoder.prototype = {
geocode : function(cb) {
if (this.address === "") return false;
#!/usr/bin/env ruby
require 'net/ftp'
def get_roads
`cd shapes`
ftp = Net::FTP.new('ftp2.census.gov')
ftp.login
files = ftp.chdir("/geo/tiger/TIGER2010/ROADS")
files = ftp.list.collect {|r| r.match(/tl.*$/)[0]}
ogr2ogr -wrapdateline -t_srs EPSG:4326 nyzd_4326.shp nyzd.shp
irb(main):034:0> Shape.first.the_geom.boundary.first.points[0]
=> #<RGeo::Geos::PointImpl:0x81750c70 "POINT (-87.7805499999999910 32.4882309999999990)">
irb(main):035:0> Shape.first.the_geom.boundary.first.points[0].x
=> -87.78055
irb(main):036:0> Shape.first.the_geom.boundary.first.points[0].y
=> 32.488231
select name, ST_AsGeoJSON(the_geom) from shapes as json limit 1;