Skip to content

Instantly share code, notes, and snippets.

View jgarber's full-sized avatar

Jason Garber jgarber

View GitHub Profile
@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
# 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 / wrs.rb
Last active November 11, 2015 00:34
Weighted random sample talk notes
pond = {salmon:1, crucian:3, carp:4, herring:6, sturgeon:8, gudgeon:10, minnow:50}
pond.map { |_, weight| 0.01 ** (1.0 / weight) }
# Fractional exponents are the same as a radical, so
# crucian is the cube-root of 0.01, carp is the 4th-root of 0.01...
# https://www.desmos.com/calculator/zjgygztibi
pond.map { |_, weight| 0.99 ** (1.0 / weight) }
# crucian is the cube-root of 0.99, carp is the 4th-root of 0.99...
This was just a branch off of master. We're not using the Federated path,
but we are using SSO (it'd be nice if we could make this a separate setting)
"""Logs a user in using a token from Keystone's POST."""
referer = request.META.get('HTTP_REFERER')
auth_url = re.sub(r'/auth.*', '', referer)
- request.federated_login = True
+ request.federated_login = False
request.user = auth.authenticate(request=request, auth_url=auth_url)
@jgarber
jgarber / private.xml
Created December 23, 2014 21:21
Karabiner config
<?xml version="1.0"?>
<root>
<deviceproductdef>
<productname>APPLE_INTERNAL_KEYBOARD_TRACKPAD_0x0259</productname>
<productid>0x0259</productid>
</deviceproductdef>
<deviceproductdef>
<productname>APPLE_WIRELESS_KEYBOARD_0x0255</productname>
<productid>0x255</productid>
</deviceproductdef>
@jgarber
jgarber / dotenv-proposal.md
Last active August 29, 2015 14:06
dotenv environments loading proposal

A proposal for loading multiple dotenv files

In regards to my comment on bkeepers/dotenv#120

Proposed heirarchy of environment variable sources

  1. ENV
  2. config/**/env
  3. .env
  4. config/**/env.#{Rails.env}

Keybase proof

I hereby claim:

  • I am jgarber on github.
  • I am jasongarber (https://keybase.io/jasongarber) on keybase.
  • I have a public key whose fingerprint is 70B9 220F 2F0C 6508 1DCD 6009 21EB 9232 CC6C 2F8B

To claim this, I am signing this object:

@jgarber
jgarber / gist:8918120
Created February 10, 2014 15:42
Reset CloudStack fast
curl -Lo Vagrantfile http://git.io/Wt4DiQ
vagrant up
export VBOXID=`cat .vagrant/machines/default/virtualbox/id`
# Wait for it to come up and be ready.
VBoxManage snapshot $VBOXID take clean --live
# Make some VMs on CloudStack: http://10.0.123.101:8080/client/
time (VBoxManage controlvm $VBOXID poweroff && VBoxManage snapshot $VBOXID restorecurrent && VBoxManage startvm $VBOXID --type headless)
...
0.05s user 0.06s system 2% cpu 4.667 total
@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