Skip to content

Instantly share code, notes, and snippets.

@selfcontained
selfcontained / google+_ms_morphs
Created August 18, 2011 21:09
Google+ Martin Schoeller Morphs Snapshots
var cnvs=document.createElement('canvas'),ctx,img,idx,int,divs=document.getElementsByClassName('H-y-qa H-y-pe-ea c-m-l H-y');for(idx in divs){if(divs[idx].getAttribute('data-content-url')=='https://plus.google.com/photos/117576570968762597633/albums/5642001971943305281/5642001977563718610'){img=divs[idx].firstChild;break}}cnvs.width=img.width;cnvs.height=img.height;int=setInterval(function(){cnvs=cnvs.cloneNode();ctx=cnvs.getContext('2d');ctx.drawImage(img,0,0);document.body.appendChild(cnvs)},775);
//create data structure for dijkstra algo hotness
var Node = function(name) {
this.name = name;
this.neighbors = [];
};
Node.prototype = {
neighbors : null,
addNeighbor : function(node, distance) {
@selfcontained
selfcontained / gist:6437038
Created September 4, 2013 13:37
express app w/ mongoose models
// -----------------
// app.js
var mongoose = require('mongoose');
// your express server stuff here...
// it will make things easier to organize if you have routes defined
// in their own files and require them, passing in the app like:
require('routes/user')(app);
// after registering all your routes, connect to mongoose
# Description
# Create a Google+ Hangout and print out the url in chat
#
# Dependencies
# phantomjs
#
# Configuration
# HUBOT_HANGOUT_USERNAME
# HUBOT_HANGOUT_PASSWORD
# HUBOT_HANGOUT_VERIFY_EMAIL
@selfcontained
selfcontained / proxy.js
Created June 28, 2014 19:46
app router via path with http-proxy
// I'm just being lazy and loading both apps here for simpliciy,
// but these would be started by themselves as their own
// servers somewhere else
require('./this-app');
require('./that-app');
// core node http lib for your proxy server
// you'd probably use the "https" module here, and add certs
// you could really use any http server for this, even express, but this
// is probably sufficient and simpler, since you won't be providing anything
var nodemailer = require('nodemailer');
var engineer,
password;
exports.init = function (engineer, password) {
engineer = engineer;
password = password;
@selfcontained
selfcontained / webpack-static-html-versioned-images.js
Last active December 22, 2015 21:14
Using webpack versioned image filenames for pre-rendered static html files
var path = require('path')
var BLANK_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4wLWMwNjAgNjEuMTM0Nzc3LCAyMDEwLzAyLzEyLTE3OjMyOjAwICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpDOTBBOTBCMjg2NUQxMUU1QUY1Nzk5NzEyNkQzRTdCMSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpGNUE4QzVCODg2Q0ExMUU1QUY1Nzk5NzEyNkQzRTdCMSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkM5MEE5MEIwODY1RDExRTVBRjU3OTk3MTI2RDNFN0IxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkM5ME
@selfcontained
selfcontained / action-creator-dispatch.js
Created December 24, 2015 19:02
adding dispatch fn to redux action creators
// wa la, a redux store
var store = createStore()
// some action creators
var actions = {
add: function (value) {
type: 'ADD',
value: value
},
remove: function (id) {
@selfcontained
selfcontained / actions.js
Last active May 16, 2016 22:25
define sync & async redux actions
// Useful for defining a standard synchronous action
exports.defineAction = function (actions, definition) {
var {name, type} = definition
var [actionFn, notification] = parseActionProps(definition)
// pass in `type` via `this` context object
var actionWrapper = function () {
var context = {
// Send a message to the user that added the bot right after it connects
slapp.event('bb.team_added', function (msg) {
slapp.client.im.open({ token: msg.meta.bot_token, user: msg.meta.user_id }, (err, data) => {
if (err) {
return console.error(err)
}
let channel = data.channel.id
msg
.say({ channel, text: 'Thanks for adding me to your team!' })