Skip to content

Instantly share code, notes, and snippets.

@WingTillDie
WingTillDie / search.json.moz
Created February 20, 2021 16:13
Firefox with Google English search suggestion
{"version":6,"engines":[{"_name":"Google","_isAppProvided":true,"_metaData":{"alias":null,"order":1}},{"_name":"Amazon.com","_isAppProvided":true,"_metaData":{"order":2}},{"_name":"Wikipedia (en)","_isAppProvided":true,"_metaData":{"order":5}},{"_name":"Bing","_isAppProvided":true,"_metaData":{"order":3}},{"_name":"DuckDuckGo","_isAppProvided":true,"_metaData":{"order":4}},{"_name":"Google English","_loadPath":"[http]ddgg.nfriedly.com/duck-duck-go--google-suggest-encrypted.xml","description":"Google search with suggestion","__searchForm":"https://duckduckgo.com","_iconURL":"data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAKQWlDQ1BJQ0MgUHJvZmlsZQAASA2dlndUU9kWh8+9N73QEiIgJfQaegkg0jtIFQRRiUmAUAKGhCZ2RAVGFBEpVmRUwAFHhyJjRRQLg4Ji1wnyEFDGwVFEReXdjGsJ7601896a/cdZ39nnt9fZZ+9917oAUPyCBMJ0WAGANKFYFO7rwVwSE8vE9wIYEAEOWAHA4WZmBEf4RALU/L09mZmoSMaz9u4ugGS72yy/UCZz1v9/kSI3QyQGAApF1TY8fiYX5QKUU7PFGTL/BMr0lSkyhjEyFqEJoqwi48SvbPan5iu7yZiXJuShGlnOGbw0noy7UN6aJeGjjAShXJgl4GejfAdlvVRJmgDl9yjT0/icTAAwFJlfzO
@WingTillDie
WingTillDie / fix-pip-install-self-signed-cert.bash
Created July 4, 2023 12:02
Permanent workaround for pip install with self-signed certificate
cat >> ~/.bashrc << 'EOF'
# Permanent workaround for pip install with self-signed certificate
# The question: https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi
function pip {
case $@ in
install* ) shift 1; command pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org "$@" ;;
* ) command pip "$@" ;;
esac
}
@WingTillDie
WingTillDie / apt-quick-guide-pacman-rosetta.md
Last active July 4, 2023 13:08
apt Quick Start Guide and pacman Rosetta

apt Quick Start Guide and pacman Rosetta

Ubuntu Package Manager Quick Start Guide

Local Remote Description
dpkg -S, --search apt-file search Search for packages that owns the file
dpkg -L, --listfiles apt-file list List files owned by the package
dpkg -s, --status apt show Show package information
dpkg -l, --list apt list Search for package name

Concept: 1 package owns some file(s)

#!/usr/bin/env python3
# Modified from https://superuser.com/questions/1586386/how-to-find-wsl2-machines-ip-address-from-windows#1749524
import re
import subprocess
from itertools import repeat
class Regex_ip:
def regex_ip_with_assert(self):
return f'{self.regex_ip_assert()}{self.regex_ip()}'
@WingTillDie
WingTillDie / get_all_gist.py
Last active July 12, 2023 09:38
List GitHub Gist with Gist id and Gist name
#!/usr/bin/env python3
import subprocess
import shlex
import re
import sys
from collections import namedtuple
Entry = namedtuple('Entry', ['user_name', 'gist_id', 'gist_name'])
user_name = None
@WingTillDie
WingTillDie / fix_wsl_interop_tmux.bash
Last active July 14, 2023 07:06
Fix WSL ERROR UtilConnectToInteropServer in tmux
#!/usr/bin/env bash
# Fix WSL interop problem when attached to tmux
# fix ERROR: UtilConnectToInteropServer:300: connect failed 2:
#
# Modified from
# https://superuser.com/questions/1602401/vscode-terminal-behaves-strangely-when-opening-a-project-that-is-inside-wsl2
# Fix by search lowest ancestor of tmux: client that is init
# Then sets wsl interop id as pid of that init
@WingTillDie
WingTillDie / youtube_thumbnail.py
Last active July 14, 2023 15:00
Get YouTube Thumbnail URL
#!/usr/bin/env python3
import sys
from enum import Enum
from IPython import get_ipython
URL_TYPE = Enum('URL_TYPE', ['unsupported', 'long_url', 'short_url', 'shorts', 'music'])
def determine_url_type(url: str):
if url[:29] == 'https://www.youtube.com/watch':
url_type = URL_TYPE.long_url
elif url[:17] == 'https://youtu.be/':
url_type = URL_TYPE.short_url
@WingTillDie
WingTillDie / bash_wrapper.py
Created July 16, 2023 21:14
Python wrapper for bash
#!/usr/bin/env python3
import subprocess
import sys
bash_script = '''
echo "$0"
echo "$@"
a=3
<<<$a cat
'''
@WingTillDie
WingTillDie / rename-venv.py
Last active July 16, 2023 21:19
Rename Python venv
#!/usr/bin/env python3
#import argparse
import subprocess
import sys
import argparse
parser = argparse.ArgumentParser(prog='rename-venv.py',
description='cd <venv>/.., then run this script'
)
@WingTillDie
WingTillDie / as_script.cc
Created July 16, 2023 21:25
Run C++ as script by gcc, tcc, clang
#if 0
gcc -x c++ "$0"
if [ $? -eq 0 ]; then
./a.out "$@"
fi
exit
clang -x c++ "$0"
if [ $? -eq 0 ]; then
./a.out "$@"