Skip to content

Instantly share code, notes, and snippets.

Avatar

Olli Wilkman dronir

  • Helsinki, Finland
View GitHub Profile
View bankreference.py
# Calculate Finnish bank reference numbers
# The reference is computed by:
#
# 1. Add together the digits of the number from right to left,
# multiplied cyclically by the weights 7, 3, and 1.
# E.g. for 1234, the total is 7*4 + 3*3 + 1*2 + 7*1 == 46.
#
# 2. Subtract the total from the next highest multiple of ten.
@dronir
dronir / convert_bom.py
Last active Apr 15, 2021
Scripts to convert KiCad files for JLCPCB assembly service
View convert_bom.py
# This converts a BOM file in CSV format, produced by KiCad Pcbnew,
# by selecting File / Fabrication Outputs / BOM File
# into the format expected by the JLCPCB manufacture service.
# At least in KiCad 5.1.4 the CSV output seems a bit broken in terms of column names,
# which is reflected in this code. If it changes in later KiCad versions, this script
# needs to change, too.
# Use this by running the command line: python convert_bom.py inputfile.csv outputfile.csv
# It will overwrite your output file without asking so be careful.
@dronir
dronir / JDplot.py
Last active Apr 9, 2019
Sliced histogram plots
View JDplot.py
import numpy as np
def JDplot(data, ax, N, resolution=None, white=False, alpha=1.0, stagger=0.0, fill_color=None, fg_color=None):
"""Make a sliced histogram plot in the style of Joy Division's album cover.
- `data`, a 1D numpy array containing values.
- `ax`, the matplotlib Axes to draw onto.
- `N`, the number of histogram slices.
- `resolution`, the number of bins. Defaults to `N`.
- `white`, boolean. Sets black-on-white colour scheme instead default.
@dronir
dronir / finnish_numbers.py
Last active Apr 27, 2021
Names of numbers in Finnish
View finnish_numbers.py
from sys import argv
# Function to produce verbal names of Finnish numbers up to 10^12 - 1.
# If run on the command line, takes an integer parameter and prints the
# name of that number.
# Requires Python 3 (you should not be running Python 2.x in the year 2020 anyway).
INDIVIDUALS = {
0 : "", # zero is set to empty string here for convenience below
View make_remote.fish
function make_remote
switch (count $argv)
case 0
echo "Not enough arguments."
case 1
set REPOPATH "git-repos/$argv[1].git"
_make_remote $REPOPATH
case 2
set REPOPATH "git-repos/$argv[1].git"
_make_remote $REPOPATH
@dronir
dronir / integrator.jl
Created Mar 4, 2013
Pluto simulation v0.1
View integrator.jl
module Integrator
export PlutoSim
const G = 1.48811382e-34 # G in units of AU and day
function potential{T<:Real}(mass::Vector{T}, r::Matrix{T})
N = size(r,1)
out = zeros(N,3)
d = zeros(1,3)