Skip to content

Instantly share code, notes, and snippets.

View pletnes's full-sized avatar

Paul Anton Letnes pletnes

View GitHub Profile
@pletnes
pletnes / convert_all.py
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
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
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
pletnes / imocheck.py
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
pletnes / hosts
Last active September 2, 2021 13:12
Pihole personal blocklist
127.0.0.1 localhost
127.0.0.1 localhost.localdomain
127.0.0.1 local
255.255.255.255 broadcasthost
::1 localhost
::1 ip6-localhost
::1 ip6-loopback
fe80::1%lo0 localhost
ff00::0 ip6-localnet
ff00::0 ip6-mcastprefix
@pletnes
pletnes / pylintexample.py
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():
"""docstr"""
# pylint: disable=blacklisted-name
a=2
return a
def bar():
@pletnes
pletnes / shellcheck
Created June 3, 2020 11:11
Shellcheck - run on git-bash on windows
#!/bin/bash
exec docker run --rm -v "$(cygpath -aw .):/mnt" koalaman/shellcheck:stable "$@"
@pletnes
pletnes / cd.py
Created May 25, 2020 08:03
Contextmanager `cd` to enter/leave directory
@contextlib.contextmanager
def cd(directory):
pre_directory = os.getcwd()
os.chdir(str(directory))
try:
yield
finally:
os.chdir(str(pre_directory))
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
nullify(ptr)
@pletnes
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
pgi:
pgfortran -V
pgfortran -Minform=inform -Mbounds intertest.f90 -o intertest-pgi
./intertest-pgi
intel: