Skip to content

Instantly share code, notes, and snippets.

@phondanai
phondanai / sysctl.conf
Created October 21, 2025 08:04 — forked from maprangzth/sysctl.conf
ubuntu sysctl performance tuning
# Kernel sysctl configuration file for Linux
#
# Version 1.12 - 2015-09-30
# Michiel Klaver - IT Professional
# http://klaver.it/linux/ for the latest version - http://klaver.it/bsd/ for a BSD variant
#
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details.
@phondanai
phondanai / clojure-beginner.md
Created November 14, 2023 06:38 — forked from yogthos/clojure-beginner.md
Clojure beginner resources

Introductory resources

@phondanai
phondanai / forti-fix.sh
Created September 13, 2023 07:37 — forked from SydoxX/forti-fix.sh
Fixes Forticlient 7.0.7
#!/bin/bash
# version 2 thanks to @dhx-mike-palandra
echo "Creating /etc/NetworkManager/conf.d/99-forticlient.conf..."
sudo cat > /etc/NetworkManager/conf.d/99-forticlient.conf << 'EOF'
[keyfile]
unmanaged-devices=interface-name:~vpn*,type:tun
EOF
if [ $? -eq 0 ]

Open Search Cheat Sheet

Search with total size and sorting by timestamp

GET <index>/_search
{
  "size": 30,
  "query": {
    "match_all": {}
 },
@phondanai
phondanai / encrypt_openssl.md
Last active May 24, 2021 06:18 — forked from dreikanter/encrypt_openssl.md
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -pbkdf2 -e -in audio.wav -out audio.wav.encrypted

To decrypt:

@phondanai
phondanai / moving-zeros.clj
Created December 3, 2020 08:39
(move-zeros [1 0 0 2 0 3 0 4 5 0 6]) --> (1 2 3 4 5 6 0 0 0 0 0)
(def my-vec [1 0 0 2 0 3 0 4 5 0 6])
(concat (filter #(not= 0 %) my-vec
(filter zero? my-vec))
@phondanai
phondanai / ex7.py
Created October 13, 2019 12:00
homework 3 ex7
import numpy as np
import cv2
import sys
def median_cut(img, K):
K = int(K)
Z = img.reshape((-1, 3))
Z = np.float32(Z)
@phondanai
phondanai / extract_sift.py
Created May 28, 2018 03:38
Extract SIFT from image using OpenCV
import cv2 # pip install opencv-contrib-python
import numpy as np # pip install numpy
# load image
img = cv2.imread('/path/to/img.jpg')
# convert to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
@phondanai
phondanai / ptt_soap.php
Created February 16, 2018 03:31
Get current oil price from PTT SOAP web service using simple SOAP call from PHP.
<?php
$client = new SoapClient("http://www.pttplc.com/webservice/pttinfo.asmx?wsdl");
//echo("func");
var_dump($client->__getFunctions());
//echo("types");
var_dump($client->__getTypes());
$params = array(
@phondanai
phondanai / nginx.cron
Created February 7, 2018 07:21
Renew letsencrypt cert every 1st day every month crontab
00 00 01 */1 * /opt/certbot-auto renew --pre-hook="service nginx stop" --post-hook="service nginx start"