Skip to content

Instantly share code, notes, and snippets.

@josgraha
josgraha / combinators.js
Created March 19, 2019 20:54 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
@josgraha
josgraha / fancy-tabs-demo.html
Created July 3, 2018 14:29 — forked from ebidel/fancy-tabs-demo.html
Fancy tabs web component - shadow dom v1, custom elements v1, full a11y
<script>
function execPolyfill() {
(function(){
// CustomElementsV1.min.js v1 polyfill from https://github.com/webcomponents/webcomponentsjs/tree/v1/src/CustomElements/v1.
/*
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
@josgraha
josgraha / fun-with-compose.js
Last active November 17, 2017 17:23 — forked from anonymous/fun-with-compose.js
fun-with-compose created by josgraha - https://repl.it/NznS/2
const R = require('ramda');
const { append, compose, filter, flatten, isArray, join, map, prepend } = R
const { log } = console
// html markup functions
const UL = 'ul'
const LI = 'li'
const tagOpen = tag => `<${tag}>`
@josgraha
josgraha / typescript-pattern-matching.ts
Created July 11, 2017 15:44 — forked from rob3c/typescript-pattern-matching.ts
TypeScript pattern matching proof-of-concept
// preserved from my comment in this issue: https://github.com/Microsoft/TypeScript/issues/165#issuecomment-259598080
interface Type<T> { new(...args): T }
interface CaseResult<R> {
success: boolean;
result: R;
}
interface CaseFn<R> { (value: any): CaseResult<R> }
@josgraha
josgraha / index.html
Last active June 10, 2017 04:27 — forked from anonymous/index.html
xrZBGQ
<div id="colorbars"></div>
@josgraha
josgraha / index.html
Created January 10, 2017 21:41
D3 visualization of daily revenue through calendar format looping through the months continuously
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Calendar Loop</title>
<script type="text/javascript" src="https://d3js.org/d3.v4.js"></script>
<!-- <link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="style.css"> -->
# to install the latest stable version:
brew install scala --with-docs
# to install scala-2.10:
brew install https://raw.github.com/gist/4340744/scala.rb --with-docs
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch scala 2.9.2
brew switch scala 2.10.0
@josgraha
josgraha / index.html
Last active August 29, 2015 14:23 — forked from anonymous/index.html
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://raw.githack.com/CrossEye/ramda/master/ramda.js"></script>
<script src="http://looprecur.com/hostedjs/pointfree.browser.js"></script>
<script src="http://looprecur.com/hostedjs/monoids.js"></script>
<script src="http://looprecur.com/hostedjs/maybe.js"></script>
@josgraha
josgraha / pom.xml
Last active August 29, 2015 14:06 — forked from codahale/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- none yet -->
@josgraha
josgraha / gist:4121930
Created November 20, 2012 23:18 — forked from swannodette/gist:4120545
Possible syntaxes for flexible unifier w/ multi-lvar constraints
;;Support for simple constraints on lvars during unification was added in 76fd4d7c:
;;
;; https://github.com/clojure/core.logic/commit/76fd4d7c155161d74ad5cd8d87955148eece1fe0
;;
;;but these constraints apply to a single lvar only.
;;The unifier could support more general constraints if it accepted an explicit predicate function.
;;For instance, given this `data-numeric?` predicate and `spec` data:
(defn data-numeric? [data dimension]