Skip to content

Instantly share code, notes, and snippets.

View jgarber's full-sized avatar

Jason Garber jgarber

View GitHub Profile
@jgarber
jgarber / gist:4998894
Created February 20, 2013 19:58
Finding duplicates
->(klass){ names = klass.all.map(&:name); names.detect {|e| names.count(e) > 1 } }.call Tag
# Up arrow and change to Amenity, Usage, etc. ^
@jgarber
jgarber / clean_up_duplicates.rb
Created January 23, 2013 20:14
Get rid of duplicate BalanceComputations in the main queue
count = 25
name = "main"
starting = 0
ending = starting + count
key = "queue:#{name}"
total_size = 0
keep = {}
loop do
@jgarber
jgarber / gist:4598274
Last active December 11, 2015 12:08
Manually start sidekiq workers
pkill -f god
pkill -f sidekiq
sudo service boocx-app-web stop
sudo service boocx-api stop
cd /home/boocx
cd boocx-api
git pull
bundle
git submodule update --init
@jgarber
jgarber / gist:4597934
Created January 22, 2013 20:04
RBX crash
boocx@ip-10-71-58-116:~/boocx-api$ APP_ENV=production bundle exec rake sidekiq:workers
bundle exec sidekiq -c 50 -l logs/sidekiq.log -q main -v -r ./lib/loader.rb -e production
2013-01-22 20:03:22 +0000: Reconnecting from timeout.
Network Error: eventmachine not initialized: evma_set_pending_connect_timeout
E, [2013-01-22T20:03:22.863555 #28988] ERROR -- : Sidekiq::Processor crashed!
AWS::DynamoDB::Errors::InvalidSignatureException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
The Canonical String for this request should have been
'POST
/
@jgarber
jgarber / gist:4095047
Created November 17, 2012 11:20
Aliases to help count lines of code in a ruby+ember project
alias loc-files='git ls-files **/*.(rb|ru|coffee|scss|handlebars) script bin'
alias loc='loc-files | xargs cat | ruby -ne '\''print unless $_ =~ /^\s*#|^\s*$/'\'' | wc -l'
@jgarber
jgarber / gist:3833029
Created October 4, 2012 11:21 — forked from prathe/gist:1628799
BigDecimal#to_s without trailing zero
class BigDecimalWithoutTrailingZeroes < BigDecimal
def to_digits
_, significant_digits, _, exponent = split
if zero?
'0'
elsif exponent >= significant_digits.size
to_i.to_s
else
to_s('F')
end
@jgarber
jgarber / big_decimal_to_digits.rb
Created October 3, 2012 17:56
BigDecimal#to_digits without trailing zero
class BigDecimalWithoutTrailingZeroes < BigDecimal
def to_digits
_, significant_digits, _, exponent = split
if zero?
'0'
elsif exponent >= significant_digits.size
to_i.to_s
else
to_s('F')
end
@jgarber
jgarber / private.xml
Created August 28, 2012 01:59
KeyRemap4MacBook setup to pair program with one Dvorak - Qwerty ⌘ typist and one Qwerty typist
<?xml version="1.0"?>
<root>
<deviceproductdef>
<productname>APPLE_INTERNAL_KEYBOARD_TRACKPAD_0x024c</productname>
<productid>0x024c</productid>
</deviceproductdef>
<deviceproductdef>
<productname>APPLE_WIRELESS_KEYBOARD_0x22c</productname>
<productid>0x22c</productid>
</deviceproductdef>
@jgarber
jgarber / gist:3007310
Created June 27, 2012 22:30
Use Tmux with iTerm2 across users
brew uninstall tmux
brew install https://raw.github.com/adamv/homebrew-alt/master/other/tmux-iterm2.rb
tmux -S /tmp/pair -C new -s session_name
chmod 777 /tmp/pair
tmux -S /tmp/pair -C attach -t session_name
$ rails c
1.9.2p320 :007 > ActiveRecord::Base.connection.send :postgresql_version
=> 90102
$ rake staging console
ActiveRecord::Base.connection.send :postgresql_version
=> 80311
$ rake production console
ActiveRecord::Base.connection.send :postgresql_version