This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn logpow(base: u32, exp: u32) -> u32 { | |
let mut restexp = exp; | |
let mut intlog = 0_u32; | |
while restexp > 1 { | |
restexp /= 2; | |
intlog += 1; | |
} | |
restexp = exp - 2_u32.pow(intlog); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_outliers(a, n): | |
asorted = a[np.argsort(np.abs(a - np.median(a)))] | |
return asorted[: -n] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.rcParams["figure.dpi"] = 140 | |
plt.rcParams["axes.spines.right"] = False | |
plt.rcParams["axes.spines.top"] = False | |
plt.rcParams["legend.frameon"] = False | |
# Okabe-Ito palette | |
plt.rcParams['axes.prop_cycle'] = plt.cycler(color=["#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (c = 1; c <= 5; c++) { for (z = 1; z <= 131; z++) { Stack.setPosition(c, z, 1); r = Math.pow(z / 130, 0.6) * (430-290) + 290; makeOval(getWidth() / 2 - r, getHeight() / 2 - r, 2 * r, 2* r); run("Make Inverse"); fill(); } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sizeof_fmt(num, suffix='B'): | |
''' by Fred Cirera, https://stackoverflow.com/a/1094933/1870254, modified''' | |
for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']: | |
if abs(num) < 1024.0: | |
return "%3.1f %s%s" % (num, unit, suffix) | |
num /= 1024.0 | |
return "%.1f %s%s" % (num, 'Yi', suffix) | |
def numpysizeof(o): | |
if "nbytes" in dir(o): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\NeedsTeXFormat{LaTeX2e} | |
\ProvidesPackage{rawlikstyle}[A custom style for latex documents] | |
% always use the UTF-8 encoding | |
\RequirePackage[utf8]{inputenc} | |
% clickable links | |
\RequirePackage{hyperref} | |
% palatino font for text and maths |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import coloredlogs | |
import logging | |
if __name__=="__main__": | |
# only configure logging in the main program, everywhere else just import and use it | |
# set up logging | |
logfile_folder = "N:/data/log/" | |
logfile_date = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") | |
logfile_filename = f"bunker5_{logfile_date}.log" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use color ANSI escape sequences on windows | |
if os.name == "nt": | |
import colorama | |
colorama.init() | |
def welcome(): | |
BLACK = "\033[0;30m" | |
RED = "\033[0;31m" | |
GREEN = "\033[0;32m" | |
YELLOW = "\033[0;33m" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def brighten(color, v): | |
return np.array(matplotlib.colors.to_rgb(color)) ** (1 - v) |
NewerOlder