Skip to content

Instantly share code, notes, and snippets.

## Heh.
set nowrap
set regexp
set tabstospaces
set tabsize 2
set autoindent
unset noconvert
## PHP syntax coloring
syntax "php" "\.php[2345s~]?$"
@fixlr
fixlr / .rspec
Created June 27, 2012 20:03
Example .rspec with randomized order
--colour --order rand
@fixlr
fixlr / timestamp_formatter.rb
Created August 10, 2012 14:56
Custom rspec formatter that prints the duration of each example
require 'rspec/core/formatters/progress_formatter'
class TimestampFormatter < RSpec::Core::Formatters::ProgressFormatter
def example_started(example)
@last_start = Time.new
super(example)
end
def example_passed(example)
time_diff = Time.now - @last_start
#!/user/bin/env ruby
require 'benchmark'
ary = []
10000.times {
ary << rand(10000)
}
Benchmark.bm do |x|
#!/usr/bin/env ruby
#
require 'yaml'
require 'librato/metrics'
hostname = `hostname`.strip
queue = Librato::Metrics::Queue.new
config = YAML::load_file(File.dirname(__FILE__) + '/metrics.yml')
Librato::Metrics.authenticate(config.fetch('username'), config.fetch('token'))
class BlobGatherer
@@blobs = %w(foo bar baz qux)
def self.gather
@@blobs.shift
end
end
describe 'Before' do
context ':all' do
@fixlr
fixlr / sort_benchmark.rb
Created August 2, 2013 00:25
Benchmarks of natural sorting in Ruby.
require 'benchmark'
require 'natural_sort'
require 'naturally'
require 'natcmp'
require './lib/sort_authority'
require './lib/sort_authority/ext/enumerable'
require './sensible_sort'
ary = ['x 1'] * 100_000
require 'rake'
shared_context 'rake' do
let(:task_name) { self.class.top_level_description }
subject(:task) { Rake::Task[task_name] }
before(:all) { Rails.application.load_tasks }
its(:prerequisites) { should include('environment') }
end
@fixlr
fixlr / resolve-all-honeybadger.html
Last active August 29, 2015 13:57
Resolve all open Honeybadger.io issues on a page.
<h1>Resolve All favlet</h1>
<a href="javascript:(function(){ $('.toggle-resolved').click() })();">Resolve All (honeybadger)</a>
<ol>
<li>Drag into your browser's bookmark bar.</li>
<li>Click to mark all as resolved in Honeybadger.</li>
</ol>
# 3.2.17
MyModel.new(start_date: '12/03/09')
=> #<MyModel id: nil, start_date: "2009-12-03'>
# 4.0.4
MyModel.new(start_date: '12/03/09')
=> #<MyModel id: nil, start_date: "0012-03-09">