Skip to content

Instantly share code, notes, and snippets.

View niallo's full-sized avatar

Niall O'Higgins niallo

View GitHub Profile
@niallo
niallo / gist:3109252
Created July 14, 2012 04:54
Parse Github `Links` header in JavaScript
/*
* parse_link_header()
*
* Parse the Github Link HTTP header used for pageination
* http://developer.github.com/v3/#pagination
*/
function parse_link_header(header) {
if (header.length == 0) {
throw new Error("input must not be of zero length");
}
@niallo
niallo / app.js
Created March 2, 2013 00:43
Quick and dirty landing page & contact form server in node.js, uses hapi.js, swig and nodemailer.
var mailer = require('nodemailer')
var Hapi = require('hapi')
var util = require('util')
var template = require('swig')
var path = require('path')
var PORT = process.env.PORT || 8080
var server = new Hapi.Server(PORT)
template.init({
@niallo
niallo / gist:3029840
Last active October 1, 2017 16:11
Sample Strider Webhook Payload
{ "test_results":
{ "deploy_exitcode": null,
"finish_time": "2012-06-29T00:19:26.622Z",
"repo_url": "https://github.com/niallo/gh-markdown-cli",
"start_time": "2012-06-29T00:19:04.538Z",
"github_commit_id": "f84bda271dc884fd6b2c0badc001f8fefcacdc9f",
"test_exitcode": 0
}
}
<?php
// Get this at your MongoLab.com user page
$MONGOLAB_API_KEY = 'XXXXXXXXXXXXXX';
$DB = 'mydb';
$COLLECTION = 'mycollection';
$name = $_POST['fullName'];
$email = $_POST['email'];
$phone = $_POST['phoneNumber'];
$src = $_POST['src'];
@niallo
niallo / docker.sh
Last active December 30, 2015 13:09
Customize Strider Docker via environment variables
docker run -d -p 3000:3000 \
-e SERVER_NAME=https://strider.myhost.com \
-e DB_URI=mongodb://foo.com/strider \
-e PLUGIN_GITHUB_APP_ID=foo \
-e PLUGIN_GITHUB_APP_SECRET=bar niallo/strider
5:::{"name":"job.done","args":[{"deploy_exitcode":-1,"test_exitcode":-1,"duration":3351,"finished":"2013-09-30T19:35:11.886Z","started":"2013-09-30T19:35:08.535Z","queued":"2013-09-30T19:35:08.534Z","__v":0,"_id":"5249d26bb8305d3089000017","created":"2013-09-30T19:35:07.451Z","project":{"_id":"5249d032a7fe37038900000a","name":"strider-cd/strider-extension-loader","branches":{"master":{"plugins":[],"active":true,"deploy_on_green":true,"runner":{"id":"simple-runner"}}},"public":true,"display_url":"https://github.com/Strider-CD/strider-extension-loader","provider":{"id":"github"}},"ref":{"branch":"master"},"type":"TEST_ONLY","user_id":"51f050cf04568a0c00000008","runner":{"id":"simple-runner"},"errored":false,"trigger":{"type":"manual","message":"Retest","timestamp":"2013-09-30T19:35:07.451Z","source":{"type":"UI","page":"unknown"},"author":{"id":"51f050cf04568a0c00000008","email":"n@niallo.me","image":null}},"status":"failed"},"public"]}
/Users/niallo/projects/strider-14/strider/lib/websockets.js:110
id: user._id,
^
TypeError: Cannot read property '_id' of null
at kickoffJob (/Users/niallo/projects/strider-14/strider/lib/websockets.js:110:15)
at Object.UserSocket.events.test (/Users/niallo/projects/strider-14/strider/lib/websockets.js:180:7)
at Socket.EventEmitter.emit [as $emit] (events.js:95:17)
at SocketNamespace.handlePacket (/Users/niallo/projects/strider-14/strider/node_modules/socket.io/lib/namespace.js:335:22)
at Manager.onClientMessage (/Users/niallo/projects/strider-14/strider/node_modules/socket.io/lib/manager.js:488:38)
at WebSocket.Transport.onMessage (/Users/niallo/projects/strider-14/strider/node_modules/socket.io/lib/transport.js:387:20)
30 Sep 12:08:50 - error: Job 5249cc41f2b60ba388000008 Command failed with code 128 Error: Command failed with code 128
at badCode (/Users/niallo/projects/strider-14/strider/node_modules/strider-github/node_modules/strider-git/worker.js:46:11)
at /Users/niallo/projects/strider-14/strider/node_modules/strider-github/node_modules/strider-git/worker.js:66:35
at ChildProcess.<anonymous> (/Users/niallo/projects/strider-14/strider/node_modules/strider-simple-runner/node_modules/strider-runner-core/lib/job.js:181:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
TypeError: Cannot read property 'id' of undefined
at Object.Job (/Users/niallo/projects/strider-14/strider/node_modules/strider-simple-runner/node_modules/strider-runner-core/lib/job.js:37:21)
at Object.process [as processJob] (/Users/niallo/projects/strider-14/strider/node_modules/strider-simple-runner/node_modules/strider-runner-core/lib/index.js:19:13)
30 Sep 11:29:11 - info: Express server listening on port 3000 in development mode
/Users/niallo/projects/strider-14/strider/node_modules/mongoose/lib/utils.js:419
throw err;
^
TypeError: Cannot read property 'providers' of undefined
at striderJson (/Users/niallo/projects/strider-14/strider/lib/backchannel.js:94:20)
at /Users/niallo/projects/strider-14/strider/lib/backchannel.js:131:7
at Promise.<anonymous> (/Users/niallo/projects/strider-14/strider/node_modules/mongoose/lib/model.js:1408:21)
at Promise.<anonymous> (/Users/niallo/projects/strider-14/strider/node_modules/mongoose/node_modules/mpromise/lib/promise.js:162:8)