Categories
Internet Misc

Play PacMan on Google today

Google Doodle is showing and letting users play PAC-MAN today on their home page for celebrating 30th birthday of PAC-MAN. Go play on Google. Click on “Insert Coin” to restart the game. You will be pleasantly surprised to see Ms. PAC-MAN in 2 player mode (try inserting one more coin). Read more at http://googleblog.blogspot.com/2010/05/celebrating-pac-mans-30th-birthday.html

Play PacMan on Google

Categories
Bash Unix Admin

bash : run command on find results

Unix find command allows user to execute a command on the results by using -exec command. For example see below. {} get replaced by filename, Make sure to escape {} and ;.

find . -type f -exec ls -l {} ;

This triggers ls -l on all the files that were found. I used this with -maxdepth (how deep directory structure to examine) and -mtime (last modified time) to cleanup old files as below.

find /var/log -type f -mtime +30 -maxdepth 0 -exec rm -f {} ;
Categories
Perl

perl : Set different TimeZone for script

Here is how to set the timezone inside a perl script. A use case is when the application is communicating with some server in a different timezone and you want to log the time in the timezone of the other end instead of the timezone where this script is running.

$ENV{TZ} = ':/usr/share/zoneinfo/US/Eastern';
Categories
Hardware

Hardware : Dell GX620 SFF HTPC Bootup problem due to burned up capactiors

I added a PCI Express Video card to my Dell GX620 Small Form Factor desktop system and connected it to my Television. One small thing that I completely missed out was the amount of heat that gets generated in such a small confined spot with no outlet for that hot air. And one day it refused to boot up. It will not go to POST. The power LED will come Green, fan on the processor will come on and then switch off. After 3-4 retries it will boot up and display “A Thermal Event has occurred“. But I did not pay attention to that. Silly me. After couple of days it started to take about 20 tries. That’s when I started to search around.

There were so many posts but no real answers. But there was a common lead badmouthing Dell and other PC manufacturers that for saving cost they have used cheap capacitors that burn up.  In my case that was certainly not true. The system had best that market has to offer (Rubycon capacitors) but it was me who managed to burn them off. I got the final on it when I stumbled upon BadCaps.net. A very good website with information on what exactly was going on. So I opened up the system, took out the hard-disk and right under it on the mother board were four capacitors (2200 µF, 6.3V, 10mm) that were popped. The heat from Video card fried the poor chaps as they were too close.

Categories
php

php : How to unset a variable

PHP allows to unset or undefine a variable by using the “unset” method.

unset($variable);
Categories
php

php : How to find which modules are compiled in

“php -m” provides the list of all compiled in modules.

php -m | grep -v -e Modules] -e ^$

Got it from php.net (http://www.php.net/manual/en/install.unix.apache2.php)

Categories
Perl

perl : Create unix time from readable time

Many a times you may need to convert the human readable time into the Unix time. When all the information is passed to “mktime” it returns the unixtime. And to reverse it simply use “localtime”. Here is the example.

use POSIX;
use strict;
use warnings;

my $sec = 6;
my $min = 7;
my $hour = 8;
my $day = 9;
my $mon = 10 - 1;
my $year = 2004 - 1900;
my $wday = 0;
my $yday = 0;

my $unixtime = mktime ($sec, $min, $hour, $day, $mon, $year, $wday, $yday);
print "$unixtimen";

my $readable_time = localtime($unixtime);
print "$readable_timen";

Found at http://www.adp-gmbh.ch/perl/posix/convert_time.html

Categories
Bash Unix Admin

bash : brace expansion for automatic substitution

Bash expands a list of strings separated by commas with in braces to a list of strings separated by spaces. For example

[unixite@theunixtips:~/> echo 111-{aa,bb,cc}+{xx,yy,zz}-222
111-aa+xx-222 111-aa+yy-222 111-aa+zz-222 111-bb+xx-222 111-bb+yy-222 111-bb+zz-222 111-cc+xx-222 111-cc+yy-222 111-cc+zz-222
unixite@theunixtips:~/>

There should not be any space between suffix/prefix and the start/end bracket. Otherwise it is considered as a separate list. Now coming to a real world example where you can make use of this.

mv process.log{,.old} #This will move process.log to process.log.old
mv process.log.{old,oldest} #This will move process.log.old to process.log.oldest
Categories
Bash Unix Admin

Find Version of Redhat Linux running on the system

/etc/redhat-release contains version information on redhat systems.

unixite@theunixtips:~/ >cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.2 (Tikanga)
unixite@theunixtips:~/ >
Categories
Unix Admin

Sendmail : Configure outgoing relay server

Edit following in /etc/mail/sendmail.cf and add the name of your outgoing/relaying mailhost. Ensure that the relay server is accepting your email first.

# "Smart" relay host (may be null)
DS

e.g. if the outgoing relay is mailhost.xyzserver.com sendmail configuration should look like following.

# "Smart" relay host (may be null)
DS mailhost.xyzserver.com

After that restart the sendmail.

/etc/init.d/sendmail stop
/etc/init.d/sendmail start