Skip to content

Instantly share code, notes, and snippets.

import treq
from twisted.internet import defer, task
URLS = [
"https://google.com",
"https://github.com",
"https://example.org",
]
DONE = {}
[Unit]
Description=Deluge Bittorrent Client Web Interface
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/deluge-web -l /home/tritium/torrent/web.log -L warning
Restart=on-failure
[Install]
@tritium21
tritium21 / playground.py
Last active June 10, 2017 09:47
Holy crap, this actually works?
import collections
import functools
import re
import urllib.parse
class Request(collections.Mapping):
KEYS = '''REQUEST_METHOD SCRIPT_NAME PATH_INFO
QUERY_STRING CONTENT_TYPE CONTENT_LENGTH
SERVER_NAME SERVER_PORT SERVER_PROTOCOL wsgi.version
def make_route(route):
type_map = {'int': r'\d+', 'str': '[^/]+'}
in_arg = False
in_arg_name = False
value = ''
pat = ''
for c in route:
if not in_arg and c != '<':
pat += c
continue
#!/usr/bin/env python3
"""
Generates a bash script to readd torrents to deluge
(e.g. if you are moving machines)
"""
import argparse
import collections
import fnmatch
import functools
import itertools
import itertools
def foo(it)
source1, source2 = itertools.tee(it, 2)
falses = (i for i in source1 if not bool(i))
trues = (i for i in source1 if bool(i))
return trues, falses
def foo(sequence, obj):
for idx, item in enumerate(sequence):
if obj in item:
return idx
return 0
; <<>> DiG 9.10.3-P4-Ubuntu <<>> carnage.sdamon.com +trace
;; global options: +cmd
. 166570 IN NS f.root-servers.net.
. 166570 IN NS m.root-servers.net.
. 166570 IN NS k.root-servers.net.
. 166570 IN NS e.root-servers.net.
. 166570 IN NS i.root-servers.net.
. 166570 IN NS j.root-servers.net.
. 166570 IN NS h.root-servers.net.
; <<>> DiG 9.10.3-P4-Ubuntu <<>> NS blogofthedead.org @a0.org.afilias-nst.info
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2768
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 6
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
# Run with python py_for_pi_day.py [number of rounds] [upper limit on random number]
# Python 3.5+
import math
import random
import sys
def main(rounds, limit):
print(rounds, "Rounds")
print(limit, "Sides")