Skip to content

Instantly share code, notes, and snippets.

View garth's full-sized avatar

Garth Williams garth

View GitHub Profile
@garth
garth / Jakefile.js
Created December 1, 2011 12:06
Example Jakefile from ViennaJS meetup
// Jake is like Rake for nodejs https://github.com/mde/jake
//
// Assumes that Jake will be run in the root of the web app with coffee files in /js/ and
// a single app.less file in /css/ that can include references to other .less files
//
//requires
var sys = require('util');
var execute = require('child_process').exec;
var fs = require('fs');
@garth
garth / template.js
Created November 30, 2011 14:15
Use requirejs to dynamically load sproutcore20 handlebars templates
// dynamically load sproutcore20 handlebars templates
// add this file to the same dir as your data-main js to load a template as a dependency do
//
// define(['template!template'] function(){
// //do some SproutCore[ing]
// });
//
// templates should be located in templates folder and have a .handlebars extension
// removed partial support {{> partial}} which doesn't work in SC.Handlebars use
@garth
garth / gist:1388969
Created November 23, 2011 15:29
Convert url image ref into inline base 64 in css with nodejs
var css = 'insert lots of css here';
var files = {};
css = css.replace(/url\((\S*)\.(png|jpg|jpeg|gif)\)/g, function(match, file, type)
{
var fileName = file + '.' + type;
var size = fs.statSync(fileName).size;
if (size > 4096) {
console.log('Skipping ' + fileName + ' (' + (Math.round(size/1024*100)/100) + 'k)');
return match;
@garth
garth / vlcrc.js
Created October 5, 2011 21:30
Remote control multiple VLC apps via the command line using nodejs
// To start vlc with telnet remote control:
// ./VLC --extraintf rc --rc-host 0.0.0.0:3000
//
// To connect to multiple vlc's
// node vlcrc.js host1:3000 host2:3000
var net = require('net');
var readline = require('readline');
//addresses of servers