Skip to content

Instantly share code, notes, and snippets.

View drewdeponte's full-sized avatar

Drew De Ponte drewdeponte

View GitHub Profile
@drewdeponte
drewdeponte / test_default_value_params
Created August 3, 2015 07:41
test_default_value_params
#!/usr/bin/env ruby
def foo(a, b, c = 1, d = 2)
puts "a: #{a.inspect}"
puts "b: #{b.inspect}"
puts "c: #{c.inspect}"
puts "d: #{d.inspect}"
end
puts "Example 1: Two Arguments Passed"
@drewdeponte
drewdeponte / gist:a2a49abb932d3d277bff
Created July 10, 2015 16:33
Travis Container Service Sudo Errors
0.03s$ sudo service redis-server start
redis-server start/running, process 1810
0.07s$ sudo service elasticsearch start
* Starting Elasticsearch Server it: error setting limit (Operation not permitted)
error: permission denied on key 'vm.max_map_count'
postgresql
Starting PostgreSQL v9.3
2.17s$ sudo service postgresql stop
* Stopping PostgreSQL 9.4 database server 2.46s$ sudo service postgresql start 9.3
This job is running on container-based infrastructure, which does not allow use of 'sudo', setuid and setguid executables.
@drewdeponte
drewdeponte / iternum
Last active August 29, 2015 14:20
Script to output the Bi-Weekly Iteration Number
#!/usr/bin/env ruby --disable-gems
# Installation Instructions:
# Create a file ~/bin/iternum with this content in it and chmod u+x
# ~/bin/iternum. Then make sure that ~/bin is in your PATH environment
# variable and you should be good to go.
WEEKS_IN_ITERATION=2
def week_number
echo "woot"
trap "echo 'got SIGHUP'; exit 255" SIGHUP
trap "echo 'got SIGABRT'; exit 255" SIGABRT
trap "echo 'got SIGSEGV'; exit 255" SIGSEGV
trap "echo 'got SIGURG'; exit 255" SIGURG
trap "echo 'got SIGTTIN'; exit 255" SIGTTIN
trap "echo 'got SIGVTALRM'; exit 255" SIGVTALRM
trap "echo 'got SIGUSR2'; exit 255" SIGUSR2
trap "echo 'got SIGINT'; exit 255" SIGINT
@drewdeponte
drewdeponte / upgrade_rspec2.vim
Created February 6, 2014 20:54
Vim script to get you most of the way to the upgraded state of the rspec2 syntax.
%s/\([a-zA-Z0-9:_@\.]\+\)\.stub\>/allow(\1).to receive/gc
%s/\([a-zA-Z0-9:_@\.]\+\)\.should_receive\>/expect(\1).to receive/gc
%s/\([a-zA-Z0-9:_@\.]\+\)\.should_not_receive\>/expect(\1).not_to receive/gc
%s/\([a-zA-Z0-9:_@\.\?\[\]"'()\/~]\+\)\.should\s*==\s*\(.*\)$/expect(\1).to eq(\2)/gc
%s/\([a-zA-Z0-9:_@\.\?\[\]"'()\/~]\+\)\.should_not\s*==\s*\(.*\)$/expect(\1).not_to eq(\2)/gc
%s/\([a-zA-Z0-9:_@\.\?\[\]"'()\/~]\+\)\.should\s\+\(.*\)$/expect(\1).to \2/gc
%s/\([a-zA-Z0-9:_@\.\?\[\]"'()\/~]\+\)\.should_not\s\+\(.*\)$/expect(\1).not_to \2/gc
%s/stub\>/double/g
%s/mock\>/double/g
☺ spring rspec spec ruby-1.9.3-p327@capture_api 5769m create_capture_rlevents_CAP-1006 5cb6510
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0
/Users/adeponte/code/reachlocal/capture_api/spec/lib/internal_reporting/events_detail_report_form_spec.rb:4:in `<top (required)>': uninitialized constant InternalReporting::Event
sDetailReportForm (NameError)
from /Users/adeponte/.rvm/gems/ruby-1.9.3-p327@capture_api/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `block in load_spec_files'
from /Users/adeponte/.rvm/gems/ruby-1.9.3-p327@capture_api/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `each'
from /Users/adeponte/.rvm/gems/ruby-1.9.3-p327@capture_api/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load_spec_files'
from /Users/adeponte/.rvm/gems/ruby-1.9.3-p327@capture_api/gems/rspec-core-2.12.2/lib/rspec/core/co
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
if [[ $- == *i* ]] # check for interactive shells
then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
fi
@drewdeponte
drewdeponte / gist:4671062
Last active December 11, 2015 22:39
vagrant fail
☹ VAGRANT_LOG=INFO vagrant up
INFO global: Vagrant version: 1.0.6
INFO vagrant: `vagrant` invoked: ["up"]
INFO environment: Environment initialized (#<Vagrant::Environment:0x00000100994890>)
INFO environment: - cwd: /Users/adeponte/Desktop/vagrant_tutorials/vagrant_guide
INFO environment: Home path: /Users/adeponte/.vagrant.d
INFO plugin: Searching and loading any available plugins...
INFO plugin: Loaded 0 plugins.
INFO environment: Loading configuration...
INFO cli: CLI: [] "up" []
class DrewTest
def initialize
@name = self.class.build_name
end
def self.build_name
return "bar"
end
end
@drewdeponte
drewdeponte / rvm_help_mount
Created December 3, 2012 21:56
The help output for rvm mount
☺ rvm help mount ruby-1.9.3-p327@capture_api 32m add_cassandra_migrations 9a8dd8d
Usage:
rvm automount
rvm mount /path/to/ruby [-n {name}]
rvm mount [-r] {https://url/to/ruby.tar.bz2} [name]
## Mounting local compiled rubies