Skip to content

Instantly share code, notes, and snippets.

View hgcummings's full-sized avatar

Harry Cummings hgcummings

  • Softwire
  • London
View GitHub Profile
@hgcummings
hgcummings / s3_caching.sh
Created August 25, 2014 09:54
Script for caching and retrieving build dependencies to/from S3 - usage instructions at http://hgc.io/2014/08/26/Caching-Travis-CI-dependencies-in-S3/#The_solution
#!/bin/bash
# The MIT License (MIT)
#
# Copyright (c) 2014 Harry Cummings
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@hgcummings
hgcummings / results.html
Last active August 29, 2015 14:15
hypermeter graphs with Chart.js
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script>
<style>
body {
font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
}
#legend li {
list-style-type: none;
@hgcummings
hgcummings / generators.js
Last active August 29, 2015 14:21
Promises and generators demo
// Run with node --harmony_generators generators.js
function* generator() {
var received = yield 1;
console.log(received);
return 3;
}
var instance = generator();
var first = instance.next();
console.log(first);
@hgcummings
hgcummings / holidays.js
Last active January 1, 2016 20:56
Script to insert 2016 UK bank holidays into a MongoDB database
db.holidays.insert({ name: "New Year's Day", date: ISODate("2016-01-01") });
db.holidays.insert({ name: "Good Friday", date: ISODate("2016-03-25") });
db.holidays.insert({ name: "Easter Monday", date: ISODate("2016-03-28") });
db.holidays.insert({ name: "Early May bank holiday", date: ISODate("2016-05-02") });
db.holidays.insert({ name: "Spring bank holiday", date: ISODate("2016-05-30") });
db.holidays.insert({ name: "Summer bank holiday", date: ISODate("2016-08-29") });
db.holidays.insert({ name: "Boxing Day", date: ISODate("2016-12-26") });
db.holidays.insert({ name: "Christmas Day", date: ISODate("2016-12-27"), substitute_for: ISODate("2016-12-25") });
db.holidays.aggregate([{ $project: { name: true, original_date: { $ifNull: ["$substitute_for", "$date"] } } }, { $sort: { original_date: 1} }])
@hgcummings
hgcummings / app.js
Created February 13, 2016 12:12
Repro case for istanbul issue
module.exports = (a, b) => {
'use strict';
let result = a + b;
if (result > 0) {
console.log('Covered branch');
return true;
} else {
console.log('Uncovered branch');
return false;
}
@hgcummings
hgcummings / README.md
Last active April 7, 2016 10:07
JIRA bullets bookmarklet

Bookmarklet for turning bullet lists pasted in from MS Office into JIRA/Confluence markup bullet points.

Currently supports unordered lists up to two levels deep.

javascript:var elem = jQuery(':focus'); elem.val(elem.val().replace(/•\t/g, '* ').replace(/o\t/g, '** '));

@hgcummings
hgcummings / yacave.p2y
Created July 24, 2016 21:05
My First Code: YA Cave
'All code (c) Harry Cummings 2002
'Original concept (c) SunFlat
'For additional information and instructions,
'see readme.txt. For the latest version, see
'http://yabasic.electricweb.org.uk/
open window 640,512
draw = 1
p = 0