Skip to content

Instantly share code, notes, and snippets.

@ianmacartney
ianmacartney / ucdq.c
Created October 29, 2013 06:32
Basic dispatch queue for static memory applications (e.g. embedded). Caller is responsible for lifetime of all data passed in.
/**
* q: queue of dispatches
* d: dispatch
* front/head = top of stack
* back/end/tail = bottom of stack
*/
struct DQDispatch {
void (*fn)(void *);
void *param;
struct DQDispatch *next;
@ianmacartney
ianmacartney / ucll.c
Last active December 26, 2015 20:39
Basic linked list for static memory applications (e.g. embedded). Caller is responsible for lifetime of all data passed in.
/**
* ll: Linked List
* n: node
* front/head = top of stack
* back/end/tail = bottom of stack
*/
struct ll {
void *data;
struct ll *next;
};
@ianmacartney
ianmacartney / OhLifePhotosToDayOne.sh
Last active August 29, 2015 14:06
Move OhLife photos to Day One
#! /bin/bash
# This script will add a DayOne entry for each photo in your OhLife journal.
# It will also rename the photos to have the date in their name for you convenience
# 1. Download this gist and open the .tar.gz or whatever it downloaded as.
# 2. Go to https://ohlife.com/entries/all and log in
# 3. Once the page fully loads, right click the background and click "Save As..." and choose the directory
# where this file was downloaded.
# This will download all the photos and the html of the page.
# 4. If the name of the page was different than NAME below, change NAME below to be the name of the .html file in the directory

How to use CoffeeTags (min 0.0.2.0) with TagBar

Config types

CoffeeTags can work in 2 modes:

  • tags only for functions (default)
  • tags for functions and objects containing them

Second mode is activated by adding --include-vars to command line arguments

@ianmacartney
ianmacartney / llm.ts
Last active December 5, 2024 16:30
Implementation of chat completions and embeddings for any OpenAI-compliant services, using browser fetch and no imports/dependencies
export const CONFIG = {
// Together AI:
url: "https://api.together.xyz",
chatModel: "meta-llama/Llama-3-8b-chat-hf",
embeddingModel: "togethercomputer/m2-bert-80M-8k-retrieval", // dim 768
// OpenAI:
// url: "https://api.openai.com",
// chatModel: "gpt-4o",
// embeddingModel: "text-embedding-ada-002", // dim 1536
};
[{ "title": "The Shawshank Redemption", "text": "The movie The Shawshank Redemption"},
{ "title": "The Godfather", "text": "The movie The Godfather"},
{ "title": "The Dark Knight", "text": "The movie The Dark Knight"},
{ "title": "The Godfather Part II", "text": "The movie The Godfather Part II"},
{ "title": "12 Angry Men", "text": "The movie 12 Angry Men"},
{ "title": "The Lord of the Rings: The Return of the King", "text": "The movie The Lord of the Rings: The Return of the King"},
{ "title": "Schindler's List", "text": "The movie Schindler's List"},
{ "title": "Pulp Fiction", "text": "The movie Pulp Fiction"},
{ "title": "The Lord of the Rings: The Fellowship of the Ring", "text": "The movie The Lord of the Rings: The Fellowship of the Ring"},
{ "title": "The Good, the Bad and the Ugly", "text": "The movie The Good, the Bad and the Ugly"},
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Configuration schema for Convex project settings.\n\nDocumentation: https://docs.convex.dev/production/project-configuration#convexjson",
"type": "object",
"properties": {
"$schema": {
"type": "string"
},
"node": {
"type": "object",