Skip to content

Instantly share code, notes, and snippets.

View rjmunro's full-sized avatar

Robert (Jamie) Munro rjmunro

View GitHub Profile
@rjmunro
rjmunro / crontab
Created December 1, 2020 18:38
Header for crontab to remember what column is what
# ╭───────────────────── Mins
# │ ╭───────────────── Hours
# │ │ ╭───────────── Day of month
# │ │ │ ╭───────── Month (0-12)
# │ │ │ │ ╭───── Day of week (0-7, 0 and 7 are Sunday)
# │ │ │ │ │
@rjmunro
rjmunro / walk.js
Created March 23, 2018 20:36
Script to walk browser-compat-data and find common subtrees
#!/usr/bin/env node
// To use:
// npm install object-hash
//
var Hash = require('object-hash');
var Data = require('.');
@rjmunro
rjmunro / index.ts
Last active January 9, 2023 16:12
Typescript weirdness
var a = require('./module1');
var b = require('./module2');
// import a from './module1';
// import b from './module2';
console.log('a',a);
console.log('b',b);
@rjmunro
rjmunro / shim.js
Created May 15, 2015 13:29
Shim for console.log in IE9 when run without developer tools
// Shim console.log for IE9 when not run in with developer tools opened
// Stores log messages in window.consoleLog so you can retreive them when you open the tools.
(function () {
/*global window */
if (!window.console) {
window.consoleLog = [];
window.console = {
log: function (msg) {
window.consoleLog.push([msg, (new Date()).toIsoString()]);
}
@rjmunro
rjmunro / average.php
Created November 4, 2014 16:16
PHP array_average function
/**
* Average an array
*
* I can't belive this isn't built in to PHP.
*
* @param float[] $array
* @return float
*/
function array_average($array) {
return array_sum($array) / count($array);
@rjmunro
rjmunro / .gitignore
Created June 21, 2013 13:54
gitignore for cordova cli projects
# Android
platforms/android/assets/www
platforms/android/bin/
platforms/android/gen/
platforms/android/res/xml/config.xml
# iOS
platforms/ios/build/
platforms/ios/CordovaLib/build/
platforms/ios/www
@rjmunro
rjmunro / test-run.txt
Created June 10, 2013 18:42
Something funny is going on with CircleCI's build of php 5.3.20. I ran this test using their ssh console to try the other versions of PHP they have installed.
$ cd /home/ubuntu/.phpenv/versions/
$ for i in *; do echo; echo $i; $i/bin/php ~/test.php ; done
5.3.10
PHP Fatal error: Class 'IntlDateFormatter' not found in /home/ubuntu/test.php on line 2
Fatal error: Class 'IntlDateFormatter' not found in /home/ubuntu/test.php on line 2
5.3.20
PHP Deprecated: IntlDateFormatter::setTimeZoneId(): Use datefmt_set_timezone() instead, which also accepts a plain time zone identifier and for which this function is now an alias in /home/ubuntu/test.php on line 3
@rjmunro
rjmunro / delay.js
Created May 21, 2013 22:31
Deferred wrapper around setTimeout. Lets you do: $.delay(100).then(function () { // some delayed action });
/**
* Deferred wrapper around setTimeout. Lets you do:
* $.delay(100).then(function () {
* // some delayed action
* });
* @param time Delay time in ms.
* @return Deferred a promise that will complete after the time
*/
jQuery.delay = function (time) {
var dfr = jQuery.Deferred();
@rjmunro
rjmunro / friendly.py
Last active December 10, 2015 09:48 — forked from anonymous/friendly.py
def memoize(f):
cache= {}
def memf(*x):
if x not in cache:
cache[x] = f(*x)
return cache[x]
return memf
@memoize
def sum_factors(x):