Skip to content

Instantly share code, notes, and snippets.

View tjarratt's full-sized avatar

Tim Jarratt tjarratt

View GitHub Profile
@tjarratt
tjarratt / ie8-leaflet-projection-bug
Created August 10, 2011 23:23
standalone leaflet projection image overlay IE8
<html>
<head>
<script src="./leaflet.js"></script>
<script>
window.onload = function() {
var myCrs = L.Util.extend({}, L.CRS, {
projection: L.Projection.LonLat,
transformation: new L.Transformation(1, 0, 1, 0)
});
@tjarratt
tjarratt / leaflet-polygon-issue
Created August 11, 2011 05:23
reduced case for leaflet issue where polygons are not drawn in the correct location after setLatLngs is called
<html>
<head>
<script src="./leaflet.js"></script>
<script>
window.onload = function() {
var map = new L.Map('map');
map.setView(new L.LatLng(0, 0), 0, true);
var bounds = [
new L.LatLng(0, 0),
#!/usr/bin/env ruby
dudes = {}
i = 0
File.open('/tmp/clean.csv', 'w') do |fh|
File.open('/Users/tjarratt/Desktop/smoking_azver.csv').readlines.each do |line|
# implicitly take array of comma separated values, store them in temporary
# values that you can work with and inspect
@tjarratt
tjarratt / gist:3747152
Created September 19, 2012 01:49
Ruby Set doesn't need |=
require 'set'
fruit = Set.new(['apple', 'banana'])
fruit += ['apple'] # awesome
# => ['apple', 'banana']
def blastoff(n):
if n <= 0:
print 'BLASTOFF'
return
else:
print n
blastoff(n - 1)
def do_n(fn, n, *args):
if n <= 0:
@tjarratt
tjarratt / rebasei
Created April 26, 2013 22:41
interactive git rebase w/ random facts I find myself using interactive rebase a lot in git, and being able to get some random facts at the same time really lightens the mood of development and provides some interesting trivia!
function rebasei {
/usr/local/Cellar/elinks/0.11.7/bin/elinks -dump randomfunfacts.com | sed -n '/^| /p' | tr -d \|;
git rebase --interactive "$@"
}
@tjarratt
tjarratt / json_server.rb
Created May 6, 2013 19:39
An example of a sinatra server that accepts JSON
class JSONServer < Sinatra::Base
post "/endpoint" do
notifications = JSON[request.body.read]
notifications.each do |event|
puts event.inspect
end
return 200
end
end
@tjarratt
tjarratt / Gemfile
Created May 7, 2013 06:11
savon multipart gemfiles
source 'https://rubygems.org'
gem 'savon', :git => 'https://github.com/savonrb/savon'
# until this is merged in, you can use my company's public fork
gem 'savon-multipart', :git => 'https://github.com/nearbuy/savon-multipart'
@tjarratt
tjarratt / extend_include.rb
Created May 7, 2013 22:21
An example of simulating .extend with .include
module Something
def self.included(klass)
klass.extend(ClassMethods)
end
module ClassMethods
def something
puts 'zomg'
end
end
@tjarratt
tjarratt / git-cheat-helper.sh
Created August 30, 2013 00:15
something to implement in shell
# input: N
# foreach N
# export name = $(git log --format=%B -n 1 HEAD | head -1 | sed -e 's/ /_/g)
# git revert HEAD~1
# git stash save $name