Skip to content

Instantly share code, notes, and snippets.

View edwardhotchkiss's full-sized avatar

Edward Hotchkiss edwardhotchkiss

View GitHub Profile
// usage
var skeleton = new Skeleton({ name : 'example2' });
=> this skeleton's name is "skeleton2"
// standard encapsulating self executing closure
(function(root) {
'use strict';
/* ---- private ---- */
/**
* @private _hasConsole
*/
@edwardhotchkiss
edwardhotchkiss / Gruntfile.js
Last active December 15, 2015 05:09
Gruntfile for a project using .js and .less - for clarity sake we'll pretend that everything for the fat-client is in /src/app.js
/*!
* @description GRUNT! (.js)
*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
@edwardhotchkiss
edwardhotchkiss / Gruntfile.js
Created March 1, 2013 04:02
Grunt 0.4.0 with LESS, Uglify, Concat, CSSMin, Watch production ready file.
/*!
* @description Grunt@!!!!!
*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
@edwardhotchkiss
edwardhotchkiss / populateTableViaJSON.js
Last active December 10, 2015 21:38
Populate a two column table via data-id's that link to a JSON object (handles nested objects also, needs recursion)
// demo
!(function YODAWG(window, document) {
(typeof(console) !== 'undefined') ? console.log('YO DAWG, I HEARD YOU LIKED JAVASCRIPT, SO I PUT A FUNCTION AROUND A CLOSURE AND PARATHENSIS AROUND MY TYPEOF!') : null;
})(window, document);
// populate a table with a proxied JSON Object
YODAWG.prototype.populateTableViaJSON = function(tableSelector, dataToPopulate) {
var _self = this;
// clear View
@edwardhotchkiss
edwardhotchkiss / graphics_magick_center_image_on_canvas.js
Created October 31, 2012 03:32
Use GM Module (Graphics Magick) for Node.js to center an image on a white background canvas
var gm = require('gm');
var canvasWidth = 248;
var canvasHeight = 389;
gm(__dirname + '/original.jpg').size(function(error, size) {
if (error) {
console.error(error);
@edwardhotchkiss
edwardhotchkiss / calculatePaddedNewAspectRatio.js
Created October 26, 2012 19:02
Calculate new Width/Height of a Video or Image based on current width and height, then add padding to update to desired aspect ratio returning a new aspect ratio (say 16:9 or 4:3 etc) set of dimensions.
/**
* @method calculatePaddedNewAspectRatio
* @param {Number} rW New Aspect Ratio Width
* @param {Number} rH New Aspect Ratio Height
* @param {Number} cW Current Width
* @param {Number} cH Current Height
* @return {Object} Aspect ratio correct .width and .height
**/
@edwardhotchkiss
edwardhotchkiss / kevinneedshelp.js
Created September 23, 2012 22:50
kevin needs help
var kevin = function(error, result) {
if (error) {
console.error(error);
} else {
console.log(result);
};
};
var kevinNeedsHelp = client.performAimTransaction({
An error has occurred: {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect"}
@edwardhotchkiss
edwardhotchkiss / hosts-changes.sh
Created July 27, 2012 13:52
hosts file focus effort
127.0.0.1 knowyourmeme.com
127.0.0.1 ycombinator.com
127.0.0.1 venturebeat.com
127.0.0.1 techcrunch.com
127.0.0.1 betabeat.com
127.0.0.1 facebook.com
127.0.0.1 reddit.com