Skip to content

Instantly share code, notes, and snippets.

View samgiles's full-sized avatar
🗺️

Sam Giles samgiles

🗺️
  • Citymapper
  • London
View GitHub Profile
#
var resolvedPolyfills = {};
polyfills.forEach(function(polyfill) {
resolvers.forEach(function(resolver) {
resolver(polyfill).forEach(function(targetPolyfill) {
resolvedPolyfills[targetPolyfill.name] = targetPolyfill
})
})
});
@samgiles
samgiles / dom_recycler
Created July 17, 2014 15:42
Old DOM Element recycling test
<!DOCTYPE html>
<html>
<head>
<title>DOM Recycler</title>
<style>
/* Styles not relevant to scrolling (just to make the demo look neat and tidy) */
body { font-family: sans-serif; -webkit-text-size-adjust: 100% }
@samgiles
samgiles / .travis.yml
Last active September 22, 2015 14:55 — forked from triblondon/.travis.yml
sudo: false
language: node_js
node_js:
- "0.10"
before_install:
- npm install -g Financial-Times/origami-build-tools#node-0.10
- obt install
script:
- obt test
- obt verify
@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));
};
@samgiles
samgiles / gist:11214993
Created April 23, 2014 13:22
Full example of 'channel poisoning' for producer channels using a control channel [occam-pi]
#INCLUDE "course.module"
PROTOCOL CONTROL
CASE
poison
:
PROTOCOL TAGGED.INT
CASE
normal; INT
@samgiles
samgiles / test.occ
Created April 23, 2014 12:27
Simple producer, consumer example [occam-pi]
#include "course.module"
PROC producer(VAL INT start, step, CHAN OF INT c!)
INT count:
SEQ
count := start
WHILE TRUE
SEQ
c ! count
count := count + step
@samgiles
samgiles / gist:11173191
Last active August 29, 2015 14:00
Get the current Python path as a string with correct path separator
import sys
import os
def pythonpath():
# Remove filter if you don't care about cases such as: ':/path::', where members of the path are
# empty. It would be slightly faster to complete this operation if the filter was not run but the size of the
# input is likely to be small
os.pathsep.join(filter(lambda path: len(path) > 0, sys.path))
@samgiles
samgiles / gist:9994055
Last active August 29, 2015 13:58
auto-vectorisation example in GCC
void test_vec(double* restrict a, double* restrict b) {
int i;
double *x = __builtin_assume_aligned(a, 16);
double *y = __builtin_assume_aligned(b, 16);
for(i = 0; i < SIZE; i++) {
x[i] = x[i] + y[i];
}
}
@samgiles
samgiles / gist:9856834
Last active August 29, 2015 13:57
Steps to reproduce JIT memory errors
make wlvlang-jit PYPYPATH=~path/to/pypy
# This should pass
make test_all_jit
# Unfortunately the path to the script needs to be relative! (I should fix that)
bin/wlvlang-jit tests/benchmarks/thread-ring.wl 10 10
# This should cause a segfault or:
#