Skip to content

Instantly share code, notes, and snippets.

@kidpixo
kidpixo / config
Last active November 19, 2021 14:19
blocklet for i3blocks : get current CPU frequency from lscpu, extract the max/min and convert to GHz. Pure python, no requirments.
[cpu-freq]
interval=5
# standard color scale. MUST BE 4 VALUES.
# COLORS_FREQ='#85cc00,#b58900,#cb4b16,#dc322f'
# in MHz, if set Min/Max are not used. MUST BE 3 VALUES.
# FREQUENCIES='1500,2300,3100'
# Freq max/min MHz
# MIN_FREQ=1400
# MAX_FREQ=4100
# number of frequency intervals for color
@kidpixo
kidpixo / output.png
Last active October 22, 2021 13:00
Interpolate a Pandas.DataFrame to an input index, drop duplicated index, with scipy.interpolate methods.
output.png
@kidpixo
kidpixo / django_init
Last active October 19, 2021 09:46 — forked from kalafut/django_init
Simple creation of a single-app django project
#!/bin/bash
#
# Simple creation of a single-app django project, as described in: https://zindilis.com/posts/django-anatomy-for-single-app/
#
# ./django_init foo
#
# This will result is the following flat structure:
#
# .
# └── foo
#------------------------------------------------
# Name : yt-streamer
# Input : youtube URL
# Purpose : stream url video to mpv. see:
# https://github.com/ytdl-org/youtube-dl/issues/2124#issuecomment-32429104
#------------------------------------------------
yt-streamer() {
# locale colors do not work in sub-functions
open=$'\001'
close=$'\002'
#!/usr/bin/env python
"""Show table content with rich. Quick'n'dirty: no validity checks, only the fun :-D.
"""
import sys
from pandas import read_csv
from rich import print
from pathlib import Path
import os
size = os.get_terminal_size()
for p in sys.argv[1:]:
@kidpixo
kidpixo / example_output.png
Last active April 13, 2023 13:35
Pyhton function to check installed packages version from shell. This uses the shell default python, useful to check you local virtualenvs/conda envs.
example_output.png
# tested using https://github.com/uber/h3-py-notebooks/blob/master/notebooks/usage.ipynb
from h3 import h3
from shapely.geometry.polygon import Polygon
h3_list = [ Polygon(h3.h3_to_geo_boundary(he)) for he in h3.hex_ring(h,2)]
n = len(h3_list)
print(f'Polygon.exterior.is_closed = {h3_list[0].exterior.is_closed}')
import geopandas as gpd
@kidpixo
kidpixo / zathura_history_rofi.sh
Last active March 4, 2021 16:26
Open file from zathura history with rofi, checking if files exist. (Bash>=4.4 for array functions)
#!/bin/sh
# see https://unix.stackexchange.com/questions/467524/open-file-from-history-in-zathura
# save filepaths in history to array, reverse order
readarray -t Data < <(grep -o '/.*\.[[:alpha:]]\{,3\}' ~/.local/share/zathura/history | tac)
# loop and unset not existing files
for i in "${!Data[@]}"
do
if ! [ -e "${Data[$i]}" ]; then
alias ..='cd ..'
alias ...='cd ../../../'
################################################
# [bash - aliasing cd to pushd - is it a good idea? - Unix & Linux Stack Exchange](https://unix.stackexchange.com/a/4291/187865)
# You can then navigate around on the command-line a bit like a browser.
# - cd changes the directory.
# - back goes to the previous directory that you cded from.
# - flip will move between the current and previous directories without popping them from the directory stack.
# weresync backup
#
# autobackup on disk connect via udev rules :
# - [How to Auto Backup Files to USB Media When Connected](https://www.tecmint.com/auto-backup-files-to-usb-media-in-linux/)
# - [udev - ArchWiki](https://wiki.archlinux.org/index.php/udev)
# - [[SOLVED] automatic usb-backup with udev-rules + script / Newbie Corner / Arch Linux Forums](https://bbs.archlinux.org/viewtopic.php?id=32639)
# udevadm info -a -n sda > disk info
stop_weresync(){
WSPID=$(sudo pgrep weresync-daemon)