Skip to content

Instantly share code, notes, and snippets.

View dogterbox's full-sized avatar
😴
Working from home

Teerapong Taengmuang dogterbox

😴
Working from home
View GitHub Profile
@dogterbox
dogterbox / docker-compose.yaml
Created July 15, 2024 05:07 — forked from joebeeson/docker-compose.yaml
Anchors in docker-compose.yaml
version: "3.4"
x-defaults: &defaults
image: "dask-dev/dask-notebook"
# With lists, each entry requires its own anchor if you
# intend to extend/reuse an entry in concrete services.
configs:
- &configs_condarc
source: "condarc"
Hex ChainId (Decimal) Network
0x1 1 Ethereum Main Network (Mainnet)
0x3 3 Ropsten Test Network
0x4 4 Rinkeby Test Network
0x5 5 Goerli Test Network
0x2a 42 Kovan Test Network
0xAA36A7 11155111 Sepolia Testnet
0x89 137 Polygon Main Network
0x13881 80001 Mumbai Test Network
0xA86A 43114 Avalanche C-Chain Main Network
@dogterbox
dogterbox / gist:f4f6e75ab0b954be9ed75c7178135a88
Created January 6, 2023 13:49 — forked from mpuig/gist:1582085
How to reduce color palette with PIL
import Image
im = Image.open('image.jpg')
# using Image.ADAPTIVE to avoid dithering
out = im.convert('P', palette=Image.ADAPTIVE, colors=5)
upstream django_app {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name demo.gatos.io;
access_log /var/log/nginx/app.log;
@dogterbox
dogterbox / sonarqube-postgres.yaml
Last active July 21, 2022 15:22 — forked from pavankjadda/Sonarqube with Postgres database using docker.md
Setup Sonarqube with Postgres database using docker
version: "3"
services:
sonarqube:
image: sonarqube
ports:
- "9000:9000"
networks:
- sonarnet
environment:
@dogterbox
dogterbox / remove.sh
Created May 31, 2022 06:27 — forked from sxiii/remove.sh
Docker Swarm - Remove all Down nodes automatically
#!/bin/bash
# Requirements: linux, docker, grep, awk
# This script removes all "Down" (off) nodes from Docker Swarm
# Useful to clean stuff from time to time, if you have auto-joining nodes for example
sudo docker node rm $(sudo docker node ls | grep Down | awk -F" " '{ print $1 }')
@dogterbox
dogterbox / background.html
Created March 1, 2022 11:23 — forked from Yinnon-Haviv/background.html
Attempt to draw Google Charts in Chrome extension popups, while loading the API in the background page
<!DOCTYPE html>
<html>
<head>
// Autoload the 'corechart' visualization library, as described in:
// http://code.google.com/apis/chart/interactive/docs/library_loading_enhancements.html#enhancedloading
//
// the 'autoload' parameter is URI encoded.
<script type="text/javascript" src="https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22packages%22%3A%5B%22corechart%22%5D%7D%5D%7D"></script>
</head>
<body>
@dogterbox
dogterbox / [PYTHON]Kill_thread.md
Created January 27, 2021 08:45 — forked from Sanix-Darker/[PYTHON]Kill_thread.md
[PYTHON]Kill_thread.md

Python | Different ways to kill a Thread

In general, killing threads abruptly is considered a bad programming practice. Killing a thread abruptly might leave a critical resource that must be closed properly, open. But you might want to kill a thread once some specific time period has passed or some interrupt has been generated. There are the various methods by which you can kill a thread in python.

  • Raising exceptions in a python thread
  • Set/Reset stop flag
  • Using traces to kill threads
  • Using the multiprocessing module to kill threads
  • Killing Python thread by setting it as daemon
  • Using a hidden function _stop()
@dogterbox
dogterbox / logging.conf
Created November 24, 2020 05:12 — forked from philippegirard/logging.conf
FastAPI logging
[loggers]
keys=root,uicheckapp
[handlers]
keys=consoleHandler,detailedConsoleHandler
[formatters]
keys=normalFormatter,detailedFormatter
[logger_root]
@dogterbox
dogterbox / resize_and_pad_image_to_square.py
Created October 15, 2020 11:17 — forked from jdhao/resize_and_pad_image_to_square
this script will resize and pad an image to desired square size and keep its aspect ratio unchanged. Before running the script, please change the size and image path to valid value.
from PIL import Image, ImageOps
import cv2
desired_size = 368
im_pth = "/home/jdhao/test.jpg"
# im = Image.open(im_pth)
# old_size = im.size # old_size[0] is in (width, height) format
# ratio = float(desired_size)/max(old_size)