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
    
  
  
    
  | select z.zonedist,st_asgeojson(z.the_geom) from zones as z join districts as d on st_contains(d.the_geom, z.the_geom) or st_overlaps(d.the_geom,z.the_geom) where d.cd = 301; | 
  
    
      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 self.wb_gp_geojson | |
| self.find_by_sql( | |
| "SELECT z.zonedist,ST_AsGeoJSON(z.the_geom) | |
| FROM zones AS z JOIN districts AS d ON | |
| ST_Contains(d.the_geom, z.the_geom) | |
| OR ST_Overlaps(d.the_geom,z.the_geom) | |
| WHERE d.cd = 301;" | |
| ).map {|r| | |
| { :geojson => JSON.parse(r.st_asgeojson), :zonedist => r.zonedist } | |
| }.to_json | 
  
    
      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
    
  
  
    
  | makeWidebar : function(e, sId) { | |
| var that = this; | |
| this.initialColor = this.getInitialColor(sId); | |
| console.log(sId, this.initialColor) | |
| this.initialColor = this.initialColor.match(/[0-9]{1,3}/g) | |
| this.initialHsl = this.curHsl = rgbToHsl(this.initialColor[0], this.initialColor[1], this.initialColor[2]); | |
| _(this.el).each(function(barSegment) { | |
| that.curHsl[2] = that.curHsl[2] * .80; | |
| that.curRgb = hslToRgb(that.curHsl[0], that.curHsl[1], that.curHsl[2]); | |
| that.curRgb = _(that.curRgb).map(function(q) { return Math.floor(q) }); | 
  
    
      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 jankyLoginStatus = function(cb) { | |
| var that = this; | |
| var statusObj = {}; | |
| // see if we can get "me" | |
| FB.api('/me', function(response) { | |
| // we can't get me. Verify it's an OAuthException, and then sub in notConnected. | |
| if (response['error'] && response['error']['type'] === "OAuthException") { | |
| statusObj['status'] = "notConnected"; | |
| FB.logout(); // just to make sure we don't have stale cookies | |
| return cb(statusObj); | 
  
    
      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 buildFbPostLink = function(post_id) { | |
| var ids = post_id.split("_"); | |
| return "http://www.facebook.com/permalink.php?story_fbid=" + ids[1] + "&id=" + ids[0]; | |
| } | 
  
    
      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
    
  
  
    
  | Kernel.const_get( | |
| self.class.to_s.titleize + "Comparisons" + self.class.to_s.titleize).where("#{self.class.to_s.downcase}_id".to_sym => self.id | |
| ).collect {|r| | |
| Kernel.const_get(self.class.to_s.titleize + "Comparison").find(r.send("#{self.class.to_s.downcase}_comparison_id")) | |
| }.group_by {|r| | |
| r.send(self.class.to_s.downcase.pluralize)[1..-1].collect {|q| q.id} | |
| }.to_a.reduce([]) { |memo, bits| memo << {:ids => bits[0], :ct => bits[1].size }; memo } | 
  
    
      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 getGenericFbImg = function() { | |
| var genders = ['Female', 'Male']; | |
| var gender = genders[Math.floor(Math.random() * 2)]; | |
| return "http://www.facebook.com/images/profile/blankSilhouette" + gender + ".png" | |
| } | 
  
    
      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
    
  
  
    
  | // thx: https://github.com/bcherry/twitter-text-js/blob/master/twitter-text.js | |
| var stringSupplant = function(str, values) { | |
| return str.replace(/#\{(\w+)\}/g, function(match, name) { | |
| return values[name] || ""; | |
| }); | |
| }; | 
  
    
      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 measure | |
| t = Time.now | |
| yield | |
| Rails.logger.info Time.now - 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
    
  
  
    
  | #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'faster_csv' | |
| TIMEFLOW_HEADERS = ["StartDate", "EndDate", "Time", "Events", "Remarks", "Where", "Coordinates", "Source"] | |
| TIMELINESETTER_HEADERS = ["date", "display_date", "description", "link", "series", "html"] | |
| class TF2TS |