Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mattmanning on github.
  • I am mattmanning (https://keybase.io/mattmanning) on keybase.
  • I have a public key whose fingerprint is D38E DA93 16C3 86D4 3B6D 3630 2842 8B94 6FE4 686D

To claim this, I am signing this object:

-----BEGIN PGP MESSAGE-----
Version: GnuPG v1
hQEMAyolo95N7fZGAQf/ZdJBUQsDTe/kIz+wzYv21wzIp5HQV62G8dxVTd9VFZ6R
Zu/Q+WWuwzE70Cykh7bkO4uPVhQhuYciw7iGVkuKqtN/2besBn59jzc6h1nlbcX2
76tsHfCZ9nnyTH8Q+Heav+E9d3blxZol3FjQGuTecjNpA3M6Ljq6GgI7KFL2B4JW
5aBBIoyyi9SScP9+PAof5FRpzMsuVqIzrdFwyeR6Bh0+1KBqfy9WZ0p6v/67eBnw
dFGyx9mXJ70Wvrm3LBqScGNNEocKC+OLlpfV4s2m3TZCNRz9HBivHmBVYSrZtfVs
eXWpVxxoVX0kFI06g0wnqUfb3oAYr5FLOdyH61akb9I3ARW7dadkVrifmKLb85KN
fVW1rDzxvL3qaymdaME+Y8NZ1iPES26TEZ9vK+tL00gSmjB/yV7CCw==
# Project Euler #18 using recursion
T = DATA.readlines("\n").map {|x| x.split(' ').map {|i| i.to_i}}
# one-liner
#def max_sum(r,i) T[r+1] ? [T[r][i] + max_sum((r+1),i), T[r][i] + max_sum((r+1),(i+1))].max : T[r][i] end; puts max_sum(0,0)
def max_sum(row,item)
if T[row+1]
[ T[row][item] + max_sum((row+1),item),
# Project Euler #67
t = DATA.readlines("\n").map {|x| x.split(' ').map {|i| i.to_i}}
# 1-liner
#(t.size-2).downto(0) {|ri| t[ri].each_with_index {|v,i| t[ri][i] = [v + t[ri+1][i], v + t[ri+1][i+1]].max}}; p t[0][0]
(t.size-2).downto(0) do |row_index|
t[row_index].each_with_index do |value,index|
t[row_index][index] = [value + t[row_index+1][index],
var app = require('express').createServer();
var TwitterNode = require('twitter-node').TwitterNode;
var sys = require('sys');
var tweets = [];
var threshold = 10;
app.get('/', function(req, res){
console.log('hello world')
res.send('hello world');
require 'addressable/uri'
def remove_query_param(url, param)
uri = Addressable::URI.parse(url)
params = uri.query_values
params.delete(param)
uri.query_values = params
uri.to_s
end
@mattmanning
mattmanning / gist:989933
Created May 24, 2011 22:47
Cedar rake db:migrate failure without 'include Rake::DSL'
[~/sendgrid-example] heroku run rake db:migrate
Running rake db:migrate attached to terminal... up, run.11
rake aborted!
undefined method `task' for #<SendgridExample::Application:0x000000034ab980>
(See full trace by running task with --trace)
@mattmanning
mattmanning / gist:989923
Created May 24, 2011 22:41
Heroku deploy failure on Cedar with 'include Rake::DSL' in Rakefile
[~/sendgrid-example] git push heroku master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 367 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
-----> Heroku receiving push
-----> Rails app detected
-----> Installing dependencies using Bundler version 1.1.pre.1
Should see something like this:
>> Rails.cache
=> #<ActiveSupport::Cache::DalliStore:0x7f43ecf2e900 @data=#<Dalli::Client:0x7f43ece7be90 @ring=nil, @options={:expires_in=>0}, @servers=["mc5.ec2.northscale.net"]>, @middleware=ActiveSupport::Cache::Strategy::LocalCache, @thread_local_key=:active_support_cache_dalli_store_local_cache_69964857439360, @options={}>
Seeing this:
>> Rails.cache
=> <#ActiveSupport::Cache::MemoryStore entries=2, size=8, options={}>
@mattmanning
mattmanning / gist:1165497
Created August 23, 2011 15:41
bundler unicode
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...