Skip to content

Instantly share code, notes, and snippets.

View jgable's full-sized avatar

Jacob Gable jgable

  • Making Other People Money
  • San Carlos, CA
  • X @jacob4u2
View GitHub Profile
@jgable
jgable / magicalexport.js
Created September 17, 2013 17:59
Ghost Magical Export thingy
if (!process.env.NODE_ENV) {
console.log("Please explicitly set your node environment before running this command: > NODE_ENV=production node exporter.js");
return;
}
var fs = require('fs'),
path = require('path'),
_ = require('underscore'),
@jgable
jgable / index.js
Created September 27, 2013 19:52
Ghost Kudos Plugin Example
var fs = require('fs'),
path = require('path'),
_ = require('underscore'),
when = require('when'),
express = require('express'),
GhostPlugin = require('../../../core/server/plugins/GhostPlugin'),
knex = require('../../../core/server/models/base').Knex,
KudosPlugin;
KudosPlugin = function (ghost) {
@jgable
jgable / postsByTag.js
Created November 13, 2013 19:46
Posts by tag
postsByTag: function (tagId) {
return dataProvider.Tag.findOne({id: tagId}).then(function (found) {
if (!found) {
return when.resolve([]);
}
// TODO: Trim data sent back
return when.resolve(found.related("posts"));
});
}
@jgable
jgable / webhook-wizard.md
Created December 15, 2013 20:52
Adding a webhook for Pull Requests to a GitHub Repo

Download and install the git-at-me module and run the wizard function.

npm install git-at-me 
echo "require('git-at-me').wizard();" >> git-wizard.js
node git-wizard.js
  1. Generate a token by selecting the Token option
  2. Enter your GitHub username
@jgable
jgable / module.js
Last active January 4, 2016 12:49
ES6 Module with export default { ... }
import { $ } from 'vendor/libraries';
var foo = {
something: true
};
export default { foo: foo, bar: true };
@jgable
jgable / source1.js
Created February 12, 2014 18:50
Traceur Compiler Source Maps Examples
import { hello } from 'test1';
export var things = {
'1': 0,
'2': 0,
'3': 0,
updateThing: function (name, val) {
this[name] = val;
@jgable
jgable / sandbox-mocha.js
Created May 8, 2014 15:29
Sinon Sandbox Example
var sinon = require('sinon'),
Widget = require('../../widget');
describe('My widget', function () {
var sandbox;
beforeEach(function () {
// Create a sandbox for the test
sandbox = sinon.sandbox.create();
});
@jgable
jgable / derived.swift
Created June 12, 2014 19:55
Derived Class Method not ran
// Playground - noun: a place where people can play
import Cocoa
// Base class for parameters to POST to service
class APIParams {
func getData() -> Dictionary<String, AnyObject> {
return Dictionary<String, AnyObject>()
}
}
@jgable
jgable / permutations.js
Created September 15, 2014 14:53
Word Permutations
// To run with node: npm install lodash && node perms.js star
var _ = require('lodash'),
words = ['stars'];
function getPermutations(word) {
// Stop case for single character
if (word.length === 1) {
return [word];
}
@jgable
jgable / store.js
Created February 27, 2015 17:35
FluxBone Store with Dispatcher helpers
var dispatcher = require('./dispatcher');
/** @class Store */
var Store = Backbone.Collection.extend(/** @lends Store.prototype */ {
/**
* Instantiate a new store from the passed in models and options. Will attempt to load models
* from `getInitialData` if none are passed in.
*
* @constructor