Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥

Andrew Sullivan sllvn

🔥
View GitHub Profile
View cardioActivities.csv
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 9.
Date,Type,Route Name,Distance (mi),Duration,Average Pace,Average Speed (mph),Calories Burned,Climb (ft),Average Heart Rate (bpm),Notes,GPX File
2013-01-31 20:20:00,Running,,4.00,0:37:00,9:15,6.49,615.0,,,"4.0 @ 6.5, easiest 4 miles I've run yet. Didn't feel like running, but after first mile, pace was easy.",
2013-01-29 19:00:00,Running,,2.75,0:25:30,9:16,6.47,423.0,,,"2.75 @ 6.5",
2013-01-28 18:00:00,Running,,4.25,0:41:50,9:51,6.10,658.0,,,"1.25 @ 6.8, 0.25 @ 3.5, 1.25 @ 6.8, 0.25 @ 3.5, 1.25 @ 6.8",
2013-01-25 19:00:00,Running,,4.25,0:43:30,10:14,5.86,662.0,,,"2.5 @ 6.5, 0.25 @ 3.5, 0.75 @ 6.5, 0.25 @ 3.5, 0.5 @ 6.5",
2013-01-23 18:00:00,Running,,3.00,0:31:00,10:20,5.81,469.0,,,"1 @ 6.5, 0.25 @ 3.5, 1 @ 6.5, 0.25 @ 3.5, 0.5 @ 7.3",
2013-01-20 12:30:00,Running,,4.50,0:45:30,10:07,5.93,699.0,,,"1.25 @ 6.5, 0.25 @ 3.5, 1.25 @ 6.5, 0.25 @ 3.5, 1.5 @ 6.5",
2013-01-13 18:00:00,Running,,1.75,0:18:00,10:17,5.83,273.0,,,"Left shin pain cut run short.",
2013-01-10 12:40:00,Cycling,,2.90,0:10:00,3:27,17.40,207.0,,,"Co
View gist:4726304
[83] pry(main)> reader.objects[2].instance_of? Hash
=> true
[84] pry(main)> reader.objects.select { |x| x.instance_of? Hash }
=> []
View gist:4693484
def display_name
name = self.name
name = "N/A" if name.blank? or name.nil?
name
end
View contract.rb
class Contract < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :contract_type
has_many :contract_terms
def display_name
"#{self.contract_type.name}: #{self.person_name}"
end
View contract.rb
class Contract < ActiveRecord::Base
belongs_to :contract_type
has_many :contract_terms
def display_name
"#{self.contract_type.name}: #{self.person_name}"
end
def person_name
# todo: this seems inefficient, do we want to throw important metadata in the
View gist:4519904
p() { cd ~/projects/$1; }
_p() { _files -W ~/projects -/; }
compdef _p p
View gist:3267523
self.dateFormat = [[NSDateFormatter alloc] init];
[self.dateFormat setDateFormat:@"d MMMM YYYY"];
NSLog(@"now formatted = %@", [self.dateFormat dateFromString:@"5 August 2012"]);
View gist:3249355
import arcpy
from arcpy import env
env.workspace = "C:\UtahAddressModel\SouthJordan_July2012"
rows = arcpy.UpdateCursor("SJC_AddressPts")
for row in rows:
if row.getValue("TYPE") == "CHURCH":
row.setValue("TYPE_D", "REL")
View knight-random-walk.rb
knight = Knight.new(0, 0)
memo = Array.new
1.upto(100000) do |x|
knight.move
knight.move until knight.position == [0, 0]
puts x if x % 100 == 0
memo << knight.count
knight.count = 0
end
View knight-random-walk.rb
#!/usr/bin/env ruby
class Knight
attr_accessor :x, :y, :count
def initialize(x, y)
@x, @y, @count = x, y, 0
end
def position