Wednesday, June 18, 2008

The Last Temptation of Crust

Al Finkerton, Street Aristocrat, is enticed by a seductive pie at a Bus Stop.

One of my friends, Dax Norman, is a graphic designer who just got his masters at Ringling. This was his thesis animation, careful it is not for those with a weak stomach, it is amazing what can be done with 3D animation these days. Congratulations Dax this is awesome. Now one day when I invent my awesome game programming company I can dominate the world! (with a great graphic designer!) I just have to rip him away from those white Ipod/Iphone toting Apple weirdos. (Props to him getting a job at Apple ... Wait a second where is my Apple hookup?!) I got a DVD copy with full DVD case featuring Finkerton, the main character, along with the town as a backdrop. If you look closely you will see a sign that says, "Swee-atch" this is the invention of Dax I think anyway I find myself swapping it in often for "Sweet" lately so I thought I would give credit where credit is due. I give it two thumbs up. The title I hope you notice is a play on "The Last Temptation of Christ." A closing comment is I have never seen such a tasty bandage. You can check out some of Dax's art I really like it, I do not know if you can buy any of it, he is mostly in animation of course.

Is that done yet?

I grill allot so I find this chart useful! I also find hitting these temperatures hard but at least its safe or so it seems. So if you are curious about the cooked temperature of chicken or beef or most things this will be a useful guide. I believe this is provided somewhere else by the USDA if you want to look for it.

Meat Internal Temp. Centigrade
Fresh ground beef, veal, lamb, pork 160°F 71°C
Beef, veal, lamb roasts, steaks, chops: medium rare 145°F 63°C
Beef, veal, lamb roasts, steaks, chops: medium 160°F 71°C
Beef, veal, lamb roasts, steaks, chops: well done 170°F 77°C
Fresh pork roasts, steaks, chops: medium 160°F 71°C
Fresh pork roasts, steaks, chops: well done 170°F 77°C
Ham: cooked before eating 160°F 71°C
Ham: fully cooked, to reheat 140°F 60°C
Ground chicken/turkey 165° F 74°C
Whole chicken/turkey 180° F 82°C
Poultry breasts, roasts 170° F 77°C

Steak done!
Pork done!
Chicken done!
Grill Done!
I'm done!

Wednesday, June 11, 2008

Do you ever look at it...

And go, “Sweet cheese who came up with that syntax, I think if I could write a compiler I would come up with something more elegant than that load of crap.” I do.

For i As Integer = 0 To msgids.Length - 1

‘Do some crap


I hate the for loops in VB, they are something totally different and crappy than any other for loop I have crossed in my life. I was thinking about this while coding and just had to share and see if anyone else out there agrees. VB.NET For loops go like this:

For i As Integer = 0 To msgids.Length - 1
'Do some crap

The "To" is just so dumb, so assumptive and stupid! Now lets look at C++ derived for loops.

for(int i = 0; i < msgids.Length; i++)
//Do some crap

(In case it stays like that pretend < is actually a less than sign /shrug)

Is it just me or is the C++ style so much more elegant and so much more clear. You do not have to make assumptions you know that what we compare to each time is i but you also know you could change that at anytime to be j*i or whatever, robust and clear vs. odd and assumptive.

After programming in VB.NET for oever a Year (company forced) I have to say I missed the hell out of C++ based languages, luckily my current projects which I will reveal eventually have gotten me back into C#, Javascript, etc where the For loop actually seems logical again.

Rant over and out.

Tuesday, June 10, 2008

AJAX+ASP.NET = Win: Screw the Iframe idea ... at least for now...

Last post I talked about using an Iframe to delete a relation between two objects. Well I changed my mind and decided to go the Javascript only route with a XMLHttpRequest object. Basically this is AJAX or something very close to it and worked amazingly well. I was concerned that I would not be able to leverage ASP.NET like so many people leverage Java to use pages to return something other than a page, but I figured out a way around that (which I show at the very bottom.)

This is obviously an Intro to Ajax type situation. This is not a big class but a simple method to do an XMLHttpRequest. You could write a larger overarching Ajax framework, but this example shows the basics behind it.
The script I used is this:

This is the script to make the actual sender, it takes into account the different browsers we might have to accomodate.


var xmlhttp


(!xmlhttp && typeof XMLHttpRequest!='undefined')




xmlhttp = new XMLHttpRequest();


   catch (e)





if (!xmlhttp && window.createRequest)




xmlhttp = window.createRequest();


   catch (e)





This section does a call to the ASPX Remove page passing it the parent and child id's. If the return is false, this means we did not have an error, otherwise we did and we use our favorite Javascript Debugger Firebug to figure out what the problem is. Luckily I have tried this code and it fits my needs and works perfectly. (I do know that run is probably the dumbest function name ever, but I didnt even expect this to work :). I guess I should change it!)

