Saturday, April 06, 2013

iOS Programming Using MapKit

I played with the MapKit library today.

Apple does make this very easy.  It's really just drag and drop with a few lines of code.


Tuesday, February 19, 2013

How to Setup A Monitor For Your Website

I have problems where my website would go down during a 3 day weekend or even right when I go to sleep.  I unfortunately did not have monitors setup so I relied on visitors and free services to contact me to fix the issue.

Usually restarting the database or rebooting the system fixes these issues.  Wish I can get to the root cause of why mySQL acts this way, but for now, here is a simple method to automate the check on your website and restarting mySQL.

I've read a few articles where websites owners are just restarting the mySQL service every 2 hours or so, that's not ideal at all.  That means every 2 hours, your website has a moment that shows an error to visitors.

The Automated Solution
Simple, just check your website for a text that should always show up.  If it does not show up, reboot your server or restart mySQL.  

1. You need root access (so you can restart mysql and run a cron job).

2. SSH into your server as root

3. Create a file (monitor.sh) with your favorite editor with the following

checkPage="$(wget -qO- http://www.spoofee.com | grep 50744)"
if [ "$checkPage" == "" ]; then
  echo "Page is not loading, restarting mysql"
  /etc/init.d/mysql restart
  SUBJECT="mysql restarted"
  EMAIL="whoever@gmail.com"
  date +"%m-%d-%Y %T" | /bin/mail -s "$SUBJECT" "$EMAIL"
else
  echo "All ok";
fi


replace the red items with what's applicable to your site.  50744 is the text I'm looking for on my website to show that the page has loaded successfully.  Of course the email is optional but you would like to know how often and when these are occurring right?

4. Make sure it's executable by doing something like 
chmod 700 /home/user/scripts/monitor.sh

5. Create a cronjob to run this script every X mins.  Type
crontab -e

6. Enter the following to your cronjob.  My example runs the script every 15 minutes.
*/15 * * * * /home/user/scripts/monitor.sh

Thursday, January 31, 2013

Replacing the Acura RL Hood Molding

So the other day, I was staring at a Tesla S and ran into chains that were blocking the exit.

I come out to find this ouwie!


OUWIE!


I did some Google search and found that I can just order the hood molding / grill.  This little plastic piece costs $110.  Now I had to choose if replacing it will increase the resale value by $110.  I decided that it does not increase the resale value, but I ordered it anyways.

It Arrived!


GET OUT OF MY CAR!


After 5 mins, here it is :)