Skip to content

Instantly share code, notes, and snippets.

View kittinan's full-sized avatar
🇹🇭
:(){ :|:& };:

Kittinan kittinan

🇹🇭
:(){ :|:& };:
View GitHub Profile
@frizz925
frizz925 / main.py
Last active May 28, 2024 02:47
AES-256-CBC w/ Base64 using PyCryptodome library
from Crypto.Cipher import AES
from Crypto.Util import Padding
from hashlib import md5
from base64 import b64encode, b64decode
import sys
passphrase = sys.argv[1]
content = sys.argv[2]
print(passphrase, content)
@circa10a
circa10a / test.service
Last active March 10, 2022 15:48
A Simple Systemd Service
#/etc/systemd/system/test.service
[Unit]
Description=Test Systemd Service
[Service]
ExecStartPre=/usr/bin/echo -e "\033[0;33m Pre start \033[0m"
ExecStart=/usr/bin/sleep 10
ExecStartPost=/usr/bin/echo -e "\033[0;33m Post start \033[0m"
@korakot
korakot / colab_thai.py
Last active September 26, 2022 08:13
Set matplotlib to Thai font on MacOS
# download font file มาก่อน
!wget https://awards.opdc.go.th/awards_opdc/assets/fonts/THSarabunNew/THSarabunNew.ttf
# import and install
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
font_list = fm.createFontList(['THSarabunNew.ttf'])
fm.fontManager.ttflist.extend(font_list)
# set font
plt.rcParams['font.family'] = 'TH Sarabun New'
plt.rcParams['xtick.labelsize'] = 20.0
##
## How to install mcrypt in php7.2 / php7.3
## Linux / MacOS / OSX
##
## https://lukasmestan.com/install-mcrypt-extension-in-php7-2/
#
@kittinan
kittinan / client.py
Last active April 4, 2026 08:06
Python OpenCV webcam send image frame over socket
import cv2
import io
import socket
import struct
import time
import pickle
import zlib
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(('192.168.1.124', 8485))
@rluts
rluts / token_auth.py
Last active April 10, 2025 16:38
Token authorization middleware for Django Channels 2
from channels.auth import AuthMiddlewareStack
from rest_framework.authtoken.models import Token
from django.contrib.auth.models import AnonymousUser
from django.db import close_old_connections
class TokenAuthMiddleware:
"""
Token authorization middleware for Django Channels 2
"""
@titipata
titipata / convert_spectogram.md
Last active May 4, 2018 09:02
Convert MP4 to Spectogram

Convert files in MP4 folder to FLAC

Scipt to convert

import os
from glob import glob
import subprocess

MP4_PATH = '~/Desktop/notebooks/mp4/*.m4a' # path to all mp4 files

Thai songs similarity (experiment)

Create affinity matrix from Thai songs' spectogram

import os
import cv2
from skimage.measure import compare_ssim

dir_name = '/path/to/thaisongs/'
@ubergesundheit
ubergesundheit / readme.md
Last active January 8, 2026 18:26
systemd traefik.service

systemd Service Unit for Traefik

Adapted from caddy systemd Service Unit

The provided file should work with systemd version 219 or later. It might work with earlier versions. The easiest way to check your systemd version is to run systemctl --version.

Instructions

We will assume the following:

@MKagesawa
MKagesawa / docker-compose.yml
Created August 21, 2018 08:07
Docker-compose MySQL Image create multiple databases
# The official MySQL (https://hub.docker.com/_/mysql/) supports only one MYSQL_DATABASE environment variable.
# By modifying the entrypoint and passing shell script, you can create multiple dbs without having to make a mysql image just for this purpose.
version: '3'
services:
# Some other service connecting to mysql
db:
image: mysql:5.6