Skip to content

Instantly share code, notes, and snippets.

class ProgressBar:
def __init__(self, n):
self.total = n
self.counter = 0
self.prev_time = time()
self.time_deltas = []
def next(self):
self.counter += 1
@mwielondek
mwielondek / at2r.py
Created September 24, 2020 08:37
Transform csv-export from Airtable onto Roam readable format with proper indentation
#!/usr/bin/env python3
# For transforming export from Airtable to Roam
import sys, re
filename = sys.argv[1]
filename_out = sys.argv[2]
with open(filename, 'r') as my_file:
str = my_file.read()
@mwielondek
mwielondek / ThingsStats.scpt
Last active March 26, 2017 20:38
Javascript for Automation (JXA) task to compute what percentage of completed tasks fall into which Area in Cultured Code's Things
// how many days to go back
var dayDiff = 21;
var d = new Date();
d.setDate(d.getDate() - dayDiff);
var things = Application('Things');
var logbook = things.lists[6].toDos;
var counter = {};
@mwielondek
mwielondek / openurls.sh
Last active January 17, 2016 17:02
Reads (max 6) urls from text files in a given directory and opens them in Safari
cat * | head -n 6 | xargs open -a 'Safari'
@mwielondek
mwielondek / websocketserver.py
Last active August 20, 2019 15:01 — forked from jkp/websocketserver.py
Simple WebSocket server. Can be run independently or as a module import.
import struct
import SocketServer
import sys
from base64 import b64encode
from hashlib import sha1
from mimetools import Message
from StringIO import StringIO
DEFAULT_PORT = 9999
@mwielondek
mwielondek / capitalize.sh
Last active August 29, 2015 14:24
Shell function for capitalizing filenames. Accepts multiple args.
# usage: `capitalize foo.txt bar.log` will rename files foo.txt bar.log => Foo.txt Bar.log
function capitalize() { for i; do echo $i | gsed -r 's/\w/\u&/' | xargs mv $i; done }
@mwielondek
mwielondek / diagtravmat.py
Last active August 29, 2015 14:06
A function for diagonal matrix traversal. (python3)
def diag_trav_mat(mat,func):
# pretend to be working with a square matrix
# extend length to the largest of the sides
n = max(len(mat),len(mat[0]))
# for the amount of diagnoals
for x in range(0, 2*n-1):
# num of elements in diagonal
el = n - abs(n-1-x)