Skip to content

Instantly share code, notes, and snippets.

@luminoso
luminoso / .screenrc
Last active January 30, 2020 21:28
screen config .screenrc status bar time host window list
vbell off
term screen-256color
hardstatus off
hardstatus alwayslastline
hardstatus alwayslastline '%{= G}[ %{G}%H %{g}][%= %{= w}%?%-Lw%?%{= R}%n*%f %t%?%{= R}(%u)%?%{= w}%+Lw%?%= %{= g}][ %{y}Load: %l %{g}][%{B}%Y-%m-%d %{W}%c:%s %{g}]'
defnonblock on
scrollback 15000
setenv LD_PRELOAD /usr/lib/libjemalloc.so
@luminoso
luminoso / logger.py
Created February 4, 2020 16:06
python double file and console logger different levels
import logging
filename = 'spam.log'
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
# create file handler which logs even debug messages
fh = logging.FileHandler(filename)
fh.setLevel(logging.DEBUG)
@luminoso
luminoso / jupyter.sh
Last active August 1, 2023 13:55
base install jupyerlab datascience project
# CONDA
# create env
conda config --add channels conda-forge
conda config --set channel_priority strict
conda create --strict-channel-priority -n jupyter
conda activate jupyter
# jupyter, notebook and old notebook extensions
conda install -y jupyterlab
@luminoso
luminoso / openwrt_addons.sh
Last active March 28, 2025 13:48
openwrt base addons
apk update
# luci addons
apk add luci-app-statistics
# dns over tls
# https://openwrt.org/docs/guide-user/services/dns/dot_dnsmasq_stubby
# apk add dnsmasq stubby
# generic routing encapsulation. requirement for vpn.ua.pt
@luminoso
luminoso / clevis.sh
Last active July 15, 2023 08:58
fedora base install minimal setup
# https://wiki.archlinux.org/title/Trusted_Platform_Module#Clevis
sudo dnf install clevis\*
# check the correct partition with lsbk
sudo lsblk
# bind clevis to secure boot
sudo clevis luks bind -d /dev/nvme0n1p3 tpm2 '{"pcr_ids":"1,7"}'
@luminoso
luminoso / netns.txt
Created February 17, 2020 22:54
running an OpenVPN tunnel inside a network namespace
Linux network namespaces can be used to control which processes should be tunneled by OpenVPN.
http://www.naju.se/articles/openvpn-netns.html
Example
First create an --up and --down script for OpenVPN. This script will create the VPN tunnel interface inside a network namespace called vpn, instead of the default namespace.
cat > netns-script << 'EOF'
#!/bin/sh
case $script_type in
up)
@luminoso
luminoso / koalas.py
Created March 11, 2020 22:02
koalas itertuples wrapper for iterrows
# koalas don't support iterrows. so we convert iterrows() to itertuples() format
if internal_itertuples:
Row = namedtuple('Row', df.columns)
def convert_iterrow_to_itertuples(df):
for row in df.iterrows():
yield Row(*row[1])
itertuples = convert_iterrow_to_itertuples(df)
else:
@luminoso
luminoso / socat_to_namespace.sh
Last active February 16, 2025 15:26
socat to a network namespace
#https://unix.stackexchange.com/a/298409
sudo socat tcp-listen:500,fork,reuseaddr \
exec:'ip netns exec vpn socat STDIO "tcp-connect:127.0.0.1:5000"',nofork
@luminoso
luminoso / example.service
Created May 30, 2020 21:37
systemd unit sample
$ cat /etc/systemd/system/example.service
[Unit]
Description=basic service
[Service]
Type=notify
ExecStart=/bin/bash /usr/bin/true
Restart=on-failure
NoNewPrivileges=yes
@luminoso
luminoso / Dockerfile
Last active June 4, 2020 15:00
Docker jupyterlab under condas
FROM ubuntu:20.04
#
# 1. Hadoop
#
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -qq update && apt-get -qq -y install openjdk-14-jdk-headless wget build-essential krb5-user\
&& rm -rf /var/lib/apt/lists/* /var/log/dpkg.log