Archive for October, 2009

Removing Empty Directory

Did you know that having empty folders on you system can cause slowdown on you system?  Yes it is true specially if you have program that traverse all the files and folders on your systems.  You know, by looking to the files at our hard disk, it is a jungle out there.

Here is a simple approach to this problem:

dir <Target Dirctory> /b /ad /s | Sort /r > <output file>

EX: dir c:\Windows /b /as /s | sort /r >DirList.TXT

and append RD for each line on of the output file

The concept here is get the directory list and sort it reverse order. Why in reverse order since the directory display the top directory then it goes to it contents.  By reversing the order you will remove the inner folder first, then the outer folder.

Since RD (Remove Directory) removes empty folder only, therefore it will just remove empty folders only.

Here is a PERL function I made:

sub EraseDir()
{

if (!-d $_[0])
{
return 0; #Function Failed
}
else
{
#Get the directory list and sort it reverse order.
system (“dir $_[0] /b /ad /s | Sort /r > _junk.file”);
open LIST ,”_junk.file” || return 0; #Function Failed
open FH,”>_junk.Bat”;
foreach my $line (<LIST>)
{
chop $line;
print FH “RD \”$line\”\n”;
}

close (FH);
close (LIST);
unlink “_junk.file”;
system (“_junk.BAT”);
unlink “_junk.Bat”;
return 1; #Successful
}
}

Carnapping Modus Operandi – Egg Throwers

We got this from a text message of a friend.  True or not, it wouldn’t hurt to take precaution.

If you are driving at night and someone threw eggs on your windshield. DO NOT USE THE WIPER AND SPRAY WITH WATER. Because egg mixed with wiper became milky and block your vision up 92.5%.  Then you are forced to stop at the road side.  And someone will approach you and rob your things, or even take your car at the worst.  This is a new technique used by robbers.

A sample egg splat, imagine this on your windshield

Please inform your family and friends about this.

Noynoy Aquino 30 Sec TVC

Saw this from Facebook,  got this from www.youtube.com. I haven’t seen this on TV.  It is a short and cute teaser.  This video clip actually plays 27 seconds.

He is our hope. He is our future.  He is our destiny.

How to get free space of Hard Disk using script?

The fastest way to get the free disk space is by looking at Windows Explorer, however most of us want to do this in command line or integrate this to a program for any unknown reasons.

The next fastest and easy this is to use dir command. Why? Since it uses Windows native  command.  I don’t know if find first find next function on Assembly or C is faster than this one.

image

On dir result we see the summary at the last line.  All we need to do is place the result of dir command at a text file and parse the last line from the text file.

Here is a sample PERL script so you can understand what I meant.

sub getFreeDiskSpace ()
{
my $dirname = “$_[0]”;
#Execution of the DIR command
system(“dir $dirname /s > junk”);
open FILE,”junk” || die (“Cannot open temporary file – \”junk\””);

#Parsing of the last lines of the DIR results
@_ = <FILE>;
close(FILE);
my $lastline = @_;
my $dir_size = @_[$lastline-2];
my $disk_remain = @_[$lastline-1];
my @fields = split(/ +/,$dir_size);
$_ = $fields[3];
s/,//g; #get rid of commas in the number
my $folder_size=$_;
my $file_count=$fields[1];
@fields = split(/ +/,$disk_remain);
$_ = $fields[3];
s/,//g; #get rid of commas in the number
my $free_space=$_;
my $folder_count=$fields[1];
unlink “junk”;
return ($free_space,$folder_size,$file_count,$folder_count);
}

I go this concept from a script I found from the internet.  I modified it and to a function for portability on the future use.  What struck me the most is I am trying to look for a PERL function and this is what I’ve got.  The lesson I got from this function is “Don’t reinvent the wheel, since it is already invented.” So use what’s available on the market.

Cool Application UI for Windows Mobile

Are you bored with on your Windows Mobile Home Screen.  Bored with the looks since you saw it over and over again.  And you want to have the “WOW” factor as you’ve seen on the iPhone?

Introducing SBP Mobile Shell 3.5. It comes with the following features:

  1. Cool widgets to customize your Home screen. 
  2. Finger friendly contacts with Facebook integration
  3. Fast access to all your phone features and applications
  4. SPB Mobile Shell comes with integrated tools, not limited to the basic phone tools.  I also includes Weather forecasts, Internet, and Facebook & Twitter status
  5. Finally you can customize your device with different options such as
    • Widget position
    • Color Theme
    • Cool Background home screen
    • and many more…

