Skip to content

Instantly share code, notes, and snippets.

@saagarjha
saagarjha / file_drain.c
Created November 11, 2023 10:01
"Drain" files while they are processed to reduce free disk space requirements
// Sometimes you have a large file on a small disk and would like to "transform"
// it in some way: for example, by decompressing it. However, you might not have
// enough space on disk to keep both the the compressed file and the
// decompressed results. If the process can be done in a streaming fashion, it
// would be nice if the file could be "drained"; that is, the file would be
// sequentially deleted as it is consumed. At the start you'd have 100% of the
// original file, somewhere in the middle you'd have about half of the original
// file and half of your output, and by the end the original file will be gone
// and you'll be left with just the results. If you do it this way, you might
// be able to do the entire operation without extra space!
@mped-oticon
mped-oticon / bash_parallel.source
Created August 21, 2023 11:55
Classic Fork-join parallelism in BASH, blocking and nestable
# Classic Fork-join parallelism. bash_parallel's can be nested arbitrarily
# Silent by default; set BASH_PARALLEL_VERBOSE=1 for verbose output on stderr
function bash_parallel
{
function bash_parallel_echo
{
if [[ $BASH_PARALLEL_VERBOSE == 1 ]] ; then
echo "$@" 1>&2
fi
}
@veekaybee
veekaybee / normcore-llm.md
Last active May 9, 2024 07:47
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

@adrienbrault
adrienbrault / llama2-mac-gpu.sh
Last active April 22, 2024 08:47
Run Llama-2-13B-chat locally on your M1/M2 Mac with GPU inference. Uses 10GB RAM. UPDATE: see https://twitter.com/simonw/status/1691495807319674880?s=20
# Clone llama.cpp
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
# Build it
make clean
LLAMA_METAL=1 make
# Download model
export MODEL=llama-2-13b-chat.ggmlv3.q4_0.bin
@AndrewRadev
AndrewRadev / matchfuzzy.vim
Last active August 4, 2023 21:16
A fuzzy-finder in 40 lines of portable Vimscript
" Pick a different highlighting group by adding this in your vimrc:
"
" highlight link fuzzyMatch <group>
"
" The "default" only makes the link if it's not already set.
"
highlight default link fuzzyMatch Search
" The components of the command definition:
"
@kleinesfilmroellchen
kleinesfilmroellchen / log2-experiments.ipynb
Last active June 4, 2023 20:14 — forked from Hendiadyoin1/log2-experiments.ipynb
Some experiments with approximations of the binary logarithm
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Theldus
Theldus / README.md
Last active March 2, 2023 20:27
Helping your 'old' PC build faster with your mobile device (no root required)

Helping your 'old' PC build faster with your mobile device

It all happened when I decided to run Geekbench 5 on my phone: surprisingly the single-core performance matched my 'old'¹ Pentium T3200 and surpassed it in multicore. Since I've been having fun with distcc for the last few days, I asked myself: 'Can my phone really help my old laptop build faster? nah, hard to believe... but let's try'.

Without further ado: YES. Not only can my phone be faster, but it can significantly help in the build process, I believe the results below speak for themselves:

asciicast

Building Git (#30cc8d0) on a Pentium T3200, 8m30s

asciicast Building Git (#30cc8d0) on a Pentium T3200 (2x 2.0 GHz)+ Snapdragon 636 (4x1.8 + 4x1.6 GHz), 2m9s

@ibireme
ibireme / kpc_demo.c
Last active May 4, 2024 14:37
A demo shows how to read Intel or Apple M1 CPU performance counter in macOS.
// =============================================================================
// XNU kperf/kpc demo
// Available for 64-bit Intel/Apple Silicon, macOS/iOS, with root privileges
//
//
// Demo 1 (profile a function in current thread):
// 1. Open directory '/usr/share/kpep/', find your CPU PMC database.
// M1 (Pro/Max/Ultra): /usr/share/kpep/a14.plist
// M2 (Pro/Max): /usr/share/kpep/a15.plist
// M3: /usr/share/kpep/as1.plist
@alyssarosenzweig
alyssarosenzweig / demo.m
Created September 25, 2021 02:09
AppleJPEGDriver decode routine for the Apple M1
/*
* Copyright (C) 2021 Alyssa Rosenzweig <alyssa@rosenzweig.io>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
@BenWiederhake
BenWiederhake / lint-classes.py
Created September 12, 2021 16:53
Script that tries to identify and remove unused and unjustified headers in Serenity
#!/usr/bin/env python3
# Put this file in Meta/
from collections import defaultdict, Counter
import os
import random
import re
import subprocess
import sys