Skip to content

Instantly share code, notes, and snippets.

View h3_hexagon_to_shapely_geodataframe.py
# tested using uber-h3-py-notebooks-liaqpsi3/notebooks/notebooks/usage.ipynb
# https://hub.gke2.mybinder.org/user/uber-h3-py-notebooks-liaqpsi3/notebooks/notebooks/usage.ipynb)
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 Mar 4, 2021
Open file from zathura history with rofi, checking if files exist. (Bash>=4.4 for array functions)
View zathura_history_rofi.sh
#!/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
View bashrc.sh
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.
View weresync_automate.sh
# 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)
View sklearn_classes_sort.py
# this code rearrange numeric labels based on an input array.
# I normally use some feature of the input data.
# X is the data matrix as pandas.Dataframe
# X.shape : [ROWS, COLUMNS]
# get the k labels
n_clusters=k
k_means = cluster.KMeans(n_clusters=n_clusters, random_state=0).fit(scaler.transform(X))
labels = k_means.labels_
View sync_panes.tmux.sh
bind t set-window-option synchronize-panes # synchronize all panes in a window
# synchronize all panes in a window ; send : clear, ls , pwd , un-synchronize.
bind y set-window-option synchronize-panes \; \
send-keys clear Enter ls Enter pwd Enter \; \
set-window-option synchronize-panes
View opus_history_strin_parser.py
filter_not_zero = lambda x : list(filter(None,x))
def extract_history(opusdata, histkey=None):
if histkey is None:
histkey='History'
history = filter_not_zero([s for s in opusdata['History'].split('COMMAND_LINE')])
return [extract_single_history(h) for h in history]
View wordpress-docker-compose-v2.yaml
version: "2"
services:
mariadb:
image: mariadb
ports:
- "8081:3306"
restart: on-failure:5
# questo monta la cartella locale mariadb-data in /var/lib/mysql nel container
# quando lui scrive nel db ti trovi la roba in locale.
volumes:
View compile_clang++_setup.py
#!python
#cython: language_level=3, boundscheck=False
# distutils: language = c++
from setuptools import setup
from setuptools.extension import Extension
from Cython.Distutils import build_ext
import os
import numpy
from Cython.Build import cythonize