Skip to content

Instantly share code, notes, and snippets.

View phainamikaze's full-sized avatar

Witsanu Boonamakam phainamikaze

View GitHub Profile
@phainamikaze
phainamikaze / query.sql
Created November 15, 2023 06:20
Write a query to rank the countries in each region by their population from largest to smallest.
SELECT Region, Name, Population, RANK() over(partition by region ORDER BY population desc) as 'Ranked' FROM world.country ;
def isPrime(num):
flag = False
if num == 1:
return False
elif num > 1:
# check for factors
for i in range(2, num):
if (num % i) == 0:
# if factor is found, set flag to True
#!/bin/sh -e
/root/OoklaServer —daemon
exit 0
@phainamikaze
phainamikaze / wrk install
Created October 11, 2021 16:36
load test tools
sudo apt-get install build-essential libssl-dev git -y
git clone https://github.com/wg/wrk.git wrk
cd wrk
sudo make
# move the executable to somewhere in your PATH, ex:
sudo cp wrk /usr/local/bin
@phainamikaze
phainamikaze / imgbase64
Created October 10, 2021 07:50
image base64
<img src="data:image/png;base64,xxxxx"/>
xxxxx is imgbase64
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA+gAAAdNCAYAAADwPXCqAAN3YUlEQVR4AezBCXiUhaHv4d/3zSRMEpZggYQb2wRPrwmgBo4mIW6BNtK6oSxiUdlOxbZRrO1RC2qr1qpUe8TWGq22CmrdUFKpiEA0iwomQWFYsig2M0LMhjIhkkxm+b57x/PMuWmaICI699H/+xojRh5vIyIiIiIiIiIxZSIiIiIiIiIiMWciIiIiIiIiIjFnIiIiIiIiIiIxZyIiIiIiIiIiMWciIiIiIiIiIjFnIiIiIiIiIiIxZyIiIiIiIiIiMWciIiIiIiIiIjFnIiIiIiIiIiIxZyIiIiIiIiIiMWciIiIiIiIiIjFnIiIiIiIiIiIxZyIiIiIiIiIiMWciIiIiIiIiIjFnIiIiIiIiIiIxZyIiIiIiIiIiMedERERE5GskJXU0rkEuIvw9flpbmhEREfn/gRMRERGRrziXK4HcvElkZ08kOTmZ3nw+H273VioryhAREYklJyIiIiJfYSmpo5k7dwEJCQn4OnxUV23G7/cTMSw5mczMsRQUTCEzM4s1a/5Ga0szhyM9YwyZx2eRkjoaf083Xo+H7e5t+P3dRCQPS+akCRPpq8Pnw+tpxNfhIyp5WDInTZjIoXi9HryeRpKHJXPShIkcitfrwetpJD1jDOnpGfTV4fPR0FCP399Nb+kZY0hPz+DTVFaUEZGdPZFhyckMpMPnw+3eSpTLlcBJ2RNITUllWPJwWlua8XobaWioJ+rMgil8mg6fD7d7K//27ePZu+d9enr8iIh8FTgRERER+YpKSR3N3LkLSEhIYMP6dVRVbaYvl+tl8vImcWbBFObOXcCfH3oAX4ePQ5k2bTrZEybSW1bmWM48czIbN7yM272VYcOHU1AwhYFUVJRRWVFGxLDhwykomMKhVFaU4fU0
const fs = require('fs');
async function example() {
const client = new ftp.Client()
client.ftp.verbose = true
try {
const secureOptions = {
// Necessary only if the server requires client certificate authentication.
key: fs.readFileSync('client-key.pem'),
cert: fs.readFileSync('client-cert.pem'),
@phainamikaze
phainamikaze / gist:82a57d398e37da2e7f24fb1037420f66
Created February 6, 2021 08:09
Alibaba Cloud Tech Share – Install Cloud Hosted Router (CHR) RouterOS MikroTik
Minimal requirements:
64bit CPU with virtualization support
128 MB or more RAM for the CHR instance
128 MB disk space for the CHR virtual hard drive
You can use Elastic Compute Engine Starter Package Plan/ Entry Level Using Ubuntu 16.04 64bit
1. Open Putty, Login to your ECS using IP address root. (SSH port 22)
2. Paste this script to your terminal
wget https://download2.mikrotik.com/routeros/6.40.5/chr-6.40.5.img.zip -O chr.img.zip && \
@phainamikaze
phainamikaze / nginx.conf
Created January 6, 2021 12:04
add forward header for reverse proxy
map $remote_addr $proxy_forwarded_elem {
# IPv4 addresses can be sent as-is
~^[0-9.]+$ "for=$remote_addr";
# IPv6 addresses need to be bracketed and quoted
~^[0-9A-Fa-f:.]+$ "for=\"[$remote_addr]\"";
# Unix domain socket names cannot be represented in RFC 7239 syntax
default "for=unknown";
}
@phainamikaze
phainamikaze / static content
Created December 29, 2020 17:26
nginx serv static content single page webapp
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.html;
server_name my.domain.com;
location / {
echo 1>/sys/class/block/sdd/device/rescan
Run the growpart <DeviceName> <PartionNumber> command to resize the partition.
The following example shows that the first partition /dev/sda1 of the system disk is resized:
[root@ecshost ~]# growpart /dev/sda 1
CHANGED: partition=1 start=2048 old: size=83883999 end=83886047 new: size=209713119 end=209715167
[root@ecshost ~]# resize2fs /dev/sda1