Skip to content

Instantly share code, notes, and snippets.

@zachinglis
zachinglis / gist:9831849
Last active August 29, 2015 13:57
console.loge
window.console.loge = function(msg) {
var gifs = [
'http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-wink-212.gif',
'http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-shake-space-212.gif',
'http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-peepers-212.gif',
'http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-prizza-212.gif',
'http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-hat-212.gif',
'http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-gradient-212.gif',
'http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-fat-212.gif',
'http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-rainbow-212.gif',
@murilopolese
murilopolese / yolo
Last active August 29, 2015 14:06
Yolo Deploy
#!/bin/bash
git add -A && git commit -m "yolo" && git push $1 $2
@paulobarcelos
paulobarcelos / gist:5d9d8c2859f85fc5749a
Created November 18, 2014 18:43
eu sou sou hacker
var sync = function(){console.log('sync')}
var leftPage = false
var t = 0;
var c = function(){
if((Date.now()-t) > 500){
leftPage=true
}
else if(leftPage){
leftPage=false; sync()
};
@connor
connor / keysocket-rdio.js
Created January 1, 2012 23:55
Add keyboard shortcut to Rdio's web app
// goes with Boris Smus's keysocket extension <https://github.com/borismus/keysocket/>
var PREV = 20;
var PLAY = 16;
var NEXT = 19;
var fake_prev_el = document.createElement('div');
fake_prev_el.id = "fake_prev_el";
fake_prev_el.style.height = 0;
fake_prev_el.style.width = 0;
@rtgibbons
rtgibbons / post_test.js
Last active October 1, 2015 19:26
mocha test on Keystone Model
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
require('dotenv').load();
var keystone = require('keystone');
var chai = require('chai');
var dbURI = process.env.MONGO_URL
keystone.init({
'name': 'Post Model Test',
's3 config': {} //has to be set, but isn't used in our models
@rglover
rglover / gp-specials-board.css
Created August 8, 2012 01:11
Google Prettify - Specials Board CSS Theme
.prettyprint .str, code .str { color: #a9758c; } /* string */
.prettyprint .kwd, code .kwd { color: #d58840; } /* keyword */
.prettyprint .com, code .com { color: #767979; font-style: italic; } /* comment */
.prettyprint .typ, code .typ { color: #80aac6; } /* type */
.prettyprint .lit, code .lit { color: #ac758c; } /* literal */
.prettyprint .pun, code .pun { color: #fff; } /* punctuation */
.prettyprint .pln, code .pln { color: #fff; } /* plaintext */
.prettyprint .tag, code .tag { color: #fecf84; } /* html/xml tag */
.prettyprint .atn, code .atn { color: #ce8a45; } /* html/xml attribute name */
.prettyprint .atv, code .atv { color: #b2c869; } /* html/xml attribute value */
@tracend
tracend / handlebars.localisation.js
Last active October 16, 2018 18:11
Handlebars Localisation Helper #cc
// Handlebars Localisation Helper
// Source: https://gist.github.com/tracend/3261055
Handlebars.registerHelper('l10n', function(keyword) {
var lang = (navigator.language) ? navigator.language : navigator.userLanguage;
// pick the right dictionary (if only one available assume it's the right one...)
var locale = window.locale[lang] || window.locale['en-US'] || window.locale || false;
// exit now if there's no data
if( !locale ) return target;
@creationix
creationix / init.lua
Last active November 1, 2019 11:13
Websocket server in nodemcu using new crypto module.
wifi.setmode(wifi.STATION)
wifi.sta.config("creationix","noderocks")
wifi.sta.connect()
tmr.alarm(0, 1000, 1, function ()
local ip = wifi.sta.getip()
if ip then
tmr.stop(0)
print(ip)
dofile("websocket.lc")
dofile("main.lc")
@ofZach
ofZach / gist:d67d2ab2a0aa183b7d34f72263d5c5bd
Created November 27, 2017 07:44
looping 1d noise (tiling)
ofPolyline temp;
float ff = ofGetElapsedTimef();
for (int i = 0; i < 100; i++){
float angle = ofMap(i, 0, 100, 0, TWO_PI);
ofPoint pt= ofPoint(400,400);
float radius = 200 + ofSignedNoise(ff*0.1, cos(angle)*0.3, sin(angle)*0.3) * 100;
pt += radius * ofPoint(cos(angle), sin(angle));
temp.addVertex(pt);
}
temp.setClosed(true);
@JedWatson
JedWatson / KeystoneApiExample.md
Last active July 26, 2021 11:29
Example of how to scaffold API endpoints for Posts in a Keystone project (based on the yo keystone example).

This is an example of how to scaffold API endpoints to list / get / create / update / delete Posts in a Keystone website.

It's a modification of the default project created with the yo keystone generator (see https://github.com/JedWatson/generator-keystone)

Gists don't let you specify full paths, so in the project structure the files would be:

routes-index.js        -->    /routes/index.js         // modified to add the api endpoints
routes-api-posts.js    -->    /routes/api/posts.js     // new file containing the Post API route controllers