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
[Unit] | |
Description=Our sample program | |
After=multi-user.target | |
[Service] | |
Type=idle | |
ExecStart=/usr/bin/python3 /home/<username>/myprogram/myservice.py | |
[Install] | |
WantedBy=multi-user.target |
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
import time | |
with open("logs/myservice.log", "w") as fl: | |
while True: | |
try: | |
fl.write(time.ctime() + '\n') | |
time.sleep(1) | |
except KeyboardInterrupt: | |
break |
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
import time | |
filename = "/home/<username>/myprogram/logs/myservice.log" | |
with open(filename, "w") as fl: | |
while True: | |
fl.write(time.ctime() + '\n') | |
time.sleep(1) |
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
import time, signal | |
def exit_gracefully(signum, frame): | |
global exit_now | |
exit_now = True | |
signal.signal(signal.SIGTERM, exit_gracefully) | |
filename = "/home/<username>/myprogram/logs/myservice.log" | |
exit_now = False |
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
# Author: Teshan Liyanage <[email protected]> | |
# Original mqtt client code from https://www.eclipse.org/paho/clients/python/docs/ | |
import paho.mqtt.client as mqtt | |
import logging | |
import msgpack | |
logging.basicConfig() | |
log = logging.getLogger(__name__) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# Author: Teshan Liyanage <[email protected]> | |
def box_text(text, fmt="regular", padding=(0, 0)): | |
""" Put text into a box in unicode | |
:param text: Text | |
:param fmt: Options - [regular, bold, rounded] | |
:param padding: horizontal and vertical padding | |
:Example: |
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
#!/bin/bash -e | |
# Question: https://stackoverflow.com/questions/64427513/python3-package-file-cannot-import-from-same-directory-when-used-in-a-different?noredirect=1#comment113946981_64427513 | |
mkdir -p pyprob/mypkg | |
cd pyprob/mypkg | |
touch __init__.py | |
cat > foolib.py << EOF |
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
import cv2 | |
import os | |
from tqdm import tqdm | |
ipdir = 'Camera' | |
opdir = 'CamLow' | |
out_quality = 70 | |
fmt = ('.jpg', '.jpeg', '.png') | |
for f in tqdm([_f for _f in os.listdir(ipdir) if _f.endswith(fmt)]): |
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 ubuntu:18.04 | |
RUN apt update && apt dist-upgrade -y | |
RUN apt install -y software-properties-common | |
RUN add-apt-repository ppa:bitcoin/bitcoin | |
RUN apt update | |
RUN apt install -y build-essential gcc make perl dkms git build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libboost-all-dev | |
RUN apt install -y libdb4.8-dev libdb4.8++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libprotobuf-dev protobuf-compiler openssl1.0 libssl1.0-dev |
OlderNewer