Skip to content

Instantly share code, notes, and snippets.

@milleniumbug
milleniumbug / java_rant.txt
Last active May 7, 2024 10:55
why Java sucks
Let's start with: Java is a language that one would create when looking at the state of C++ in early 90's and thinking how can I make it "better" in terms of being error prone.
But this was only an evolution instead of a revolution STL introduced as a way of programming
(sure, they weren't first, but I'd say they were the first to introduce it to masses)
The rest is a consequence of being backward
Problem with null pointers? Still there
Speaking of pointers in Java, I like how Java fans continuously say "they're not pointers, they're references"
But guess what happens when you access a null reference? A NullPointerException is thrown
So what I don't like?
Collections API. Just terrible.
The "unmodifiable" lists are your regular lists that throw exceptions on modifications
@milleniumbug
milleniumbug / getmus.ps1
Last active April 14, 2024 22:29
download video from YouTube, extract music and normalize volume
param(
[string]$url
)
yt-dlp `
$url `
--quiet `
--extract-audio `
--audio-format mp3 `
--audio-quality 3 `
#!/bin/bash
# USAGE
# gettranscript.sh url [lang]
set -euo pipefail
URL="$1"
LANG="${2:-en}"
p=`mktemp`
dir=$(dirname "$p")
file=$(basename "$p")
cd "$dir"
@milleniumbug
milleniumbug / frequently-misunderstood-japanese-translator-guide.md
Last active February 26, 2023 17:50
Frequently Misunderstood Japanese: A Handy Guide For Translators - yomichan dictionary version

Frequently Misunderstood Japanese: A Handy Guide For Translators

Adapted the guide in a form friendly for use with yomichan and software that can read yomichan dictionary format (e.g. Didactical Enigma)

How to use

Place the .json files in a .zip file. Files must be in root directory, which is why "Download ZIP" option won't work.

@milleniumbug
milleniumbug / prepare_cbz.sh
Created July 27, 2022 16:23
given a download directory in Tachiyomi, prepare it for creating a cbz archive
#!/bin/bash
find -name '.nomedia' -delete
for i in *; do
newname=$(echo "$i" | sed -r 's/.*Ch\.([0-9]+)\.?([0-9]*).*$/\1 \2/' | awk '{ printf("%05d%02d", $1, $2) }')
mv "$i" "$newname";
done
find -name '*.png' -print0 -or -name '.jpg' -print0 | while IFS= read -r -d '' file; do d=`dirname $file`; b=`basename $file`; mv "$file" "${d}/${d}_${b}"; done
@milleniumbug
milleniumbug / random.md
Last active August 17, 2021 23:48
C++11 <random> for babbies

A 3-minute introduction to C++11 <random> for rand() converts:

How to use a pseudo-random number generator:

  1. Include the necessary headers:

If you did this previously...

#!/usr/bin/env python3
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(b"Cookie/tGSIMonjf803gVn4GaOQhjPwd45NxbWbSlNuN2/UPI=", ("127.0.0.1", 5005))
@milleniumbug
milleniumbug / android_rant.txt
Created July 2, 2018 19:31
why Android sucks
wow fuck android
the general platform is fundamentally broken and even the open source applications are hilariously broken for many reasons
you have no way of distinguishing client and non-client area in general when you visit web, so have fun distinguishing ads from real UI elements - very needed when you want to distinguish ads. since you can't block ads without rooting reliably, rooting is required to have usable Android experience
if you visit a website and you want to download a specific image you can typically long-press it - unless shitty scripts break the functionality, in which case it results in endless "I long-press a button, some random text gets selected"
sometimes it may result in you actually managing to trigger the popup
but sometimes nope
on normal PC you would just "inspect element" that shit out
and in general it's bullshit when you actually want to anything beyond "consume internet content"
I have this file manager that I have been using for a while, except now it seems to fail copy from a
@milleniumbug
milleniumbug / install_hub.sh
Created June 27, 2018 22:18 — forked from Taytay/install_hub.sh
Install latest version of Github's hub on Linux
#!/bin/bash
# Installs latest release of hub on Linux
# Echo, halt on errors, halt on uninitialized ENV variables. (https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/)
set -euxo pipefail
# Hub doesn't have a way to install the latest version using `apt` yet, so I wrote this as a hacky substitute.
# This will be unnecessary when this issue is resolved: https://github.com/github/hub/issues/718#issuecomment-65824284
# Linux options include: