Skip to content

Instantly share code, notes, and snippets.

View kungtotte's full-sized avatar

Thomas Landin kungtotte

  • Stockholm, Sweden
View GitHub Profile
let
rate = 40.0
weekly_discount = 50.0
weekend_discount = 20.0
test_data = [1, 2, 3, 4, 5, 6, 7, 8, 9]
proc total_cost(days: int): float =
result = days.float * rate
if days >= 7:
result -= weekly_discount
@kungtotte
kungtotte / gist:07c9d16918653d2f8b6fc6894d93e01c
Created November 14, 2018 12:45
Nim versus Rust binary sizes
fib_nim.nim:
proc fib(n: int32): int32 =
if n == 0 or n == 1:
return n
else:
return fib(n - 1) + fib(n - 2)
when isMainModule:
echo "Fib 15: ", fib(15)

Keybase proof

I hereby claim:

  • I am kungtotte on github.
  • I am kungtotte (https://keybase.io/kungtotte) on keybase.
  • I have a public key ASBx8YHMJJfgEt0Kkcc_8w_pmgdiPgQSQtzp1Nzvbgc_mAo

To claim this, I am signing this object:

@kungtotte
kungtotte / gist:c2a8a74134971703bec4635b14853362
Created August 26, 2018 05:56
Steam System Information
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz
CPU Family: 0x6
@kungtotte
kungtotte / FTP_example.py
Last active April 17, 2016 20:24
FTP upload refactor
def establish_ftp_session(address, username, password):
session = ftplib.FTP(address)
session.login(username, password)
# this is where you want to check that the
# user actually logged in
return session
def server_space(session, filesize):
filelist = session.nlst()
used_space = 0
@kungtotte
kungtotte / file_glob_example.py
Last active April 17, 2016 20:26
Selenium upload example
import glob
from os.path import abspath
from selenium import webdriver
def create_driver():
options = webdriver.ChromeOptions()
options.add_extension('adblockpluschrome-1.11.0.1591.crx')
driver = webdriver.Chrome(chrome_options=options)
return driver