Skip to content

Instantly share code, notes, and snippets.

Michael Kirk michaelkirk

Block or report user

Report or block michaelkirk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:948835
params = {"longitude":194.5432,"latitude":194.5432}
ct = CountThreshold.create!(params)
#was longitude assigned?
puts ct.longitude
# re populate ct from the DB based on it's ID to make sure the fields were persisted.
#was longitude persisted?
michaelkirk / gist:948842
Created Apr 29, 2011
ruby, dumb but true
View gist:948842
#this is dumb but true
irb(main):001:0> a = {:a => 1}
=> {:a=>1}
irb(main):002:0> a['a']
=> nil
irb(main):003:0> a[:a]
=> 1
def setup_test_database(variables):
# Setup the testing database
world.test_runner = django_nose.NoseTestSuiteRunner()
# Setup environment.
# Create Base DB
world.test_db = world.test_runner.setup_databases()
michaelkirk /
Created Mar 6, 2012 for lettuce, using south
from lettuce import after, before, world
from selenium import webdriver
from import call_command
from django.test.simple import DjangoTestSuiteRunner
import lettuce_webdriver.webdriver
def setup_test_database_and_env(variables):
# FIXME when path_for_test_db_setup is outside of this method,
# running ./ test explodes
michaelkirk / unoptimize_to_xs_hack.rb
Created Apr 26, 2012
work around for rails 3 to_xs
View unoptimize_to_xs_hack.rb
# work around for
class String
alias_method :to_xs, :original_xs
# Too many crusty old git branches? Run this to find likely candidates for deletion
# It lists all the remote branches and sorts them by age.
# Folks at pivotal shared this with me
#$ .
# 2012-05-04 09:42:29 -0700 4 minutes ago Ted & Bill \torigin/hey_Bill
michaelkirk / .ackrc
Created Jun 5, 2012
get ack to search cucumbers
View .ackrc
View application_helper.rb
module ApplicationHelper
def usable_time_ago(time)
time_string = if ( - time) < 10.days
time_ago_in_words(time) + " ago"
"<abbr class='datetime' title='#{time}'>#{time_string}</abbr>".html_safe
michaelkirk / download_dom_node.js
Created Aug 28, 2012
client side file generation and download
View download_dom_node.js
// Download a piece of the DOM in a file
// Based on
var $node = $("svg")[0];
var text = new XMLSerializer().serializeToString($node);
// large data URI support is dubious but works on most "modern" browsers.
var data_uri = "data:application/octet-stream," + encodeURIComponent(text);
$("body").append("<a href='" + data_uri + "'>Save</a>");
View overlapping_prefixes.rb
# given a list of numbers, print any prefixes that overlap.
# e.g. [1, 2, 34, 35] has no overlaps
# e.g. [1, 2, 34, 3, 5] overlaps (3 is more general than 34)
# This is useful in the TZip gem, since if our prefixes
# overlap, the more specific mapping will never be used - probably
# not the intended behavior of anyone inputting a mapping.
# Note: this doesn't detect duplicate prefixes, since they've already
You can’t perform that action at this time.