Skip to content

Instantly share code, notes, and snippets.

View jgarber's full-sized avatar

Jason Garber jgarber

View GitHub Profile
@jgarber
jgarber / gist:7452338
Created November 13, 2013 16:50
One of my students just asked about the behavior below and I didn't have a good answer. Do you have an explanation?
2.0.0p247 :001 > a = [1, 2]
=> [1, 2]
2.0.0p247 :002 > a[1]
=> 2
2.0.0p247 :003 > a[2]
=> nil
2.0.0p247 :004 > a[1,1]
=> [2]
2.0.0p247 :005 > a[2,1]
=> [] ## <- Why is this not nil?
@jgarber
jgarber / MIT-LICENSE.txt
Created April 4, 2012 14:57
Responsive video
Copyright (c) 2011 ZURB, http://www.zurb.com/
@jgarber
jgarber / Vagrantfile
Created February 8, 2014 17:50
CloudStack simulator
Vagrant.configure("2") do |config|
config.vm.box = "cloudstack-simulator"
config.vm.box_url = "https://dl.dropboxusercontent.com/u/4153969/PromptWorks/cloudstack-simulator.box"
config.vm.network "private_network", ip: "10.0.123.101"
config.vm.provider "virtualbox" do |vbox|
vbox.memory = 2048
end
end
@jgarber
jgarber / audio-buttons.py
Last active April 2, 2021 17:15
Dog's talking buttons
# This script requires a Raspberry Pi 2, 3 or Zero. Circuit Python must
# be installed and it is strongly recommended that you use the latest
# release of Raspbian.
import os
import board
import digitalio
import pygame
from tasko import Loop
@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
/
# initialization file (not found)
@jgarber
jgarber / curl
Last active June 21, 2016 14:47
Slow CloudFront on Verizon FiOS in Philadelphia
curl -o bundle.js -v https://d3ki9tyy5l5ruj.cloudfront.net/prod/compressed/build/bundles/c00321e18d419e70a4a6a80d416c4b24de679582/apps/asana/bundle.js
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 54.230.205.176...
* Connected to d3ki9tyy5l5ruj.cloudfront.net (54.230.205.176) port 443 (#0)
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.cloudfront.net
* Server certificate: Symantec Class 3 Secure Server CA - G4
* Server certificate: VeriSign Class 3 Public Primary Certification Authority - G5
> GET /prod/compressed/build/bundles/c00321e18d419e70a4a6a80d416c4b24de679582/apps/asana/bundle.js HTTP/1.1
@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
set background=dark
set guifont=Menlo\ for\ Powerline:h14
colorscheme solarized
set guioptions=egmt
let &colorcolumn=join(range(80,999),",")
@jgarber
jgarber / check_heroku_apps.rb
Created December 3, 2013 14:48
Find Heroku apps that haven't been patched for CVE-2013-4164
GOOD_VERSIONS = %w[1.8.7p375 1.9.2p321 1.9.3p484 2.0.0p353]
apps = `heroku apps`.split("\n")
apps.each do |app|
next if app.include? "My Apps"
app = app.split(" ")[0]
output = `heroku run "ruby -v" -a #{app} 2>&1`
match = output.match(/ruby ([\d.p]+)/)
version = match ? match[1] : "unknown"
puts "#{app}\t#{version}\t#{GOOD_VERSIONS.include?(version) ? "OK" : "UPGRADE"}"
end