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
@bachkukkik
bachkukkik / octave.md
Created July 31, 2016 12:34 — forked from obstschale/octave.md
An Octave introduction cheat sheet.

Octave CheatSheet

GNU Octave is a high-level interpreted language, primarily intended for numerical computations.
(via GNU Octave)

Basics

  • not equal ~=
  • logical AND &&
@bachkukkik
bachkukkik / macos_raspi_backup_clone.md
Last active May 31, 2020 07:48
MacOS Terminal for Backup and clone raspberry pi SD Card

Backup Procedure:

Check disk -> unmount disk -> Backup SD Card -> Eject

Clone Procedure:

Check disk -> unmount disk -> Format card -> unmount disk -> Clone SD Card -> Eject

MacOS Command Line

  • Check disk diskutil list

  • unmount disk sudo diskutil unmountDisk /dev/disk4

Ref: https://www.makeuseof.com/tag/raspberry-pi-update-raspbian-os/

  • Begin by updating the repository package list: sudo apt-get update && sudo apt-get upgrade
  • When this is done, run the upgrade command: sudo apt-get dist-upgrade
  • Follow any prompts and wait for the Pi to be upgraded. When you’re done, type: sudo apt-get clean
  • This will discard any unneeded files that have been downloaded as part of the upgrade. Finish by restarting: sudo reboot

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
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...'
@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'
@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 / 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 / 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>
### !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,