Use Python to:
- send a plain text email
- send an email with attachment
- receive and filter emails according to some criteria
import struct | |
# returns encoded dict | |
# this function assumes data in a particular format: it contains an array of field and values. | |
# each field is represented as a tuple of size 4 (value, wire type, field number, if field is an array) | |
# eg. message Msg { int64 id = 1; string text = 2; } => [[1234, 'varint', 1, False], ['hello world', 'string', 1, False]] | |
# also we can assume that every protobuf message is a dict at start, so this function is an entry point for encoding. | |
def encode_dict(data): | |
encoded_value = b'' | |
for d in data: |
[Unit] | |
Description=Redis persistent key-value storage | |
After=network.target | |
[Service] | |
Type=notify | |
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd --daemonize no | |
ExecStop=/usr/bin/redis-cli -p 6379 shutdown | |
ExecReload=/bin/kill -USR2 $MAINPID | |
Restart=always |
## 安裝語系檔 | |
`$ sudo locale-gen "en_US.UTF-8"` | |
## 重新設定語系檔 | |
`$ sudo dpkg-reconfigure locales` | |
## 設定檔 |
Use Python to:
# Set variables in .bashrc file | |
# don't forget to change your path correctly! | |
export GOPATH=$HOME/golang | |
export GOROOT=/usr/local/opt/go/libexec | |
export PATH=$PATH:$GOPATH/bin | |
export PATH=$PATH:$GOROOT/bin |
# /etc/sysctl.conf | |
# Clemens Gruber, 2014 | |
# | |
# Uncomment this to prevent users from seeing information about processes that | |
# are being run under another UID. | |
security.bsd.see_other_uids=0 | |
## I/O |
""" An example of a Linux daemon written in Python. | |
Based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ | |
The changes are: | |
1 - Uses file open context managers instead of calls to file(). | |
2 - Forces stdin to /dev/null. stdout and stderr go to log files. | |
3 - Uses print instead of sys.stdout.write prior to pointing stdout to the log file. | |
4 - Omits try/excepts if they only wrap one error message w/ another. |