Apr 16

I just realized I have been running incorrectly for the past 10 years of my life.

 I was a sprinter in high school track. I was taught at the time to always run on my toes. It made sense, and sense then I have always ran on my toes.

However, I didn’t make the connection that running on your toes is targeted for sprinting only! Whenever I ran long distances I was running on my toes. This was not a problem until recently, when I realized I have shin splints.

So I did some research, and this is what I find out. When you’re walking, you should strike your heel first. When running, your feet should hit the ground flat - no heel or toe first, but both. When you’re sprinting, go toes first. I’m going to take a couple days off from running to let my shin/calves heal and then try again, only this time running more balanced.

I also found the following advice, which I’m going to try out: “A proper distance running stride is difficult to describe without showing it, but it is truly thing of beauty. It should feel almost like you are pulling the ground underneath you as you glide over the road/trail/field.”

Apr 15

I read a really great article from success magazine: http://www.successmagazine.com/Ten-Life-Laws/PARAMS/article/92/channel/210.  Here are the excerpts I particularly liked:

Law #2: You create your own experience.
You need to accept accountability for your life and your role in creating the results that are your life. You are accountable for your life. Good or bad, successful or unsuccessful, happy or sad, fair or unfair, you own your life. You create the results in your life, all of the time. If you don’t like your job, you are accountable. If your relationships are on the rocks, you are accountable. If you are not happy, you are accountable. Whatever your life circumstance, you can no longer dodge responsibility for how and why your life is the way it is.

If you don’t accept accountability, you will misdiagnose and mistreat every problem you have. And things won’t get better. By convincing yourself that you are a victim, you guarantee no progress, no healing, and no victory. Your irresponsibility prevents you from making progress to improve your life.

Law #7: Life is managed; it is not cured.
Learn to take charge of your life and hold on. Never are you without problems or challenges. Life has to be managed. If you accept this, you are less likely to label every problem as a crisis or to conclude that you’re not handling your life successfully. Success is a moving target, and your life must be actively managed. How well your life is working five years from now will be a function of how well you actively manage yourself from now until then. As a life manager, your objective is to manage your life in a way that generates high-quality results. You may not be the only client you have, particularly if your family includes children or people who act like children. But you are your most important client. To give something in your roles, as spouse or parent, you must take care of yourself.

Law #8: We teach people how to treat us.
Own, rather than complain about, how people treat you. Learn to renegotiate your relationships to have what you want. You shape the behavior of those with whom you interact. How you interpret and react to another’s behavior determines whether or not they are likely to repeat it. You actively participate in defining your relationships.

People treat you the way they do because you have taught them, based on results, which behavior gets a payoff. Results (not intentions) influence the people with whom you interact. If the people in your life treat you in an undesirable way, you’ll want to figure out what you are doing to reinforce, elicit, or allow that treatment.

Mar 29

In developing Easy Export, I created a cron script that updates the user’s fbml on their profile page periodically. It worked great, but after some time I started getting the following execption thrown:

 'Invalid parameter', on line 1520 in facebookapi_php5_restlib.php

After looking into it, I realized it’s because I was trying to set the fbml on a user who previously had the application installed, but had since removed it. So to fix it, you can either ignore the error (empty try/catch block around setFBML) or check whether the user has the application added before trying to make this call - via users_getInfo( $user_id, ‘has_added_app’ )

Mar 26

I created a facebook application several weeks ago, but never got to write about it. It was actually pretty painless.

I wanted copies of all the pics I had been tagged in on my own computer. It was taking me forever to click through all of them individually. So I made this app - which will save you lots of time if you ever want to do the same. It also makes a spreadsheet of all your friends and packages everything up in a single zip file.

I made it public so others can use it to.

For more info:
http://www.shanelabs.com/easyexport/

Or to install it:
http://www.facebook.com/apps/application.php?id=21759489312

Mar 26

I couldn’t find a function already created for PHP that calculates someone’s age based on their birthdate and the current date (in unix timestamp format - seconds since 1970). First I tried this:

$age = date("Y",$endtime) - date("Y",$starttime);

