Skip to content

Instantly share code, notes, and snippets.

@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"
@phondanai
phondanai / audio_tools.py
Created December 9, 2017 10:39
Audio tools for numpy/python. Constant work in progress.
# License: BSD 3-clause
# Authors: Kyle Kastner
# Harvest, Cheaptrick, D4C, WORLD routines based on MATLAB code from M. Morise
# http://ml.cs.yamanashi.ac.jp/world/english/
# MGC code based on r9y9 (Ryuichi Yamamoto) MelGeneralizedCepstrums.jl
# Pieces also adapted from SPTK
from __future__ import division
import numpy as np
import scipy as sp
from numpy.lib.stride_tricks import as_strided