Skip to content

Instantly share code, notes, and snippets.

Avatar

Robert (Jamie) Munro rjmunro

View GitHub Profile
@rjmunro
rjmunro / index.ts
Last active May 25, 2021
Typescript weirdness
View index.ts
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 / crontab
Created Dec 1, 2020
Header for crontab to remember what column is what
View crontab
# ╭───────────────────── Mins
# │ ╭───────────────── Hours
# │ │ ╭───────────── Day of month
# │ │ │ ╭───────── Month (0-12)
# │ │ │ │ ╭───── Day of week (0-7, 0 and 7 are Sunday)
# │ │ │ │ │
@rjmunro
rjmunro / .gitignore
Created Jun 21, 2013
gitignore for cordova cli projects
View .gitignore
# 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 / walk.js
Created Mar 23, 2018
Script to walk browser-compat-data and find common subtrees
View walk.js
#!/usr/bin/env node
// To use:
// npm install object-hash
//
var Hash = require('object-hash');
var Data = require('.');
@rjmunro
rjmunro / test-run.txt
Created Jun 10, 2013
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.
View test-run.txt
$ 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
Deferred wrapper around setTimeout. Lets you do: $.delay(100).then(function () { // some delayed action });
View delay.js
/**
* 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();
View 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):
@rjmunro
rjmunro / shim.js
Created May 15, 2015
Shim for console.log in IE9 when run without developer tools
View shim.js
// 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 Nov 4, 2014
PHP array_average function
View average.php
/**
* 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);