Thursday, March 27, 2008

1 + 1 = 3?

Well this was an interesting problem that someone had brought up to me and I felt is merits a post because it is handy if you are ever bound by these strict restrictions ;).

Problem: You have 2 integer variables A and B. You are limited to having only two variables and no more. How would you swap the values of A and B without using a third variable?

Answer: This is the easy part. Someone mentioned this problem to me in passing and I guess it just stuck in my brain. Today while I was working I wasn't even thinking about it and the answer just hit me.

Simple form:

A = A + B
B = A - B
A = A - B

Broken down:

A = A + B
B = (A + B) - B = A
A = (A + B) - B = B

And there we have it ... somewhat useless information that is cool at the same time! =)

Monday, March 10, 2008

Airport fun.

Well I recently went on a plane trip to St. Louis and I learned something interesting. On my return trip I had gotten to the airport fairly early and made it to the gate my flight was supposed to leave from and well to my surprise there was another flight leaving for the exact same destination I was heading only about 2 hours earlier. Well I talked to the person at the counter for that gate to see if I could possibly get on the earlier flight. I half expected her to say "No, I'm sorry" but she didn't. She just asked me if I had any bags checked for my original flight and when I said no she printed me out a ticket for the earlier flight. Needless to say I was pretty pleased by all of this especially because I found out later that the flight I was supposed to take was delayed by like an hour, which would have sucked! Anyway lesson learned her is that if you do not have any bags checked and there are open seats on the sooner flight they will allow you to get on the flight which is AWESOME! :)

Monday, March 3, 2008

Sharing is caring.

I'm going to try and post interesting things I learn here and there. My goal is to learn something new every day. So here goes first post. I recently had a job interview and there were a few questions that stuck in my mind.

First on the list was this, "If you just added a new virtual host host to your apache config file, how would you make your new vhost live without downing the server?"... granted not the exact words but same basic problem. Now all be it simple I did not know the answer because I have never used this function before. Well the answer is quite simple once you verify that your settings are correct and that you did not modify any of the other already running vhosts you can simply use the "reload" option with apache.

Next up, this question I knew was possible I just did not know the exact method to do it. The question, "Is it possible to have multiple IP's on a single NIC, if so how would you do this?" Well I knew it was possible, but how to do it is another question. So since I hate not knowing I took the time to find the answer. The most common method of doing this would be called "aliasing". To do this from the command line you would use ifconfig in a fashion similar to this...

ifconfig eth0:0 netmask up

Now to kind of explain what is happening there "eth0" is our hardware device we use ":" to create and alias of that device call "0". You could have named the device "eth0:1" etc.

Now I'll explain the better way of doing this so that your system will manage the connection instead of manually creating it every time. What we need to do is create "/etc/sysconfig/network-scripts/ifcfg-eth0:0" so that it will start up automatically when the system starts. Your config will look something similar to this...


Well that is all I have for you currently. Thank you for your time.

Have a nice day!