Skip to content

Instantly share code, notes, and snippets.

View Himura2la's full-sized avatar
💭
Nya?

Himura Kazuto Himura2la

💭
Nya?
View GitHub Profile
@Himura2la
Himura2la / README.md
Last active June 30, 2025 18:55
Easy Flakes: transition to flakes with unstable channel and home-manager.

Upgrade

nix flake update  # minor
sudo nixos-rebuild switch --flake '.?submodules=1'

sudo nix-channel --add https://channels.nixos.org/nixos-25.05 nixos  # major (for nix-shell)

Clean

@Himura2la
Himura2la / clean.bat
Created March 2, 2025 02:52
Clean default Android directories on external drive
for /f "delims=" %%i in ('dir /ad /b') do rd "%%i"
@Himura2la
Himura2la / new_table.sql
Created February 22, 2025 12:42
Create table and user in PostgreSQL
CREATE USER nyarden;
CREATE DATABASE nyarden;
GRANT ALL PRIVILEGES ON DATABASE nyarden TO nyarden;
ALTER USER nyarden WITH PASSWORD '';
@Himura2la
Himura2la / ssl-query.sh
Created December 6, 2024 08:43
Use OpenSSL to get information on a remote TLS cert
ssl-query() { openssl s_client -connect "$1" </dev/null | openssl x509 -text -noout; }
@Himura2la
Himura2la / README.md
Last active September 11, 2024 08:53
Convert text file to JSON string

Usage

wget https://gist.githubusercontent.com/Himura2la/c2ef40ce86b1698e1a7db8b144657912/raw/toJson.sh
chmod +x toJson.sh
./toJson.sh < file
@Himura2la
Himura2la / update-config.sh
Created July 1, 2024 19:28
Update file in a named volume
#!/bin/sh
echo "Usage: $0 deploy|extract (default: deploy)"
engine=podman
script_dir="$(readlink -f "$(dirname "$0")")"
set -x
action=${1-deploy}
cc=$($engine run --rm -dtv grafana-config:/g -v prometheus-config:/p busybox)
@Himura2la
Himura2la / requests.py
Last active May 29, 2025 12:59
An alternative for undeservedly popular library
from urllib.request import urlopen, Request
from urllib.error import HTTPError, URLError
def fetch(url, method=None, data=None, headers={}):
try:
with urlopen(Request(
url,
data=data.encode('ascii') if data else None,
headers=headers,
method=method
@Himura2la
Himura2la / certs.sh
Created January 10, 2024 12:30
Generate your own TLS certificate chains
# CA
openssl ecparam -genkey -name prime256v1 -out ca.key
cat > ca.conf <<EOF
[req]
prompt = no
x509_extensions = ext
distinguished_name = dn
[ext]
stat /dev/ttyUSB0 # Gid: ( 18/ dialout)
sudo usermod -aG dialout $USER
sudo reboot
@Himura2la
Himura2la / nginx.conf
Created October 13, 2023 20:15
nginx plain text response
server {
listen 80;
server_name nya.nya;
default_type text/plain;
return 200 'nya nyaaaa~\n';
}