Personal.X-Istence.com

Bert JW Regeer (畢傑龍)

Interesting bug

I was starting to see something interesting in the output from my Google AppEngine based project. I was automatically creating a link based on a config setting, named SETTINGS["contact"], and the code would work perfectly the first time the page was created and loaded, however multiple refreshes of the same page would show that the link was gaining slashes even when it shouldn't have.

The logic was as follows:

if contact is "mailto:" then do nothing
else
        if contact does not start with "/" or not with "http"
                contact = "/" + contact

This code would work perfectly the first time around, however if I had properly tested by setting contact = "/contact" as well, I may have caught this bug faster.

However since that piece of code was only being called once per page view, it worked perfectly as far as I was aware, the thing is I started seeing more and more slashes being prepended to contact each time I refreshed the page. I looked at the code above, and did not see that my logic should have contained an "and" instead of an "or". Even so if the code is being loaded once per page view the variable "contact" that started off containing the word "contactme" should only turn into "/contactme" and not "////contactme" on the fourth page load.

Each time I added in a logging or debugging statement and refreshed the page it would go back to "/contactme", I would change another thing, or add another debug statement and "/contactme" was there staring me in the face. It took me a little while before I hit refresh a couple of times and noticed that my debug output now contained what I had seen beforehand. That is when it hit me, Google AppEngine caches imports that included my global variables. As long as I did not modify any of the files in my project it would happily use the cached variable, which after the first reload would contain "/contactme", then because of my use of or instead of and, would become "//contactme" on the second reload.

Google AppEngine has some very aggressive caching, which may well be required to have it run at the scale Google wants it to run. This is just another warning for myself that I need to watch out when I modify global variables and that they will stay the same across different sessions.

This is the logic I ended up with:

if contact is "mailto:" or contact starts with "http" then do nothing
else
        if contact does not start with "/"
                contact = "/" + contact

Works exactly how I had expected it to work.

Project file structure

I'm currently working on a new website that will be hosted on Google AppEngine, however I am currently in the middle of revamping some older code and realised that maybe just maybe it belongs with the model rather than in a separate directory.

The setup currently is to have a models directory and a forms directory, they contain the models and the forms respectively, however I am starting to realise more and more that the form is a direct extension of the validation required in the model (which is not possible with the current database stuff that Google AppEngine offers), the form is taking user input and making sure that it is correct and then just passing it off to the model to check it into the datastore.

I'm thinking of merging the form into the model source code so that I can remove the forms folder entirely, since it just doesn't make sense to have the two in separate locations whereby one may be changed but the other may not. I'm afraid that they may get to be out of sync, and cause issues.

Will have to think about it for a little bit, no need to make rash decisions this late into the evening and blow away part of my source tree.

End of an Era

Today is the close of an era in computing, one that I find extremely sad because of all of the things that Sun has given to the world in terms of creations. Many things in computing would not exist today were it not for Suns engineers. It is sad to see a company that was so full of potential get sold to a company that has been known to be notoriously aggressive about keeping everything a company secret and not sharing.

Goodbye Sun (Already redirects to Oracle, even all the content has been moved).

Arizona; I'm here to stay for a little longer

Major corporation contacted me this past monday while I was in Colorado (Helped a friend move there!), and unfortunately they do not think they have a place for me on their team.

On the 15th of January I had my first interview with the corporation, and unfortunately I really think I didn't get hired because of that interview. During the interview I was extremely nervous and was unable to calm my nerves as I was unable to gauge the feelings of the guy on the other end of the phone. The connection quality was extremely low and there was much static as such I had to repeat much of what I said during the interview multiple times, and had to ask for the interviewer to repeat the questions. During this same interview I also completely blanked out and mixed up seven different programming languages. Afterwards when I was able to think clearly again I realised how easy the question was and implemented what the interviewer had asked for in minutes.

The second interview came an hour later. This one went extremely well, best of all the phone connection was perfect so I was able to understand the interviewer and him me. He was interested in some of the projects I had worked on in the past and was able to get me to loosen up and feel more at ease. The programming questions he asked me were easy to implement and I did much better, this time writing almost valid C++ programs without any significant issues. The guy was much more easy going, and we even had a pretty good conversation over email after the interview was over regarding the Near Space program I was a part of.

As mentioned before, I did not get the job. I was really looking forward to it as it would provide some very unique and interesting challenges that I wouldn't have been able to find at any other workplace. Great perks and benefits and I would have been amongst some of the smartest people in the world. I'm attempting to put it all behind me. I've been firing off my resume to all kinds of different job opportunities. If you happen to know anyone that is hiring a computer programmer/software engineer with experience in Unix based operating systems and a big interest in hardware design (electronics) please contact me using bertjw@regeer.org as my email address.

--

Before I went on vacation I decided to purchase a Flickr Pro account to upload my staggering amount of pictures to the internet so that I could more easily share with my friends and family. Please feel free to peruse my Flickr Photostream. I took some pictures while I was on break in Hoboken from across the Hudson towards New York, I personally find them to be absolutely fantastic, so please take a look at my pictures of New York during the day and night. I've always loved doing night photography of cities and towns, but never really get the opportunity to do so. These pictures were taken from the balcony in my dads apartment, which is right on the river.

--

In closing I just wanted to link to the XKCD comic that was just published a couple of hours ago: Spirit. Now, generally XKCD's comics are funny, however this one just hit close to home as I have always thought of the robots I have built as beings, as equals. The first thought that came to mind was Fry's dog in Futurama. It is by far one of the saddest scenes in Futurama invoking some very powerful emotions. Randall does a good job in personifying Spirit in this cartoon! I really have to stop cutting onions while browsing the web!

Late nights and Interviews

244 is a Hardware Studio if you are to believe the sign outside of the door, however really it is just an empty workspace/lab where individuals such as myself can sit down and start doing work, or procrastinate. It is open 24/7. Every Saturday a group of ex and current students from UAT gather in the lab and sit down together to work on various projects and to just have fun. We off course have our very own resident pizza connoisseur, and everyone adds to a large pot of cash so that at around 10 PM we all get some of the best pizza available around town.

Last night was another of such nights. Some people were playing MW2, others were working on Java/C# homework and I was working on my next project. My next project is rather interesting in that it has required research on my part as to how to accomplish what I want safely. Being in the lab surrounded by people also working generally gets me working on my projects as well. I've got a general layout of the electronics involved in my head, and I know what I need to do it safely, so now I need to start gathering the parts, sampling certain chips from manufacturers and sourcing other parts that I can't sample.

All of my research gets collected in various locations, right now most of it is still in my bookmarks bar, which is starting to overflow so much that it is becoming a useless tool, I've been trying to look for a tool that can help me organise my projects far more efficiently and in a way that will allow me to add notes to web pages, or at least to links.

My phone screens with the large company I mentioned in my previous post went okay. The first phone screen I was extremely nervous and was unable to really understand the guy on the other because of a bad phone connection (It was his end, my phone had full signal strength). Not only that, but I felt that he wasn't really interested and I couldn't get a good vibe from him. I was so nervous my brain melted together multiple programming languages to create a mish-mash of crap that wouldn't compile unless you happened to write a parser that could take JavaCPythonJavaScriptRubyC++Scheme syntax. If you have done so, well kudos to you! The second phone screen went much better, this interviewer was interested in my Near-Space balloon launches which helped ease my mind, and while on the interview he was able to give me feedback, tell me a little bit about himself and just in general provide some banter while I was trying to program which really helped. Hopefully they average the two of them out, and I get a passing grade. Now the waiting game starts all over though, so I hope to hear back from them within the next week. I really hope I didn't screw it up for myself.