I am a Nerd!!!

A few months back I came across a blog post “The Nerd Handbook” (read here). While reading it I felt as if it was about me. I always thought about myself to be very different, but now I know, I am just one of the many nerds. Its so intriguing that the author of the post is such an observant man. After reading his post I am trying to get rid of some of the negative traits of nerds. So, wish me luck.

autoWallChange: Automatically changes wallpaper

About the script
This is a KDE (may not work in KDE 4) only shell script which changes wallpaper every few minutes as set by you. KDE too has a built-in feature to change wallpaper but it has few limitations:-

  1. It doesn’t show pictures within the sub-directories of the given path.
  2. It applies the same picture position setting (i.e. Scala&Crop, Tile, etc.) to all the pictures.

This script allows you to apply different picture position settings to pictures from different directories. e.g. if you use the following settings

picDir=”/home/geek/Pictures”
shapeDir=”Rectangle Square Tall”
shapeMode=”8 8 5″

Then pictures from /home/geek/Pictures/Rectangle and /home/geek/Pictures/Square will be shown using Scale & Crop position setting, and pictures from /home/geek/Pictures/Tall will be Titled Maxpect. Following is the table for which number stands for what position setting.

  • 1 -> Centered
  • 2 -> Titled
  • 3 -> Center Titled
  • 4 -> Centered Maxpect
  • 5 -> Titled Maxpect
  • 6 -> Scaled
  • 7 -> Centered Auto Fit
  • 8 -> Scale & Crop

This script is best used with my iflickrDown script (see here).

The code
License: GNU Public License version 3.

[code lang=”bash”]#!/bin/bash
#Coded by AppleGrew
#License: GPL version 3

#############################################
############Alternative way to set###########
##########the following variables############
#Create another shell script and export it #
#from there. #
#===============SAMPLE=======================
# #!/bin/bash
# export picDir="/home/geek/Pictures" #Donot put ‘/’ at the end
# export shapeDir="Square Rectangle Tall"
# export shapeMode="8 8 5"
# export changeWallIntv=2 #in mins
#
# ./autoWallChange >/tmp/autoWall.log & #Launching the main program.
############Configs##########################
picDir="" #Donot put ‘/’ at the end
shapeDir=""
shapeMode=""
changeWallIntv=1 #in mins
#############################################

tmpFile="/tmp/autoWallChange.tmp"
lstFile="/tmp/autoWallChange.lst"
fileLen=0
factor=0

shapeDir=( $shapeDir )
shapeMode=( $shapeMode )

echo "${shapeDir[@]}"
echo "${shapeMode[@]}"

function refreshFileList(){
local DIR_PATH=$1
local sM=$2
echo "Refreshing content of ‘$DIR_PATH’, shape mode is $sM"

if [ -a "$DIR_PATH" ] && [ -d "$DIR_PATH" ] && [ -w "$DIR_PATH" ]
then
for f in `find "$DIR_PATH" -type f -print | sed ‘s/ /|/g’`
do
matchFound=0
for fl in `cat "$tmpFile"`
do
fl=`echo "$fl"|sed -e ‘s/\([^>]*\)>\([^>]*\)/\1\n\2/g’|head -n 1|tail -n 1`
[[ "$fl" == "$f" ]] && matchFound=1 && break
done
[[ $matchFound == 0 ]] && printf "%s>%d\n" $f $sM >>"$tmpFile" && let ‘fileLen++’
done
let ‘factor=(fileLen-1)*100000000/32767’
fi
echo "Refreshed"
}

printf "">"$tmpFile" #Creating new empty file.
i=0
for shape in ${shapeDir[@]}
do
test -a "$picDir/$shape" && find -L "$picDir/$shape" -type f -print > "$lstFile.$i"
test -a "$picDir/$shape" && refreshFileList "$picDir/$shape" ${shapeMode[$i]}
let ‘i++’
done

shownPicsLine=0
lastL=""
totShown=0
RANDOM=$$
while true
do
let ‘l=(factor*RANDOM+100000000)/100000000’
test $totShown -ge $fileLen && lastL="" && totShown=0
while echo "$lastL" | grep -o "\"$l\"" > /dev/null
do
let "l++"
test $l -gt $fileLen && l=1
done
lastL="${lastL}\"$l\""
let "totShown++"

