Skip to content

Instantly share code, notes, and snippets.

View ChatchaiJ's full-sized avatar

Chatchai Jantaraprim ChatchaiJ

View GitHub Profile
#!/bin/bash
LOCATION="$1"
[ -z "$LOCATION" ] && { echo "Usage: $0 LOCATION"; exit; }
FILE=$(
find $LOCATION -type f -exec ls --full-time {} \; |\
cut -f6- -d' ' |\
sort -r |\
#!/bin/sh
B="/sys/class/backlight/intel_backlight/brightness"
[ ! -f "$B" ] && { echo "Brightness can't be changed"; exit 0; }
[ -z "$1" ] && { echo "Usage: 0 value"; echo "where 1 < value < 937 "; exit 0; }
[ "$1" = 0 ] && { echo "Hmmm, you shouldn't do that, please use 1 instead"; exit 0; }
echo $1 | sudo tee $B
#!/bin/bash
[ -z "$1" ] && { echo "Usage: $0 [0-100]"; exit 0; }
re='^[0-9]+$'
if ! [[ "$1" =~ $re ]] ; then # this is not work in dash!
echo "error: Not a number" >&2
exit 1
fi
#!/bin/sh
MPS=`amixer contents | grep 'Master Playback Switch' | cut -f1 -d,`
amixer cset $MPS 1 > /dev/null
#!/bin/sh
MPS=`amixer contents | grep 'Master Playback Switch' | cut -f1 -d,`
amixer cset $MPS 0 > /dev/null
@ChatchaiJ
ChatchaiJ / lookup.sh
Created March 15, 2016 13:43
loop lookup ip address of a server from google public dns
#!/bin/bash
SVR="8.8.8.8"
HOST="ftp.coe.psu.ac.th"
SLEEPTIME=10
[ "$1" ] && HOST="$1"
while true; do
DATE=`date +%Y%m%d`
#!/usr/bin/perl -w-
use strict;
use warnings;
my $HOME = "http://www.dailynews.co.th";
my $PAGEURL = "$HOME";
unlink "newspaper" if -f "newspaper";
system("wget -q -O newspaper $PAGEURL");
#!/usr/bin/perl -w-
use strict;
use warnings;
my $HOME = "http://www.thairath.co.th";
my $PAGEURL = "$HOME/newspaper";
unlink "newspaper" if -f "newspaper";
system("wget -q -O newspaper $PAGEURL");
@ChatchaiJ
ChatchaiJ / minimal-psuautosigned.sh
Created December 14, 2015 06:29
Minimal PSU Autosigned Script
#!/bin/bash
USER="YOUR-PASSPORT-ID"
PASSWD="YOUR-PASSPORT-PASSWORD"
COOKIES="cookies.txt"
/usr/bin/curl \
--connect-timeout 10 \
--max-time 10 \
-s -k \
@ChatchaiJ
ChatchaiJ / my-passwod-generator.sh
Created December 8, 2015 07:44
My Password Generator
#!/bin/sh
LOG="$HOME/.my_password_generator.log"
echo -n "Enter [Key]: "
stty -echo
read key
stty echo
# echo "[$key]" # -- for debug only -- #
echo "*******************"