Skip to content

Instantly share code, notes, and snippets.

@bodqhrohro
bodqhrohro / gist:37d06d3e58bf34aac066
Last active August 29, 2015 14:24
Simple wrapper for bytebeat
#!/bin/sh
echo "main(t){for(t=0;;++t)putchar($1);}" > /tmp/bytebeat.c
gcc /tmp/bytebeat.c -w -std=c11 -o /tmp/bytebeat
chmod +x /tmp/bytebeat
/tmp/bytebeat|aplay -q
@bodqhrohro
bodqhrohro / getcurrenttrack.sh
Last active December 29, 2019 05:52
System monitoring
#!/bin/bash
MAX_LENGTH=30
deadbeef --nowplaying "%t|%a|%b|%e|%l>"|while IFS='|' read -d '>' -a track_params; do
track_name="${track_params[3]}/${track_params[4]}\n🎵 ${track_params[0]}\n👽 ${track_params[1]}\n💿 ${track_params[2]}"
if [[ $track_name = 'nothing\nnothing' ]]; then
track_name=■;
fi
echo -e $track_name
.urlbar-input:not(:focus) {text-align:center;font-weight:bold}
.urlbar-input:focus {background-color: #F7F7F7;height:24px}/*box-shadow: 0 0 2px 3px rgba(68,115,196,0.7)*/
#urlbar:not(:focus) {background-color: transparent;border:0}
#urlbar box, #urlbar toolbarbutton {border: 0;background:transparent}
@bodqhrohro
bodqhrohro / pic4a
Last active September 1, 2017 12:07
pic4a.ru uploader
#!/bin/bash
#Requirements: curl, jq, sed, grep
#Usage: pic4a <filename>
#token=`curl -s https://pic4a.ru/|grep csrfmiddlewaretoken|sed "s/.*value='\([^']*\)'.*/\1/"`
token=`curl -s https://pic4a.ru/ -c - -o /dev/null|grep csrf|sed 's/.*csrftoken\s\+\(.*\)/\1/'`
curl -# \
-F "csrfmiddlewaretoken=$token" \
-b "csrftoken=$token" \
-F "files[]=@$1" \
@bodqhrohro
bodqhrohro / gist:fe62afea6a1d2cf3aacc69f5828e0e77
Created October 3, 2016 08:10
Manually set tabulation modes in Vim
:command Tab0 :set noet sw=8 sts=0
:command Tab2 :set et sw=2 sts=2
:command Tab4 :set et sw=4 sts=4
@bodqhrohro
bodqhrohro / gist:17c4f1c2878a50ae3a0320cb65d1010b
Created October 3, 2016 08:13
Map loloswitcher to LShift, RShift and AltGr
Sequence0=(?<!1,29,1;|1,29,2;|1,97,1;|1,97,2;|1,56,1;|1,56,2;|1,100,1;|1,100,2;)1,42,1;1,42,0;$
Sequence1=(?<!1,29,1;|1,29,2;|1,97,1;|1,97,2;|1,56,1;|1,56,2;|1,100,1;|1,100,2;)1,54,1;1,54,0;$
Sequence2=(?<!1,29,1;|1,29,1;|1,42,1;|1,42,2;|1,97,1;|1,97,2;|1,56,1;|1,56,2;|1,54,1;|1,54,2;)1,100,1;1,100,0;$
@bodqhrohro
bodqhrohro / apt-size-change
Last active March 3, 2019 16:04
Verbose log of upgradeable packages
# ported to Python, thanks to KillTheCat
import subprocess
def get_installed_size(block: str) -> int:
def size_in_byte(data: list) -> int:
if len(data) != 2:
return 0
inc = 1
@bodqhrohro
bodqhrohro / smartlighten
Created April 12, 2019 14:48
Preset for Compiz Color Filter
!!ARBfp1.0
TEMP output;
TEMP input;
TEMP bright;
TEMP dark;
TEX input, fragment.texcoord[0], texture[0], RECT;
MUL dark.rgb, input, 5;
MUL bright.rgb, input, 0.55;
@bodqhrohro
bodqhrohro / maildir_decode.py
Last active June 14, 2019 09:52
Decode the filenames of attachments exported with munpack
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from email.header import decode_header, HeaderParseError
import os
import re
import itertools
from pprint import pprint
encodings = ( 'UTF-8', 'utf-8', 'koi8-r', 'KOI8-R' )
@bodqhrohro
bodqhrohro / vidqgif.sh
Created February 22, 2020 20:22
Compress a video to a tiny GIF with a very strong quantization and no dithering
#!/bin/sh
# parameters: input, output
# make a 256-colors palette first
palettefull=$( mktemp --suffix=.png )
ffmpeg -i "$1" -vf 'palettegen' -y "$palettefull"
# quantize the palette (palettegen's builting limiter
# tries to preserve too much similar shades)
palettequant=$( mktemp --suffix=.png )