Skip to content

Instantly share code, notes, and snippets.

View samgiles's full-sized avatar
🗺️

Sam Giles samgiles

🗺️
  • Citymapper
  • London
View GitHub Profile
@samgiles
samgiles / polyio-names.js
Last active September 30, 2023 02:49
Polyfill.io Name resolution pseudocode
// Functional Helper: When lambda returns an array, compose concat and map to return a flattened result.
// See https://gist.github.com/samgiles/762ee337dff48623e729 for an example
Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
// Mock, imagine this is some function that maps a modernizr test name to the polyfill.io nomenclature, if it doesn't map,
// it must return the name as is. Must always be an array.
function getListOfPolyFillsForModernizrTest(name) {
var mock = {
@samgiles
samgiles / flatMap.js
Created June 20, 2014 11:32
Javascript flatMap implementation
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
public static void main(String[] args) {
Integer x = 128;
Integer y = 128;
Integer a = 127;
Integer b = 127;
if (a == b) {
System.out.println("a == b");
} else {
System.out.println("a != b");
class Cmake < Formula
desc "Cross-platform make"
homepage "https://www.cmake.org/"
url "https://github.com/Kitware/CMake/releases/download/v3.19.7/cmake-3.19.7.tar.gz"
sha256 "58a15f0d56a0afccc3cc5371234fce73fcc6c8f9dbd775d898e510b83175588e"
license "BSD-3-Clause"
head "https://gitlab.kitware.com/cmake/cmake.git"
# The "latest" release on GitHub has been an unstable version before, so we
# check the Git tags instead.
@samgiles
samgiles / keybase.md
Created October 14, 2020 15:29
keybase.md

Keybase proof

I hereby claim:

  • I am samgiles on github.
  • I am samgiles (https://keybase.io/samgiles) on keybase.
  • I have a public key whose fingerprint is 931D 1228 A7A1 7D43 991B F823 6AA0 F17C AB7C 7B01

To claim this, I am signing this object:

@samgiles
samgiles / postgistogeojson.js
Created April 4, 2012 07:38
A function that converts a PostGIS query into a GeoJSON object.
/*
* A function that converts a PostGIS query into a GeoJSON object.
* Copyright (C) 2012 Samuel Giles <sam@sam-giles.co.uk>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@samgiles
samgiles / async-streams-and-promises.js
Last active October 6, 2017 00:04
Returning a Stream in a Promise is an anti-pattern.
/** Method 1. Use a PassThrough stream */
var PassThrough = require('stream').PassThrough;
function myAsyncContent() {
var myContentStream = new PassThrough();
var streamPromise = getAsyncInfo().then(function(info) {
return createStreamFromInfo(info);
});
@samgiles
samgiles / schemav2.sql
Last active January 20, 2017 15:44
Initial Postgres (+PostGIS ) Schema for Journey
CREATE TABLE poi (
id SERIAL PRIMARY KEY,
location GEOGRAPHY(POINT, 4326),
address TEXT
);
CREATE INDEX poi_location_index ON poi USING gist (location);
CREATE TABLE "user" (
id SERIAL PRIMARY KEY,
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.