This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
backup_check_disk() { | |
######################################################################## | |
# Function to check the current external disk | |
# | |
# This function iterates over a list of paths of possible external disks | |
# and checks if each path exists. It returns the basename of the first | |
# path that exists. | |
# | |
# Returns: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------ | |
# Name : yt-streamer | |
# Input : youtube URL | |
# Purpose : stream url video from youtube to mpv. see: | |
# https://github.com/ytdl-org/yt-dlp/issues/2124#issuecomment-32429104 | |
# Dependencies : yt-dlp, mpv | |
#------------------------------------------------ | |
yt-streamer() { | |
# add help option == print and exit | |
if [[ "$1" == "-h" ]] || [[ -z "$1" ]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
check_backup_disk() { | |
local -a EXTERNAL_DISK_PATHS=( | |
"/dev/disk/by-id/usb-SOME_EXTERNAL_USB_XXXXXXXXXXXXXXX-0:0" | |
"/dev/disk/by-id/usb-SOME_External_USB_3.0_XXXXXXXXXXXXXX-0:0" | |
) | |
CURRENT_DISK="" | |
for path in "${EXTERNAL_DISK_PATHS[@]}"; do | |
if [[ -e "$path" ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import subprocess | |
import re | |
PACMAN_KERNEL_VERSION = subprocess.getoutput("pacman -Qi linux | sed -n -e '/Version/p'").split(':')[1].strip().split('.') | |
RUNNING_KERNEL_VERSION = subprocess.getoutput("uname -a") .split(' ')[2].strip().split('.') | |
if len(RUNNING_KERNEL_VERSION) != 4: | |
tmp=re.split(r'-', RUNNING_KERNEL_VERSION[-1],1) | |
RUNNING_KERNEL_VERSION[-1] = tmp[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_prompt () | |
{ | |
# see [Setting color on git status in bash prompt - Stack Overflow](http://stackoverflow.com/questions/24837340/setting-color-on-git-status-in-bash-prompt) | |
if [ $(git rev-parse --is-inside-work-tree &>/dev/null; printf "%s" $?) == 0 ] | |
then | |
local GIT_PROMPT="${RESET}(${DIM}g${RESET}|" | |
git_branch () { git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'; } | |
# assemblate status statistic,substitute ? with U | |
git_status () { git status --porcelain 2>/dev/null | cut -c 1-2 | sort | uniq -c | sed 's/ *//;s/ */:/;s/\?/U/g' | paste -sd "|" -; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first 10 naturals | |
nat = np.arange(1,10) | |
# multiply them | |
nat_df = pd.DataFrame( | |
columns=nat, | |
index=nat, | |
data=np.matmul(nat[:,np.newaxis],nat[:,np.newaxis].T)) | |
def sumDigits(no): | |
return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### | |
# colors: relabelling the classes using the first centroids values | |
# calculate all the class centers in data space | |
y = X.groupby(labels).mean().values | |
# position of the data feature used to sort lables | |
feature_index = find_nearest(700) | |
# here the sorting index | |
centroids_sorting_index = np.argsort(y[:, feature_index]) | |
# here the sorting labels, not the index!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# open a new vim file with syntaxt highlight set at cli. | |
# example : vimscratch python | |
# default : open a new file directly skipping github.com/mhinz/vim-startify | |
alias vimscratch='_f() { if [ -z "$1" ]; then vim -c "let g:startify_disable_at_vimenter = 1"; else vim -c "let g:startify_disable_at_vimenter = 1" -c "set ft:$1" -c "set ft";fi }; _f' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[core] | |
excludesfile = $HOME/.gitignore_global | |
editor = vim | |
# pager = delta | |
[filter "media"] | |
required = true | |
clean = git media clean %f | |
smudge = git media smudge %f | |
[push] | |
default = simple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define CONDACOMMAND externally to overwrite this, I use conda or mamba | |
# default is to use mamba, a looooot faster | |
CONDACOMMAND=${1:-'mamba'} | |
# DRYRUNCONDACOMMAND : is set to anything, just print the commands | |
if [ -z $DRYRUNCONDACOMMAND ] | |
then | |
echo "DRYRUNCONDACOMMAND is unset, this is the real stuff" | |
DRYRUNCONDACOMMAND='' | |
else |
NewerOlder