Skip to content

Instantly share code, notes, and snippets.

@j1fig
j1fig / swapctx
Created November 13, 2022 22:26
Context switch tracking hook
#!/usr/bin/env python3
# Context switch tracking app.
# Stores context switches in a local SQLite DB.
from datetime import datetime
import os
import sqlite3
LOCAL_DIR = os.path.expanduser("~/.swapctx")
LOCAL_DB = os.path.join(LOCAL_DIR, "swapctx.db")
@j1fig
j1fig / maisliberdade.py
Last active July 21, 2021 12:51
membros da IL, membros da Mais Liberdade
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
def get_mais_liberdade_members():
url = 'https://maisliberdade.pt/fundadores/'
response = requests.get(url)
soup = BeautifulSoup(response.content, features="html.parser")
@j1fig
j1fig / size.py
Last active March 27, 2017 10:59
recursively gets size of object, guaranteeing not counting same obj twice. literally copied from http://stackoverflow.com/a/30316760 but might contain further improvements.
import sys
from numbers import Number
from collections import Set, Mapping, deque
try: # Python 2
zero_depth_bases = (basestring, Number, xrange, bytearray)
iteritems = 'iteritems'
except NameError: # Python 3
zero_depth_bases = (str, bytes, Number, range, bytearray)
iteritems = 'items'