This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Sankey = function(opts) { | |
| this.opts = opts; | |
| this.el = $("#" + this.opts.el); | |
| this.graphsReady = 0; | |
| this.graphWidth = this.el.width(); | |
| }; | |
| Sankey.prototype.initPaper = function() { | |
| this.paper = Raphael(document.getElementById(this.opts.el)); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RDB | |
| attr_reader :headers, :data | |
| def initialize(f) | |
| @file = File.open(f).readlines | |
| @data = @file.reject {|q| q =~ /^#/ } | |
| @headers = @data.shift.chomp.split("\t") | |
| @data.shift # remove schema line | |
| @data.map! {|q| q.chomp.split("\t")} | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def dms_to_coord(dms, latlng) | |
| re = latlng == 'lat' ? /^([\d]{2})([\d]{2})([\d]{2}(?:\.[\d]+)?)/ : /^([\d]{3})([\d]{2})([\d]{2}(?:\.[\d]+)?)/ | |
| q = dms.split(re) | |
| q.shift | |
| d, m, s = q.map(&:to_f) | |
| res = d + m / 60 + s / 3600 | |
| #yolo | |
| latlng == 'lng' ? "-#{res}" : res | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://www.mapbox.com/blog/processing-landsat-8/ | |
| task :landsat_2014 => :environment do | |
| dirs = Dir["#{Rails.root.to_s}/db/initial/raster/*"].reject {|q| q =~ /tar\.gz/ } | |
| dirs.each do |dir| | |
| scene_id = dir.split("/")[-1] | |
| [4,3,2].each do |band| | |
| `gdalwarp -t_srs EPSG:3857 #{dir}/#{scene_id}_B#{band}.TIF #{dir}/#{scene_id}_B#{band}-projected.tif` | |
| end | |
| `convert -combine #{dir}/#{scene_id}_B{4,3,2}-projected.tif #{dir}/#{scene_id}_RGB-projected.tif && \ | |
| convert -channel B -gamma 0.925 -channel R -gamma 1.03 -channel RGB -sigmoidal-contrast 50x16% #{dir}/#{scene_id}_RGB-projected.tif #{dir}/#{scene_id}_RGB-projected-corrected.tif && \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| color = Dir["./hermitage\ color/*"] | |
| infra = Dir["./hermitage\ infra/*"] | |
| start_color = 213 | |
| start_infra = 297 | |
| color_idx = 0 | |
| infra_idx = 0 | |
| def mk_filename(idx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| color = Dir["./west bay pass 1 color/*"] | |
| infra = Dir["./west bay pass 1 infra/*"] | |
| color_idx = 0 | |
| infra_idx = 0 | |
| def mk_filename(idx) | |
| prefix = "IMG_" | |
| no_str = idx < 1000 ? "0#{idx}" : idx | |
| "#{prefix}#{no_str}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TilesController < ApplicationController | |
| around_filter :up_s3 | |
| def tile_response(map) | |
| respond_to do |format| | |
| format.png { | |
| send_data map.to_png, :content_type => Mime::Type.lookup_by_extension("png"), :disposition => "inline" | |
| } | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //pollxmlgen - a brute force poll api generator... | |
| //@author al shaw | |
| //sept 2009 | |
| //---global stuff-- | |
| error_reporting(0); | |
| //---deal with query strings | |
| $challenger1 = $_GET['challenger1']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| (1..50).each {|i| `curl -u username:pass http://twitter.com/statuses/user_timeline.xml?page=#{i} -o twitter_page_#{i}.xml`} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| ajaxPaginate (will_paginate via jQuery) | |
| @author Al Shaw for TPM PollTracker (http://polltracker.talkingpointsmemo.com) <al@talkingpointsmemo.com> | |
| December 2009 | |
| USAGE! | |
| Stick this in your page somewhere, with the div you want to inject the new content into as the argument. | |
| Here, the injected_div is `.index_polls`. For it to work, you need to have a raw version of your content to inject. | |
| The raw version should take the format <page>?format=list_only&page=[pagenumber]. |
OlderNewer