Skip to content

Instantly share code, notes, and snippets.

View videah's full-sized avatar
🐺
Feelin' Wolfy

videah

🐺
Feelin' Wolfy
View GitHub Profile
@ahoho
ahoho / convert-hf-to-pth.py
Created April 2, 2023 19:35
Convert huggingface model to pytorch checkpoint (modified from alpaca-lora)
# Convert a huggingface LLaMA checkpoint to an (unsharded) pytorch checkpoint
# comes from https://github.com/tloen/alpaca-lora/blob/main/export_state_dict_checkpoint.py
import argparse
import json
from pathlib import Path
import torch
import transformers
from transformers import LlamaForCausalLM, LlamaTokenizer # noqa: E402
@DavidBuchanan314
DavidBuchanan314 / widevine_fixup.py
Last active September 13, 2024 21:45
Patch aarch64 widevine blobs from ChromeOS to work on non-ChromeOS linux, including platforms with 16K page size like Apple Silicon / Asahi Linux
"""
MIT License
Copyright (c) 2023 David Buchanan
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

Server-Sent Events

There's something called server-sent events which is an alternative to using web sockets if you want to break free from the strict request-response scheme.

I want to explore this technology using Dart.

First, let's create the simplest webserver that could possibly work:

Future main(List arguments) async {
@Treeki
Treeki / acnh_unsave.py
Created March 25, 2020 03:06
savefile decrypter for Animal Crossing: New Horizons
# savefile decrypter for Animal Crossing: New Horizons
# copyright Ash Wolf (Ninji) 2020
import struct, binascii, sys, Crypto.Cipher.AES, Crypto.Util.Counter
if len(sys.argv) != 4:
print('Usage: %s [main.dat] [mainHeader.dat] [output.dat]' % sys.argv[0])
sys.exit()
class SeadRandom:
@jarek-przygodzki
jarek-przygodzki / docker-shell-on-host.md
Last active August 17, 2022 03:50
Docker: get a shell on the host
$ docker run --privileged --pid=host -it alpine:3.8 \
nsenter -t 1 -m -u -n -i sh
  • --rm : removes the container after it is stopped
  • -ti (or -t -i) : adds a tty and leaves the standard input opened
  • --privileged : grants additional permissions to the container, it allows the container to gain access to the devices of the host (/dev)
  • --pid=host : use the host's Process ID Namespace. Allows the container to use the process tree of the Docker host (the machine in which the Docker daemon is running)
# Usage:
# 1) Ctr+S downloads page to ~/Desktop/books.html
# 2) Run script
# 3) Find your books in /tmp/humble_books
# 4) Read them
# 5) Profit
cat ~/Desktop/books.html |
grep "https://dl.humble.com" |
sed -n -E 's/.data-web\=\"(https://dl.humble.com/([.]+).([a-z]+)?["]+)./\1 \2 \3/p' |
sed 's/&/&/g' > /tmp/humble_books_list && cat /tmp/humble_books_list |
@EntranceJew
EntranceJew / irony.css
Created April 4, 2016 14:48
to prevent your code from going straight to production, include this
.ironic {
font-family: "Comic Sans MS", "Comic Sans", cursive;
color: rebeccapurple;
font-size: 26pt;
text-shadow: black 0px 3px 18px;
text-align: center;
display: block;
width: 100%;
@jart
jart / lolc.sh
Last active June 7, 2023 15:44
Run C code in Bash
#!/bin/bash
# lolc.sh - run c code in bash
# by justine tunney <[email protected]>
# licensed mit or apache 2.0
runc() {
local bin=$(mktemp -u)
gcc -xc -o ${bin} /dev/stdin || return
chmod u+x ${bin}
${bin} "$@"
@justecorruptio
justecorruptio / 2048.c
Created April 4, 2014 03:49
Tiny 2048 in C!
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2
@julionc
julionc / archlinux_install.sh
Last active February 12, 2018 19:03
Things to do after install ArchLinux (2012.12.01)
#!/usr/bin/env bash
# Things to do after install ArchLinux (2012.12.01)
pacman --noconfirm -S sudo
# Enabled archlinuxfr repo
arch=$(uname -m)
sudo cp /etc/pacman.conf /etc/pacman.conf.bak
echo "" >> /etc/pacman.conf
echo "[archlinuxfr]" >> /etc/pacman.conf