Skip to content

Instantly share code, notes, and snippets.

Avatar
📎
procrastinating...

hyphenc

📎
procrastinating...
View GitHub Profile
@hyphenc
hyphenc / 4bit-ints.c
Created May 8, 2022
4 bit ints (0-15) 0000-1111
View 4bit-ints.c
#include <stdio.h>
#include <stdlib.h>
struct bitfield {
// uses 4 bits but is padded to 8
unsigned char bit1: 1;
unsigned char bit2: 1;
unsigned char bit3: 1;
unsigned char bit4: 1;
} bf;
@hyphenc
hyphenc / simple-rot.c
Created Jan 8, 2022
shift lowercase alphabet by NUMBER. can only do one wraparound
View simple-rot.c
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
if(argc!=3) {
printf("usage: ./rot CHAR NUMBER\n works with lowercase alphabet (ascii 97-122).\n NUMBER can be negative. only one wraparound is implemented currently.\n");
exit(1);
}
@hyphenc
hyphenc / unicode-emoji-v14.0.txt
Created Jan 7, 2022
unicode version 14.0 relevant emoji (gender-neutral options)
View unicode-emoji-v14.0.txt
😀 grinning face
😃 grinning face with big eyes
😄 grinning face with smiling eyes
😁 beaming face with smiling eyes
😆 grinning squinting face
😅 grinning face with sweat
🤣 rolling on the floor laughing
😂 crying laughing
🙂 slightly smiling face
🙃 upside-down face
View extract-emoji.fish
#!/bin/bash
# download this pages as html
# https://unicode.org/emoji/charts/full-emoji-list.html
paste -d " " (grep -oP "(?<=<td class='chars'>).*?(?=</td>)" Full\ Emoji\ List,\ v14.0.html | psub) (grep -oP "(?<=<td class='name'>).*?(?=</td>)" Full\ Emoji\ List,\ v14.0.html | psub) > ~/emojout
@hyphenc
hyphenc / precise-age-in-years.fish
Created Jun 9, 2021
print precise age (precision: 9 after decimal point) in fish shell. replace date
View precise-age-in-years.fish
while true
printf "%.11g\r" (echo "("(date +%s%5N)"-"(date -d '2000-01-01 00:01' +%s%5N)")/100000/60/60/24/365.25" | bc -l)
end
@hyphenc
hyphenc / mp3-sony-walkman-fix.fish
Last active Jun 9, 2021
mp3 player (sony walkman) album art not displayed fix [fish shell]
View mp3-sony-walkman-fix.fish
# fix album cover art not being recognized by various (sony walkman) mp3 players (~2011ish)
mkdir ./img
for i in (ls -1 *.mp3)
eyeD3 --write-images=img "$i"
eyeD3 --remove-all-images "$i"
# this is the magic. convert progressive to baseline jpgs
convert img/FRONT_COVER.jpg -interlace none img/cov.jpg
eyeD3 --add-image "img/cov.jpg:FRONT_COVER" "$i"
rm img/*
@hyphenc
hyphenc / pulseaudio-mic-auto-adjust-fix.txt
Last active Apr 26, 2021
pulseaudio fix autoadjusting mic
View pulseaudio-mic-auto-adjust-fix.txt
# https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting
append
[Element Mic Boost]
volume = zero
[Element Int Mic Boost]
volume = zero
@hyphenc
hyphenc / mngmc.sh
Created Sep 28, 2020
manage a temp minecraft install
View mngmc.sh
#!/bin/bash
MC="java -Xmx2G -Xms1024M -jar ./server.jar --nogui"
###### script ######
download() {
echo -e "\e[96mfetching available versions...\e[0m"
mapfile -t avail_versions <<< "$(curl -s https://mcversions.net/ | grep -Po '(?<=<h5 class="stable">Stable Releases</h5>).*?(?=<div class="noVersionsFound hidden">)' | grep -Po '(?<=<a class="button" href=").*?(?=">Download</a>)' | sed 's;/download/;;g' | tac)"
for (( i=0; i<${#avail_versions[@]}; i++ )); do
printf "[%d] %s\n" "$i" "${avail_versions[$i]}"
@hyphenc
hyphenc / goodreads-cover-url-extractor.js
Last active Jul 24, 2020
goodreads get cover urls for all books visible in 'my books'
View goodreads-cover-url-extractor.js
r="";
for(var i=1; i<document.querySelectorAll("table > tbody > tr").length; i++) {
r += document.querySelectorAll("table > tbody > tr:nth-of-type("+i+") > td:nth-of-type(4) > div > a")[0].title + "\n" + document.querySelectorAll("table > tbody > tr:nth-of-type("+i+") > td:nth-of-type(3) > div > div > a > img")[0].src.replace(/\._.*/,".jpg") + "\n\n"
}
console.log(r)
@hyphenc
hyphenc / startpage-light-mode.css
Last active Jul 20, 2020
light mode for my startpage, see hyphenc/startpage on github
View startpage-light-mode.css
@font-face {
font-family: "Fira Code";
src:local("Fira Code Regular"),
url("font/firacode.woff2") format("woff2"),
url("font/firacode.woff") format("woff");
}
* {
font-family: "Fira Code", monospace;
font-size: 20px;
background-color: #eee;