Skip to content

Instantly share code, notes, and snippets.

View mattly's full-sized avatar
💭
I may be slow to respond.

Matthew Lyon mattly

💭
I may be slow to respond.
View GitHub Profile
class MiniTest::Spec
# beacuse test names are really just comments, and therefore a code smell
def self.expect(desc=nil, &block)
@counter ||= 0; @counter += 1
desc ||= "[#{@counter}]"
name = ["test_", description_stack.join(' '), desc].join(' ')
define_method name, &block
end
end

HOWTO: iPhone AT&T Tethering

In 10 steps:

  • Update iTunes to 8.2 via Software Update
  • Update your iPhone to the 3.0 release (out today - June 17th)
  • Download this dmg and mount it: tethering file
  • Enable hidden carrier testing option (in Terminal.app): defaults write com.apple.iTunes carrier-testing -bool TRUE
  • Start up iTunes
require 'time'
require 'date'
STAMP = "2009/06/29 23:19:35 +0000"
class Time
def self.parse_utc(string)
string =~ /(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2})/
utc($1, RFC2822_MONTH_NAME[$2.to_i - 1], $3, $4, $5, $6)
end
$.fn.googleMap = function(address, options) {
var defaults = {
zoom: 14,
mapTypeId: google.maps.MapTypeId.HYBRID
}
options = $.extend(defaults, options || {});
var map = new google.maps.Map(this[0], $.extend(options, {
center: new google.maps.LatLng(44.081996, -123.0286928),
}));
# --- [redacted]
Host *.staging.redacted.com
User mattly
Host *.production.redacted.com
User mattlyon
Port 37846343
Host *.redacted.com
ForwardAgent yes
#!/usr/bin/env ruby
# from http://errtheblog.com/posts/89-huba-huba
home = File.expand_path('~')
Dir['*'].each do |file|
next if file =~ /install.rb/
target = File.join(home, ".#{file}")
if File.exists?(target)
File.unlink(target)
// mattly.mantakeys
// transforms manta coordinates into notes based on row/col relations
post("mattly.mantakeys (c) Matt Lyon 2009\n");
autowatch = 1;
// Setup
inlets = 2;
setinletassist(0, "from manta");
setinletassist(1, "from external");
class MelodyBase
include Alexandria
design :hooks do
hash :predictive
# this indicates there are map.js and reduce.js functions in
# designs/hooks/views/predictive that are designed to be
# called from a group reduce, the results of which look like a
# ruby hash full of keys/values.
# predictive is a map/reduce view that looks at a "hook" document,
irb(main):010:0> pp = d['things'].find.map{|p| p}
=> [{"_id"=>4b26a1aed12cf2e15b000001, "title"=>"testing"}, {"_id"=>4b2ece72c055229bc2000001, "title"=>"test"}, {"_id"=>"4b2ece72c055229bc2000001", "body"=>"updating the previous document"}]
irb(main):012:0> pp[1]['_id'].class
=> Mongo::ObjectID
irb(main):013:0> pp[2]['_id'].class
=> String