Skip to content

Instantly share code, notes, and snippets.

View kittinan's full-sized avatar
🇹🇭
|||

Kittinan kittinan

🇹🇭
|||
View GitHub Profile
@kittinan
kittinan / wireguard.md
Created October 7, 2023 13:39
Ubuntu 22.04 add wireguad config file to network manager

Ubuntu 22.04 add wireguad config file to network manager.

nmcli connection import type wireguard file YourConfigFile.conf
@kittinan
kittinan / yolov8_virtualcam.py
Last active September 21, 2023 16:54
Ultralytics YOLOv8 object detection model to detect objects in a video stream from a webcam and stream the annotated video to a virtual camera device.
"""
pip install ultralytics pyvirtualcam
Enable virtual camera on Linux:
modprobe v4l2loopback devices=1 max_buffers=2 exclusive_caps=1 card_label="VirtualCam"
# Remove v4l2
modprobe -r v4l2loopback
"""
@kittinan
kittinan / cloudflare_tunnel.md
Last active December 20, 2021 04:40
Cloudflare tunnel
@kittinan
kittinan / tunnel-jupyter.md
Last active August 17, 2021 14:34
ssh tunnel to access jupyter notebook server

Server

  • run jupyter notebook
jupyter notebook
  • do not forget check ssh server config /etc/ssh/sshd_config
@kittinan
kittinan / mnist_tf.py
Created January 21, 2021 12:39
this code from https://www.tensorflow.org/datasets/keras_example to test my GPU training work
import tensorflow.compat.v2 as tf
import tensorflow_datasets as tfds
tf.enable_v2_behavior()
(ds_train, ds_test), ds_info = tfds.load(
'mnist',
split=['train', 'test'],
shuffle_files=True,
as_supervised=True,
@kittinan
kittinan / selenium.py
Created October 22, 2020 10:33
Python Selenium screenshot capture
# pip install -U selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--window-size=1920,1080")
#chrome_options.add_argument("--disable-gpu")
#chrome_options.add_argument("--no-sandbox") # linux only
@kittinan
kittinan / fake_berthai.ipynb
Created October 14, 2020 16:21 — forked from cstorm125/fake_berthai.ipynb
fake_berthai.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kittinan
kittinan / multiple_process.py
Created October 6, 2020 14:38
Python utilities function to run multiple processes on your function
from tqdm.autonotebook import tqdm
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor, wait, as_completed
import multiprocessing
import time
def run_multiple_process(func, params=[], num_cpu=None, verbose=True):
start_time = time.time()
@kittinan
kittinan / fix_tensorflow.md
Created July 11, 2020 17:26
Fix Failed to get convolution algorithm.

Fix Tensorflow 2.X Keras Error

If you install correct Tensorflow, cuDNN and CUDA Toolkit version and got this error message.

Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.

Try to Add this code below before import your tensorflow

@kittinan
kittinan / create_swap.sh
Created April 20, 2020 07:07
Ubuntu 18.04 create swap
#!/bin/bash
# Run as root
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
sysctl vm.swappiness=10
echo "vm.swappiness=10" >> /etc/sysctl.conf