Skip to content

Instantly share code, notes, and snippets.

View jawj's full-sized avatar

George MacKerron jawj

View GitHub Profile
@jawj
jawj / whc-sites-2021.psql
Created February 1, 2023 20:49
SQL to load UNESCO World Heritage Sites 2021 into PostgreSQL/PostGIS
-- == create schema == --
begin;
drop type if exists category cascade;
create type category as enum ('Natural', 'Cultural', 'Mixed');
drop type if exists category_short cascade;
create type category_short as enum ('N', 'C', 'C/N');
@jawj
jawj / whc-sites-2021.csv
Created February 1, 2023 20:39
World Heritage Sites 2021 | Data from https://whc.unesco.org/en/syndication/ converted to CSV | Copyright © 1992 – 2022 UNESCO/World Heritage Centre
We can't make this file beautiful and searchable because it's too large.
unique_number,id_no,rev_bis,name_en,name_fr,short_description_en,short_description_fr,justification_en,justification_fr,date_inscribed,secondary_dates,danger,date_end,danger_list,longitude,latitude,area_hectares,C1,C2,C3,C4,C5,C6,N7,N8,N9,N10,criteria_txt,category,category_short,states_name_en,states_name_fr,region_en,region_fr,iso_code,udnp_code,transboundary
230,208,Rev,Cultural Landscape and Archaeological Remains of the Bamiyan Valley,Paysage culturel et vestiges archéologiques de la vallée de Bamiyan,"<p>The cultural landscape and archaeological remains of the Bamiyan Valley represent the artistic and religious developments which from the 1st to the 13th centuries characterized ancient Bakhtria, integrating various cultural influences into the Gandhara school of Buddhist art. The area contains numerous Buddhist monastic ensembles and sanctuaries, as well as fortified edifices from the Islamic period. The site is also testimony to the tragic destruction by the Taliban of the two standing Buddha statues, w
@jawj
jawj / install.txt
Last active March 29, 2023 05:44
Debug serverless driver in Chrome + Wireshark from any AWS region
# using AWS Lightsail, Ubuntu 20.04
# in dashboard, allow TCP on port 5901
sudo apt update && sudo apt upgrade -y && sudo apt install -y \
tigervnc-standalone-server tigervnc-xorg-extension \
xfce4 wireshark node # pick any window mgr, say yes to non-root packet capture
# set up VNC
@jawj
jawj / iso8601us.ts
Created May 23, 2021 15:40
Convert between 6dp ISO8601-format dates and Unix epoch microseconds in Zapatos
import { DateString, strict } from 'zapatos/db';
/**
* Convert a `DateString` (to 6dp) to microseconds since 1 January 1970.
* Nullability is preserved (e.g `DateString | null` becomes `number | null`)
* using `strict`. Note: only dates before 5 June 2255 can be represented
* within `Number.MAX_SAFE_INTEGER` this way.
*/
export const toUnixMicroseconds = strict((d: DateString) => {
const
@jawj
jawj / LinkableTextView.h
Last active January 10, 2020 12:34
UITextView with tappable links even when not selectable
//
// LinkableTextView.h
//
// Created by George MacKerron on 2020/01/09.
// Copyright © 2020 George MacKerron. MIT licenced.
//
@import UIKit;
@interface LinkableTextView : UITextView
@jawj
jawj / liars-cheats-thugs-racists-crooks.md
Last active November 26, 2019 11:45
Liars, cheats, thugs, racists and crooks — references

Liars

Johnson repeated the claim that leaving the EU would save £350m/week in contributions even after the ONS told him it was “a clear misuse of official statistics”. Full Fact

The Department for Work and Pensions has spent £100s of millions of public money disseminating misinformation about Universal Credit for Tory political advantage. The Guardian

Cheats

During the leaders’ TV debate, the Tory press Twitter account (@CCHQPress) rebranded as factcheckUK in order to dupe people into thinking their partisan commentary was impartial. BBC News

@jawj
jawj / CAMediaTimingFunction+GMTimingBlock.h
Last active January 22, 2017 03:42
An easing category on CAMediaTimingFunction, with thanks to Mozilla
//
// CAMediaTimingFunction+GMTimingBlock.h
//
// Created by George MacKerron on 2015/06/11.
// Copyright (c) 2015 George MacKerron. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
@jawj
jawj / crc.coffee
Last active August 29, 2015 14:13
String CRC in CoffeeScript
# tested against OS X cksum: `echo -n 'hello' | cksum -o 3` == "hello".crc32()
String.CRC32Table = # ref: http://www.w3.org/TR/PNG/#D-CRCAppendix
for c in [0..255] # (can clobber c with impunity below thanks to CoffeeScript)
for k in [0..7]
c = if c & 1 then 0xedb88320 ^ (c >>> 1) else (c >>> 1)
c >>> 0
String::crc32 = (crc = 0xffffffff) ->
for i in [0...@length] by 1
@jawj
jawj / AlignmentRectRespectingSlider.h
Last active August 29, 2015 14:06
A UISlider subclass for iOS7 that respects alignmentRectInsets on custom thumb images
@interface AlignmentRectRespectingSlider : UISlider
@end