Skip to content

Instantly share code, notes, and snippets.

View tbergman's full-sized avatar

tbergman

View GitHub Profile
@cloneofsimo
cloneofsimo / watch_setup.sh
Created October 25, 2024 22:18
latex-watcher
#!/bin/bash
# Install required packages if not present
check_and_install_dependencies() {
local packages=("inotify-tools" "texlive" "texlive-latex-extra" "biber")
echo "Checking and installing dependencies..."
for package in "${packages[@]}"; do
if ! dpkg -l | grep -q "^ii $package "; then
sudo apt-get install -y "$package"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import dspy
from dspy.functional import TypedPredictor
import os
from dotenv import load_dotenv
from transitions import Machine
load_dotenv()
llm = dspy.OpenAI(
model='gpt-3.5-turbo',
@0xdevalias
0xdevalias / audio-to-midi.md
Last active December 1, 2024 10:48
Some notes on Automated Audio Transcription (AAT) / Automated Music Transcription (AMT) (aka: converting audio to midi)

Automated Audio Transcription (AAT) / Automated Music Transcription (AMT) (aka: converting audio to midi)

Some notes on Automated Audio Transcription (AAT) / Automated Music Transcription (AMT) (aka: converting audio to midi)

Table of Contents

@kallebysantos
kallebysantos / App.tsx
Last active May 12, 2025 03:33
Running Local AI models with FastAPI and Vercel AI SDK
import "./App.css";
import { useEffect, useState } from "react";
import { useCompletion } from "ai/react";
function App() {
const [apiResponse, setApiResponse] = useState("");
useEffect(() => {
fetch("/api/reply?value=Hello from React App!")
.then((response) => response.json())
@KexinFeng
KexinFeng / BertTranslator.java
Last active February 1, 2025 21:14
Deploying HuggingFace QA model in Java
import ai.djl.modality.nlp.DefaultVocabulary;
import ai.djl.modality.nlp.Vocabulary;
import ai.djl.modality.nlp.bert.BertToken;
import ai.djl.modality.nlp.bert.BertTokenizer;
import ai.djl.modality.nlp.qa.QAInput;
import ai.djl.ndarray.NDArray;
import ai.djl.ndarray.NDList;
import ai.djl.ndarray.NDManager;
import ai.djl.translate.Batchifier;
import ai.djl.translate.Translator;
@dusskapark
dusskapark / convert-rico-for-object-detection.ipynb
Last active March 1, 2024 16:56
Convert RICO for Object Detection.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ornicar
ornicar / browser-ndjson-stream-reader.js
Last active October 31, 2025 22:43
Read a ND-JSON stream from the browser or from nodejs
/* FOR THE BROWSER
Utility function to read a ND-JSON HTTP stream.
`processLine` is a function taking a JSON object. It will be called with each element of the stream.
`response` is the result of a `fetch` request.
See usage example in the next file.
*/
const readStream = processLine => response => {
const stream = response.body.getReader();
const matcher = /\r?\n/;
@zadvorsky
zadvorsky / Geometry.js
Created June 1, 2021 02:12
Three.js deprecated `Geometry` in favor of `BufferGeometry` some time ago, though they still offer the `Geometry` class as an external ES6 module. This is that same class, but modified to use the global THREE namespace, so it can be included in a regular script tag for older projects without a build step. Once included, the script defines `THREE…
const _m1 = new THREE.Matrix4();
const _obj = new THREE.Object3D();
const _offset = new THREE.Vector3();
class Geometry extends THREE.EventDispatcher {
constructor() {
super();
@cevr
cevr / editableTextMachine.ts
Last active November 14, 2021 15:25
xstate fp utils POC
import * as x from './xstate-fp';
export enum EditableTextState {
idle = 'idle',
editing = 'editing',
}
export enum EditableTextEvent {
mouseenter = 'mouseenter',
mouseleave = 'mouseleave',