Skip to content

Instantly share code, notes, and snippets.

{-# 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
# 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/', '')
@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"
@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 / 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>
const Connected = {};
function removeUser(conferenceId, uid, ws)
{
const Conf = Connected[conferenceId];
const a = Conf[uid];
if (a.length == 1) {
if (Conf.numParticipants == 1) {
delete Connected[conferenceId];
} else {
Apr 7 07:54:05 iPhone D6UI_000[1111] <Notice>: [2018.04.07-14.54.05:434][599]LogTemp: New Timestamp 167582.664033
Apr 7 07:54:05 iPhone D6UI_000[1111] <Notice>: [2018.04.07-14.54.05:441][600]LogTemp: cars.yaml => /var/containers/Bundle/Application/B35C3FD0-D203-4712-A0DF-1EB53006E9A6/D6UI_000.app/cars.yaml
Apr 7 07:54:05 iPhone D6UI_000[1111] <Notice>: [2018.04.07-14.54.05:589][608]LogBlueprintUserMessages: [UIMap_C_1] Sun direction: P=196.459335 Y=104.594971 R=0.000000
Apr 7 07:54:05 iPhone D6UI_000[1111] <Notice>: Created a hitchy pipeline state for hash 4000000000049000000000b733194b5 (this = 0x13b7a5a00)
Apr 7 07:54:05 iPhone D6UI_000(CFNetwork)[1111] <Notice>: Task <42FAADA6-8045-47AC-8337-D29AAA6C0E48>.<0> received response, status 200 content K
Apr 7 07:54:05 iPhone D6UI_000(CFNetwork)[1111] <Notice>: Task <42FAADA6-8045-47AC-8337-D29AAA6C0E48>.<0> response ended
Apr 7 07:54:05 iPhone D6UI_000[1111] <Notice>: [2018.04.07-14.54.05:684][613]LogVaRest: On process request complete https://maps.googl
// Fill out your copyright notice in the Description page of Project Settings.
#include "SighthoundRecognizerComponent.h"
#include "AppleARKitBlueprintFunctionLibrary.h"
#include "AppleARKitSession.h"
#if PLATFORM_IOS
#import <Foundation/Foundation.h>
#import <CoreMedia/CoreMedia.h>
#import <CoreVideo/CoreVideo.h>
#pragma once
#include "CoreMinimal.h"
#include "MediaTexture.h"
#include "AVFoundation/AVFoundation.h"
#include "CoreMedia/CoreMedia.h"
#include <Metal/Metal.h>
@class FSampleBufferDelegate;
#include "IOSCamera.h"
#include "IMediaTextureSink.h"
#include "MediaTexture.h"
@interface FSampleBufferDelegate: NSObject<AVCaptureVideoDataOutputSampleBufferDelegate>
@property (assign) FIOSCamera* Target;
@end