This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # from https://github.com/microsoft/WSL/issues/8151#issuecomment-2276363014 | |
| curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - | |
| sudo apt-get install -y nodejs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # prependfrontmatter ./index.html | |
| alias prependfrontmatter="sed -i '1i---\n---'" | |
| # https://unix.stackexchange.com/questions/99350/how-to-insert-text-before-the-first-line-of-a-file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # python citygeocoder.py > '~citygeocoder.json' | |
| # https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial/en | |
| # https://github.com/OSMNames/OSMNames, http://github.com/OSMNames/OSMNames/issues/208 | |
| # https://osmnames.org/download/ | |
| # https://stackoverflow.com/questions/74261733/how-to-fetch-gps-coordinates-of-worlds-largest-cities-from-wikidata-via-sparql | |
| # FIXME: for some reason misses Helsinki | |
| import sys | |
| import json | |
| import urllib.parse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Usage: to extract all eml files in current directory into the current directory: python uneml.py *.eml | |
| import os | |
| import sys | |
| import email | |
| import email.policy | |
| for input_path in sys.argv[1:]: | |
| print('eml', repr(input_path)) | |
| eml = email.message_from_file(open(input_path), policy = email.policy.default) | |
| for part in eml.walk(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://github.com/wp-cli/entity-command/issues/512 | |
| # https://developer.wordpress.org/cli/commands/option/list/ | |
| # https://developer.wordpress.org/cli/commands/option/update/ | |
| # export options to a pretty-formatted JSON file | |
| wp option list --format=json | jq '.' > wpoptionimpex.json | |
| # [ | |
| # { | |
| # "option_name": "name1", | |
| # "option_value": "value1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://en.cppreference.com/w/c/string/byte/strrchr | |
| #include <stdio.h> | |
| #include <string.h> | |
| int main(int argc, char* argv[]) | |
| { | |
| if(argc < 2) | |
| return -1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # works only with a single, non-batched tensor of token ids | |
| import torch | |
| def bpedetokenize_loop(token_ids, token_utf8bytes, token_lens): | |
| inds = torch.cat((torch.zeros_like(token_lens[:1]), token_lens.cumsum(-1))) | |
| return torch.cat([token_utf8bytes[inds[i]:inds[i_p_1]] for i, i_p_1 in zip(token_ids, token_ids + 1)]) | |
| def bpedetokenize_vec(token_ids, token_utf8bytes, token_lens): | |
| inds_begin = torch.cat((torch.zeros_like(token_lens[:1]), token_lens[:-1].cumsum(-1))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # before running download captcha.onnx from https://huggingface.co/spaces/docparser/Text_Captcha_breaker | |
| # python -m pip install numpy pillow onnxruntime --user --break-system-packages | |
| import argparse | |
| import PIL.Image | |
| import numpy | |
| import onnxruntime | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--model-path', default = 'captcha.onnx') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // gcc -shared -fPIC log_file_access_dynamic.c -o log_file_access_dynamic.so -ldl; LD_PRELOAD=$PWD/log_file_access_dynamic.so /usr/bin/cat log_file_access_dynamic.c | |
| #define _GNU_SOURCE | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #include <errno.h> | |
| #include <dlfcn.h> | |
| #include <sys/stat.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://stackoverflow.com/questions/78931597/binary-integer-representation-printing-in-linux-shell?noredirect=1#comment139167055_78931597 | |
| alias fmti4struct="python -c 'import sys,struct;sys.stdout.buffer.write(struct.pack(\"<I\",int(sys.argv[1])))'" | |
| alias fmti4tobytes="python -c 'import sys,struct;sys.stdout.buffer.write(int(sys.argv[1]).to_bytes(4,\"little\"))'" | |
| # fmt4istruct 2123 > foo.txt | |
| # xxd foo.txt | |
| ## 00000000: 4b08 0000 K... |