Skip to content

Instantly share code, notes, and snippets.

View jsumners's full-sized avatar

James Sumners jsumners

View GitHub Profile
@jsumners
jsumners / app.js
Created May 22, 2015 19:56
A simple usage of Mongoose and its promise API
'use strict';
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test2');
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function dbOpenCB(callback) {
console.log('open callback called');
});
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.2/"
>
<channel>
@jsumners
jsumners / gist:e6b5d0a699f16ba980a3
Last active November 24, 2022 16:09 — forked from thgaskell/gist:5987fccbd8473b5ef78f
Introduction to Sequelize Migrations

What are Migrations

Just like how we use Git to version control source code, we use migrations to manage the state of our database schemas.

I'm not really sure what that means...

Imagine you're working on project with another developer, and you're both tasked with creating a specific part of an event planning application. Let's say you are in charge of creating the Users and your friend is going to create the Events.

Let's say you and your friend divided the work in a way so that neither of you will have to to use each other's code to finish your tasks. While you're working on your part of the application, you only really need to touch the Users table when you are working with the database.

Creating models and migrations

@jsumners
jsumners / pdns_control.py
Created August 20, 2015 19:18
Ansible modules for PowerDNS's authoritative and recursive control utilities
#!/usr/bin/python
DOCUMENTATION = '''
---
module: pdns_control
author: "James Sumners"
short_description: Issue pdns_control commands
requirements: [ pdns_control ]
description:
- Issue PowerDNS authoritative server pdns_control commands
options:
# Let's return to screen
set-option -g prefix C-a
unbind-key C-b
# more intuitive keybindings for splitting
unbind %
bind h split-window -v
unbind '"'
bind v split-window -h
@jsumners
jsumners / data.bin
Last active November 1, 2015 16:37

'use strict';
/**
* Mirrors nodejs.org/dist (mostly). It doesn't grab Windows stuff
* because I'm not interested in that. And it's configured to only
* grab specific version trees.
*
* Relies on a 'dist' directory being present in the directory
* where the script is run.
*/
@jsumners
jsumners / example.yml
Created July 12, 2016 19:23
Ansible plugin to loop subset of a hash
vars:
users:
foo:
uid: 1
bar:
uid: 2
foobar:
uid: 3
tasks:
@jsumners
jsumners / keybase.md
Last active October 17, 2017 18:29
keybase.md

Keybase proof

I hereby claim:

  • I am jsumners on github.
  • I am jsumners (https://keybase.io/jsumners) on keybase.
  • I have a public key whose fingerprint is 7023 E596 B8E3 0C32 B59C BEB3 9F15 17B3 1988 9114

To claim this, I am signing this object:

@jsumners
jsumners / foo.js
Created October 25, 2016 13:40
jsdoc-to-markdown documenting a factory function that returns an object literal
/**
* @module foo
*/
/**
* Describe initialization
* @param {object} someInnerGlobal A context
* @return {fooFactory}
* @alias init
*/