This file contains 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
ActionController::Base.session = { | |
:key => '_old_cookie_name', | |
:secret => 'yoursecret' | |
} |
This file contains 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
if cookies['_old_cookie_name'] | |
redis = Redis.new | |
val = redis.get cookies['_old_cookie_name'] | |
if val | |
old_session = Marshal.load val | |
old_session.each{|k,v| session[k] = v} | |
redis.incr 'migrated_sessions' | |
end | |
cookies.delete '_old_cookie_name' | |
end |
This file contains 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
require 'ostruct' | |
class Lexer | |
def initialize | |
@tokens = [] | |
@curr_token_i = -1 | |
end | |
def scan(str) | |
case str |
This file contains 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
.details | |
- if route.distance | |
%h2.distance | |
#{distance(route.distance, :km_mi, true)} |
This file contains 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
// dont worry, not doing a massive refactoring... just going to put | |
// new things and things i touch into this backbone view instead of | |
// adding to the hugely long init below | |
PlannerView = Backbone.View.extend({ | |
el: $('#route_container'), | |
initialize: function() { | |
this.map = Routes.activeMap; | |
this.bind('jump_to:change', _.bind(this.onJumpToChange, this)); | |
// set up places autocomplete for gi |
This file contains 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
// allow setting / triggering of events for all instances | |
_.extend(SG, Backbone.Events); | |
_.extend(SG.prototype, Backbone.Events, { | |
// allow binding to events triggered from any instance | |
// used for hooking into initialize:after by plugins | |
setupGlobalEvents: function() { | |
this.bind('all', function() { | |
var argsWithoutEv = Array.prototype.slice.call(arguments, 1); | |
SG.trigger.apply(SG, [arguments[0], this].concat(argsWithoutEv)); |
This file contains 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
(ns datafun.core | |
(:require [com.twinql.clojure.http :as http]) | |
(:use [cheshire.core])) | |
(defn fetch-url [url] | |
(:content (http/get (java.net.URI. url) :as :string))) | |
(def route (parse-string (fetch-url "http://ridewithgps.com/routes/815146.json") true)) | |
(def points (:track_points route)) |
This file contains 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
desc 'Set best for based on description from tom (cycling and walking only)' | |
task :batch_set_initial_best_for => :environment do | |
modified = [] | |
unmodified = 0 | |
[ | |
[ | |
# walking types | |
[11, 27, 28, 18], | |
# walking best for | |
11, |
This file contains 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
[[1,2],[3,4]].each do |(a,b)| | |
puts "a: #{a}, b: #{b}" | |
end | |
output: | |
a: 1, b: 2 | |
a: 3, b: 4 |
This file contains 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
ruby-1.9.2-p290 :001 > a = Route.find 309908 | |
=> #<Route id: 309908, group_membership_id: 35, name: "test", description: "", created_at: "2011-12-07 17:29:45", distance: 3220.55, elevation_gain: 38.656, elevation_loss: 210.293, visibility: 0, first_lat: 44.003060000000005, first_lng: -123.10965000000002, last_lat: 44.00095, last_lng: -123.09212000000001, secret_key: nil, bad_elevations: false, is_trip: false, postal_code: "97405", locality: "Eugene", administrative_area: "Oregon", has_histogram_image: false, pavement_type_id: nil, country_code: "US", average_rating: 0.0, category_id: 0> | |
ruby-1.9.2-p290 :002 > a.course_points | |
=> [{"x"=>-123.09956999999997, "y"=>43.99689, "t"=>"Left", "n"=>"Skarpt til venstre og inn på Willamette St", "d"=>1558.2270196996717, "i"=>45}, {"x"=>-123.09476000000001, "y"=>44.00251, "t"=>"Right", "n"=>"Sving til høyre og inn på Coachman Dr", "d"=>2319.6279202483624, "i"=>-1}, {"x"=>-123.0924, "y"=>44.00288, "t"=>"Right", "n"=>"Ta til høyre mot E 49th Ave", "d"=>2561.46875989974, "i |
OlderNewer