Skip to content

Instantly share code, notes, and snippets.

View RyanSiu1995's full-sized avatar
🍹
Vacation Forever

Ryan, Siu Long Wa RyanSiu1995

🍹
Vacation Forever
View GitHub Profile
@RyanSiu1995
RyanSiu1995 / git-prune-branches
Last active October 1, 2021 14:06
Sync the local branches with origin remote
#!/bin/bash -e
git fetch origin -p
REMOTE=$(git branch -r | sed "s/origin\///g")
BRANCHES=$(git branch | awk -F ' +' '! /\(no branch\)/ {print $2}')
for branch in $BRANCHES; do
if [[ -z $(echo $REMOTE | grep -w $branch) ]]; then
git branch -D $branch
fi
done
from hvac import Client
import yaml
class
class Config:
def _load_config(self):
client = Client(url = self.vault_url)
client.auth_approle(self.role_id, self.secret_id)
#!/bin/bash
PGHOST=$1
PGPORT=$2
PGUSER=$3
PGPASSWORD=$4
PGDATABASE=$5
if [[ -z "$PGHOST" ]] || [[ -z "$PGPORT" ]] || [[ -z "$PGUSER" ]] || [[ -z "$PGPASSWORD" ]] || [[ -z "$PGDATABASE" ]]; then
echo "Usage: ./dump.sh [HOST] [PORT] [USERNAME] [PASSWORD] [DB]"
public class IDGenerator {
static final String ID_SYMBOL_SET = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
public static String generateEncoderId(int length) {
StringBuilder buffer = new StringBuilder(length);
for(int i = 0; i < length; ++i) {
Integer idx = random.nextInt(ID_SYMBOL_SET.length());
buffer.append(ID_SYMBOL_SET.charAt(idx));
}
return buffer.toString();
@RyanSiu1995
RyanSiu1995 / drop_all_tables.sql
Created May 30, 2019 06:22
Drop All Tables in Database without Deleting the Database
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = "hydradb";
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;