Skip to content

Instantly share code, notes, and snippets.

View simonmcmanus's full-sized avatar

Simon McManus simonmcmanus

View GitHub Profile
@simonmcmanus
simonmcmanus / generate-build-dependencies.js
Created March 20, 2014 15:11
Bundled Dependencies Generator
'use strict';
/**
* Takes a look and the dependencies object and adds each item to the bundled dependencies array.
*/
var fs = require('fs');
var file = __dirname + '/../package.json';
var pkg = require(file);
public class GenerateHash
{
private string key;
private string secret;
public GenerateHash(string key, string secret)
{
this.key = key;
this.secret = secret;
}
@simonmcmanus
simonmcmanus / app.js
Last active August 29, 2015 14:01
Upload an asset using the register/complete routes using the AdBank A5 API
'use strict';
var request = require('request');
var path = require('path');
var fs = require('fs');
var config = require('./config');
var generateHash = require('adstream-adbank-api-generate-hash');
var url = config.api + '/assets/register';
'use strict';
var request = require('request');
var path = require('path');
var fs = require('fs');
var config = require('./config');
var generateHash = require('adstream-adbank-api-generate-hash');
var url = config.api + '/assets/register';
@simonmcmanus
simonmcmanus / gist:6d2919b20b1e8cb11871
Created June 18, 2014 09:07
write object of compiled jade templates to a file - not finished
'use strict';
var fs = require('fs');
var jade = require('jade');
var path = require('path');
var buildOut = function(folder, relativePath, out) {
var currentFolder = folder + '/' + relativePath;
var files = fs.readdirSync(currentFolder);
var counter = files.length;
/**
* Get a deeply nested object property without throwing an error
*
* Usage:
* _.get(obj, 'foo.bar');
* _(obj).get('foo.bar');
*
* @param {Object} obj
* @param {String} path Path e.g. 'foo.bar.baz'
* @return {Mixed} Returns undefined if the property is not found
@simonmcmanus
simonmcmanus / LYS
Last active August 29, 2015 14:12
Possible inconstancy is tfl data:
<?xml version="1.0" encoding="utf-8"?>
<ROOT xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://trackernet.lul.co.uk">
<Disclaimer>This system is an INFORMATION ONLY system, relying entirely on
information received from the relevant Operational Railway Control System(s). It is NOT
considered a safety related system in the Railway Engineering sense. However,
the information reported may trigger user intervention by staff regarding possible
incidents on the railway, and confirmation of the situation observed should be obtained prior
to any corrective action being taken.</Disclaimer>
<WhenCreated>4 Jan 2015 9:05:52</WhenCreated>
var bundler = watchify(browserify('./src/main.js', watchify.args));
function bundle() {
return bundler.bundle()
// log errors if they happen
.on('error', notify.onError(notifyError))
.pipe(source('src/main.js'))
.pipe(buffer())
.pipe(rename('kormorant-dev.min.js'))
.pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
@simonmcmanus
simonmcmanus / gist:553bc763c339501ce203
Last active August 29, 2015 14:15
async-parallel-no-fail
'use strict';
var _ = require('underscore');
/**
Custom implementation of Parallel:
Async.parallel stops on the first error.
This module captures all errors (but does not call the error callback)
The result is that if one data request for a page fails, it does not stop
{
"node": true,
"bitwise" : true,
"camelcase" : true,
"curly" : true,
"eqeqeq" : true,
"forin" : true,
"freeze" : true,
"immed" : true,