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);
@ChatchaiJ
ChatchaiJ / check-packtpub-freelearning.perl
Created August 3, 2015 05:06
Check latest free ebook from packt pub.
#!/usr/bin/perl -w-
use strict;
use warnings;
use autodie;
my $URL = "https://www.packtpub.com/packt/offers/free-learning";
my $CMD = "curl -s -S $URL";
my ($match_title, $bookname) = (0, "");
#!/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 / pkgorphremove
Created December 8, 2015 06:46
Remove Orphaned Packages
#!/bin/sh
# --------------------------------------------------------------------- #
# pkgorphremove : Remove Orphaned Packages. #
# Loop repeate removing/purging orphan packages #
# #
# version 0.1 : 2004-08-08 (cj) initial. #
# --------------------------------------------------------------------- #
while [ "`deborphan`" ]
@ChatchaiJ
ChatchaiJ / pkgupgrade
Created December 8, 2015 06:48
Upgrade debian package on the system
#!/bin/bash
# --------------------------------------------------------------------- #
# pkgupgrade - Upgrade debian package on the system. #
# #
# version 0.1 - cj (200x-xx-xx) init. #
# version 0.2 - cj (2013-07-17) comment, and start/finished time #
# added. #
# --------------------------------------------------------------------- #
@ChatchaiJ
ChatchaiJ / pkgupdate
Created December 8, 2015 06:50
Get list of packages to be updated on debian system
#!/bin/sh
# ********************************************************************* #
# pkgupdate : script for calling from crontab to update debian #
# packages on a machine using apt-get #
# Mainly this is a two commands #
# #
# apt-get update && apt-get upgrade -y -d upgrade #
# #
# but made readable report from the output of those #
@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;"