Skip to content

Instantly share code, notes, and snippets.

@kidpixo
kidpixo / update_metakernel.py
Last active July 5, 2022 13:24
Write metakernel to custom location and update KERNELS. Optionally, create symlink to Kernels location.
# -*- coding: utf-8 -*-
"""This module contains code related to NAIF/SPICE.
"""
import pathlib
def update_metakernel(metakernel_path=pathlib.Path,
metakernel_version=None,
KPATH=None,
outdir=None,
symlink=None,
# useful imports
import pathlib
import numpy as np
import pandas as pd
# define pandas options
opts = {
'display.max_columns': None,
'display.max_colwidth': 50,
'display.expand_frame_repr': False, # Don't wrap to multiple pages
'display.max_rows': 14, # maximum number of rows pandas should output
@kidpixo
kidpixo / link_to_tmp.sh
Last active June 28, 2022 20:07
quickly symlink current directory to /tmp/
@kidpixo
kidpixo / python_version_checker.py
Last active June 27, 2022 08:20
Pyhton function to check installed packages version from shell. Pure python, no requirements. Now with CLI colors!
#!/usr/bin/env python
"""Pyhton function to check installed packages version from shell. Pure python, no requirements.
"""
# define CLI colors
RED = '\033[31m' # mode 31 = red forground
GREEN = '\033[1;32m' # mode 32 = green forground
CYAN = '\033[34m' # mode 32 = green forground
RESET = '\033[0m' # mode 0 = reset
@kidpixo
kidpixo / overload_division_dict.ipynb
Created June 16, 2022 12:10
extend python dict class to use overload division operator à la pathlib
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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:
@kidpixo
kidpixo / extract_rpm.sh
Created May 6, 2022 09:57
rpm - yum install in user home for non-admins : unpack rpm and move executable, manpages etc to $USER home.
#!/bin/bash
# see : rpm - yum install in user home for non-admins
# http://unix.stackexchange.com/questions/61283/yum-install-in-user-home-for-non-admins
# Usage:
# 0. check your architecture
# uname -a
# Linux laser.pe.ba.dlr.de 3.10.0-514.21.1.el7.x86_64 #1 SMP Sat Apr 22 02:41:35 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
#
# 1. search a packet for your architecture.
# Example: gnu parallel for x86_64 architecture.
# 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kidpixo
kidpixo / mark_fzf.sh
Last active April 6, 2022 15:23
create a soft symlink directory in ~/.marks with directories and cdmark jump with fzf preview
#------------------------------------------------
# Name : mark
# Input : path
# Purpose : soft symlink passed path to ~/.marks
# empty input raises error cose 1
#------------------------------------------------
mark() {
# # add help option == print and exit
# if [ "$1" == "-h" ]; then
# echo "Usage:"