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 argparse | |
# https://stackoverflow.com/a/9377686 | |
class UniqueAppendAction(argparse.Action): | |
def __call__(self, parser, namespace, values, option_string=None): | |
unique_values = set(values) | |
setattr(namespace, self.dest, unique_values) | |
servers = ["ApaServer", "BananServer", "GulServer", "SolServer", | |
"RymdServer", "SkeppServer", "HavsServer", "SovServer" ] |
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 random | |
import string | |
def _random_string(N, chars=string.ascii_uppercase + string.digits): | |
""" To generate values from a set of chars and a given length | |
""" | |
return ''.join(random.choice(chars) for _ in range(N)) |
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 reaching_max_messages(current_hour_bitrange): | |
""" | |
from https://stackoverflow.com/a/29281409 | |
""" | |
# https://stackoverflow.com/a/29281409 | |
# https://docs.mongodb.com/manual/reference/operator/query/bitsAllSet/ | |
pipeline = [ | |
{ |
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 download_file(): | |
""" | |
http://code.runnable.com/UiIdhKohv5JQAAB6/how-to-download-a-file-generated-on-the-fly-in-flask-for-python | |
""" | |
... | |
some_text = "" | |
filename = "FILENAME" | |
response = make_response(some_text, 200) | |
response.content_type = "text/plain" | |
response.headers[ |
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 itertools import chain, islice, zip_longest | |
# izip_longest in python2 | |
def grouper(iterable, n, fillvalue=None): | |
""" | |
# https://stackoverflow.com/a/434411 | |
>>> aaa = [1, 2, 3, 5, 6, 1, 3, 4, 8, 2094283, 123] | |
>>> [_ for _ in grouper(aaa, 3)] | |
[(1, 2, 3), (5, 6, 1), (3, 4, 8), (2094283, 123, None)] |
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
# Example nginx + git HTTP Smart mode (git-http-backend) + HTTP Authentication + HTTPS redirect | |
# [email protected] - http://jeroen.massar.ch | |
server { | |
listen 192.0.1.1:80; | |
listen [2001:db8::1]:80; | |
# Redirect all non-HTTPS traffic to the HTTPS variant | |
return 301 https://$host$request_uri; | |
} |
Requirements:
- fcgiwrap
- spawn-fcgi
- nginx
- git
Repository setup (without anonymous access):
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
========================================== ========================================== | |
TMUX COMMAND WINDOW (TAB) | |
========================================== ========================================== | |
List tmux ls List ^b w | |
New -s <session> Create ^b c | |
Attach att -t <session> Rename ^b , <name> | |
Rename rename-session -t <old> <new> Last ^b l (lower-L) | |
Kill kill-session -t <session> Close ^b & |