Skip to content

Instantly share code, notes, and snippets.

View simonmcmanus's full-sized avatar

Simon McManus simonmcmanus

View GitHub Profile
@simonmcmanus
simonmcmanus / gist:6579103
Created September 16, 2013 10:42
Example RSS Atom Feed
<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>Sun Feed</title>
<link>http://www.thesun.com</link>
<description>big stories</description>
<atom:link href="http://RSS-FEED-URL.com" rel="self" type="application/rss+xml"/>
<item>
@simonmcmanus
simonmcmanus / gist:5857608
Created June 25, 2013 10:52
node build system.
{
"cmd": ["/usr/local/bin/node ${file}"],
"selector": "source.js",
"shell": true,
"quiet": true
}
@simonmcmanus
simonmcmanus / gist:5857607
Created June 25, 2013 10:52
sublime jasmine running that formats the code to make it nice
var sys = require('util');
var exec = require('child_process').exec;
var puts = function puts(error, stdout, stderr) {
var out = stdout.split('\n');
if(out[2].slice(0, 8) === 'Finished') {
console.log(out[3]);
}else {
console.log(stdout);
{
"article": {
"headline": "Girls Aloud",
"headlineSpan": 1,
"hideHeadline": false,
"type": "article",
"articleCoverPageWidth": 1,
"copy": "<p>&nbsp;The men who carried out the brutal killing of a soldier in London yesterday are British citizens of Nigerian background who converted to a radical form of Islam, sources have confirmed. But it is understood that the men, who are being treated in separate hospitals while under arrest, are not thought to have links</p>",
"publishDate": "2012-11-19T14:28:11Z",
"style": "Sun_Main_Article",
@simonmcmanus
simonmcmanus / ex.js
Last active December 17, 2015 21:49
simple render example
var app = require('express').createServer();
app.get('/', function(req, res){
res.send('hello world');
});
app.get('/:name', function(req, res){
res.send('hello ' + req.param.name);
});
(function(exports){
exports.HOME = '/';
exports.LOGIN = '/login';
exports.USERS = '/users';
exports.USER = '/users/:user';
// also add URL functions here that can be shared between client and server.
exports.build = function(str, tokens) { .. };
})(typeof exports === 'undefined' ? namespace.urls={} : exports);
@simonmcmanus
simonmcmanus / hi.js
Last active December 17, 2015 21:09
Node.js/Clientside include
var sayHi = function() {
return 'Hi';
};
if(typeof exports === 'object'){
exports.sayHi = sayHi;
} else {
// your browser export
}
/**
* Module dependencies.
*/
var express = require('express');
var http = require('http');
var path = require('path');
var app = express();
@simonmcmanus
simonmcmanus / frax.js
Last active December 15, 2015 10:29
PJAX as Page.js middleware.
var frax = function(context, next) {
if(!context.init) {
$.get(context.canonicalPath+'?_pjax=true', function(markup) {
if(context.delay) {
context.pending = markup;
}else {
context.container.html(markup); // cached $('#container')
}
next();
});
@simonmcmanus
simonmcmanus / blend.js
Last active December 15, 2015 10:29
Get an API for free with Blend. After calling the middleware just call res.blend()
var _blend = function(req, res, next) {
res.blend = function(params) {
params.buildData(params.params, function(e, d) {
if(req.headers['content-type'] === 'application-json') {
res.json(d);
} else { // render html
params.buildSelectors(d, function(selectors) {
if(req.headers['content-type'] === 'sizlate') {
var options = {