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
| #!/bin/bash | |
| export BORG_RSH='ssh -i ~/.ssh/id_ed25519' | |
| export BORG_REPO='ssh://user@storage:22/./mail' | |
| export BORG_PASSPHRASE='**********' | |
| export ARCHIVE=$(date +'%a-%Y-%m-%d') | |
| /usr/bin/borg create \ | |
| --verbose \ |
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
| function header { | |
| echo "" | |
| echo "$(tput setaf 6)$1$(tput sgr0)" | |
| echo "" | |
| } | |
| header "Creating MySQL database ..." |
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
| #!/usr/bin/awk -f | |
| /Host:/ { print "define host {"; | |
| print "\tuse\tgeneric_host"; | |
| gsub(/[\(\)]/, ""); print "\thost_name\t", $3; | |
| print "\taddress\t\t", $2; | |
| print "}"; } |
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 bottle import route, run, template, abort, Response | |
| APP_VERSION = '0.1.1' | |
| @route('/hello/<name>') | |
| def index(name): | |
| return template('<b>Hello {{name}}</b>!', name=name) | |
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
| class NestedNamespace(SimpleNamespace): | |
| """ Wrapping dictionaries in namespace to access it with dot notation. """ | |
| def __init__(self, dictionary, **kwargs): | |
| super().__init__(**kwargs) | |
| for key, value in dictionary.items(): | |
| if isinstance(value, dict): | |
| self.__setattr__(key, NestedNamespace(value)) | |
| else: | |
| self.__setattr__(key, value) |
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 ipaddress import ip_address | |
| """ Two IP addresses are known """ | |
| start = ip_address('192.168.1.0') | |
| end = ip_address('192.168.1.254') | |
| print("From {} to {}".format(start, end)) | |
| for ip in range(int(start), int(end)): | |
| print(ip_address(ip)) | |
| """ Network address is known """ |
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
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| Ecryption/Decryption REST Service | |
| ================================= | |
| INSTALLATION | |
| ------------ |
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
| CREATE KEYSPACE mail | |
| WITH replication = { | |
| 'class': 'SimpleStrategy', | |
| 'replication_factor': 1 | |
| }; | |
| CREATE TABLE mailbox ( | |
| box_id text, year int, | |
| received timestamp, |
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
| """ | |
| Test validity of certificates. | |
| Tested on Ubuntu with Python 3.5 and python3-openssl package. | |
| """ | |
| import ssl | |
| from datetime import datetime | |
| from warnings import warn |
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 string | |
| from collections import Counter | |
| george_takei_tweet = "When the media gave him millions in free air time, Trump loved them. Now when they do their job and ask questions, it's a global conspiracy." | |
| tweet = george_takei_tweet.lower() | |
| tweet = ''.join(ch for ch in tweet if ch not in set(string.punctuation)) | |
| contains = Counter(tweet.split(' ')) | |
| eval("contains['trump'] and contains['conspiracy']") | |
| # ==> 1 |