Skip to content

Instantly share code, notes, and snippets.

View jasonrhodes's full-sized avatar

Jason Rhodes jasonrhodes

View GitHub Profile
@jasonrhodes
jasonrhodes / 0_reuse_code.js
Created October 21, 2015 17:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jasonrhodes
jasonrhodes / returnPromise.js
Last active August 29, 2015 14:25
Returning inside of promises -- paste this into your console to confirm
console.clear();
if (typeof Promise === "function") {
var resolver = function () { return new Promise(function (resolve, reject) { resolve(); }) };
} else {
var resolver = require('q');
}
resolver()
.then(function() {
export PS1="\n${RED}\u⍟${NO_COLOR} at ${LIGHT_BLUE}\h${NO_COLOR} in ${GREEN}\w${NO_COLOR}\$(__git_ps1 ' on ${PINK}%s')\$(__hg_ps1 ' on ${PINK}%s')${NO_COLOR}\n\$ "
##
# Shell colors
# Note: In OS X Terminal, open preferences and make sure you check
# 'Display ANSI colors' and 'Use bright colors for bold text'
# then you can adjust each color and bright color variant there
##
BLACK="\[\e[0;30m\]" GREY="\[\e[1;30m\]" # in preferences: black
RED="\[\e[0;31m\]" BRIGHT_RED="\[\e[1;31m\]" # in preferences: red
GREEN="\[\e[0;32m\]" BRIGHT_GREEN="\[\e[1;32m\]" # in preferences: green
@jasonrhodes
jasonrhodes / client.js
Created May 8, 2015 13:48
Attempting to convert an all-callback lib to do callbacks and promises together, with one unsolved issue
var q = require('q')
, request = require('request');
module.exports.request = function(options, callback) {
var deferred = q.defer();
request(options, function(err, res, body) {
if (err) {
deferred.reject(err);
return;
module.exports = {
/**
*
* Custom validaton rules for arrays
*
*/
// Verifies that passed in value is an array
isArray: function(list) {
return Array.isArray(list);
repo 1: templates
- shared
- footer.html
- template-a
- index.html
- template-b
- index.html
/template-a/index.html
if (e.keyCode === 8) {
// keeps browser from navigating back a page
event.preventDefault();
deleteLast();
} else if (e.keyCode === 32) {
// keeps browser from scrolling down like some kinda a-hole
event.preventDefault();
canvas.append('<div class="swatch" />');
// && || if
testCase && doSomething();
// vs.
if (testCase) { doSomething(); }