Skip to content

Instantly share code, notes, and snippets.

Avatar

Colin Gourlay colingourlay

View GitHub Profile
@colingourlay
colingourlay / example.js
Last active Aug 28, 2021
Lodash / Underscore sort object keys. Like _.sortBy(), but on keys instead of values, returning an object, not an array. Defaults to alphanumeric sort.
View example.js
var obj = {b: 3, c: 2, a: 1};
_.sortKeysBy(obj);
// {a: 1, b: 3, c: 2}
_.sortKeysBy(obj, function (value, key) {
return value;
});
// {a: 1, c: 2, b: 3}
View scottish-tablet-recipe.md

Scottish Tablet

  • Preparation time: 40 minutes
  • Total time: 3 hours
  • Makes: ~50 portions

Ingredients

  • 1kg caster sugar
  • 250g butter
@colingourlay
colingourlay / idle-analytics.js
Created Sep 7, 2016
Defer the standard Google Analytics script until the page is idle, in supported browsers.
View idle-analytics.js
(function(x,y,z){(x[y]&&x[y](z))||z()})(window,'requestIdleCallback',function(){
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-X', 'auto');
ga('send', 'pageview');
});
@colingourlay
colingourlay / LICENSE
Last active Jan 5, 2021
Standalone getScript. This performs the same ability as jQuery.getScript, including the optional callback, but doesn't support the Promises implementation shared with all the other jQuery.ajax methods.
View LICENSE
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@colingourlay
colingourlay / apple-web-dynamic-type.css
Last active Nov 30, 2020
Support Apple's dynamic text sizing in web content (iOS Safari & WebViews)
View apple-web-dynamic-type.css
/*
To support dynamic type in iOS, we need to set Apple's
system font and then define font-families and rem-based
font-sizes on descendant elements:
*/
@supports (font: -apple-system-body) {
html {
font: -apple-system-body;
}
}
View groups-descriptions.js
export default GROUPS_DESCRIPTIONS = {
abortion: `People who strongly or somewhat agree that a woman should be able to have an abortion under any circumstances.`,
age: `Responses across seven different age brackets.`,
'alcohol consumption': `People who drink at least one or more drinks per week.`,
ancestry: `People were asked the ethnic or cultural origins of their ancestors and could select multiple responses, which were coded as either ‘white’ or ‘non-white’. A person who listed a ‘non-white’ ancestry was categorised as having non-white ancestry.`,
assimilation: `People who somewhat or strongly agreed with the statement ‘Most immigrants these days don’t try hard enough to fit into Australian society’.`,
'birth country': `People were categorised based on whether they were born in Australia or elsewhere.`,
'cannabis legalisation': `People who strongly or somewhat agreed with the statement ‘Marijuana should be legalised’.`,
'cannabis use': `People who ever use cannabis.`,
'Chinese Australian'
View kill.sh
sudo /usr/local/McAfee/AntiMalware/VSControl stopoas
sudo killall VShieldService
sudo killall VShieldScanner
@colingourlay
colingourlay / flat.js
Last active Jun 15, 2019
The `flat` function allows you to write then-able functions without explicitly creating your own Promises, and instead receiving the promise resolution/rejection functions as a destructure-able object as a first argument.
View flat.js
function flat(fn) {
return function (...args) {
return new Promise((resolve, reject) => {
fn.call(this, {resolve, reject}, ...args);
});
};
}
@colingourlay
colingourlay / key.md
Created Feb 28, 2019 — forked from shobotch/key.md
Twitter (un)official Consumer Key
View key.md

Twitter Official Consumer Key

Twitter for Android

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN
Consumer key:    IQKbtAYlXLripLGPWd0HUA
View 1106432499704451072_responses_by_minute_since_publication.csv
minutesSincePublication quotes replies retweets quotesCumulative repliesCumulative retweetsCumulative
1 0 0 0 0 0 0
2 0 1 0 0 1 0
3 0 2 1 0 3 1
4 0 3 0 0 6 1
5 0 3 1 0 9 2
6 0 4 0 0 13 2
7 0 1 2 0 14 4
8 0 2 1 0 16 5
9 0 3 0 0 19 5