Skip to content

Instantly share code, notes, and snippets.

@weisjohn
weisjohn / brode.js
Last active December 22, 2015 09:59
A joke
var chirp = require('twitter')
, _ = require('lodash') // cause underscore is so 2009..
;
module.exports = function(app) {
// bro shortcuts for getting the tweets
app.get('/mah/chirps', function(req, res) {
// closures, like a pro javascript dude
function hollaback(fail, party) {
@weisjohn
weisjohn / ga-part.js
Created September 5, 2013 17:52
Google Analytics beforeunload inpsection
// this code isn't intended to work:
if (J.body) {
a = aa(a);
try {
var c = J[qa]('<iframe name="' + a + '"></iframe>')
} catch (d) {
c = J[qa]("iframe"), ha(c, a)
}
c.height = "0";
@weisjohn
weisjohn / rotate_logs.sh
Last active December 20, 2015 19:39
rotate logs
#!/bin/bash
# rotates logs for all services on this box
# the services for which we should rotate logs
SERVICE_DIR=~/mysrc
services=$(ls $SERVICE_DIR)
function rotate {
logfile=$SERVICE_DIR/$1/logs/$2.log
@weisjohn
weisjohn / gist:5861939
Created June 25, 2013 20:12
rwd iframes bookmarklet
javascript:document.write('<!DOCTYPE html><html><head><meta charset="utf-8"><title>Responsive Design Testing</title><style>body %7B margin: 20px; font-family: sans-serif; overflow-x: scroll; %7D.wrapper %7B width: 6000px; %7D.frame %7B float: left; %7Dh2 %7B margin: 0 0 5px 0; %7Diframe %7B margin: 0 20px 20px 0; border: 1px solid %23666; %7D</style></head><body><div class="wrapper"><div class="frame"><h2>240<span> x 320</span> <small>(mobile)</small></h2><iframe src="' + window.location + '" sandbox="allow-same-origin allow-forms" seamless width="240" height="320"></iframe></div><div class="frame"><h2>320<span> x 480</span> <small>(mobile)</small></h2><iframe src="' + window.location + '" sandbox="allow-same-origin allow-forms" seamless width="320" height="480"></iframe></div><div class="frame"><h2>480<span> x 640</span> <small>(small tablet)</small></h2><iframe src="' + window.location + '" sandbox="allow-same-origin allow-forms" seamless width="480" height="640"></iframe></div><div class="frame"><h2>768<sp
@weisjohn
weisjohn / postponed.js
Created June 21, 2013 22:45
an example of variable delays in event handlers
// how long should we wait for a function to fire?
var delay = 0;
// a simple way to wrap functions to be delayed
function postponed(fn) {
return function() {
setTimeout(fn, delay);
}
}
@weisjohn
weisjohn / twitter_dm_deleter.js
Created May 16, 2013 14:02
Twitter DM cleanup, use with caution inside a browser session on the site.
// global used to stop things if it get's out of hand
var run = true;
function enter_dm() {
var li = $(".dm-thread-list.js-dm-thread-list").children("li")[5];
$(li).click();
}
@weisjohn
weisjohn / twss.coffee
Last active December 17, 2015 09:59 — forked from mutewinter/twss.coffee
That's what see said hubot script.
# Description:
# Use Skynet to determine if a thing that was said is actually something
# S.H.E (Silicon Helix Entity) said.
#
# Dependencies:
# "twss": "0.1.6"
#
# Commands:
# Just say something like, "that was hard". Hubot will do the rest.
#
// configure twitter integration
var twit = require('twit');
var T = new Twit({
consumer_key: '...'
, consumer_secret: '...'
, access_token: '...'
, access_token_secret: '...'
});
// express app
@weisjohn
weisjohn / index.html
Created January 2, 2013 04:25
getUserMedia example
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<video id="sourcevid" autoplay="true">NO SUPPORT FOR VIDEO </video>
</body>
</html>
@weisjohn
weisjohn / server.py
Created December 5, 2012 20:09
simple python server
import SimpleHTTPServer;
map = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;
map[""] = "text/plain"
for key, value in map.items():
map[key] = value + ";charset=UTF-8"
SimpleHTTPServer.test()