pfileL=`cat "$tmpFile"|head -n $l|tail -n 1`
pfilePath=`echo "$pfileL"|sed -e ‘s/\([^>]*\)>\([^>]*\)/\1\n\2/g’|head -n 1|tail -n 1|sed ‘s/|/ /g’`
pfileMode=`echo "$pfileL"|sed -e ‘s/\([^>]*\)>\([^>]*\)/\1\n\2/g’|head -n 2|tail -n 1`

if [ $totShown -ge $fileLen ]
then
lastL=""
totShown=0
fi

[ -f "$pfilePath" ] && dcop kdesktop KBackgroundIface setWallpaper "$pfilePath" "$pfileMode"

i=0
for shape in ${shapeDir[@]}
do
if test -a "$picDir/$shape" && ! find -L "$picDir/$shape" -type f -print | diff "$lstFile.$i" ->/dev/null
then
echo "’$picDir/$shape’ content changed"
refreshFileList "$picDir/$shape" ${shapeMode[$i]}
find -L "$picDir/$shape" -type f -print > "$lstFile.$i"
fi
let ‘i++’
done
echo "sleeping"
sleep "${changeWallIntv}m"
done<[/code]

Posting PHP codes on blog.

If you want to post PHP code on blog or any web page then its easy. Use the command:-

php -s /path/to/your/php/script > The_Code_to_post

This will generate a html code that you can directly paste in the web page’s code to display your code with syntax highlighting, but if you post this code in Blogger.com or Drupal then you will notice extraneous blank lines after every line of your code. This is due the fact that Blogger.com and Drupal insert a line break themselves whenever they encounter a new-line or carriage-return. To fix this problem, use the following command instead of the above one.

php -s /path/to/your/php/script | tr -d ‘\n\r’ > The_Code_to_post

Uploaded two projects on Sourceforge.net

A few days ago I uplaoded two projects on Sourceforge.net (world’s largest open source programs’ repository). They are LANSim and AG’s Library Manager.

LANSim

(Update: This has now been uploaded to Github – https://github.com/applegrew/lansim. Please download or fork it from there.)

This is a network simulator. This is meant to be user friendly as well as feature rich. This field lacks software with good user interface. Even the commercial softwares in this field is quite lame. This aimed to go along Multisim(R) and Blender(R) form.

URL:-

Homepage: lansim.sourceforge.net
SF site: sourceforge.net/projects/lansim

Developers:-

1) Rohit Singh
2) Dhiraj Prakrash
3) and me.

AG’s Libray Manager

This a versatile library manager made in Java. It requires MySql at backend to store the database. This is not made to function only as a library manager but can be used in many places like CD rental shops etc. It has the feature to export the result to Microsoft Excel format. It can also import from there (but there isn’t any easy way to do so currently). The number of fields of information you want to store for your items can be customised by changing the MySQL table structure (Currently there isn’t any easy way to do so).

Url:-

Homepage: libmanager.sourceforge.net
SF site: sourceforge.net/projects/libmanager

Developer:-

Me

Dataone – BSNL Broadband: Common problems and quick fixes.

I am a BSNL Dataone user and as any BSNL user knows that in case of problem u can turn towards BSNL for help. So, I guess I should help fellow users to let know the solutions to common problems I faced or face.

problem When trying to dial and connect to BSNL you get Error 678 – Remote computer is not responding.
sol Make sure that the link light of your modem (actually router) is ON (green). If not then wait for about 2 mins. If still not contact ur BSNL local exchange.

If the link light is lit happily then make sure the router is connected to ur computer. Now turn OFF the router. And now turn it ON. Wait for link light to turn ON. Now try. It should connect now.

problem I get Invalid Username or Password and I am pretty sure that they r correct.
sol Nothing. It happened to me sometimes. Just keep redialing.

problem The check usage site doesn’t open.
sol Then goto alternative portals of the same site. Try any one of the followings.
http://10.240.43.216/
http://10.240.89.199/
http://10.240.16.195/
http://10.240.0.195/

problem Connection gets lost after a power cut though u r using an UPS.
sol My router (Huawei MT882) has this problem. The reason I guess is that it is extremely sensitive to slight distruption of power which happens when online UPSs switch to battery mode from AC mode. So, getting an offline UPS may help.