Skip to content

Instantly share code, notes, and snippets.

@unktomi
unktomi / index.html
Created April 17, 2020 15:01
React Calendar with Events
<div class="calendar-rectangle">
<div id="calendar-content" class="calendar-content"></div>
</div>
@unktomi
unktomi / Promise.swift
Last active February 2, 2023 00:31
Promises in Swift
import Foundation
// Somebody at apple should be fired for getting async / await so badly wrong
// And presumably not the same person should also get fired for all this crazy @escaping fun
func compose<A, B, C>(_ apply: @escaping ((A) -> B), andThen: @escaping (B) -> C) -> ((A) -> C) {
return {
(x: A) in
andThen(apply(x))
@unktomi
unktomi / gist:4f0e1ec9f7b3c9fa301d8e4f9cbcee57
Created October 27, 2023 16:55
GPT 3.5 turbo planning hallucinations
{
"model": "gpt-3.5-turbo-0613",
"messages": [
{
"role": "system",
"content": "I want you to ignore the order of statements in the user input and focus only on the logical implications that the words denote.\n\nI need you to find a way to fulfill the goal while respecting all the restrictions. This does NOT need to happen simultaneously however. You can explore different paths and then if you find a restriction was violated, backtrack, learning from the mistake, and try a different strategy. Likewise if you discover the goal cannot be reached without undoing a previous action, backtrack, undo, and try a different strategy"
},
{
"role": "user",
"content": "I have some plates stacked in a specific order, with the blue plate at the bottom, followed by the yellow plate, then the red plate, and finally the orange plate on top"
# Converts OpenAI compatible function calling JSON schema to a prompt that instructs the LLM to return
# a JSON object that is a choice of a function call conforming to one of the functions or a message reply
def convert_schema_to_typescript(schema):
if not schema:
return 'any'
if '$ref' in schema:
return schema['$ref'].replace('#/definitions/', '')
{-# LANGUAGE GADTs, RankNTypes #-}
newtype Const a b = Const { getConst :: a }
newtype Ran g h a = Ran { runRan :: forall r. (a -> g r) -> h r }
data Lan g h a where
Lan :: h i -> (g i -> a) -> Lan g h a
type Cont r a = Ran (Const r) (Const r) a
type Selection r a = Ran (Const r) (Const a) a