Skip to content

Instantly share code, notes, and snippets.

const fs = require('fs');
const qs = require('querystring');
const https = require('https');
const query = {
key: fs.readFileSync('/home/jcreed/private/maps-api2', 'utf8').replace(/\n/g, ''),
input: "chipotle",
inputtype: "textquery",
fields: "formatted_address,name",
location: "40.7831,-73.9712", // manhattan
#include <stdio.h>
#define GOOD1 99586915107664152904966939075856564224.0
#define GOOD2 298759386401549014052982412761733529600.0
#define BAD 298759406683958617704652836708984815616.0
int isGood(float x) {
return 1.0 / (1.0 / x) == x;
}
float disc(float x) {
@jcreedcmu
jcreedcmu / pattern.ts
Created February 17, 2019 22:50
pattern.ts
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
type Elim<T extends { t: string }, U extends string> = T extends { t: U } ? never : T;
type Choose<T extends { t: string }, U extends string> = T extends { t: U } ? T : never;
type Prog<T, U> = { k: 'src', v: T } | { k: 'ans', v: U };
interface PreMatcher<T extends { t: string }> {
cas<S extends string, U>(tag: S, f: (x: Omit<Choose<T, S>, 't'>) => U): Matcher<Elim<T, S>, U>;
}
interface Matcher<T extends { t: string }, U> {
@jcreedcmu
jcreedcmu / b.ts
Created January 1, 2019 20:08
b.ts
type Lang = 'en' | 'es';
type Intl<T> = {
forms: { new_form: T },
hello: T
};
type Dict<T extends string, U> = { [k in T]: U };
type LangDataIn = Dict<Lang, Intl<string>>;
type LangDataOut = Intl<Dict<Lang, string>>;
@jcreedcmu
jcreedcmu / enum2.ts
Last active September 16, 2018 17:48
enum2.ts
import { range, sum, uniq } from './util';
function paths(s) {
function swap(s, n) {
const sc = [].concat(s);
const tmp = sc[n];
sc[n] = sc[n + 1];
sc[n + 1] = tmp;
return sc;
}
@jcreedcmu
jcreedcmu / enum.ts
Created September 16, 2018 15:46
enum.ts
export function range(n) {
const rv = [];
for (let i = 0; i < n; i++)
rv.push(i);
return rv;
}
const r = Math.random;
type Point = {x: number, y: number};
@jcreedcmu
jcreedcmu / RelationList.agda
Created August 30, 2018 11:02
RelationList.agda
module RelationList (A : Set) where
-- Converse of relation
converse : (A → A → Set) → (A → A → Set)
converse R a a' = R a' a
-- A list of things (a1, a2, ... an) with relations
-- u -R-> a1 -R-> a2 -R-> ... -R-> an -R-> v
data Rist' (R : A → A → Set) (v : A) : (u : A) → Set where
rnil : {u : A} → (r : R u v) → Rist' R v u
{-# OPTIONS --without-K #-}
open import HoTT
module b where
A : Set
A = ℕ
rev : (A → A → Set) → (A → A → Set)
rev R a a' = R a' a
@jcreedcmu
jcreedcmu / DagTypes.agda
Created August 23, 2018 19:51
DagTypes.agda
module DagTypes where
data Unit : Set where
* : Unit
data Void : Set where
data Sum (A B : Set) : Set where
inl : A → Sum A B
inr : B → Sum A B
@jcreedcmu
jcreedcmu / mastodon.css
Created August 16, 2018 17:09
mastodon.css
@media (min-width: 1024px) {
.tabs-bar {display: flex; width: 785px; margin-left: calc(25% + 155px); z-index: 1;}
.columns-area {width: calc(50% + 300px); margin: -60px auto auto;}
.column {display: none;}
.column:last-child {display: flex; min-width: 800px; margin-top: 55px;}
}
a[data-preview-title-id="column.community"] {
display: none;
}