Skip to content

Instantly share code, notes, and snippets.

@mattmanning
mattmanning / vim questions
Last active December 29, 2015 12:09
I'm trying to learn vim. These are unanswered questions I have.
I use the "find in project" feature of TextMate a lot. What's a good vim plugin for that? I can fall back on grep on the terminal, but it would be nice to do it in the editor and open files directly from search results.
Is there any way to do fuzzy filename matching / completion with the :edit command?
How do I get it to handle indentations in Ruby code correctly? (2 spaces soft tabs)
@mattmanning
mattmanning / pi.rb
Created August 6, 2012 20:30
Estimate pi using random points and the distance formula
#!/usr/bin/env ruby
#
# Estimate pi using 1 random point:
# ./pi.rb 1
#
# Estimate pi using 1000 random points:
# ./pi.rb 1000
class Point
def initialize
class Array
def inc(val)
map {|e| e + val}
end
end
def add1(arr, val, n)
case n <=> 0
when 0
arr.inc(val)
Dear Matt,
Thank you for contacting Online Support.
Go Daddy is the world’s largest domain name registrar with more than 50 million domain names in our portfolio. Go Daddy has a full time presence in Washington D.C. and takes an active role in Congressional and legislative proposals.
Included in Go Daddy’s legislative efforts is the Stop Online Piracy Act (SOPA). We are currently reviewing the most recent legislative proposal and continue to educate ourselves on the many facets of SOPA. We look forward to working with Congress to refine legislative language about this issue when appropriate.
To review Go Daddy's statement on the matter, you can read this article:
@mattmanning
mattmanning / gist:1430691
Created December 4, 2011 17:02
Fixing Apachebench on OS X Lion
If you're getting this error trying to use ApacheBench on OS X Lion:
Benchmarking mwmanning.com (be patient)...apr_socket_recv: Connection reset by peer (54)
You need to download the latest beta version of Apache and rebuild ab. Here's how (assuming you have homebrew installed).
brew install pcre
tar xzvf httpd-2.3.15-beta.tar.gz
cd httpd-2.3.15-beta
./configure
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0L8ZLq6XbWgDJFTk5RE+hvGKCPHk7OuAME666HgeoG1uBYpUOu9W9OTOoUpSVA1fEsT9v1Q5y39gPoExGknqLEKm7DWQ8j8gITLI9u/pN5W6Mk8n9WzSbn0e9iymjdO7SyUH5y2V+vWjlAeb9RfSY+cpcVpfdVdQ+SaoOGRtr90pGO6Lgun5z2Kh+bgN2D0flQ4uVF+akG2FRZjUL74Slmdgqnji6SODBXemyAsKLx2dLkYVuVHmDYIkFoqDEqxQQ0H0d7oVYp82tsQgm/Q0znVAnZ/Kw18POuUu5hdbsQ5OVA+mhf8KoylAD6Doe2BDi39vJqOZ3U20q0OV2/a6cQ== matthew@redhouse.local
@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...
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 / drugwars.txt
Created June 1, 2011 16:09
Drugwars for the TI-82/83/83+ Calculators
Lbl G
ClrHome
Disp " J.M.'S DRUGWAR"," SIMULATION",""," VERSION 2.00",""," JUST SAY NO."
2000→Z
5000→Y
0→V
100→K
1→B
2→N
0→I
@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)