Skip to content

Instantly share code, notes, and snippets.

Avatar

Zee zspencer

View GitHub Profile
@zspencer
zspencer / embedding_in_node.js
Last active Nov 29, 2018
Implementation Strategies for Integrating External Services in your Application
View embedding_in_node.js
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();
}
View activemodel-type-with-active-model-dirty-example.rb
# 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
View keybase.md

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:

View fib-with-generic-memoize.js
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 / fizz-buzz.clj
Created Apr 17, 2015
Drop this into lighttable and Cmd+enter!
View fizz-buzz.clj
;; Anything you type in here will be executed
;; immediately with the results shown on the
;; right.
(defn fizz? [number]
(zero? (rem number 3)))
(fizz? 1)
(fizz? 3)
(fizz? 6)
(fizz? 10)
View roman_numeral_spec.rb
describe "Converting Arabic Numerals to Roman Numerals" do
NUMERAL_TRANSLATIONS = {
1 => "I",
2 => "II",
5 => "V",
10 => "X"
}
NUMERAL_TRANSLATIONS.each_pair do |arabic, roman|
it "converts #{arabic} to #{roman}" do
expect(arabic_to_roman(arabic)).to eql(roman)
View gist:ccb7dd7d41d2e9a77ca6
---
layout: nil
---
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Musings and Mutterings of Zee Spencer</title>
<link rel="self" type="application/atom+xml" href="http://zeespencer.com/index.xml" />
<link href="http://zeespencer.com/" />
<updated>{{ site.time | date_to_xmlschema }}</updated>
View curl.txt
$ curl -L -v www.apprenticeshipcommunity.com/
* Hostname was NOT found in DNS cache
* Trying 50.31.225.93...
* Connected to www.apprenticeshipcommunity.com (50.31.225.93) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: www.apprenticeshipcommunity.com
> Accept: */*
>
< HTTP/1.1 404 Not Found
@zspencer
zspencer / code.rb
Last active Aug 29, 2015
best times for hacking
View code.rb
OPTIMAL_SCHEDULE_MAPPING = {
:zspencer => [
"Friday 5-7PM PST",
"Wednesday 5-7PM PST",
"Wednesday 6-8PM PST",
"Saturday 10AM-11AM PST",
"Saturday 11AM-12PM PST",
"Sunday 10AM-11AM PST",
"Sunday 11AM-12PM PST"
],
You can’t perform that action at this time.