Skip to content

Instantly share code, notes, and snippets.

@FATESAIKOU
FATESAIKOU / encryptAndDecrypt
Created August 12, 2024 06:27
Encrypt and Decrypt with openssl
#!/usr/bin/env bash
PASSWORD=$1
# encryption
echo "Hello, world!" | openssl enc -aes-256-cbc -pbkdf2 -iter 10000 -a -salt -pass pass:"$PASSWORD" > helloWorld.crypted
# decryption
cat helloWorld.crypted | openssl enc -d -aes-256-cbc -pbkdf2 -iter 10000 -a -pass pass:"$PASSWORD" # Output "Hello, world!" here
@FATESAIKOU
FATESAIKOU / myAutossh.sh
Last active January 10, 2023 11:03
my autossh
#!/usr/bin/env bash
PORT=$1
AUTOSSH_CMD="ssh -Nf -D$PORT fatesaikou@fws.csie.io"
# SSH clean up function
function stopNfSSHs() {
pids=( $(ps -ef | grep '[s]sh -Nf' | awk '{print $2}') )
if [ "${#pids[@]}" -gt 0 ]; then
echo "Tunnel stop ${pids[@]}"
#!/usr/bin/env bash
TUTORID=$1
START=$2
curl 'https://www.cambly.com/api/reservations' \
-H 'authority: www.cambly.com' \
-H 'accept: application/json, text/javascript, */*; q=0.01' \
-H 'accept-language: zh-TW,zh;q=0.9,ja-JP;q=0.8,ja;q=0.7,en-US;q=0.6,en;q=0.5' \
-H 'cache-control: no-cache' \
#!/usr/bin/env bash
get_time_cands () {
local HOUR=3600
local DAY=$(( $HOUR * 24 ))
local WEEK=$(( $DAY * 7 ))
PIVOT_WEEK=$(( ( $(date +"%s") - $DAY * 4 ) / $WEEK * $WEEK + $DAY * 4 + $WEEK - 9 * $HOUR ))
local AVA_DATES=( $(( $PIVOT_WEEK )) $(( PIVOT_WEEK + $DAY * 2 )) $(( $PIVOT_WEEK + $DAY * 4 )) )
#!/usr/bin/env bash
# Args
REPOSITORY=$1;
CONTEXT='DOCKER_BUILD_CONTEXT';
PROFILE='AWS_PROFILE';
REGION='REGION';
# Check args
if [ ${#REPOSITORY} -eq 0 ]; then
#!/usr/bin/env sh
CHECK_INV=600
REMOTE_USER='remote_user'
REMOTE_PORT=22
REMOTE_HOST='example.com'
DST_PORT=22
SRC_PORT=2222
# This will update the kubectl config(default at ~/.kube/config)
aws eks update-kubeconfig --region <region code> --name <cluster name>
import os
from flask import Flask
app = Flask(__name__)
@app.route("/", methods=['GET'])
def sleep():
os.popen('sleep 10 &') # 沒有 & 就不會放背景執行,雖然依然會立刻回傳,但 python 會開一個 bash 等它的輸出,關掉服務就會直接終止 job
return 'sleep!'
set -e
role=$1
mfa_arn=$2
profile=$3
temp_profile=tf_temp
if [ -z $role ]; then echo "no role specified"; exit 1; fi
if [ -z $mfa_arn ]; then echo "no mfa arn specified"; exit 1; fi
if [ -z $profile ]; then echo "no profile specified"; exit 1; fi
#!/usr/bin/env bash
echo "CREATE DATABASE sampledb" | PGPASSWORD=password psql -h localhost -U user
# or
cat your.sql | PGPASSWORD=password psql -h localhost -U user