Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dronir's full-sized avatar

Olli Wilkman dronir

View GitHub Profile
@dronir
dronir / integrator.jl
Created March 4, 2013 17:56
Pluto simulation v0.1
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)
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 / finnish_numbers.py
Last active April 27, 2021 11:09
Names of numbers in Finnish
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
@dronir
dronir / JDplot.py
Last active April 9, 2019 16:47
Sliced histogram plots
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 / convert_bom.py
Last active April 15, 2021 22:35
Scripts to convert KiCad files for JLCPCB assembly service
# 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.
# 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.