image image image A screen shot of my Home Screen and add widget feature

Aside from the aesthetics, the feature I like the most is you can select different windows with special effects.

image image

And it has cool message reading pane for emails and SMS

image

    For full presentation please refer to this video by SPB
    This cool application cost only for US$29.95. (PHP 1,403.46)  And you can try this for 15 days before purchase.

      LTO License Plate Verification using SMS

      I just got this from an email and I think this is usefull for all of car owners.

      LTO Car Plate Number Verification System

      1. Applies to used/old or brand new cars
      2. Provides information about the REGISTRATION of any of your vehicles, whether it is filed genuinely at any LTO Office or not.
      3. There are CHECKPOINTS nowadays and some unscrupulous policemen will tell you that your CAR REGISTRATION is not duly registered even if you show the OFFICIAL RECEIPT- LTO CAR REGISTRATION. The policeman will tell you that it is either tampered or fake and you have no choice but to give the policeman bribe money.

      How to use this system:

      1. On your cellphone text this message:

      < LTO space VEHICLE space XXXooo >

      ( where XXX000 stands for your vehicle’s PLATE NUMBER ( Philippines ) ) i.e.   LTO VEHICLE ZFH185

      2. SEND to 2600 and wait for Auto generated reply then save to your phone.  (An amount of P2.50 or P2.00 will be charged when you send to 2600)

        A reply message from 2600 will inform you the following about the plate no.:

        • Car Plate:
        • Model:
        • Year:
        • Color:
        • Date of Last Registered:
        • LTO Apprehension: if any
        • LTO Alarm: if any

        This is useful for:

        1. If there is a problem in CHECKPOINTS, just show this text message to the officer in charge.
        2. This text message from 2600 is also very important when buying an old and cheap used car.
        3. This will also be useful when you are following a car with a doubtful car plate no.
        4. When you register your car at any LTO Office, try to check this out whether your car is genuinely registered, or a tampered/fake OR was issued to you by an LTO employee or fixer.

        Art of Magic

        Key terms to remember:

        • Salamangka = Magic
        • Salamangkero = Magician

        When I was a little boy, I usually see magicians who performed their tricks and I was amazed and believed that “magic” really existed.  Until I realized that these were mere tricks and not magic.  How come many people still amazed when they see magic show?  The answer is Showmanship, the way on how they delivered the performance.  Someone told me if you want a successfully show, even if your tricks are simple, you need a good presentation and a good delivery.  In short nasa boka lang yan… (It in the way you say it) After watching an episode of Breaking the Magicians’ Code: Magic’s Biggest Secrets Finally Revealed, I understand more on how things works and I was more amazed to magic than ever before.

        Metal chain magic trick revealed

        Some people ask, if these magicians can do magic, how come they are not rich?  They can use magic to create money, and not to perform on birthday parties and any other parties anymore.  As I mentioned a while ago, these are tricks and skits that they performs to entertain us.  Anyway I know some who does magic for money. 😉

        Moving on, if you think deeper you can see some botched magic made by our dearest government official everyday.  Just tune in to you favorite TV or radio program.  I will not state names, and I know that you can related on what I am saying.  If not just go to Google.com and search the issue there.  If these tricks are successfully performed, we will not know them.  Here are some famous examples of magic tricks that our great performers botched.

        1. Diosdado Macapagal Boulevard – the most expensive boulevard in the whole universe according to Sen. Ping Lacson
        2. DeptEd Noodle Scam – PHP 12 from famous brand compared to PHP 18-22 from unknown noodle company and they said it is due to egg.
        3. Hello Garci – no explanation needed.  Nag sorry lang OK na (Just said sorry and everything back to normal).
        4. Series of expensive Lamp Post, we can see this everywhere, look at Manila Bay around 2004
        5. Le Cirque – as we know that salary of a Bank Manager is almost the same or higher than the salary of our President.  And the salary of a Congressman is smaller than the president.  So how did they magic money, as they claimed that they use their own money?
        6. At marami pang iba haay buhay…. (And many more. Oh! life….)

        See the difference? It’s magic… So on your next birthday party if you want a magician you know where to find him/her… 🙂