Skip to content

Instantly share code, notes, and snippets.

View keller's full-sized avatar

Keller Davis keller

View GitHub Profile
@keller
keller / kate_birthday.coffee
Created January 28, 2012 04:27
Birthday Card for Kate
sing = (lyric, song) ->
lines = (song.line(i, lyric) for i in [0...song.length])
full_song = lines.join(",\n")+"!"
alert full_song
birthday =
length: 4
line: (line, lyric) ->
lyric + if (line == 2) then " birthday, dear #{@name}" else " birthday to you"
to: (@name) ->
@keller
keller / react-redux.js
Last active January 30, 2018 21:34
Simple react-redux implemententation using all "render props" and react-broadcast@next
import React, { Component } from "react";
import { createContext } from "react-broadcast";
const StoreContext = createContext();
class Connected extends Component {
state = this.props.store.getState();
componentDidMount() {
this.props.store.subscribe(() => {
this.setState(this.props.store.getState());
/* naive implementation of useState and useEffect */
let states = [];
let newStates;
let _render = () => {};
let unsubs = [];
let deps = [];
let newDeps;
### Keybase proof
I hereby claim:
* I am keller on github.
* I am keller (https://keybase.io/keller) on keybase.
* I have a public key whose fingerprint is F7A9 B006 F1B7 C2DD FAEE 7DF6 33E0 2B67 721F F6D4
To claim this, I am signing this object:
//Lambda Calc JS
const TRUE = x => y => x;
const FALSE = x => y => y;
const ZERO = x => y => y;
const ONE = x => y => x(y);
const SUCC = n => x => y => x(n(x)(y));
const MULT = x => y => z => x(y(z));
@keller
keller / fizz.sh
Last active July 19, 2021 14:46
Linked to from twitter
curl -s https://gist.githubusercontent.com/keller/8589abe5431d62c6568e2af15414989a/raw/de15e6030a078dba18386dcb457e063e8d8e458f/fizzbuzz_min.js | node -
@keller
keller / fizzbuzz.js
Last active October 20, 2021 17:18
Fizz Buzz in lambda calculus and JS. Also version in Racket: https://gist.github.com/keller/8aa87814c120e725f9ed6c223642e981
const ZERO = f => a => a;
const ONE = f => a => f(a);
const TWO = f => a => f(f(a));
const THREE = f => a => f(f(f(a)));
const FIVE = f => a => f(f(f(f(f(a)))));
const SUCC = n => f => a => f(n(f)(a));
const MULT = x => y => f => x(y(f));
#lang racket
(define TRUE (λ (x) (λ (y) x)) )
(define FALSE (λ (x) (λ (y) y)) )
(define ZERO (λ (f) (λ (a) a)))
(define ONE (λ (f) (λ (a) (f a))))
(define TWO (λ (f) (λ (a) (f (f a)))))
(define THREE (λ (f) (λ (a) (f (f (f a))))))
(define FIVE (λ (f) (λ (a) (f (f (f (f (f a))))))))
function* nums(n) {
yield n;
yield* nums(n + 1);
}
function* primes(seq) {
const prime = seq.next().value;
yield prime;
const nextSeq = function* () {
#!/bin/bash
#
# Script written by GPT-4
#
# Description:
# This script generates commit message suggestions based on the staged git diff.
# It uses the OpenAI Chat API with the specified model to generate the suggestions,
# and outputs a list of recommended commit messages. The user can customize the
# model, maximum number of lines from the git diff, and whether to follow
# conventional commit message format.