Skip to content

Instantly share code, notes, and snippets.

View joemccann's full-sized avatar
💭
Thinking

Joe McCann joemccann

💭
Thinking
View GitHub Profile
@joemccann
joemccann / flash-spawn-fcgi.sh
Created October 28, 2010 21:28
Run this to "flash" your PHP process when it is spun up using nginx. If you modify your PHP.INI you need to do this.
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
@joemccann
joemccann / base64img.js
Created November 23, 2010 05:14
How?
var fs = require('fs'),
sys = require('sys'),
base64 = require('base64'); // this module is installed.
var foo = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAKIAeYDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+kxbCMxpmNRGIwRyf9o5OCxyRtzuBfDE5Jzm/b6dA5JVFVwxJKkgEMzsApAUlgOPmBCgqx
@joemccann
joemccann / perlin-flames.js
Created November 30, 2010 16:57
Perlin Flames uncompressed, but obfuscated.
// Variable usage: (* marks globals, all other variables are used for various purposes by various parts of the code)
// a = calculator
// b* = random data
// c* = main canvas
// d* = main canvas style / main canvas context
// e = calculator
// f =
// g* = main canvas composite operations
// h* = 300 (height)
// i = counter
@joemccann
joemccann / object.js
Created December 6, 2010 14:09
From bramstein.com
/*!
* JavaScript Core Object v0.53
*
* Licensed under the new BSD License.
* Copyright 2008-2009, Bram Stein
* All rights reserved.
*/
(function() {
function getInternalType(value) {
return Object.prototype.toString.apply(value);
@joemccann
joemccann / async-google-font-loader.js
Created December 8, 2010 17:21
Async google font loader.
WebFontConfig = {
google: { families: [ 'Droid Sans' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
@joemccann
joemccann / konami-code.js
Created December 8, 2010 19:23
Konami code
(function($) {
$.fn.konami = function(callback, code) {
if (code == undefined) code = "38,38,40,40,37,39,37,39,66,65";
return this.each(function() {
var kkeys = [];
$(this).keydown(function(e) {
kkeys.push(e.keyCode);
if (kkeys.toString().indexOf(code) >= 0) {
@joemccann
joemccann / keyframe-animation-append.js
Created December 9, 2010 16:46
Append keyframe animations programmatically.
// Does not work in Safari 5
// Technique one:
var lastSheet = document.styleSheets[document.styleSheets.length - 1];
var newName = 'foo';
lastSheet.insertRule("@-webkit-keyframes " + newName + "{ 0% { -webkit-transform: rotateY(0) translate3D(0,0,0); } 25% { -webkit-transform: rotateY(45) translate3D(0,0,-1000px); } 50% { -webkit-transform: rotateY(90) translate3D(0,0,-2500px);} 75% { -webkit-transform: rotateY(135) translate3D(0,0,-1000px);} 100% { -webkit-transform: rotateY(180) translate3D(0,0,0px);} }", lastSheet.cssRules.length);
document.getElementById('#foo').style.webkitAnimationName = newName;
@joemccann
joemccann / node-couchdb-traits-bug-fix.js
Created December 25, 2010 23:07
The bug in current node-couchdb module throws an error with version 0.4.0 of traits module. Line 25 is the change.
(function (exports) {
if (typeof JSON === "undefined") {
throw new Error("JSON is required. Plesae include json2.js if you are running this in the browser");
}
var
Q = require("promised-io/promise"),
HttpClient = require("promised-io/http-client").Client,
Trait = require("traits").Trait,
base64 = require("./base64"),
@joemccann
joemccann / create_images_json_object_from_dir.js
Created January 14, 2011 21:17
Scan a directory and create a JSON object of images (and write it to a file) of all the images in that directory.
var sys = require("sys"),
fs = require("fs");
function processImageDir(path, outFilename, cb) {
fs.readdir(path, function(err, files) {
var imgfiles = [];
// Check for images and push on the array if it's a match.
files.forEach(function(name) {
@joemccann
joemccann / HTML5_Suggested_Boilerplates.md
Created January 18, 2011 22:39
A compendium of HTML5 related scripts, frameworks and templates/boilerplates alongside suggested best practices.