Example Code:

function run(i , j, element)


//This grabs the element name we passed which when we remove we are hiding

element = element + "";

//The URL of the aspx page that is going to accept this request and

// delete the relation in the database



//The meat! We use the xmlhttp from the code that creates it way above 

   //We are using the "GET" method, sending it the URL, and true means asynchronous response.

// this is not sending the request just creating the object, we send further down."GET",url,true);


// Now we defie an function to handle when the status of the XMLHttp object changes.



       // ReadyState = 4 means all done

if (xmlhttp.readyState==4)


//Read the response text, In my case I am only returning

// false when the backend was unable to process the move

// so we should probably have an else to show failure but I didnt do that yet:)

if(xmlhttp.responseText == "false") 


document.getElementById(element).style["visibility"] = "hidden"; 




//I tell the backend that this is a form 


   // I send the request


return false


Now if you are anything like I was when I started off down this path you might be wondering, well wtf does remove.aspx do??? I will show you that too but if you only cared about the java you are done :).

This is the only function in Remove.aspx and all it does is send back the exceptions/"" or the word false if it was executed successfully.

The Response.End is particularly important so that you only send what you write to the Response, otherwise it will send whatever design etc that is included in the actual page and that would just be crippling yourself because you would have to sift through all that crap on the Javascript side.

So this is sort of a way to give yourself utility function calls with no UI problems. Technically this might be mixing UI and Business logic but the sheer power it provides is just too powerful to pass up.


protected void Page_Load(object sender, EventArgs e)


int parentid;

int childid;

cret ret = new cret();


if (Request.QueryString["pid"] != null && Request.QueryString["cid"] != null && Int32.TryParse(Request.QueryString["pid"], out parentid) && Int32.TryParse(Request.QueryString["cid"], out childid))
Response.ContentType = "text/plain";
ret = DBData.removeParentalLink(parentid, childid);



If there are any questions or comments feel free.

Monday, June 9, 2008

The Iframe workaround

I am programming in ASP.NET and one of the unfortunate results of this is that you have to basically load a page each time that you want to perform some action because it is a server based language. So I was going to have to do a page redirection and reload on a page that wants to remove a relation between two objects because you have to know what both objects are and there will be several choices on the page so it is not as easy just knowing them like so many things on pages are. Well I am going to do some quasi AJAX to use javascript to call a URL change to a .src in an iframe to get around this annoying little feature, this way we remove the relation without having to disorient the user with page change. So I will call removeLink.aspx?id1=22&id2=55 and we will remove the relation between 22 and 55. GENIUS! If this works pretty well I will post the basics of how to do it I am blogging this so I remember to do it as well.

Wednesday, June 4, 2008

I did a century - Reach the Beach

It was hard but fun and I never posted about it here because I guess I forgot I have been putting my biking accomplishments up here, but other than the century I have totally wussed out in the biking area, I have not ridden to work recently but immediately after the race I came down with flu/pneumonia-like symptoms, I am still hacking up some gnarly loogies. I am pretty happy about having done this though, if I had to do it again, I would pass, we did one hill that was straight up 800ft of elevation gain, I would rather do rollers all day than have a bunch of giants to conquer and that is what we had sections of giants that made you just want to lay down on the road and call the sag team. Interesting events included seeing (then doing) a run through a graveyards sprinkler system. We tried to keep it as respectful as possible by waiting for the sprinklers to come back to the roads or paths to throw ourselves into them. It was also the hottest set of days I have seen in Oregon spring time it was 95F+. I was also called a genius by several people, as they joined me sitting under the one shade tree on an exceptionally long jaunt through the treeless Oregon farmland. It was fun though!

.NET MySQLConnection - How to handle it...

I am trying to figure out the best way to handle a MySQLConnection in C#, though in reality any connection has the same principles (SQLServer, ODBC, etc.) Basically from what I understand Opening and Closing the connection is slow, so I want to minimize my open and closes, however I have to do several things when adding database objects and I also want to minimize the length of functions and allow repititious code to be reused.

So we have conflicting goals:
  • Open and close DB connection as little as possible
  • Break up long functions into smaller callable functions (so that adding relations for instance can be called without adding two or even one object to relate)
It's bad because when you go from one function to another it is always scary to send it the connection out (or byref) which is how I think I would have to send it for its open state to be maintained and so that you do not have to sit there and run the risk of opening multiple connections to the database if you pass it by value.

My ultimate solution to this quandary:
  • Public static MySqlConnection in the DBData Class which can be referenced within each function and its state can be checked and maintained (if you opened it you close it, if it was open you leave it)
I am not sure if this is the best option but it gives me the most flexibility and so far has come off without a hitch, that I have noticed anyway. I welcome comments or other suggestions and thoughts.