Skip to content

Instantly share code, notes, and snippets.

View richard-flosi's full-sized avatar

Richard Flosi richard-flosi

  • Remote, US
View GitHub Profile
@richard-flosi
richard-flosi / app.js
Created April 9, 2014 18:02
Spine App example with navigation method
module.exports = (function() {
var App,
Spine = require('spine'),
$ = Spine.$;
// extend Spine
require('spine/lib/local');
require('spine/lib/ajax');
require('spine/lib/route');
require('spine/lib/manager');
@richard-flosi
richard-flosi / slug.js
Created April 9, 2014 17:59
Hem precompiler for nunjucks templates
/* jshint node: true */
var argv = process.argv.slice(2);
var fs = require('fs');
var hem = new (require('hem'))();
hem.compilers.html = function(path) {
var nunjucks = require('nunjucks'),
name = path.split('app/')[1],
opts = {
name: name,
@richard-flosi
richard-flosi / package.json
Created March 17, 2014 17:15
.html extension compiler for nunjucks templates in hem for spine.
# add hem and nunjucks to your package.json
{
...
"dependencies": {
...
"hem": "~0.3.6",
"nunjucks": "~1.0.1"
}
}
@richard-flosi
richard-flosi / slug.js
Created March 13, 2014 22:51
Use ect.js templates with hem by adding this to your slug.js for your spine.js project.
var argv = process.argv.slice(2);
var fs = require('fs');
var path = require('path');
var hem = new (require('hem'))();
var ect = require('ect');
// ect compiler
hem.compilers.ect = function(path) {
var renderer, content, template;
renderer = ect({});
@richard-flosi
richard-flosi / spine-html5-history-navigate.coffeescript
Last active August 29, 2015 13:57
Spine with HTML5 History. How to navigate your links without reloading your app and handle the cases when you want to open a link in a new window.
require('lib/setup')
Spine = require('spine')
$ = Spine.$
Spine.Route = require('spine/lib/route')
Stacks = require('controllers/stacks')
class App extends Spine.Controller
constructor: ->
@richard-flosi
richard-flosi / bottle-cors.py
Created September 26, 2012 16:55
Bottle with Cross-origin resource sharing (CORS)
"""
Example of setting up CORS with Bottle.py.
"""
from bottle import Bottle, request, response, run
app = Bottle()
@app.hook('after_request')
def enable_cors():
"""