Skip to content

Instantly share code, notes, and snippets.

View siutin's full-sized avatar
🐴

martin chan siutin

🐴
View GitHub Profile
#!/bin/bash
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
echo "Usage: $0 <repository_name> [output_file]"
exit 1
fi
REPOSITORY_NAME="$1"
OUTPUT_FILE="$2"
#!/bin/bash
LEFT=$1
RIGHT=$2
BASE=$2
OUT=$2
echo $LEFT
echo $RIGHT
echo $BASE
@siutin
siutin / any2TGvideoSticker.sh
Created February 1, 2022 05:02
create Telegram Video Sticker from images/video
#!/bin/bash
ffmpeg -i $1 -c:v libvpx-vp9 -pix_fmt yuva420p -auto-alt-ref 0 -r 30 -t 3 -filter:v scale=512:-1 -an $1.webm
@siutin
siutin / sequential_subset.rb
Last active January 13, 2021 13:33
sequential_subset? in ruby
def sequential_subset?(a, b)
m = a.size
n = b.size
(0 ... n).each do |i|
j = 0
(0 ... m).each do |_|
break if b[i + j] != a[j]
j += 1
end
return true if j == m
@siutin
siutin / xbstream-extract
Created October 12, 2020 01:41
xbstream-extract
#!/bin/bash
FILE=$1
OUTPUT_FOLDER=$(basename "${FILE%.*}")
[ -z "$FILE" ] && echo "ERROR: file path is required" && exit 1
[ -z "$OUTPUT_FOLDER" ] && echo "ERROR: cannot set output folder" && exit 1
[ -d "./$OUTPUT_FOLDER" ] && echo "ERROR: output folder exists" && exit 1
echo "OUTPUT_FOLDER: $OUTPUT_FOLDER"
mkdir ./$OUTPUT_FOLDER
@siutin
siutin / fail2ban-client-ls-ip
Last active March 23, 2019 19:13
list all banned ip in fail2ban
#!/bin/bash
## usage: fail2ban-client-ls-ip [JAIL]
JAIL=$1
PROGNAME=$0
if [ -z $JAIL ]; then
[ -z $PROGNAME ] && echo "ERROR: $PROGNAME is empty" && exit 1
sudo fail2ban-client status |
@siutin
siutin / uptimerobot.sh
Last active February 14, 2019 05:23
Uptime Robot Ubuntu notification
#!/bin/bash
#
# usage: API_KEY=XXXX MONITOR_NAME=GOOGLE uptimerobot.sh
#
keep=$HOME/.uptimerobot-status
if [ -z "$MONITOR_NAME" ]; then
(>&2 echo "ERROR: MONITOR_NAME is required")
exit 1
@siutin
siutin / supervisord whoami
Created November 28, 2018 07:03
supervisord whoami
[program:whoami]
command=/bin/bash -l -c 'echo "whoami: $(whoami)"'
stdout_logfile=/dev/stdout
startsecs = 0
autorestart = false
@siutin
siutin / default.conf
Created November 3, 2018 07:31
Apache Websocket Proxy (socket.io) with Load Balancing
<VirtualHost *.:443>
ServerName whatever-domain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLProxyEngine on
ProxyPreserveHost on
RewriteEngine On
const TreeNode = function (value) {
this.left = null
this.right = null
this.value = value
}
// accept muliple sorted unqiue numbers arrays
const buildTreeNodes = function (...arrs) {
let node = new TreeNode()
for (let i = 0; i < arrs.length; i++) {