Skip to content

Instantly share code, notes, and snippets.

@tfiers
tfiers / unit_type_check_MVP.py
Created September 28, 2020 13:59
`Quantity[pF]` MVP, via typish (via nptyping NDArrayMeta)
from dataclasses import dataclass, fields, Field
from typish import SubscriptableType
import yunit
class QuantityMeta(SubscriptableType):
@property
def typed_unit(cls):
@tfiers
tfiers / init.ipynb.py
Last active July 25, 2020 19:44
init.ipynb (Useful initialisation notebook)
%config InteractiveShell.ast_node_interactivity = 'last_expr_or_assign'
@tfiers
tfiers / ChromeTotalMemory.py
Last active October 15, 2017 19:33
How much memory does Chrome use in total? Python script to find this out on a Windows machine.
# coding: utf-8
#
# Montiors the total memory usage of all Chrome processes.
# To be run on a Windows machine.
# Requirements:
# - Python 3.6+
# - Pandas
print('Press Ctrl-C to quit')
print('\n..', end='')
@tfiers
tfiers / inspect.py
Created July 8, 2017 09:46
Inspect a python object when there is no documentation (or help(obj)) available.
from pprint import pformat
from tabulate import tabulate
rows = []
for name in dir(obj):
val = getattr(obj, name)
if callable(val):
try:
content = val()
@tfiers
tfiers / SQLite
Last active January 10, 2017 14:23
Facebook post insight & event attendees tracker
-- Export to csv via SQLite Database Browser:
create table promo_post_data as select * from pagepostdata where post_name='Promo-post'
-- Export to csv via SQLite CLI:
sqlite> .header on
sqlite> .output c:/work/dataout.csv
sqlite> .mode csv
sqlite> SELECT * FROM pagepostdata WHERE post_name='Promo-post'
sqlite> .output stdout
@tfiers
tfiers / Vraag7.py
Last active December 17, 2015 00:38
"What does that function look like?"
class A:
def f(self, x): return self.f(x/2) + 1
class B(A):
def f(self, x=10):
if x < 0: return self.f(x+200) + 2
if x > 20: return A.f(self,x-50) + 3
else: return x
from pylab import *