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 / 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 / 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 / HTML5_Suggested_Boilerplates.md
Created January 18, 2011 22:39
A compendium of HTML5 related scripts, frameworks and templates/boilerplates alongside suggested best practices.
@joemccann
joemccann / turbo_stylesheet.less
Created January 23, 2011 16:19
A mirror of Jeffrey Way's CSS3 "Classes" Stylesheet
/* http://snipplr.com/view.php?codeview&id=47181 */
/* Credit: Jeffrey Way */
.border-radius( @radius: 3px ) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
.outline-radius( @radius: 3px ) {
@joemccann
joemccann / stylus.js
Created April 5, 2011 17:40
Does it write to a file?
var express = require('express')
, css = require('stylus')
, str = require('fs').readFileSync(__dirname + '/public/css/style.styl', 'utf8');
// What makes sense to me is pass in "str" to be rendered and write that data to the file named "style.css".
// But examples show it being named "style.styl" which I thought was already loaded from "str"???
css.render(str, {filename: __dirname + '/public/css/style.css'}, function(err, css){
if (err) throw err;
console.log(css);
});
@joemccann
joemccann / wtf-stylus-express.js
Created April 5, 2011 21:42
Won't "compile" the .styl sheet and throws no errors.
/**
* Module dependencies.
*/
var express = require('express')
, stylus = require('stylus');
var app = express.createServer();
function compile(str, path) {