Skip to content

Instantly share code, notes, and snippets.

View tobixen's full-sized avatar

Tobias Brox tobixen

  • Redpill-Linpro
  • Oslo, Norway
View GitHub Profile

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
import requests
def count_chars(text):
"""Count the frequency of each character in the given text."""
freq = {}
for char in text:
freq[char] = freq.get(char, 0) + 1
return freq
@tobixen
tobixen / gist:0abc42b0b51d87f5700a221a310b122e
Created July 31, 2021 08:51
Python program for calculating required wind force on a boat to raise a kellet to a certain vertical position
from math import sqrt
try:
from nose.tools import assert_almost_equal
except:
assert_almost_equal = lambda x, y: True
def daumann_kalk(ankertaulengde, dybde, daumannlengde, dausynk, daumannsvekt):
l1 = ankertaulengde - daumannlengde
l2 = daumannlengde
@tobixen
tobixen / print_si.py
Created March 15, 2018 18:33
converting a number like 50000 into 50k, 1000000 into 1M, etc
from math import log10
import sys
def print_si(number):
units = ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
thousands = int(log10(number)//3)
base = number//1000**thousands
print("%d %s" % (base, units[thousands]))
if __name__ == '__main__':