Skip to content

Instantly share code, notes, and snippets.

View jshirley's full-sized avatar

Jay Shirley jshirley

View GitHub Profile
@jshirley
jshirley / usblamp.js
Created November 9, 2012 17:01
Using Node + node-hid to control the Dream Cheeky USB LED Light on OS X
var HID = require('HID'),
path;
HID.devices().forEach( function(device) {
if ( device.product.match(/Dream Cheeky/) ) {
console.log(device);
path = device.path;
}
});
@jshirley
jshirley / paged-model-list.js
Created August 28, 2012 17:49
An extension to mix-in to your ModelList to support pagination. Still WIP.
YUI.add('paged-model-list', function(Y) {
var NS = Y.namespace('BackOffice.Model'),
Lang = Y.Lang,
isString = Lang.isString,
isArray = Lang.isArray,
isObject = Lang.isObject;
function PagedList() { }
PagedList.prototype = {
/* Render the login action */
app.get('/login', function(req, res) {
res.render('login')
});
/* Handle posting, if it fails this redirects back to /login, following POST-Redirect-GET */
app.post('/login',
requireAuth(Y),
function(req, res) {
/**
YUI.add('handlebars-helpers', function(Y) {
var NS = Y.namespace('TDP'),
Handlebars = Y.Handlebars,
Lang = Y.Lang,
isString = Lang.isString,
isArray = Lang.isArray,
isObject = Lang.isObject,
isFunction = Lang.isFunction,
Aeach = Y.Array.each,
/*
*/
var template = Y.Handlebars.compile('{{{ render_form form }}}'),
goal = this.get('model'),
output = template(
{
form : {
/**
Values is a short-hand, it just sets values for each of the elements below correctly.
new Queue('build TDP')
.task('files', file_list)
//.task('jslint')
.task('concat')
// With the replace line in, I get no output at all. It just silently fails.
.task('replace', { regex: "^.*?(?:logger|Y.log).*?(?:;|\\).*;|(?:\r?\n.*?)*?\\).*;).*;?.*?\r?\n", replace: '', flags: 'mg' })
.task('jsminify')
//.task('inspect')
.task('write', { name: './tdp-bundle-min.js' })
.run();
FancyApp = Y.Base.create('fancyApp', Y.App, [ Y.App.ResponsiveViews, Y.App.Transitions ], {
views : {
GoalListView : {
type : NS.GoalListView,
responsive: [
{ view : 'GoalListPhoneView', condition: function() { /* Determine dynamically */ } },
{ view : 'GoalListPhoneView', 'maxWidth' : '480px' },
{ view : 'GoalListFullView', 'minWidth' : '481px' }
}
},
@jshirley
jshirley / build.js
Created August 1, 2012 17:22
This is a setup I'm using with a YUI_config to leverage Y.Loader to build static rollup files.
/*
This is the Node.js file, it will export files directly to
`tdp-bundle-min.js` which obviously won't work well for you!
This relies on having a YUI_config that can be parsed and
passed into Y.Loader. Everything you need should be in this
gist, though. You may need to change the path to your
YUI_config file (mine is named `bundle.js`).
However, it's an easy change, just scroll down and edit it.
@jshirley
jshirley / autoview.js
Created July 29, 2012 21:08
AutoView, parse markup to fetch models and views accordingly.
YUI.add('tdp-autoview', function(Y) {
var NS = Y.namespace('TDP'),
View = Y.Base.create('tdpAutoView', Y.View, [], {
render : function() {
this.findViews();
return this;
},
// When you define your module, you specify a function to run when it's being added in.
// This includes a `Y` object:
YUI.add('myModule', function(Y) {
Y.Foo = function() { alert("Foo"); };
});
// When you *use* your module, you declare a similar function that gets a `Y` object passed in.
YUI().use('myModule', function(Y) {
Y.Foo = function() { alert("Bar"); };
});