Skip to content

Instantly share code, notes, and snippets.

View zspencer's full-sized avatar

Zee zspencer

View GitHub Profile
@zspencer
zspencer / embedding_in_node.js
Last active November 29, 2018 16:14
Implementation Strategies for Integrating External Services in your Application
const client = require('twilio')(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
class Person {
sendVerificationCode() {
client.messages
.create({
body: i18n__('verification_code', { verificationCode: this.verificationCode }),
to: this.mobileNumber, from: process.env.TWILIO_OUTGOING_NUMBER
})
.done();
}
# I frequently use ActiveModel::Type to define complex objects in my database. When doing
# so, there is always a moment when I run into a bug that is caused by me forgetting to
# support ActiveRecord knowing that the complex type is dirty!
# So here's a quick example that I can reference when I go to make a complex type again
# that plays nicely *with* ActiveModel::Dirty!
# frozen_string_literal: true
begin

Keybase proof

I hereby claim:

  • I am zspencer on github.
  • I am zspencer (https://keybase.io/zspencer) on keybase.
  • I have a public key ASAn-Zbj9I_z_uZTV5lT3lfUHI6-dnfLeBnbJQRV5Icmlgo

To claim this, I am signing this object:

b_favorite_color: true
@zspencer
zspencer / bootstrap.sh
Created May 30, 2012 02:04
Bootstrapping like a boss
#symlink gcc to a non-llvm version installed xCode's CLI tools
if [ -f /usr/bin/gcc-4.2 ]; then
sudo rm /usr/bin/gcc
sudo ln -s /usr/bin/gcc-4.2 /usr/bin/gcc
sudo rm /usr/bin/cc
sudo ln -s /usr/bin/gcc-4.2 /usr/bin/cc
fi
@zspencer
zspencer / .gitconfig
Last active April 6, 2016 00:17
git remove-extraneous-branches
[alias]
# Prints merged branches without the current working branch and mainline branches
extraneous-branches = "!f() { git branch --merged | grep -v -e 'gh-pages' -e 'master' -e 'staging' -e 'production'; }; echo `f`"
# Deletes the extraneous branches with a soft -d
remove-extraneous-branches = "!f() { git extraneous-branches; }; git branch -d `f`"
reb = remove-extraneous-branches
function findFib(index) {
var values = [0,1];
if(index in values) { return values[index]; }
return findFib(index - 2) + findFib(index - 1);
}
function memoize(fn) {
var cache = {};
return function() {
var args = Array.prototype.slice.call(arguments);
@zspencer
zspencer / game_of_life.rb
Created October 10, 2013 19:46
Conways Game of Life
class Judge
def cast_judgement(cell)
if cell.neighbor_count < 2 || cell.neighbor_count > 3
cell.kill!
end
end
end
class Cell
[zee@prime ~]$ sudo salt 'hedgehog.makeheadspace.com' grains.items
hedgehog.makeheadspace.com:
cpu_flags: fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good unfair_spinlock pni vmx cx16 popcnt hypervisor lahf_lm
cpu_model: QEMU Virtual CPU version 1.0
cpuarch: x86_64
defaultencoding: None
defaultlanguage: None
domain: makeheadspace.com
fqdn: hedgehog.makeheadspace.com
gpus:
@import "susy";
$total-columns: 12;
$column-width: 4em;
$gutter-width: 1em;
$grid-padding: $grid-padding;
body {
font-family: Helvetica, sans-serif;
background-image: image-url('gray_jean.png');