Skip to content

Instantly share code, notes, and snippets.

View jaanli's full-sized avatar
🍉
Hungry

Jaan Lı 李 PhD jaanli

🍉
Hungry
View GitHub Profile
@jaanli
jaanli / copy.sh
Created April 29, 2024 14:51
Large language model (LLM) helper script to copy context into long-context-window language models to improve their ability to help users with programming tasks.
#!/bin/bash
# Instructions:
# Make this executable (`chmod a+x copy.sh`), then move this to `/usr/local/bin` on Mac (`sudo mv ../copy.sh /usr/local/bin`).
# Prompt to generate this using Claude or GPT-4 or Gemini:
# write a short bash script for mac that first:
# * uses the tree command
# * then runs cat on every entry recursively in the tree command (every file within every folder in the directory)
@jaanli
jaanli / absorbing-information.md
Created April 13, 2024 16:57
Patterns for reducing information overload.
@jaanli
jaanli / research-patterns.md
Last active April 13, 2024 11:48
Research patterns for finding information online

Information is often behind paywalls, behind artificial intelligence interfaces that require payment, and going to the source is often required to advance basic science and biomedical research.

Here are simple workflows tested over the years for accessing information:

graph TB
A[Can I access plain text content that contains the information needed to satisfy my intent?] --> B(<a href='https://web.archive.org'>Wayback Machine</a>)
A --> C(<a href='https://archive.is'>archive.is</a>)
A --> D(<a href='https://libgen.rs'>Library Genesis</a>)
A --&gt; E[<a href="https://bing.com">Bing Cached Pages</a>Search on Bing, click arrow by result, click 'Cached']
@jaanli
jaanli / accounting-with-large-language-models.md
Last active April 30, 2024 03:50
Cents & Sensibility: How to do accounting 101 in one hour with large language models

Cents & Sensibility: The Ledger Luminaries' Revolution

I'm scared to account; scared of statements of business dealings, credits and debits, and tracking of all this money-related stuff. Scared of reciting these transaction histories, and yet reckoning with these computations and enumerations is as deathly certain as taxes.

It is silly that this problem has not been solved given fancy new technology like AI and large language models. It's also silly how much big institutions skim off the top, like 1.5–3.5% per credit card transaction, and our expanding web of subscriptions to Substacks, Youtubes and the like that become more numerous and Medusa-like the harder they are to track, aggregate, categorize, and analyze across instutitions. I'm also scared of Mint.com (I used it for many years) as they broker our data, but still need the help of software and technology to manage money. This feels like a data problem that should have been solved long ago 🤯

So the goal here was to spend a few hours on a weekend t

@jaanli
jaanli / automatically_delete_wandb.ai_projects.test.js
Created February 21, 2024 20:04
Delete Weights and Biases (wandb.ai) projects automatically. Use with `WANDB_EMAIL="myemail" WANDB_PASSWORD="mypassword" npx playwright test automatically_delete_wandb.ai_projects.test.js
import { test, expect } from '@playwright/test';
test('Delete W&B Projects', async ({ page }) => {
// Navigate to the login page and log in
await page.goto('https://wandb.ai/login');
await page.getByPlaceholder('name@work-email.com').fill(process.env.WANDB_EMAIL);
await page.getByPlaceholder('your password').fill(process.env.WANDB_PASSWORD);
await page.click('text=Log In');
// Wait for navigation to ensure login is complete
import torch
import torch.nn.functional as F
import time
from flash_attn import flash_attn_qkvpacked_func
# Ensure torch supports bf16 on the current device; CUDA support for bf16 might be device-dependent
assert torch.cuda.is_bf16_supported(), "CUDA device does not support bf16."
# Data Preparation
batch_size = 1
@jaanli
jaanli / latexit-template-keynote-whitney.tex
Last active May 15, 2020 06:56
LaTeXiT template for settings that look okay with Keynote and Whitney font
\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amssymb} %maths
\usepackage{amsmath} %maths
\usepackage{mathtools}
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
% TABLES
\usepackage{booktabs}
\usepackage{array}
@jaanli
jaanli / 2017-06-21-tea-talk-development.md
Last active December 3, 2018 20:38
Quick overview of snapshot of dev environment / workflow

Towards a better mac development environment in 2018

Progress, perspectives, & new beginnings.

Advice: Install everything. Go all-in on all the suggested tools for a week, then see what sticks. Start using all of them at once. There's a large 'activation energy' to switching tools but it is worth the up-front investment for a lifetime of saved milliseconds on everyday tasks like switching directories, etc.

Useful tools:

  • brew cask: install most desktop applications brew cask install spotify evernote simplenote dropbox vlc slack 1password skim caffeine mactex skype anaconda google-chrome alfred iterm2 flux spectacle rescuetime sublime-text macbreakz little-snitch
@jaanli
jaanli / Dockerfile
Created June 6, 2017 18:36
Dockerfile for dotfiles with vim + tmux + c++ dev environment & private github ssh key support. Using dotfiles from https://github.com/altosaar/dotfiles
# Fixed ubuntu version
FROM ubuntu:16.04
# Install Ruby and Rails dependencies
RUN apt-get update && apt-get install -y \
tmux \
gdb \
gcc \
g++ \
python \
@jaanli
jaanli / black_box_vi_bayesian_linear_regression.py
Created February 11, 2017 17:32
Black box variational inference for Bayesian linear regression. Numpy and scipy only.
"""Use black-box variational inference (https://arxiv.org/abs/1401.0118) to
fit Bayesian linear regression (https://en.wikipedia.org/wiki/Bayesian_linear_regression)
and ensure it gets the analytic posterior mean from wikipedia.
"""
import numpy as np
import scipy.stats
def generate_data(cfg):
"""synthetic data: