How to find the largest files or directories in Linux?

Monday 8 September 2008 @ 9:23 am

My VPS disk usage is already 96% so I have to find a way to search for the largest files/directories in Linux and check if they should be deleted or not.   I’m sure I can find files such as web log files which I can delete.

There isn’t any 1 linux command to do this but you can string a couple of commands to do the job.  Here’s what I use.
# du -a /home | sort -n -r | head -n 300

  • du : Estimate file space usage
  • sort : Sort lines of text files or given input data
  • head : Output the first part of files i.e. to display first 10 largest file

Better yet, you can run it in your background using this

# du -a /home | sort -n -r | head -n 300 >  spacehog.txt &

This will create a text file called spacehog.txt which you can review later after the background process finished.





Nude Lady Turning Clockwise and Counter Clockwise

Monday 1 September 2008 @ 12:08 pm

nude lady spinning clockwise and counter clockwise

Someone forwarded an email to me with the following image.   Let me quote the content

If you see this lady turning clockwise, you are using your right brain. 
If you see her turning counterclockwise, you are using your left brain. 
Some people do see both ways, but most people see it only one way.

See if you can make her go one way and then the other by shifting the brain’s current.
BOTH DIRECTIONS CAN BE SEEN!

Experimentation has shown that the two different sides, or hemispheres, of the brain are responsible for different manners of thinking. 


Most individuals have a distinct preference for one of these styles of thinking.  Some, however, are more whole-brained and equally adept at both modes.

In general, schools tend to favor left-brain modes of thinking, while downplaying the right-brain ones.  Left-brain scholastic subjects focus on logical thinking, analysis and accuracy.  Right-brained subjects, on the other hand, focus on aesthetics, feeling and creativity.

At first glance, I saw the lady turning counterclockwise.  But after a few seconds of staring, I can see her turning clockwise.  I can’t do it on demand immediately but once I force my brain to “see” the lady turn the other way, in a few seconds, I can.

I can probably do this because I’m left handed when I write but right handed when I do other tasks


Things that I can do left handed:

Write, paint, play table tennis, use a knife, use chopsticks, badminton


Things that I can do right handed:

Bowling, shoot a basketball, billiards, eat using spoon/fork, badminton





To All Pinoy Kids Who Were Born In The 1950’s, 60′ s, 70’s and early 80’s !!

Thursday 31 July 2008 @ 8:30 am

First, some of us survived being born to mothers who did not have an OB-Gyne and drank San Miguel Beer while they carried us.

While pregnant, they took cold or cough medicine, ate isaw,and didn’t worry about diabetes.

Then after all that trauma, our baby cribs were made of hard wood covered with lead-based paints, pati na yung walker natin, matigas na kahoy din at wala pang gulong.

We had no soft cushy cribs that play music, no disposable diapers (lampin lang), and when we rode our bikes, we had no helmets, no kneepads , sometimes wala pang preno yung bisikleta.

As children, we would ride in hot un-airconditioned buses with wooden seats (yung JD bus na pula),or cars with no airconditioning & no seat belts (ngayon lahat may aircon na)

Riding on the back of a carabaoon a breezy summer day was considered a treat.(ngayon hindi na nakakakita ng kalabaw ang mga bata)

We drank water from the garden hose and NOT from a bottle purchased from 7-11( minsan straight from the faucet or poso).

We shared one soft drink bottle with four of our friends, and NO ONE actually died from this.Or contacted hepatitis.

We ate rice with star margarine, drank raw eggs straight from the shell, and drank sofdrinks with real sugar in it (hindi diet coke), but we weren’t sick or overweight kasi nga……

WE WERE ALWAYS OUTSIDE PLAYING!!

We would leave home in the morning and play all day, and get back when the streetlights came on. Sarap mag patintero, tumbang preso , habulan at taguan.

No one was able to reach us all day( di uso ang cellphone , walang beepers ). And yes, we were O.K.

We would spend hours building our wooden trolleys (yung bearing ang gulong) or plywood slides out of scraps and then ride down the street, only to find out we forgot the brakes! After hitting the sidewalk or falling into a canal (sewerage channel) a few times, we learned to solve the problem ourselves with our bare & dirty hands .

We did not have Playstations, Nintendo’s, X-boxes, no video games at all, no 100 channels on cable, no DVD movies, no surround stereo, no IPOD’s, no cellphones, no computers, no Internet, no chat rooms, and no Friendsters. …… …WE HAD REAL FRIENDS and we went outside to actually talk and play with them!

We fell out of trees, got cut, broke bones and teeth and there were no stupid lawsuits from these accidents.The only rubbing we get is from our friends with the words..masakit ba ? pero pag galit yung kalaro mo,,,,ang sasabihin sa iyo..beh buti nga !

We played marbles (jolens) in the dirt , washed our hands just a little and ate dirty ice cream & fish balls. we were not afraid of getting germs in our stomachs.

We had to live with homemade guns ” gawa sa kahoy, tinali ng rubberband , sumpit , tirador at kung ano ano pa na puedeng makasakitan. Pero masaya pa rin ang lahat.

We made up games with sticks ( syatong ), and cans ( tumbang preso )and although we were told they were dangerous, wala naman tayong binulag o napatay.paminsan minsan may nabubukulan lang.

We walked, rode bikes, or took tricycles to a friend’s house and knocked on the door or rang the bell, or just yelled for them to jump out the window!

Mini basketball teams had tryouts and not everyone made the team. Those who didn’t pass had to learn to deal with the disappointment. Wala yang mga childhood depression at damaged self esteem ek-ek na yan. Ang pikon, talo.

Ang magulang ay nandoon lang para tignan kung ayos lang ang mga bata, hindi para makialam at makipag-away sa ibang parents.

That generation of ours has produced some of the best risk-takers, problem solvers, creative thinkers and successful professionals ever! They are the CEO’s, Engineers, Doctors and Military Generals of today.  The past 50 years have been an explosion of innovation and new ideas.

We had failure, success, and responsibility. We learned from our mistakes the hard way.

You might want to share this with others who’ve had the luck to grow up as real kids. We were
lucky indeed.

And if you like, forward it to your kids too, so they will know how brave their parents were.

It kind of makes you wanna go out and climb a tree, doesn’t it?!

PS - The big letters are because your eyes may not be able to read this if they were typed any smaller(at your age =).

[taken from forwarded email]





PRC.GOV.PH Hacked!!!

Monday 28 July 2008 @ 9:15 am

I was going to prc.gov.ph and then suddenly, google blocked me with this message

prc-site-hacked.JPG

Then  I clicked on  “Why was this site blocked” and gave me this

prc.gov.ph site hacked

I checked the URL and google.com redirected me to

http://safebrowsing.clients.google.com/safebrowsing/diagnostic?client=Firefox&hl=en-US&site=http://prc.gov.ph/

If you can’t see the pic.   Here’s the exact message

What is the current listing status for prc.gov.ph/?

This site is not listed as suspicious.Part of this site was listed for suspicious activity 5 time(s) over the past 90 days.

What happened when Google visited this site?

Of the 479 pages we tested on the site over the past 90 days, 116 page(s) resulted in malicious software being downloaded and installed without user consent. The last time Google visited this site was on 07/27/2008, and the last time suspicious content was found on this site was on 07/25/2008.

Malicious software includes 125 trojan(s), 100 exploit(s), 72 scripting exploit(s). Successful infection resulted in an average of 4 new processes on the target machine.

Malicious software is hosted on 11 domain(s), including o7o8gm.cn, heiheinn.cn, hiwowpp.cn.

7 domain(s) appear to be functioning as intermediaries for distributing malware to visitors of this site, including hiwowpp.cn, heihei117.cn, loveqianlai.cn.

Has this site acted as an intermediary resulting in further distribution of malware?

Over the past 90 days, prc.gov.ph/ did not appear to function as an intermediary for the infection of any sites.

Has this site hosted malware?

No, this site has not hosted malicious software over the past 90 days.

Next steps:

It seems like prc.gov.ph was hacked and it is trying to infect people who browse that site.  By the looks of it,  the hackers have used china domains  (chinese hackers???).   I don’t even think the guys at prc.gov.ph are aware of this.
So everybody beware.





How to Send Mail from PHP via SMTP

Thursday 24 July 2008 @ 11:04 am

I was working on a project and needed to send mails via php using an SMTP server.    It seems that Fedora doesn’t have this built in when I installed my linux box.   So anyway, for those people who are searching for information on how to send mail from php via SMTP,  below are the steps.

Step # 1: Download  Pear Packages for Mail, Net_SMTP, and Net_Socket

# cd /tmp
# wget http://download.pear.php.net/package/Mail-1.1.14.tgz
# wget http://download.pear.php.net/package/Net_SMTP-1.2.10.tgz
# wget http://download.pear.php.net/package/Net_Socket-1.0.8.tgz

Untar all files:

# tar -zxvf Mail-1.1.14.tgz
# tar -zxvf Net_SMTP-1.2.10.tgz
# tar -zxvf Net_Socket-1.0.8.tgz

Step#2:  Copy the files to /usr/share/pear

# cd /usr/share/pear
# mkdir Net
# cd Net
# cp /tmp/Net_SMTP-1.2.10/SMTP.php .
# cp /tmp/Net_Socket-1.0.8/Socket.php .
# cd ..
# cp -avr /tmp/Mail-1.1.14/Mail/ .
# cp -avr /tmp/Mail-1.1.14/Mail.php .

You’re Done!

Now to test, try this small php program.
include("Mail.php");
/* mail setup recipients, subject etc */
$recipients = "yournamehere@domain.com";
$headers["From"] = "from@yourdomain.com";
$headers["To"] = "receipient@theirdomain.com";
$headers["Subject"] = "test via smtp";
$mailmsg = "Hello, This is a test.";
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "smtp.yourserver.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "test";
$smtpinfo["password"] = "test";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$mail_object->send($recipients, $headers, $mailmsg);
?>

Now check your email and see if it worked!





The Ultimate Virtual Reality Racing Car

Wednesday 23 July 2008 @ 6:31 pm

What happens if you have a virtual reality googles that senses the movement of your head, then controls a camera inside an RC car that moves in sync with that head movement, and then connects to a remote control?

It is one awesome Virtual Reality Racing Car.

I wish they make a car seat unit with a real steering and pedal controls to come with in.  That would be a more Ultimate Virtual Reality car racing gam.





Hammer Black Widow Venom bowling ball

Monday 21 July 2008 @ 9:21 am

Dark. Deadly. Diabolic. She’s back, and her poison will kill the competition. Black Widow Venom uses our proven Widow Series core with a brand new Lethal Bite Reactive coverstock. Lethal Bite Reactive is our most aggressive coverstock to date, giving Venom more sharp backend motion on medium-heavy to medium oil lane conditions. Long and strong is a ridiculous understatement.


Hammer Black Widow Venom Technical Specs

Coverstock: Lethal Bite Reactive

Factory Finish:  4000 grit abralon

Color: Black/Carmel

Hook(1-60): 54

