Skip to content

Instantly share code, notes, and snippets.

View pletnes's full-sized avatar

Paul Anton Letnes pletnes

View GitHub Profile
pletnes /
Last active February 15, 2023 10:35
Duckdb 0.6.1 timestamp-in-csv parsing issues
#!/usr/bin/env python
from datetime import datetime
from pathlib import Path
import duckdb
import sql_statements
def main():
pletnes / .bashrc
Last active January 16, 2023 17:06
bashrc for CKAD
export do="--dry-run=client -o yaml"
alias k=kubectl
alias kn='kubectl config set-context --current --namespace '
alias kga='kubectl get all'
alias kgj='kubectl get jobs'
alias kgp='kubectl get pods'
alias kg='kubectl get '
alias ka='kubectl apply '
pletnes / .vimrc
Last active January 16, 2023 18:01
Simplest portable vimrc imaginable
set expandtab
" the filetype plugin determines filetypes from file contents
filetype plugin on
" use indent rules based on the filetype
filetype indent on
" turn on syntax highlighting
syntax on
" guess indentation
pletnes /
Created December 23, 2022 10:21
Python function that validates a vessel's IMO number, using the checksum digit (public domain license)
def is_imo(num: int):
Validates IMO number using the checksum digit.
ns = str(num)
sm = sum(d * d2 for d, d2 in zip(map(int, ns[:6]), range(7, -9, -1)))
return str(sm)[-1] == ns[-1]
pletnes / hosts
Last active September 2, 2021 13:12
Pihole personal blocklist localhost localhost.localdomain local broadcasthost
::1 localhost
::1 ip6-localhost
::1 ip6-loopback
fe80::1%lo0 localhost
ff00::0 ip6-localnet
ff00::0 ip6-mcastprefix
pletnes /
Created October 28, 2020 07:23
Function scope pylint rules
# Both foo and bar trigger the "blacklisted-name" pylint rule.
# Placing a #pylint pragma inside the foo block ensures that only this function is not triggering the rule.
def foo():
# pylint: disable=blacklisted-name
return a
def bar():
pletnes / shellcheck
Created June 3, 2020 11:11
Shellcheck - run on git-bash on windows
exec docker run --rm -v "$(cygpath -aw .):/mnt" koalaman/shellcheck:stable "$@"
pletnes /
Created May 25, 2020 08:03
Contextmanager `cd` to enter/leave directory
def cd(directory):
pre_directory = os.getcwd()
program archaic
implicit none
! This is actually a program input
integer, parameter :: M = 10000
integer, allocatable, dimension(:) :: iwork
integer, pointer, dimension(:) :: ptr
integer, pointer, dimension(:,:) :: ptr_remap
integer :: i, start, length
pletnes / Makefile
Last active April 4, 2016 07:57
Makefile and code - illegal fortran syntax?
.PHONY: all pgi intel gcc nag clean
all: gcc intel nag pgi
pgfortran -V
pgfortran -Minform=inform -Mbounds intertest.f90 -o intertest-pgi