Skip to content

Instantly share code, notes, and snippets.

View icodeforlove's full-sized avatar
:octocat:
Indefinitely In Bangkok

Chad icodeforlove

:octocat:
Indefinitely In Bangkok
View GitHub Profile
@icodeforlove
icodeforlove / safari.sh
Created April 16, 2012 23:53
Enable Safari’s debug menu
# Enable Safari's debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
@icodeforlove
icodeforlove / gist:2657066
Created May 11, 2012 02:06
setTimeout + setInterval for non modern browsers
/**
* adds param support to older engines
*
* var timeoutID = window.setTimeout(func, delay, [param1, param2, ...]);
* var intervalID = window.setInterval(func, delay, [param1, param2, ...]);
*/
if (!Function.prototype.bind) (function () {
window.setTimeout = helper(window.setTimeout);
window.setInterval = helper(window.setInterval);
@icodeforlove
icodeforlove / generate_keyframe_animation.js
Last active October 5, 2015 15:47
helper for generating static css for keyframe animations
function generate_keyframe_animation (name, frames, height) {
var steps = [];
for (var frame = 0; frame < frames; frame++) {
var percent = ((frame / (frames - 1)) * 100).toFixed(2);
steps.push('\t' + percent + '% { background-position: 0px ' + (-height * frame) + 'px; }');
}
return '@-webkit-keyframes ' + name + ' {\n' + steps.join('\n') + '\n}';
function RollingAverage ($config) {
$config = $config || {};
this._average = $config.average || 0;
this._numbers = $config.numbers || 0;
}
RollingAverage.prototype.push = function (number) {
this._numbers++;
var weight = 1 / this._numbers;
this._average += (number - this._average) * weight;
return this._average;
body {
background-color: #eeeeee;
}
#posts {
margin: 0px;
padding: 0px;
list-style: none;
}
#posts .post {
* {
font-family: helvetica;
color: #eeeeee;
}
.count {
margin-right: 10px;
height: 50px;
padding: 4px;
text-align: center;
@icodeforlove
icodeforlove / new_bashrc.sh
Created August 11, 2012 20:53 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful. Now a repo: https://github.com/josephwecker/bashrc_dispatch
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# Now a repo with faster code- please refer to https://github.com/josephwecker/bashrc_dispatch - thanks gioele
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
# Are you tired of trying to remember how darwin/mac-osx treat them differently from linux?
# Are you tired of not having your ~/.bash* stuff work the way you expect?
#
var express = require('express');
var app = express(),
everyauth = require('everyauth');
everyauth.tumblr
.consumerKey('')
.consumerSecret('')
.findOrCreateUser( function (sess, accessToken, accessSecret, user) {
console.log(arguments);
})
@icodeforlove
icodeforlove / mp4-chunk-test.js
Created September 18, 2012 22:57
Simple file server test for video
/*jshint node:true*/
var fs = require('fs'),
http = require('http'),
path = require('path'),
port = 1338,
dir = '.';
http.createServer(function (request, response) {
var filePath = path.join(dir, path.basename(request.url));
if (path.extname(request.url) !== '.mp4' || !fs.existsSync(filePath)) return throw404();
@icodeforlove
icodeforlove / dabblet.css
Created October 12, 2012 00:05
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;