This file contains 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 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) | |
This file contains 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
# 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 } |
This file contains 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 struct | |
import SocketServer | |
import sys | |
from base64 import b64encode | |
from hashlib import sha1 | |
from mimetools import Message | |
from StringIO import StringIO | |
DEFAULT_PORT = 9999 |
This file contains 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
cat * | head -n 6 | xargs open -a 'Safari' |
This file contains 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
// 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 = {}; |
This file contains 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
#!/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() |
This file contains 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
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 |