Skip to content

Instantly share code, notes, and snippets.

View jshirley's full-sized avatar

Jay Shirley jshirley

View GitHub Profile
/* 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) {
/**
@jshirley
jshirley / ci.pl
Created July 9, 2012 18:31
Automatically run tests when a file is modified
use Filesys::Notify::Simple;
use App::Prove;
use lib qw(lib);
my $tests = @ARGV;
my $watcher = Filesys::Notify::Simple->new([ './lib', './t/lib' ]);
my $prove = App::Prove->new;
@jshirley
jshirley / CurryQuinoa.md
Created June 26, 2012 01:16
Curry Quinoa Recipe

Curried Quinoa

This is one of my favorite foods. I was bored and thinking of recipes I'd like to try and thought this one up. It is delicious.

Ingredients

One Medium Onion 3 cloves garlic French Beans

@jshirley
jshirley / macros.tt
Created May 29, 2012 17:06
Bootstrap Form Macros. Use these in combination with Twitter Bootstrap CSS, Catalyst::Plugin::MessageStack and Data::Manager
[%~
# Some illustrious documentation to get you started:
#
# The macros defined are to generate markup to save people from copy and pasting
# markup. They copy and paste hashes instead, which should be safer (in theory)
#
# The macros for forms are:
# * text_field - A simple text field, pass in type to override input type
# * password_field - A password field, equivalent to
# text_field({ type => 'password', ... })
@jshirley
jshirley / compile.sh
Created March 7, 2012 16:35
How I manage my Handlebars templates in my YUI application.
#!/bin/bash
# This script should be switched up to be a buildy task, see
# https://github.com/mosen/buildy
#
# Each root/templates/(*)/(*).html should be baked to:
# -> template-$1-$2/template-$1-$2-min.js
#
# Then a template rollup file
@jshirley
jshirley / gist:1973907
Created March 4, 2012 17:04
Managing start_server with start-stop-daemon and graceful restarting.
#!/bin/bash
PORT=5000
# This should be the directory name/app name
APP="TDP"
PIDFILE="$HOME/$APP.pid"
STATUS="$HOME/$APP.status"
# The actual path on disk to the application.
APP_HOME="$HOME/$APP"
@jshirley
jshirley / handlebars.js
Created February 9, 2012 14:15
A forked Handlebars compiler to wrap everything in Y.add blocks.
#!/usr/bin/env node
var optimist = require('optimist')
.usage('Precompile handlebar templates.\nUsage: $0 template...', {
'f': {
'type': 'string',
'description': 'Output File',
'alias': 'output'
},
'k': {
@jshirley
jshirley / Guide.pm
Created January 27, 2012 14:23
Our macro.tt file for handling inputs consistently. Requires YUI3 grids to look proper.
sub guide : Local {
my ( $self, $c ) = @_;
unless ( $c->debug ) {
$c->detach('/error/not_found');
}
my $template = 'index.tt';
if ( @{ $c->req->args } ) {
@Satyam
Satyam / gist:1547708
Created January 1, 2012 16:28
App plugin
/*
App plugins can be loaded over an instance of App by setting a route with a wildcard path
such as:
{
path:'/:app/*',
callback: 'dispatchApp'
}
where the app param is the module name of the plugin,
which should have its entry in the YUI config file (unless loaded by some other means)
*/