Skip to content

Instantly share code, notes, and snippets.

View ThatsJustCheesy's full-sized avatar

Ian Gregory ThatsJustCheesy

View GitHub Profile
@ThatsJustCheesy
ThatsJustCheesy / find_node_modules.fish
Created December 26, 2024 16:43
Find heaviest objects in the universe (macOS, fish)
for f in (find ~ -type d -name node_modules -prune -print); du -sh $f; end | gsort -h
@ThatsJustCheesy
ThatsJustCheesy / main.py
Last active December 25, 2024 16:08
LangChain OpenAI API proxy on Google Cloud Functions
from typing import Any, AsyncIterator, Dict, Iterator, List, Optional
from langchain_core.language_models import BaseChatModel, SimpleChatModel
from langchain_core.load import dumpd, dumps, load, loads
from langchain_core.messages import AIMessage, AIMessageChunk, BaseMessage, HumanMessage
from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
import requests
import functions_framework
@ThatsJustCheesy
ThatsJustCheesy / automerge-entry.ts
Last active July 27, 2024 12:15
Automerge SQL storage adapter
import { Column, DataType, Model, Table } from "sequelize-typescript";
// Implements storage for Automerge history entries (incremental changes and snapshots).
// https://automerge.org/docs/under-the-hood/storage/#the-storage-model
@Table({
// https://github.com/sequelize/sequelize-typescript/issues/105#issuecomment-832075653
indexes: [
{
name: "automerge_entry_key",
fields: ["key0", "key1", "key2"],
@ThatsJustCheesy
ThatsJustCheesy / Navigate UTSC Website.js
Last active July 31, 2022 20:49
Always show side menu on UTSC's website because people (like me) forget it exists
// ==UserScript==
// @name Navigable UTSC Website
// @description Auto-shows the side menu on UTSC's website, because people forget it exists and attempt to use Google instead.
// NOTE: Small window sizes break this.
// @match *://www.utsc.utoronto.ca/*
// ==/UserScript==
function inIframe() {
try {
return window.self !== window.top;
@ThatsJustCheesy
ThatsJustCheesy / ParagraphsToSlides.vba
Created July 30, 2022 01:37
Make PowerPoint slides from plain text paragraphs
' This macro creates slides from plain text on your clipboard.
' Two consecutive line breaks begin a new slide.
' New slides will be duplicates of the selected slide,
' which must contain a single text box and nothing else.
'
' Usage:
' 1. Prepare plain text paragraphs of your slide content
' 2. Copy the text to your clipboard
' 3. Select a slide that contains a single text box with desired formatting
' 4. Run ParagraphsToSlides as a macro
@ThatsJustCheesy
ThatsJustCheesy / curry.cr
Created July 1, 2022 04:30
Crystal Proc#curry method (implemented with macros)
struct Proc(*T, R)
def curry
{% begin %}
{% for i in 0...T.size %}
->(arg_{{i}} : {{T[i]}}) {
{% end %}
self.call(
{% for i in 0...T.size %}
arg_{{i}},
{% end %}
@ThatsJustCheesy
ThatsJustCheesy / gist:861f02c6c28e00e725c29cd13744be85
Created October 11, 2021 17:55
Stupid simple instant messaging via netcat with desktop notifications
nc -l $IN_PORT | bash -c "while true; do read msg; osascript -e \" display notification \\\"\$msg\\\" \" & done"
nc $OUT_ADDRESS $OUT_PORT
@ThatsJustCheesy
ThatsJustCheesy / dequarantine-and-open.sh
Created July 4, 2021 05:58
macOS script: Open downloaded file(s) bypassing gatekeeper dialog
#!/bin/bash
# Either use from the command line, or put in an Automator workflow
# that takes files as input and save it as a Quick Action.
# For bonus points, assign a nice keyboard shortcut.
for file
do
xattr -r -d com.apple.quarantine "$file"
open "$file"
done
#include<stdio.h>
#include<math.h>
int
main
()
{;
int
x=
((
void
@ThatsJustCheesy
ThatsJustCheesy / ?
Last active January 13, 2021 21:24
bash script that describes typical filesystem objects—lists directories, describes files, and resolves links on the way
#!/bin/bash
script_canonical_name='?'
file="${1:-$(pwd)}"
if [[ -h "$file" ]]
then
echo "$script_canonical_name: is a link to $(readlink "$file")"
file=$(realpath "$file")
fi