Skip to content

Instantly share code, notes, and snippets.

Avatar
☀️
😎

Simeon Willbanks simeonwillbanks

☀️
😎
View GitHub Profile
@simeonwillbanks
simeonwillbanks / barrier.rb
Created Jan 24, 2014
Create resource contention. http://rubygems.org/gems/barrier "barrier", "~> 1.0.0" #gem #ruby
View barrier.rb
require 'thread'
# A synchronization barrier enables multiple threads to wait until all threads
# have all reached a particular point of execution before any thread
# continues.
class Barrier
# Initialize new barrier. The _count_ argument specifies the number of threads
# that must call #wait before any of them successfully return from the call.
# The value specified by _count_ must be greater than zero.
@simeonwillbanks
simeonwillbanks / benchmark.rb
Last active Jan 3, 2016
Copy Hash #ruby #benchmark
View benchmark.rb
require 'benchmark'
puts "\n\n"
puts RUBY_VERSION
iterations = 100_000
Benchmark.bmbm do |bm|
bm.report 'Hash#dup' do
WHITELIST1 = { :protocols => { :from => 'constant' } }
@simeonwillbanks
simeonwillbanks / .vimrc
Created Jan 10, 2014 — forked from robmiller/.vimrc
#writing #TechWordsToAvoid #vim
View .vimrc
highlight TechWordsToAvoid ctermbg=red ctermfg=white
autocmd FileType markdown match TechWordsToAvoid /\c\<\(obviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy\)\>/
autocmd BufWinEnter *.md match TechWordsToAvoid /\c\<\(obviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy\)\>/
autocmd InsertEnter *.md match TechWordsToAvoid /\c\<\(obviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy\)\>/
autocmd InsertLeave *.md match TechWordsToAvoid /\c\<\(obviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy\)\>/
autocmd BufWinLeave *.md call clearmatches()
@simeonwillbanks
simeonwillbanks / byebye.sh
Created Dec 18, 2013
Kill development processes #bash #ruby
View byebye.sh
$ export BYEBYE=ruby
$ ps x | grep $BYEBYE | cut -d' ' -f1 | xargs kill -9
@simeonwillbanks
simeonwillbanks / bulk.sh
Created Oct 2, 2013
Redis Bulk Operations #redis #xargs #wc #unix
View bulk.sh
# Count all keys which match a wildcard from database 1
redis-cli -n 1 KEYS "foo:*" | wc -l
# Delete all keys which match a wildcard from database 1
redis-cli -n 1 KEYS "foo:*" | xargs redis-cli -n 1 DEL
@simeonwillbanks
simeonwillbanks / .git-config
Created Sep 26, 2013
Git diff binary files with Apache Tika #git #tika #diff
View .git-config
# .git/config
[diff "office"]
binary = true
textconv = /usr/bin/java -jar /usr/local/share/tika-app.jar --text
@simeonwillbanks
simeonwillbanks / nodes_presenter.rb
Last active Dec 23, 2015
Presenter < SimpleDelegator #ruby
View nodes_presenter.rb
class NodesPresenter < SimpleDelegator
def initialize(id_or_object)
@node = id_or_object.is_a?(Integer) ? NodeDecorator.find(id_or_object) : id_or_object.decorate
super @node
end
def ancestor(key)
NodesPresenter.new(@node.ancestor(key))
end
@simeonwillbanks
simeonwillbanks / .rspec
Created Sep 18, 2013
rspec-instafail integration #rspec #tdd #ruby
View .rspec
--colour --drb --require rspec/instafail --format RSpec::Instafail
@simeonwillbanks
simeonwillbanks / .gemrc
Created Sep 18, 2013
example gemrc #gem #gemrc #ruby
View .gemrc
# http://guides.rubygems.org/command-reference/#gem_environment
---
install: --ri --rdoc # gem install with docs
update: --ri --rdoc # gem update with docs
verbose: true # Verbosity of the gem command
backtrace: true # Print backtrace when RubyGems encounters an error
@simeonwillbanks
simeonwillbanks / test-install.sh
Last active Dec 21, 2015
Use rbenv and zsh to run a test suite against multiple rubies. #ruby #zsh #rbenv #tdd
View test-install.sh
rubies=(1.8.7-p358 ree-1.8.7-2011.03 1.9.2-p290 1.9.3-p429 2.0.0-p247)
for r in $rubies
do
rbenv local $r; bundle install --without debug; CI=true bundle exec rake;
done