Skip to content

Instantly share code, notes, and snippets.




  • Expose their mappings so that they are programmatically consumable and easily associated w/ the right plugin
  • Expose a list of migrations, which are one of:
    • Transform: Migrate a document from one version to the next
    • Seed: Create a new document
  • Old data which is imported will be run through the migrations before being persisted
View gist:b468830d187635a64cc4eefba93ebbeb
Look for `// CHRIS:` comments to get some inline thoughts.
Well, I learned something new. I've never seen "text/babel" as a script type. How are you transpiling your JSX?
I think if I were interviewing you, I'd ask why you didn't use ES6 modules or TypeScript, and something like Webpack to bundle them. It's something you should familiarize yourself with, since every production stack you will work with will be using some equivalent. (TypeScript + VS Code is a great combo, by the way.)
You'll also benefit from using a linter on your JavaScript. It catches bugs, and ensures you format things nicely (which helps when someone's interviewing / reviewing your code!)
So here's what I'd recommend after a quick scan:
chrisdavies / stripe-currencies.js
Created Nov 7, 2016
A handy list of currency codes and descriptions for use with Stripe.
View stripe-currencies.js
'use strict';
// The STRIPE-supported currencies, sorted by code
export const currencies = [
'description':'United Arab Emirates Dirham'
chrisdavies / open_struct_perf_test.rb
Created Jun 23, 2016
A perf test of Ruby's OpenStruct vs a few other options
View open_struct_perf_test.rb
# OpenStruct is slow. But if you need/want similar functionality,
# you can achieve it with really good perf results. See the impl
# of NotificationEvent below.
# Benchmark results from my Macbook (2.6 GHz Intel Core i5)
# Rehearsal -----------------------------------------------------
# Literal 1.060000 0.020000 1.080000 ( 1.080056)
# NotificationEvent 1.350000 0.000000 1.350000 ( 1.367066)
# OpenStruct 11.500000 0.110000 11.610000 ( 11.646464)
chrisdavies / theme-blue.scss
Created Aug 20, 2015
File-scoped variables in SASS
View theme-blue.scss
// A single mixin per file allows file-scoped variables
@mixin theme-blue {
// File-scoped variables
$main-bg: white;
$main-fg: #333;
$accent-bg: #00B4EF;
$accent-fg: white;
$content-width: 700px;
$gutter-width: 1rem;
chrisdavies / sorted-router-example.js
Last active Dec 16, 2016
A naive wrapper around Backbone router to make it understand route specificity (so route order doesn't matter)...
View sorted-router-example.js
// Example usage of SortedRouter
var SortedRouter = require('./sortedrouter');
var router = new SortedRouter();
// Supports multiple URLs
router.route('', 'books', show('<h1>Books</h1>'));
router.route('books/new', show('<h1>New Book</h1>'));
router.route('books/:id', show('<h1>Show Book</h1>'));
chrisdavies / bad-markup.html
Created Jan 17, 2015
This markup has a problem. Can you spot it?
View bad-markup.html
<!-- Notice that the quoatation marks are not consistent. They should all be
" but some are “ Note, this last one is slanted. I'm not even sure how that
one got in, but I noticed some students had those slanty quotes! That's not
valid HTML! -->
<form method=“get" action=“/save-user”>
<div class="form_div personal">
<label>Name<br><input type=“text” name=“userName” required="required"></label>
chrisdavies / qunit-zombie.js
Last active Apr 12, 2016
Gulp task for running qUnit with zombiejs
View qunit-zombie.js
// This is what your gulp task should look like
gulp.task('qunit', function(done) {
var files = glob.sync('./test/**/*.html');
// Runs through each qunit file (one at a time, though this could be relatively easily parallelized)
function runAllQunits(testFiles) {
var browser = new Zombie();
chrisdavies / toggle-checkbox.html
Created Dec 3, 2014
A CSS-only (no JS) checkbox toggle control. Might make the label text (yes/no) markkup rather than CSS injected content.
View toggle-checkbox.html
<!DOCTYPE html>
<html xmlns="">
<title>Toggle Example</title>
body {
font-family: sans-serif;
chrisdavies / gist:9d9c0aff6229ef1d3eef
Created Oct 28, 2014
Rust - lifetime constraint and generic constraint on a struct
View gist:9d9c0aff6229ef1d3eef
use std::io::Writer;
// This specifies lifetime constraint of 'a
// Type W must implement the Writer trait
// Type W has the lifetime 'a (the same as the related struct instance)
pub struct Foo<'a, W: 'a + Writer> {
writer: &'a mut W
You can’t perform that action at this time.