Skip to content

Instantly share code, notes, and snippets.

View colingourlay's full-sized avatar

Colin Gourlay colingourlay

View GitHub Profile
@colingourlay
colingourlay / index.css
Last active January 8, 2024 00:27
Mosaic with CSS grid
body {
margin: 0;
}
.wrapper {
display: grid;
grid-template-columns: repeat(auto-fill, 50vw);
grid-template-rows: repeat(auto-fill, 50vw);
}
@colingourlay
colingourlay / apple-web-dynamic-type.css
Last active September 16, 2023 15:43
Support Apple's dynamic text sizing in web content (iOS Safari & WebViews)
/*
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;
}
}
@colingourlay
colingourlay / scottish-tablet-recipe.md
Last active March 3, 2023 05:39
Scottish Tablet Recipe

Scottish Tablet

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

Ingredients

  • 1kg caster sugar
  • 250g butter
@colingourlay
colingourlay / daily.json
Created January 12, 2022 02:26
Wordle words
[
"cigar",
"rebut",
"sissy",
"humph",
"awake",
"blush",
"focal",
"evade",
"naval",
@colingourlay
colingourlay / example.js
Last active October 22, 2021 15:16
Lodash / Underscore sort object keys. Like _.sortBy(), but on keys instead of values, returning an object, not an array. Defaults to alphanumeric sort.
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}
@colingourlay
colingourlay / idle-analytics.js
Created September 7, 2016 07:41
Defer the standard Google Analytics script until the page is idle, in supported browsers.
(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 January 5, 2021 19:43
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.
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
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'
sudo /usr/local/McAfee/AntiMalware/VSControl stopoas
sudo killall VShieldService
sudo killall VShieldScanner
@colingourlay
colingourlay / flat.js
Last active June 15, 2019 22:42
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.
function flat(fn) {
return function (...args) {
return new Promise((resolve, reject) => {
fn.call(this, {resolve, reject}, ...args);
});
};
}