Length(1-60):46
RG (#15):2.50

Diff(#15):  0.06

Mass Bias Rating High





How to Legally Mine Keywords from Your Competitor’s Websites

Monday 14 July 2008 @ 11:12 am

I’ve posted a new post at searchengineherald.com about the above topic and I would like to give an indepth example of this one complete with screen caps so you can fully understand and see how to do this.

This is exactly the same techniques some SEO’s use and they DON’T WANT you to know about it.   I’m spilling beans right now so better bookmark this webpage so you can get back to it later as a very good reference when you do your keyword research.

So here’s one actual example of how to do this in detail.
If for example, I am into real estate and I would like to find keywords for “condominium”,  I’ll probably type this at Google.

inurl:awstats.pl intitle:”Statistics of” condominium

Google returned this page

mine keywords from your competitors websites

I tried clicking the first one and got this

keyword research

Oh…what lovely keywords.   These are the actual keywords people use to reach that specific website.

Think about how powerful this technique is!  It saves you tons of money and time on keyword research.   Now go out and use it!





What’s Inside A Laptop Battery?

Wednesday 11 June 2008 @ 5:29 pm

If you were wondering what’s inside a laptop battery, you’re just like me. Fortunately I have an old, defective laptop battery. Just like the show “Mad Labs”, smash labs, and mythbusters, I opened it up and here’s what it looks like.

laptop battery

There are 4 Li-ion cells and at the center is some sort of a charge controller.

The main chip of the laptop battery
laptop battery controller

This seems to be some sort of temperature monitor which senses the temperature of the cells.
temperature sensor?

This one, I don’t know. A diode perhaps that senses temperature also?

unknown component





DIY Variable Voltage Bench Power Supply using ATX power from PC

Monday 12 May 2008 @ 1:47 am

How to Add Variable Voltage to Your ATX Based Bench Power Supply

from wikiHow - The How to Manual That You Can Edit
If you’ve built a bench power supply using an old ATX computer power supply, you may feel limited by the choice of voltages + 3.3V, + 5V, and +/- 12V DC. Suppose you’re breadboarding a circuit that’s meant to be run off a 9V battery? This is how to build an add-on variable-voltage “module” for your power supply.

Steps

  1. Gather the materials required and construct the circuit from the circuit diagram. It would be a good idea to get the datasheet for the regulator from the manufacturers website.
  2. Get some banana leads and connect the +12V and -12V outputs from your modded ATX supply and connect it to the input of your variable module. Use a multimeter to measure the output voltage.
  3. Once you have built the circuit test it carefully and measure the output voltage. You should be able to vary the voltage from about 1.5V up to 22V by turning the variable resistor. If you are using the LM317 the output current will be restricted to 1.5A, if using the LM338K it should be slightly higher check the datasheet for exact information.

Tips

  • I used a small piece of veroboard to build this little addon. You could use matrix board or design a small PCB. It wouldn’t be difficult.
  • Use sensible wire lengths if creating a permanent connection to the ATX supply.
  • Make sure that the +12V binding post is well isolated from ground and from the -12V binding post.
  • During use the regulator may get hot. Use a heatsink if necessary.

Warnings

  • If you’ve already built an ATX Power Supply based bench/lab supply, you’ve already run the risks - this project is less dangerous. Soldering irons can burn you, hand tools can cut you; don’t drink and hack.
  • Use common sense. If you find the regulator gets hot use a heatsink.

Things You’ll Need

  • You will need the following materials:
  • 1x LM317 or LM338K Voltage regulator (With heatsink and heatsink paste)
  • 1x 100nF Capacitors (ceramic or tantalum)
  • 1x 1uF Capacitors Electrolytic
  • 1X 1N4001 or 1N4002 Power Diode
  • 1X 120 Ohm resistor
  • 1x 5k Ohm variable resistor
  • Optional
    • Some Veroboard or a matrix board and some suitably thick wire for connecting the circuit.
    • A small enclosure about the size of a wall wart to put the circuit in.

  • Indispensable
    • An ATX power Supply already modded to provide +12V, -12V, +5V and -5V

Related wikiHows

Sources and Citations

Article provided by wikiHow, a collaborative writing project to build the world’s largest, highest quality how-to manual. Please edit this article and find author credits at the original wikiHow article on How to Add Variable Voltage to Your ATX Based Bench Power Supply. All content on wikiHow can be shared under a Creative Commons license.