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 / linkify.js
Created May 27, 2011 15:11
Use of link method for linkifying tweets.
// Courtesy of @redwolves
String.prototype.linkify = function() { return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) { return m.link(m) }) };
@joemccann
joemccann / failed-monit-memory-script.sh
Created April 5, 2011 23:23
monit memory mgmt fail
description "Memory Monitor"
author "Joe McCann"
start on startup
stop on shutdown
script
if memory usage > 75% then exec killall node
end script
@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) {
@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 / phonegap_sencha_tutorial.md
Created January 31, 2011 20:19
Quick setup of Phonegap and Sencha tutorial.

Note: You need to be on a Mac.

Note: This is purposely verbose. Yes, I know a lot of this can be simplified. Fork it and show me.

  1. Install git
  2. Open your terminal.
  3. mkdir ~/Documents/phonegap_sencha
  4. cd ~/Documents/phonegap_sencha
  5. git clone https://github.com/phonegap/phonegap-iphone.git && cd phonegap-iphone
  6. git reset --hard HEAD
@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 / 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 / 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 / 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 / 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;