But then I realized that this might not be completely accurate, base on the calendar, leap year, etc. So here’s what I ended up with:

function computeAge($starttime,$endtime)
{
     $age = date("Y",$endtime) - date("Y",$starttime);
    //if birthday didn't occur that last year, then decrement
    if(date("z",$endtime) < date("z",$starttime)) $age--;
    return $age;
}

Let me know if you have any improvements!

Mar 07

I’ve got a google maps application on an ASP.NET ajax enabled page through an update panel. I had used setInterval to run a javscript function periodically and update the markers on the map. Over time, I noticed that when the map was updated through ajax while the javascript code was executing, i got the one of the following two errors:

'__e_' is null or not an object
'undefined' is null or not an object

These errors didn’t seem to have any effect, other than a javascript error being noted.

Through debugging, I determined that it was because of GEvent.addListener(), GEvent.clearListeners(), and marker.setImage(). Because I was getting real time updates, it was ok if every once in a while these things didn’t get updated - I could just ignore it and it probably will be updated next round. So, if you simply put these calls in a try/catch block, the errors don’t get generated.

try
{
    marker.setImage(newImagePath);
}
catch(err){} //it's ok to fail here - ignore it.

Good luck!

Mar 07

I’ve got a project where I’m using google maps within an ASP.NET web part in an update panel. The google maps code requires you to run some javascript as soon as the page loads. Usually people put this in <body onload=x> or use javascript: window.onload=x, but when I did those either the method wouldn’t run, or web parts would get messed up. I’m guessing because there’s some web parts javascript that needs to run at page load, and since you can only assign one method, they were interfering with eachother.

 I tried just running the google maps initialization script after I write all the needed elements to the page, but then I was randomly getting the dreaded IE error “Internet Explorer cannot open the internet site. Operation Aborted.” The common fixes to this error suggest calling your initialization script with an onload trigger (not possible for me as described above) or moving your script to the bottom of the page, outside of the body tag.

Sounds like an easy fix, but since I was using web parts within update panels I had to use ScriptManager.RegisterStartupScript in order to inject the code, which didn’t allow me to place exactly where the script was being placed. After long hours of trying many many workarounds, I finally found about the PageRequestManager pageLoaded event. It’s a javascript class that is available when you use asp.net’s ajax, and it can be used to register functions that should be triggered once the page is loaded. Here’s the javascript you need:

var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_pageLoaded(myFunctionToRunOnLoad);

It took me forever to find this, I wish it was documented more. Hopefully it solves your problems!

Mar 05

I was having trouble getting Dundas Gauge for ASP.NET to reflect the value that I was assigning it. For some reason, the needle always pointed to the default 0. I was using this code:

//create circular gauge
GaugeContainer gauge = new GaugeContainer();
CircularGauge circleGauge = new CircularGauge();
gauge.CircularGauges.Add(circleGauge);

//scale
CircularScale scale = new CircularScale();
scale.Minimum = -100;
scale.Maximum = 100;
circleGauge.Scales.Add(scale);

//pointer
CircularPointer pointer = new CircularPointer();
pointer.Type = CircularPointerType.Needle;
pointer.Value = 10;
circleGauge.Pointers.Add(pointer);

//display
gauge.ImageType = ImageType.Png;
gauge.Width = new Unit(200);
gauge.Height = new Unit(200);
gauge.Page = Page;
gauge.RenderType = Dundas.Gauges.WebControl.RenderType.BinaryStreaming;
gauge.RenderControl(writer);

So “pointer.Value = 10;” was not working. After looking at some examples, I figured out that this worked:

gauge.CircularGauges[0].Pointers[0].Value = 10;

I’m not sure what the difference is, but give it a try if you’re having a similar problem.

Mar 02

I was at a relative’s funeral yesterday, and someone eulogized her as “taking delight in other people’s happiness.” What a great mantra to live by. I’m gonna try to adopt it.

Mar 02

Well, here’s my first blog and my first blog entry. I’m gonna use this blog to help me document some of the lessons I learn, through life or software, so that other people can learn from them.  Enjoy!