Skip to content

Instantly share code, notes, and snippets.

View hatarist's full-sized avatar

Igor Hatarist hatarist

View GitHub Profile
@hatarist
hatarist / yandex-music_full-width_no-bloat.css
Created September 30, 2023 13:55
userstyle: yandex music (full-width, no bloat)
/* моя волна */
.rup__animation { display: none; } /* дебильная анимация моей волны */
.rup { display: none; } /* хотя нет, вся "моя волна" дебильная */
/* делаем поменьше отступы основной части интерфейса */
.centerblock {
padding: 10px 30px 60px;
}
.d-header__title {
@hatarist
hatarist / README.md
Created June 30, 2023 16:45
Python RGB to color name

RGB to color name converter using Python

Dependencies

Oops, I was too lazy to implement the RGB to HSL conversion myself, hence you need the colormath.

Usage example

get_color_name((241, 95, 188)) # 'pink'
@hatarist
hatarist / karabiner-fn-to-ctrl.json
Last active October 23, 2021 00:03
Karabiner Elements: Convenient `fn` to `ctrl` replacement.
{
"title": "Fn improvements (gist.github.com/hatarist)",
"rules": [
{
"description": "Change Fn+key to Ctrl+key",
"manipulators": [
{
"from": {
"key_code": "spacebar",
"modifiers": {
@hatarist
hatarist / pppretty.py
Last active June 9, 2019 22:53
Formats a list of dictionaries as a fancy psqlish-style table.
def ppprint(data, fields=None, precision=2):
"""
P-P-PRETTY PRINTER!
>>> ppprint([{"foo": 1.2, "bar": "beer"}, {"foo": "bazzzzz", "bar": "bad"}])
"""
if fields is None:
fields = list(data[0].keys())
formatted_fields = []
@hatarist
hatarist / clean_json.py
Last active August 9, 2018 21:09
this 100% mature and tested function strips C-style comments and trailing commas from a (not-so-valid) JSON
import re
def clean_json(payload):
# remove C-style comments
payload = re.sub(re.compile("/\*.*?\*/",re.DOTALL), '', payload)
payload = re.sub(re.compile("//.*?\n" ), '', payload)
# remove trailing commas
payload = re.sub(re.compile(r',\s*?([\]\}])'), r'\1', payload)
return payload
#!/bin/bash
export threads=10
export src="/home/local/stuff/"
export dest="scp@govno:/home/remote/stuff/"
rsync -aL -f"+ */" -f"- *" $src $dest && (cd $src && find . -type f | xargs -n1 -P$threads -I% rsync -av % $dest/% )
@hatarist
hatarist / ipv6gen.py
Created May 2, 2018 13:11
I'm a lazy ass who didn't think it's worth to bother with the standard ipaddress library
import random
import sys
from netaddr import IPNetwork, IPAddress
def generate_random_ipv6(subnet):
network = IPNetwork(subnet)
return str(IPAddress(random.randrange(network.first, network.last)))
:) CREATE TABLE my_table (date Date DEFAULT today(), s String) ENGINE = MergeTree(date, (date), 8192);
:) INSERT INTO my_table (s) VALUES ('1. foo');
:) ALTER TABLE my_table ADD COLUMN f Float64;
:) INSERT INTO my_table (s) VALUES ('2. bar');
:) SELECT * FROM my_table;

Copy this URL and paste it into the address bar to import it in the Karabiner Elements:

karabiner://karabiner/assets/complex_modifications/import?url=https://gist.githubusercontent.com/hatarist/f2888c1940e7ebccfeea184181c7726b/raw/karabiner-fn-to-ctrl.json)
@hatarist
hatarist / pg_get_table_sizes.sql
Created September 8, 2017 15:48
PostgreSQL: get table size (data & index & toast)
SELECT
*,
pg_size_pretty(table_bytes) AS table,
pg_size_pretty(index_bytes) AS index,
pg_size_pretty(total_bytes) AS total
FROM (
SELECT
*, total_bytes - index_bytes - COALESCE(toast_bytes, 0) AS table_bytes
FROM (
SELECT