Skip to content

Instantly share code, notes, and snippets.

Avatar

Jon Abrams JonAbrams

View GitHub Profile
@JonAbrams
JonAbrams / gist:9165022
Created Feb 23, 2014
Example one-line if statement
View gist:9165022
if (age >= 21)
giveBeer()
@JonAbrams
JonAbrams / .gitignore
Last active Aug 29, 2015
Getting a Synth app running on heroku
View .gitignore
node_modules
@JonAbrams
JonAbrams / gist:926fc687b5f1658854dc
Created May 16, 2014
Stub out a JSON API response using Synth
View gist:926fc687b5f1658854dc
exports.getIndex = function (req, res) {
return [
{
title: "Duck Game",
developer: "Landon Podbielski",
tile_image: "https://www.ouya.tv/gamehub/listimgs/6d547a77-1a81-403c-8065-0cea25c5d81c.jpg"
},
{
title: "TowerFall",
developer: "Matt Makes Gamers Inc.",
@JonAbrams
JonAbrams / gist:af4020ea3dd31cf3ffc2
Created Sep 18, 2014
Scrape list of URLs and prints them - Uses promises
View gist:af4020ea3dd31cf3ffc2
var Promise = require('bluebird'); // The best promise library out there
var request = require('request-promise'); // Scrapes the specified url, returns promise e.g. request(url)
var urls = process.argv.slice(2); // List of URLs to scrape
Promise.map(urls, request) // Returns an array of promises to the results of scraping the url
.each(console.log) // Call console.log on each resolved promise
.catch(console.error);
View gist:b2fc1ef65fe85660c7c3
### Keybase proof
I hereby claim:
* I am JonAbrams on github.
* I am jonabrams (https://keybase.io/jonabrams) on keybase.
* I have a public key whose fingerprint is 85C9 3D40 9117 7873 F035 F412 DD07 CC1A 9A43 AED2
To claim this, I am signing this object:
View gist:3b06be7f612c6e0cf6e0
(function () {
var ogJSONParse = JSON.parse;
JSON.parse = function (text, reviver) {
try {
return ogJSONParse(text, reviver);
} catch (err) {
console.error('Failed to parse: ', text);
console.error(err.stack);
return {};
View gist:2853296
history.pushState( {
old_text: old_text.val(),
new_text: new_text.val(),
slug: new_path
}, null, new_path);
View gist:2855320
if (typeof history.pushState === "undefined") {
// Refresh the page to the new URL if pushState not supported
location.href = new_path
}
history.pushState({
old_text: old_text.val(),
new_text: new_text.val(),
slug: new_path
}, null, new_path);
View gist:2889174
$(document).ready(function () {
if (typeof(history.replaceState) !== "undefined") {
history.replaceState({
old_text: old_text.val(),
new_text: new_text.val(),
slug: location.pathname.replace("/", "")
}, null, null);
}
});
View gist:2952547
window.onpopstate = function (event) {
if (event.state == null) {
return;
}
old_text.val(event.state.old_text);
new_text.val(event.state.new_text);
};