Skip to content

Instantly share code, notes, and snippets.

View jgarber's full-sized avatar

Jason Garber jgarber

View GitHub Profile
@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: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: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 / 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: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 / gist:5698080
Created June 3, 2013 13:16
Work-in-progress: Democratic rebuttal to "Welcome to the Republican Party"
The original:
Father-Daughter Talk
A young woman was about to finish her first year of college. Like so many others her age, she considered herself to be a very liberal Democrat, and was very much in favor of the redistribution of wealth. She was deeply ashamed that her father was a rather staunch Republican, a feeling she openly expressed. Based on the lectures that she had participated in, and the occasional chat with a professor, she felt that her father had for years harbored an evil, selfish desire to keep what he thought should be his.
One day she was challenging her father on his opposition to higher taxes on the rich and the addition of more government welfare programs. The self-professed objectivity proclaimed by her professors had to be the truth and she indicated so to her father. He responded by asking how she was doing in school. Taken aback, she answered rather haughtily that she had a 4.0 GPA, and let him know that it was tough to maintain, insisting that she was taking a very difficult cours
@jgarber
jgarber / gist:5893179
Last active December 19, 2015 03:49
Setting up motion with a raspberry pi camera
ssh-copy-id pi@192.168.X.X
# on the pi
sudo su -
cat <<EOF >> /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="Your SSID Here"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
run_list(
'recipe[chef-solo-search]',
'recipe[rails_application]'
)
default_attributes(
rails: {
app: {name: "sample_app"},
deploy: {
repository: "https://github.com/jgarber/sample_app_2nd_ed.git"
@jgarber
jgarber / pias-ff.rb
Created August 27, 2013 02:34
PIAS fast-forward
require 'json'
def replace_json(node, &replacement_action)
case node
when Hash
node.each_value do |item|
yield item
replace_json(item, &replacement_action)
end
when Array
@jgarber
jgarber / make_one_dimensional.rb
Created September 14, 2013 18:05
Flatten deep hash of attributes into readable keys and values.
def make_one_dimensional(input = {}, output = {}, prefix = nil)
if input.respond_to?(:each)
input.each do |key, value|
key = [prefix, key].compact.join('.')
case value
when Hash
make_one_dimensional(value, output, key)
when Array
value.each_with_index do |v, index|
array_key = "#{key}[#{index}]"