Skip to content

Instantly share code, notes, and snippets.

View ChatchaiJ's full-sized avatar

Chatchai Jantaraprim ChatchaiJ

View GitHub Profile
#!/usr/bin/perl -w-
use strict;
use warnings;
use DateTime;
use Data::Dumper;
my $locale = DateTime->DefaultLocale;
print Dumper($locale);
#!/bin/bash
MSG="$1"
[ -z "$MSG" ] && exit
RES="/tmp/sendMessage.$$"
LOG="/tmp/bot_sendmessage.log"
BOTTOKEN="${HOME}/.tgbot-token"
#!/bin/bash
MAILSVR="mailscan.in.psu.ac.th"
R4=`echo "quit" | nc -w 3 -4 $MAILSVR 25`
R6=`echo "quit" | nc -w 3 -6 $MAILSVR 25`
D=`date '+%Y%m%d %H:%M'`
echo -n "$D "
@ChatchaiJ
ChatchaiJ / setnextfreeunixid
Created December 8, 2015 06:53
Set nextfreeunixid in ldap server
#!/bin/sh
# --------------------------------------------------------------------- #
# setnextfreeunixid : Set nextfreeunixid in ldap server allow #
# smbldap-tools to start adding account at the #
# appropriate place. #
# #
# version 0.1 : cj (2004-12-20) initial. #
# --------------------------------------------------------------------- #
@ChatchaiJ
ChatchaiJ / ban-ip-ssh-attack
Created December 8, 2015 06:55
Using iptable to filter ip that try to guess root's and other account's password
#!/usr/bin/perl -w-
# --------------------------------------------------------------------- #
# ban-ip-ssh-attack - using iptable to filter ip that try to #
# guess root's and other account's password. #
# #
# version 0.1 - cj (2005-05-05) initial version. #
# version 0.2 - cj (2005-05-09) working version. #
# version 0.3 - cj (2005-05-31) takasila version. #
# --------------------------------------------------------------------- #
@ChatchaiJ
ChatchaiJ / drop-unuse-mysql-database.sh
Created December 8, 2015 06:58
Drop unused students' database
#!/bin/bash
MYSQLDIR="/var/lib/mysql"
cd $MYSQLDIR
LIST=$( find . -maxdepth 1 -type d -mtime +365 -print |\
sed -e 's/^\.\///' |\
grep ^s4 )
for d in $LIST; do
echo "drop database $d;"
@ChatchaiJ
ChatchaiJ / psuautosigned.sh
Created December 8, 2015 07:10
Signed-in with PSU Login to access internet
#!/bin/sh
# --------------------------------------------------------------------- #
# psuautosigned Signed-in with PSU Login to access internet. #
# #
# version 0.1 - cj (2010-06-11) modified from engautosign-3 #
# version 0.1a - cj (2010-06-14) read login/password from user #
# if any of them doesn't provide from $CONF #
# version 0.1b - cj (2010-06-15) uses of function bug fixed. #
# thanks to aj. Panyarak for this. #
@ChatchaiJ
ChatchaiJ / buildvdimage.sh
Created December 8, 2015 07:20
Build raw disk image for VirtualBox and install debian system on it
#!/bin/bash
# --------------------------------------------------------------------- #
# buildvdimage - Build raw disk image for VirtualBox and install #
# debian system on it. So we can start using the new #
# virtual machine immediately without to install and #
# configure that system manually. #
# #
# Part of this script was modified from #
# http://blog.quinthar.com/2008/07/ #
@ChatchaiJ
ChatchaiJ / debmirror-checkspeed.sh
Created December 8, 2015 07:23
Check Debian Mirror Speed
#!/bin/bash
SITES="
ftp.th.debian.org
ftp.kr.debian.org
ftp.jp.debian.org
ftp.tw.debian.org
ftp.nz.debian.org
ftp.debianclub.org
mirror1.ku.ac.th
@ChatchaiJ
ChatchaiJ / dmtc.sh
Created December 8, 2015 07:27
Debian Mirror Trace Check
#!/bin/bash
# --------------------------------------------------------------------- #
# dmtc - Debian Mirror Trace Check #
# Check projects/trace directory in debian's mirror to #
# see which mirror has more up-to-date data. #
# #
# version 0.1 - cj (2013-05-17) init. #
# version 0.2 - cj (2013-05-17) some bug fixed. #
# version 0.2a - cj (2013-05-18) archive in progress detection added. #