Skip to content

Instantly share code, notes, and snippets.

@anzz1
anzz1 / quickedit.c
Created February 26, 2023 11:29
quickedit.c
// quickedit.c
// cl /MD /Zl /O1 /Ob2 /Oi /GS- /kernel /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /c quickedit.c
// link kernel32.lib /entry:"main" /subsystem:console /pdb:none /machine:I386 /nodefaultlib /incremental:no /manifest:no /safeseh:no /emitpogophaseinfo /RELEASE /OPT:REF /OPT:ICF /OPT:NOWIN98 /MERGE:.rdata=.text quickedit.obj
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#include <windows.h>
@anzz1
anzz1 / h264.bat
Created March 15, 2023 21:25
h264.bat
@echo off
if [%~1]==[] echo h264: No input file specified.&exit /b 1
:loop
if [%~x1]==[.mp4] (set "_outfile=%~n1_1.mp4") else (set "_outfile=%~n1.mp4")
ffmpeg -hide_banner -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i "%~1" -vf "hwupload,hwdownload,format=nv12" -c:v h264_nvenc -profile:v high -preset slow -pix_fmt yuv420p -rc vbr_hq -b:v 0 -c:a libfdk_aac -b:a 0 -ar 44100 -ac 2 -f mp4 "%_outfile%" || call :chksz "%_outfile%"
shift
if not [%~1]==[] goto loop
goto :eof
:chksz
if [%~z1]==[0] del "%~1"
@anzz1
anzz1 / gif.bat
Created March 15, 2023 21:25
gif.bat
@echo off
if [%~1]==[] echo gif: No input file specified.&exit /b 1
:loop
if [%~x1]==[.gif] (set "_outfile=%~n1_1.gif") else (set "_outfile=%~n1.gif")
ffmpeg -hide_banner -vsync 0 -i "%~1" -vf "fps=20,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 -final_delay 300 -f gif "%_outfile%" || call :chksz "%_outfile%"
shift
if not [%~1]==[] goto loop
goto :eof
:chksz
if [%~z1]==[0] del "%~1"
@anzz1
anzz1 / convert-pth-to-ggml.py
Last active March 29, 2023 13:26
ugly hardcoded hack for point-alpaca conversion
# Convert a LLaMA model checkpoint to a ggml compatible file
#
# Load the model using Torch
# Iterate over all variables and write them to a binary file.
#
# For each variable, write the following:
# - Number of dimensions (int)
# - Name length (int)
# - Dimensions (int[n_dims])
# - Name (char[name_length])
@anzz1
anzz1 / gpt4x.cmd
Last active April 8, 2023 16:35
one-click-gpt4x
<# :
@echo off
cd /d "%~dp0"
md bin 2>nul
md models\gpt4-x-alpaca-13b-ggml 2>nul
md prompts 2>nul
if not exist "bin\wget.exe" (
powershell -nol -noni -nop -ex bypass -c "&{[ScriptBlock]::Create((cat '%~f0') -join [Char[]]10).Invoke()}"
)
if not exist "bin\main.exe" (
@anzz1
anzz1 / ip.sh
Created April 27, 2023 11:01
ip.sh
#!/bin/sh
ipvalid() {
if expr "$1" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then
return 0
fi
return 1
}
# IP=$(ifconfig wlan0 | grep -m1 'inet addr:' | cut -d: -f2 | cut -d' ' -f1)
@anzz1
anzz1 / time.sh
Created April 27, 2023 11:44
time.sh
#!/bin/sh
# dt=$(echo -ne "GET / HTTP/1.1\r\nHost: whatismyip.akamai.com\r\nAccept: text/plain\r\nConnection: close\r\n\r\n" | nc -w1 whatismyip.akamai.com 80 | awk -F': ' '/Date: /{print $2;exit}')
# t=$(date -d "$dt" +%s)
a=$((printf "c%47s" | nc -uw1 pool.ntp.org 123 | xxd -s40 -l4 -p) 2>/dev/null)
if [ ! -z "$a" ]; then
b=$((printf "%d" 0x$a) 2>/dev/null)
if [ "$b" -gt 2208988800 ] 2>/dev/null; then
t=$((0x$a-2208988800))
@anzz1
anzz1 / .gitignore
Last active November 10, 2023 22:16
.gitignore
# Git
!/**/.gitkeep
!/**/.keep
# Object files
*.d
*.o
*.ko
*.obj
*.elf
@anzz1
anzz1 / xldd.sh
Created May 2, 2023 02:22
xldd.sh
#!/bin/sh
xldd() { if [ -z "$1" ]; then echo 'xldd: usage: xldd <elf>'; else if [ -z "$CROSS_COMPILE" ]; then echo 'xldd: error: $CROSS_COMPILE not defined'; else if [ -x "$CROSS_COMPILE""readelf" ]; then echo "xldd: "$1""; "$CROSS_COMPILE""readelf" -d "$1" | grep "Shared library:"; else echo "xldd: error: "$CROSS_COMPILE""readelf" is not executable"; fi; fi; fi; }

Repo Rinse

This will blow away anything that is not committed.

git reset --hard
git submodule foreach --recursive 'git reset HEAD . || :'
git submodule foreach --recursive 'git checkout -- . || :'
git submodule update --init --recursive
git clean -d -f -f -x
git submodule foreach --recursive git clean -d -f -f -x