Skip to content

Instantly share code, notes, and snippets.

View phongsathorn1's full-sized avatar
๐Ÿ™‚
Be Smile

Phongsathorn Kittiworapanya phongsathorn1

๐Ÿ™‚
Be Smile
  • TMBThanachart Bank (ttb bank)
  • Krung Thep Mahanakhon Amon Rattanakosin Mahinthara Ayuthaya Mahadilok Phop Noppharat Ratchathani Burirom Udomratchaniwet Mahasathan Amon Piman Awatan Sathit Sakkathattiya Witsanukam Prasit (Bangkok), Thailand
  • 17:13 (UTC +07:00)
  • LinkedIn in/phongsathorn1
View GitHub Profile
@ESWZY
ESWZY / compress_video.py
Last active November 27, 2025 05:42
An example Python code for compressing video file to target size.
# Simplified version and explanation at: https://stackoverflow.com/a/64439347/12866353
import os
import ffmpeg
def compress_video(video_full_path, size_upper_bound, two_pass=True, filename_suffix='cps_'):
"""
Compress video file to max-supported size.
:param video_full_path: the video you want to compress.
:param size_upper_bound: Max video size in KB.
import numpy as np
from scipy.linalg import eigh
def cca_predict(X, Y, X_new, kx, ky, whitening=False):
"""
Canonical correlation analysis and prediction
Python version of the original R function at: https://github.com/jmhewitt/telefit/blob/master/R/cca.predict.R
:param X: training samples of the predictor with shape M1 x N (M1 variables, N observations)
:param Y: training samples of the predictand with shape M2 x N (M2 variables, N observations)
:param X_new: test samples of the predictor
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active January 26, 2026 09:00
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@datlife
datlife / mnist_tfdata.py
Last active May 24, 2023 02:03
Training Keras model with tf.data
"""An example of how to use tf.Dataset in Keras Model"""
import tensorflow as tf # only work from tensorflow==1.9.0-rc1 and after
_EPOCHS = 5
_NUM_CLASSES = 10
_BATCH_SIZE = 128
def training_pipeline():
# #############
# Load Dataset
@pvilas
pvilas / install-opencv-cuda.sh
Created September 18, 2017 12:22
Installing OpenCV CUDA and python3 (Tested on AWS p2.xlarge and Deep Learning Ubuntu AMI 22_Aug_2017)
echo "First, you must manually donwload CUDA8 from https://developer.nvidia.com/cuda-downloads"
echo "Ideas taken from https://github.com/BVLC/caffe/wiki/OpenCV-3.2-Installation-Guide-on-Ubuntu-16.04 and http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/"
echo "Installing Nvidia drivers"
# Start clean
sudo apt purge nvidia-*
# Add the PPA
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt-get install nvidia-367
@harryfinn
harryfinn / security.ubuntu.com-timeout-on-apt-get-update.md
Last active October 15, 2024 01:56
security.ubuntu.com timeout on apt-get update

security.ubuntu.com timeout on apt-get update

Issue

When running the apt-get update command, the process 'hangs' when checking security.ubuntu.com endpoints. This is apparantely due to an issue some sites face when trying to connect over IPv6 and whilst it is assumed that this will be fixed at some point in the future (sooner rather than later judging by the transition to IPv6 by most), the fix below resolves this issue, allowing the update process to complete successfully.

Fix

@darrenjs
darrenjs / ssl_server_nonblock.c
Last active December 31, 2025 12:00
OpenSSL example using memory BIO with non-blocking socket IO
/*
This file had now been added to the git repo
https://github.com/darrenjs/openssl_examples
... which also includes a non blocking client example.
-------------------------------------------------------------------------------
ssl_server_nonblock.c -- Copyright 2017 Darren Smith -- MIT license
@yuyay
yuyay / kcca.py
Last active October 21, 2021 04:54
kernel canonical correlation analysis in python
#! encoding=UTF-8
"""
kernel canonical correlation analysis
"""
import numpy as np
from scipy.linalg import svd
from sklearn.metrics.pairwise import pairwise_kernels, euclidean_distances
class KCCA(object):
@soheilhy
soheilhy / nginxproxy.md
Last active July 5, 2025 15:29
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active March 16, 2026 18:37
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results