Skip to content

Instantly share code, notes, and snippets.

View tdreyno's full-sized avatar

Thomas Reynolds tdreyno

  • Portland, OR
  • 21:10 (UTC -07:00)
View GitHub Profile
@tdreyno
tdreyno / airports.json
Created December 13, 2012 18:50
JSON data for airports and their locations
This file has been truncated, but you can view the full file.
[
{
"code": "AAA",
"lat": "-17.3595",
"lon": "-145.494",
"name": "Anaa Airport",
"city": "Anaa",
"state": "Tuamotu-Gambier",
"country": "French Polynesia",
"woeid": "12512819",
@tdreyno
tdreyno / solarized.css
Created August 4, 2011 17:32
Solarized Pygments CSS
.hll { background-color: #ffffcc }
.c { color: #586E75 } /* Comment */
.err { color: #93A1A1 } /* Error */
.g { color: #93A1A1 } /* Generic */
.k { color: #859900 } /* Keyword */
.l { color: #93A1A1 } /* Literal */
.n { color: #93A1A1 } /* Name */
.o { color: #859900 } /* Operator */
.x { color: #CB4B16 } /* Other */
.p { color: #93A1A1 } /* Punctuation */
@tdreyno
tdreyno / church.js
Created April 22, 2020 01:34
Basic church encoding in JS
// Lambda calculus: Church 1940-ish
//
// <expression> := <name> | <function> | <application>
// <function> := λ <name>.<expression>
// <application> := <expression><expression>
//
// expression := name | function | application
// function := name => expression
// application := expression(expression)
//
@tdreyno
tdreyno / to.ts
Last active January 9, 2020 17:42
Helper method to make `reduce(to(` be a somewhat awkard way to transform arrays to other types.
export function to<A, T>(fn: (items: A[]) => T) {
return (sum: any, _item: A, index: number, all: A[]): T => {
const isLast = index === all.length - 1;
if (!isLast) {
return sum;
}
return fn(all);
};
export function loadStories(userId: string) {
return Task.map2(
myStories => storiesSharedWithMe =>
({
myStories,
storiesSharedWithMe,
}),
userStories(userId).map(listToLookup),
userSharedStories(userId).map(listToLookup),
@tdreyno
tdreyno / andThen.ts
Last active October 23, 2019 19:53
It's like map, but you get the whole list.
interface Array<T> {
andThen: <U>(this: T[], fn: (items: T[]) => U) => U;
}
Array.prototype.andThen = function<T, U>(this: T[], fn: (items: T[]) => U): U {
return fn(this);
};
@tdreyno
tdreyno / sprite_sheet.css
Created March 8, 2012 17:44
60 fps CSS Animation
@keyframes animate-particle {
0% {
background-position: 0 0px; }
1.695% {
background-position: 0 -124px; }
3.39% {
background-position: 0 -248px; }
@tdreyno
tdreyno / easing.scss
Created May 7, 2011 02:02
Easing functions for Sass 3.1
@function linear() {
@return cubic-bezier(0.250, 0.250, 0.750, 0.750); }
@function ease() {
@return cubic-bezier(0.250, 0.100, 0.250, 1.000); }
@function ease-in() {
@return cubic-bezier(0.420, 0.000, 1.000, 1.000); }
@function ease-in-quad() {
@return cubic-bezier(0.550, 0.085, 0.680, 0.530); }
@tdreyno
tdreyno / DataModel.js
Created February 23, 2015 20:55
Google I/O 2015 Experiment Data Serializer
var PIXI = require('pixi.js/bin/pixi.dev.js');
/**
* Data model and serialization.
*/
module.exports = (function() {
'use strict';
/**
* URL-safe character mapping.
@tdreyno
tdreyno / 1-demo.ts
Last active September 25, 2017 23:15
// Vector of number types
const v1 = vector([1, 2, 3, 4]);
console.log(v1.toString());
// Vector of string types
const v2 = vector(["a", "b", "c", "d"]);
console.log(v2.toString());
// Vector of vector types