This file contains hidden or 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 csv | |
import sys | |
me = '' | |
them = '' | |
paid_to_me = 0 | |
paid_to_them = 0 | |
payment_from_them = 0 | |
payment_to_them = 0 |
This file contains hidden or 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 _max(values, func=None): | |
if not func: | |
return max(values) | |
maybeMax = values[0] | |
for v in values: | |
if func(v, maybeMax): | |
maybeMax = v | |
return maybeMax |
This file contains hidden or 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
(define fpmap | |
(lambda args | |
(map (lambda (iter) | |
(apply (first args) iter (remove-last (rest args)))) (last args)))) | |
(define (remove-last l) | |
(reverse (rest (reverse l)))) |
This file contains hidden or 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
# https://architizer.com/sitemap-firms.xml | |
# Step 1: Download the above link to the file 'sitemap-firms.xml' and put it in the same directory as the python script. | |
# Step 2: Run the python script. It's sorta hacked together so it only half works, but it should do the basics. You can filter | |
# the list more if you want. | |
import xml.etree.ElementTree as ET | |
import requests | |
import re | |
email_regex = 'mailto:\S+@\S+\.\S+' |
This file contains hidden or 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
# Fixed Point Map: | |
# fpmap(function, fixed_point..., list) | |
def fpmap(*argv): | |
if len(argv) < 2: | |
# bad map paramaters | |
raise TypeError("fpmap must have at least two arguments") | |
# function to call | |
f = argv[0] | |
# List to pass to map |
This file contains hidden or 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 sys | |
def sieve(N): | |
P = [1 if x % 2 == 1 or x == 2 else 0 for x in range(N+1)] | |
m = 3 | |
n = m**2 | |
while n <= N: | |
if P[m] == 1: | |
while n <= N: | |
P[n] = 0 |
This file contains hidden or 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
rmn = {1000 : 'M', | |
900 : 'CM', | |
500 : 'D', | |
400 : 'CD', | |
100 : 'C', | |
90 : 'XC', | |
50 : 'L', | |
40 : 'XL', | |
10 : 'X', | |
9 : 'IX', |
This file contains hidden or 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
from operator import neg | |
class Maybe(object): | |
def __init__(self, v, failed=False): | |
self.v = v | |
self.failed = failed | |
def bind(self, f): | |
if self.failed: | |
return self | |
try: |
This file contains hidden or 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
# A Dockerfile for PEP622, pattern matching. | |
# https://www.python.org/dev/peps/pep-0622/ | |
FROM alpine:3.12 | |
# ensure local python is preferred over distribution python | |
ENV PATH /usr/local/bin:$PATH | |
# http://bugs.python.org/issue19846 | |
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. | |
ENV LANG C.UTF-8 |
This file contains hidden or 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
select dayofweek(checkin), count(code), sum(datediff(checkout, checkin)*rate) | |
from reservations | |
join rooms on rooms.roomcode=reservations.room | |
group by dayofweek(checkin) | |
order by dayofweek(checkin) |
NewerOlder