Skip to content

Instantly share code, notes, and snippets.

View heetbeet's full-sized avatar

Simon Streicher heetbeet

View GitHub Profile
@heetbeet
heetbeet / fmin_wrapping.ipynb
Created March 13, 2019 07:58
Wrapping scipy optimize fmin for a bit more flexability
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@heetbeet
heetbeet / Untitled.ipynb
Last active August 20, 2019 20:33
Some functions to help with analysing cpp files.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@heetbeet
heetbeet / put_this_in_ipynb_top.py
Last active August 18, 2019 16:44
A Jupyter header to convert the following code into a .py file.
import __main__ as main
if not hasattr(main, '__file__'):
jupyter_name = 'your-jupyter-filename'
import os
import subprocess
subprocess.call(['jupyter',
'nbconvert',
'--to',
'script',
@heetbeet
heetbeet / inkscape-grabber.py
Created August 22, 2019 11:11
Download inkscape and all its dependancies into your current folder, and create a portable wrapper entry point.
import os
import subprocess
def sh(*params, strip=True):
p = subprocess.Popen(params,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
@heetbeet
heetbeet / example.bat
Last active August 27, 2019 09:57
A Linux/Windows header to run a file (with .bat extension) as a Python script. Python must be in os path.
""" " 2>NULL & @echo off 2>/dev/null
:; /usr/bin/env python "$0" "${@}"; exit $?
@echo off & call python %0 %* & exit /b
"""
print('hello')
@heetbeet
heetbeet / emdw-restructure.md
Last active September 4, 2019 10:19
Emdw restructure

Emdw code restructure

Johan du Preez and I are in the process of restructuring emdw with the following aims:

  1. easier integration with external libraries and projects, less reinventing the wheel
  2. more use of Boost (less reinventing the wheel) https://github.com/boostorg https://www.boost.org/
  3. moving our tests from PatrecII to Google Test https://github.com/google/googletest
  4. moving our linear algebra and matrix libraries from gLinear and PatrecII to xtensor https://github.com/QuantStack/xtensor
  5. removing gLinear and PatrecII as external libraries
  6. easier housekeeping and modularisation
  7. separating core components from work-in-progress
  8. support for clang and cling https://github.com/QuantStack/xeus-cling
@heetbeet
heetbeet / email-attachment-extractor.py
Created December 17, 2019 19:52
Extract all email attachments from eml files
'''
The MIT License (MIT)
Copyright (c) 2014 Patrick Olsen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@heetbeet
heetbeet / multiitem_excel_formulas.py
Last active February 12, 2020 14:57
When does excel use a single item from a named range v.s. all the items?
'''
This script serves as and answer to the stack overflow question
https://stackoverflow.com/questions/59652623/when-does-excel-use-a-single-item-from-a-named-range-v-s-all-the-items
'''
import urllib.request
from path import Path
import collections
@heetbeet
heetbeet / python.py
Created May 2, 2020 12:47
Compile this file to get a mini python.exe with auto-py-to-exe
'''
This script mimicks part of the python executable, in order for it to be
compiled and shipped using auto-py-to-exe
'''
import sys
import os
thisdir = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(thisdir, 'site-packages'))
sys.path.insert(0, os.path.join(thisdir))
@heetbeet
heetbeet / regwalk.py
Created August 3, 2020 19:02
Walk through windows registry
import winreg
from contextlib import suppress
import itertools
from path import Path
def subkeys(path, hkey=winreg.HKEY_CURRENT_USER):
flags=0
with suppress(WindowsError), winreg.OpenKey(hkey, path, 0, winreg.KEY_READ|flags) as k:
for i in itertools.count():