Skip to content

Instantly share code, notes, and snippets.

import { Dictionary, Entry, entries, dict } from './Dictionary';
import { KVPair, kvPair } from './object';
import { identity } from './utils';
type Transformer<C, X> = (c: C, context?: X) => C;
type Getter<S, C> = (s: S) => C;
type Setter<S, C> = (s: S, v: C) => S;
type Reducer<R, C, X> = (sum: R, value: C, context: X) => R;
@eddking
eddking / Main.purs
Created December 11, 2017 16:18
Free monad example in purescript
module Main where
import Data.Generic
import Prelude
import Control.Monad.Free (Free, liftF, runFreeM)
import Control.Monad.Eff
import Control.Monad.Eff.Console (log, CONSOLE)
import Control.Monad.Eff.Random (randomBool, RANDOM)
data Action =
@eddking
eddking / review-data-export.js
Last active February 13, 2019 19:02
export pull request & review data from github via the http api
const request = require('request-promise-native');
const parseLinkHeader = require('parse-link-header');
const fs = require('fs');
/*
* This is an idempotent script for downloading pr & review data for a single repository
* Set the repo and auth variables below, then run and wait. its not speedy, but it works
*
* If you stop the script or it dies or you trigger abuse detection, it is safe to restart.
* it will only download the remaining data, any requests that were pending at the time of
@eddking
eddking / run.ts
Last active July 17, 2024 18:41
Streaming Function Calling with OpenAI assistants API
import { Assistant } from "openai/resources/beta/assistants/assistants";
import { Message } from "openai/resources/beta/threads/messages/messages";
import { RequiredActionFunctionToolCall } from "openai/resources/beta/threads/runs/runs";
import { Thread } from "openai/resources/beta/threads/threads";
import { searchInput } from "src/handlers/search";
import { adminUpdateAiThreadExtra } from "src/operations/ai_thread";
import { openai } from "../lib/openai";
import {
getMessageContent,
parsePlain,