Skip to content

Instantly share code, notes, and snippets.

View ChatchaiJ's full-sized avatar

Chatchai Jantaraprim ChatchaiJ

View GitHub Profile
@ChatchaiJ
ChatchaiJ / verify-sdcard.sh
Created April 18, 2024 01:21
check that sdcard that how much actually it could contain data
#!/bin/sh
SDCARD="$1"
RANDFILE="/tmp/rand10m"
TMPBIN="/tmp/tmp.bin"
MAGICWORD="--i-know-what-i-am-doing"
BS="10240"
COUNT="1024"
@ChatchaiJ
ChatchaiJ / video-record.sh
Last active July 3, 2022 18:37
Record video from webcam using ffmpeg
#!/bin/sh
LEN=10 # video length in seconds
SLEEP=3 # sleep time in seconds
SAVEDIR="/tmp/camera"
CAMERA=$1
# How to use thi script
[ -z "$CAMERA" ] && echo "Usage: $0 /dev/videoX ## where X is [0..n]" && exit
@ChatchaiJ
ChatchaiJ / reprepro-config.sh
Created May 29, 2022 17:35
Config reprepro on debian server to create debian repository -- example add python package to repos
#!/bin/sh
BASEDIR="/srv/repos/apt/debian"
CONFDIR="${BASEDIR}/conf"
DISTFILE="${CONFDIR}/distributions"
OPTIONS="${CONFDIR}/options"
DEBWORKDIR="/home/cj/work"
# DEBFILE="${DEBWORKDIR}/python_3.10.4-1_amd64.deb"
DEBFILE="python_3.10.4-1_amd64.deb"
@ChatchaiJ
ChatchaiJ / build-repos.sh
Created May 29, 2022 17:33
Prepare debian system + apache2 server to be debian repository
#!/bin/sh
REPODIR="/srv/repos/apt/debian"
CONF="/tmp/repos-$$.conf"
APACHECONFDIR="/etc/apache2/conf-available"
[ ! -d "${APACHECONFDIR}" ] && \
echo "Apache2 conf directory is not available, is it installed?" && \
exit
#!/usr/bin/env bash
NAME="Chatchai Jantaraprim"
EMAIL="cj@cjv6.net"
[ -d ".gnupg" ] && echo "Directory .gnupg exist" && exit
# rm -rf .gnupg
mkdir -m 0700 .gnupg
touch .gnupg/gpg.conf
@ChatchaiJ
ChatchaiJ / build-python-deb-package.sh
Last active July 4, 2022 23:50
Create python 3.10.4 debian package from source
#!/bin/bash
# ----- work space config -----
WORKDIR="$(pwd)"
SRCDIR="${WORKDIR}/src"
BUILDDIR="${WORKDIR}/build"
LOGDIR="${WORKDIR}/log"
# ----- package config -----
NAME="python"
@ChatchaiJ
ChatchaiJ / modify-grafana-password
Created February 26, 2021 08:33
Change user password of a user in grafana sqlite3 db
#!/usr/bin/perl -w-
use strict;
use warnings;
use Crypt::PBKDF2; # libcrypt-pbkdf2-perl
use String::Random qw(random_string); # libstring-random-perl
use constant HASHCLASS => 'HMACSHA2';
use constant ITERATION => 10000;
#!/bin/sh
CUAD="/root/bin/can-user-access-dir" # Can this 'user' access this 'directory'
[ -z "$1" ] && echo "Usage: $0" && exit
USER=$1
### Prepare working space ###
T=`mktemp -d --tmpdir=/tmp .XXXXX`
#!/bin/sh
[ "`id -u`" != 0 ] && echo "Must be root to run this script" && exit -1
[ -z "$2" -o "$3" ] && echo "Usage: $0 user directory" && exit -1
USER="$1"
DIR="$2"
id "$USER" >& /dev/null || {
echo "User '$USER' not exist";
@ChatchaiJ
ChatchaiJ / vncconf.sh
Created March 16, 2020 11:47
Create script and passwd for runing vnc at remotehost
#!/bin/sh
# What need to be done
# 1. local binary script: ${REMOTE}-vnc
#
#| #!/bin/sh
#|
#| PORT=5998
#| tmux new ssh -L${PORT}:localhost:${PORT} pi-01 bin/vnc-at-${PORT} \; \
#| split -v "sleep 3; vncviewer -passwd $HOME/.vnc/pi-01-${PORT} localhost:${PORT}" \; \