Skip to content

Instantly share code, notes, and snippets.

View bachkukkik's full-sized avatar
:octocat:
Unable to comply, building in progress

Bachkukkik bachkukkik

:octocat:
Unable to comply, building in progress
View GitHub Profile
version: '3'
services:
portainer:
container_name: portainer
image: portainer/portainer-ce
command: -H unix:///var/run/docker.sock
restart: always
ports:
- 8000:8000

Root of the Django project is where manage.py resides

Prerequisites

  • $ mkdir basic_django
  • $ cd basic_django
  • $ virtualenv assume user already !pip install --user virtualenv
  • $ virtualenv -p python3 .
  • $ source bin/activate
  • $ pip install django
from flask import Flask
from flask_restful import Api, Resource
app = Flask(__name__)
api = Api(app)
names = {
"kukkik": {
"age": 30,
"gender": "male"
### !pip install pathos
import multiprocessing
import concurrent.futures
from pathos.multiprocessing import ProcessingPool
workers = int(multiprocessing.cpu_count())
@errors_pusher
def parallel_threading(main_func,
lst_args: list,
@bachkukkik
bachkukkik / ngrok_8888_self_restart.service
Last active November 26, 2020 01:46
start ngork on system boot
#### cat /etc/systemd/system/ngrok_8888_self_restart.service
[Unit]
Description= bachkukkik_xavier start ngork on system boot
[Service]
Type=simple
PIDFile=/run/ngrok_jupyter.pid
ExecStart=/home/<your username>/ngrok http http://localhost:8888
User=<your username>
Group=<your group>
@bachkukkik
bachkukkik / jupyter_notebook_config.py
Last active July 11, 2020 08:57
~/.jupyter/jupyter_notebook_config.py ### jupyter notebook config; http:// only; not recommended for public notebook
## if not yet done
## $ jupyter notebook --generate-config
## $ jupyter notebook password
## $ python
## [1] from notebook.auth import passwd
## [2] passwd() # fill in correct password
## [3] exit()
## $ sudo nano ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.allow_remote_access = True
@bachkukkik
bachkukkik / jupyter_self_restart.service
Last active June 30, 2020 07:42
Linux : jupyter self restart
#### cat /etc/systemd/system/jupyter_self_restart.service
[Unit]
Description= pi_kk start Jupyter Notebook on system boot
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/pi/.local/bin/jupyter-notebook --config=/home/pi/.jupyter/jupyter_notebook_config.py
User=pi
Group=pi
@bachkukkik
bachkukkik / slack_error_pusher_decorator_function.py
Last active December 14, 2020 07:27
push errors for slack notification
import os
from functools import wraps, partial
from inspect import signature
# https://stackoverflow.com/questions/55748500/simulate-the-assignment-of-function-arguments-to-args-and-kwargs
try:
module = os.path.basename(__file__)
except:
module = 'some_plain_str'
import concurrent.futures
import time
start = time.perf_counter()
def do_something(seconds):
print(f'Sleeping {seconds} second(s)...')
time.sleep(seconds)
return 'Done Sleeping...'

Confirm Model / OS

  • [RPi] Confirm Raspberry Pi Model cat /proc/device-tree/model
  • [RPi] Confirm Operating System cat /etc/os-release

Networking commands

  • IP scanner sudo nmap -O -sT 192.168.1.0/24
  • pi network config