This is a placeholder file so we can host images.
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
from copy import deepcopy | |
from collections import deque | |
# Expand a tree to the "leaves" | |
def leaves_of(item, dependencies): | |
# return the leaf nodes | |
def dfs2(item, level, visited): | |
result = [] | |
if item in dependencies: |
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 | |
# example of grafana/loki api when you need push any log/message from your python script | |
import requests, time | |
import names # get some random data | |
nano_ts = int(time.time()*1e9) | |
name = names.get_full_name() | |
# push msg log into grafana-loki | |
url="http://localhost:3100/loki/api/v1/push" |
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 | |
import re, sys, csv, argparse | |
from datetime import datetime | |
myTimezone = '' # does rclone log in locale timezone? | |
def perror(str): | |
print(str, file=sys.stderr) | |
# Function operates "in place" by reference on dict d, i.e. has side-effects on d |
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
package main | |
import ( | |
"constraints" | |
"fmt" | |
) | |
type Number interface { | |
constraints.Integer | constraints.Float | constraints.Complex | |
} |
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 | |
import argparse, sys, re, slugify | |
# Return a "slug" (HTTP safe) name - https://stackoverflow.com/questions/19335215/what-is-a-slug | |
def markdown_title_name(t): | |
return slugify.slugify(t) | |
class markup_doc: | |
def __init__(self, f): | |
self.text = f.readlines() # Store as separate lines, for ease of processing |
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 | |
# External dependencies: https://github.com/treyhunner/names | |
import random, names | |
count_default = 10 # Default length of list | |
def random_n_digits(n): | |
s = '' | |
for i in range(n): | |
s += random.choice('0123456789') |
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 | |
import imaplib, os | |
# Very simple IMAP client - prints messages in inbox | |
imap_host = os.getenv('IMAP_HOST') | |
imap_user = os.getenv('IMAP_USER') | |
imap_pass = os.getenv('IMAP_PASSWORD') | |
# connect to host using SSL | |
imap = imaplib.IMAP4_SSL(imap_host) |
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 | |
import argparse, csv, sys | |
import dns.resolver | |
def domainpart(n): | |
# A valid email address contains exactly one @, otherwise return None = invalid | |
parts = n.split('@') | |
if len(parts) == 2: | |
return parts[1] | |
return None |
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 | |
# Bubble blaster game from Carol Vorderman book pp.164 onwards | |
from tkinter import * | |
HEIGHT = 500 | |
WIDTH = 800 | |
window = Tk() | |
window.title("Bubble Blaster") | |
window.attributes("-topmost", 1) |
NewerOlder