Monday, February 28, 2005

I've been toying with ECMAScript for the past week or so, mostly to update some dynamic user interface elements in a web application we have.  Every time I use it, I'm always impressed at the cool things I can do with it.  It also makes me wish that Microsoft had not messed with it as part of the CLR (JScript.NET).  Their newest version of JScript seems to merely make it into an alternate syntax, and not really take advantage of what it could do as a prototype-driven language with closure support.

I found this article that claims that it is the world's most misunderstood language.  I think I agree.  It's incredibly powerful, but very underutilized because of the confusion surrounding it.  Closures coupled with prototypes can yield some very slick code if you understand what you're doing (and I guess maybe that's the problem).  All you really need is a nice IDE to help you manage your objects and their prototype chain.

I'm also getting more into Python and Ruby, which are also very slick.  I'm just not sure how they should fit into a project.  In general, a project with fewer languages is more maintainable.  But imagine trying to build a skyscraper when your only tool is a hammer that works really well. (OK, maybe hammer is not the best analogy.  Maybe a blowtorch?  I don't know)

[UPDATE] I just had to include this link, where the author shows us how to do lot of different code reuse patterns, including multiple inheritance in Javascript.  My favorite quote:

This large set of code reuse patterns comes from a language which is considered smaller and simpler than Java

posted on Monday, February 28, 2005 10:56:23 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Sunday, February 27, 2005

I've been playing with the Flickr API alot, experimenting with some different things that I have planned for the future.  One of the things I'd like to do is to create context sensitive image collages on the fly for my blog entries.  Thought I'd show you this cool example from a first-pass collage creator.

collage creator.jpg

Of course most collages wouldn't have this many pictures, but I thought it was cool.  I need to do some randomizing.  I'm filling from the upper left corner in diagonals for reasons you'll see when I get it working the way I want.

I've also been playing with some client-side Flickr stuff using XmlHTTPRequest to dynamically load images for a slide show type thing like MSN spaces has.  I might upload an example of that later.

posted on Sunday, February 27, 2005 6:46:19 PM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Friday, February 18, 2005

I just got back from Brad's talk at the Austin .NET User's Group meeting.  It was my first meeting, and I felt a little bad about not being a more active part of the local community.  It was a solid, interesting talk, even though I was pretty familiar with both topics (exceptions and memory management).  I managed to ask an intelligent question about a change in Whidbey regarding unhandled exceptions on all threads terminating the app rather than on the main thread only.  My question was on the ThreadAbortException, which seemed like a monkey wrench in that plan.  Turns out that there's nothing to worry about there as that exception is already pretty special.

Despite the great technical content, these were my favorite quotes (emailed to myself via my mobile so I wouldn't forget them:

  • Everyone should be using ... using (referring to C#'s using blocks)
  • It's like feeding peanut butter to a dog (referring to using some of the new GC (garbage collector) methods to help in memory management.)

I'm always really impressed with the CLR team's desire to do the right thing with the framework and to help developers do the right thing. Thanks for adding Austin to your "world tour", Brad. BTW, the slide template seemed like the right choice to me.

posted on Friday, February 18, 2005 6:35:46 PM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Thursday, February 17, 2005

Since my last rant about vending machine prices, they've raised the price to 70 cents for 12 oz. cans here at work.  Ridiculous.  I only wish I knew who "they" was so I could complain.

posted on Thursday, February 17, 2005 10:34:23 AM (Pacific Standard Time, UTC-08:00)  #    Comments [3]
 Tuesday, February 15, 2005
Turns out, my problem with metadata in my pictures was I didn't have the latest RAW support installed.  This was evidently something that Adobe fixed.  Oh well, at least I learned alot about XMP and got more of the Flickr API implemented.  I'll have to come up with a strategy for replacing 1GB of pictures.  I also want to add a few more steps in my processing.  Alot of the pictures turned out a little dull.  I think I won't be in such a hurry to get them uploaded in the future.
posted on Tuesday, February 15, 2005 8:15:06 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Saturday, February 12, 2005

Whew, what an ordeal.  I finally got my Adobe Photoshop CS in the other day, and last night, I created a "Droplet" for batch converting all my raw files from my Canon Digital Rebel. Droplets are a really sweet feature that lets you create a little executable from recorded actions for batch operations.  So, I burned through about 2000 images, creating big jpgs suitable for uploading to my newly upgraded Flickr account.  It was getting pretty late, so I fired up an uploader an set it to upload my 1GB limit (roughly 900 pictures).

This morning, I checked my account, only to find that none of the metadata had been uploaded.  All my images appeared to have been taken on Feb 11, 2005...uh oh.  So, I set out to find out what happened.  Turns out, Photoshop saves the metadata in it's XMP format within the file. XMP is simply an rdf encoding of the data in an XML payload within the file.  It's actually pretty cool, but Flickr doesn't read this data yet.  So I set out to "fix" my pictures, since I can't upload anymore until next month and I have lots more to upload.

After looking at lots of libraries and Adobe's XMP SDK, I decided it would be easy enough to pull the data out myself.  So, I built a little app using my FlickrApi library I just created that would blast through my uploaded pictures, find the corresponding image on my local pc, pull the xmp data out of the file, and set the "date taken" on the Flickr site.  That way, I can at least organize them more easily.

It worked perfectly.  It blasted through about 900MB in less than a minute.  Look for the pictures as I tag them, annotate them, and change them from private to public.  I'll have to see if there's a way to have Photoshop preserve that data next time because I'd really like to have the rest of the metadata available.  I'll probably make my XMP parser available as well if anyone's interested.  As far as I know, there is not another managed implementation available.

posted on Saturday, February 12, 2005 2:59:33 PM (Pacific Standard Time, UTC-08:00)  #    Comments [5]
 Friday, February 11, 2005

Last night, I made alot of progress creating a .NET API for Flickr.  There doesn't seem to be alot of activity on the Flickr.NET project, and I don't like some of the decisions they made in the design.  They seem to have taken a direct wrapping approach to it rather than designing an API that fits in the .NET world.  It's amazing how spoiled you get when you're used to using good API's.  You start saying things like, "You mean I get an array back from this method?  Eww."  or "That's a silly name for that member."  Of course, it's probably appropriate to note that Flickr.NET seems to have been created with an emphasis on uploading.  I'm more interested in sifting through the metadata.

Anyway, I've got most of the functionality that I'm interested in implemented, and I'll be doing the rest a little at a time.  I've used the design guidelines fairly strictly, and I think I'm coming up with something that's really approachable for .NET users, and is still correlated enough to the Flickr API documentation that the parallels are easily discoverable.  You may notice some bizarreness here as I play with the different kinds of integration I have planned for my blog.

posted on Friday, February 11, 2005 7:36:12 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
Our church is doing a new pictorial directory this year, and last night was our night to go up and get our pictures taken.  I usually dread those events because they want to take alot of pictures and then pressure you into buying them.  This, however, was the best experience I have ever had.  We filled out a paper that let us define what we were interested in, and the photographer used that to determine what kind of pictures to take.  I indicated we weren't interested in any, so he took a total of 6 pictures.  We picked one for the directory, and we were done.  Our appointment was at 9:00pm.  We got there a little early, and were back in the car at 9:05.
posted on Friday, February 11, 2005 7:14:31 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Thursday, February 10, 2005

I typically use the well-done MSN Web Messenger at work to avoid firewall issues, and to avoid stomping on our company's branded version of messenger (which sucks BTW).  When attempted this morning, I got the following message:

We can't sign any more people in right now. Please try signing in again later.

I wonder if it's just a web messenger problem or MSN messenger in general.

[UPDATE] Now I'm getting the ASP.NET "Server Too busy" exception, so I'm betting it's a web messenger only thing.

posted on Thursday, February 10, 2005 7:17:30 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Wednesday, February 09, 2005

This is one of the coolest things I've seen in a long time.  Try my flickr name (marklio).  It lets you drill through my contacts and see their information.  Keeping clicking and you'll see all kinds of cool things.  It really helped me see Flickr as a web service rather than just a photo sharing site.  It gave me alot of ideas.  Things like using tag matching to automatically creating blog entry backgrounds that are relevant to the content.  I'm going to be playing with that.

Their API is really nice and well-documented.  Some people made a .NET wrapper for the API, but it's not up-to-date and I wasn't really impressed with the design.  I'll probably roll my own and just implement the things I need as I go.

 

posted on Wednesday, February 09, 2005 8:52:26 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Tuesday, February 08, 2005

In an earlier post, I mentioned that I wished HttpModules were more scriptable in ASP.NET.  You can easily create Controls, Pages, HttpHandlers, and web services all without having to compile anything, but as far as I know HttpModules have to be compiled and registered in the web.config in order to start working.

So, I created a ScriptableHttpModule.  You register it in the config the same as a regular module, but it allows you to create .asmodx files that are compiled and called just like regular modules and give you the same kind of dynamic compilation model as the other .asXx files.  I'm still tweaking it a bit, but it looks pretty promising.

posted on Tuesday, February 08, 2005 6:39:29 PM (Pacific Standard Time, UTC-08:00)  #    Comments [2]

marklio.com, as well as my dad's site bellcountyblogger.com, is now being served from a real server!  I just made the switch a little earlier today to a hosting company.  I've been really impressed with them so far.  The transition was absolutely seamless, although I am still hammering out some email details that were not available before.  I'm discontinuing the gallery in favor of hosting all my images on Flickr.  That way all those images won't take a bit out of my bandwidth (although I have plenty).  Hopefully that will provide a better experience for everyone, especially once they integrate photo printing.  My redirector will continue redirecting the old dnsalias addresses.  Hopefully those will all get cleaned up before my port 80 gets blocked. Up until now, I've been relying on the business class cable modem service provided by my employer, but they're discontinuing that soon and the standard package blocks port 80.

posted on Tuesday, February 08, 2005 6:30:30 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Monday, February 07, 2005

my blogmap I just ran across BlogMap, a cool project that attempts to organize RSS information by location.  It lets you "geo-code" your blog so that it can be browsed and searched by location. It doesn't put the icon exactly where you live since it's by zip code rather than exact address, but it's pretty close.  My house is just under the little blob in the lower-right-hand corner (it's a park).

Anyway, once you've geo-coded your site, your feed is added and can be found through a somewhat clumsy (at this point) map, or by searching for a city.  The system needs some work to be really useful, but it's pretty dang cool!  Chandu has done some excellent work on it and I hope he continues to make this into an extremely useful tool.

It really adds alot of scope to content to know where it's coming from.


posted on Monday, February 07, 2005 9:50:16 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Friday, February 04, 2005

After some banging of my head on a wall, I found what I believe to be a bug in Oracle's .NET data provider (or ODP).  Or, at the very least, it is some non-intuitive behavior.  We have a byte-based enum that is stored in the db for a reporting tool.  As we all know, bytes are unsigned, but somehow a bunch of my values were negative in the database.  Closer inspection indicated that my values had been treated as if byte was signed.  After a thorough review of my code, I fired up Reflector to dig through the ODP code.  After a little while, It became clear ODP was treating my byte as if it were signed.  Although the actual problem is in unmanaged world, here's a troubling method that's called during the binding process:

internal unsafe void SetPrmValCtx(byte b, int index)
{
*(((sbyte*) (this.m_pOpoPrmValCtx.pBltVal + index))) = b;
}

It was easy enough to work around, since our API is several layers removed from ODP itself.  But annoying nonetheless, especially since using an sbyte (signed byte) as a parameter value will throw an exception.  Just thought Google might be able to help someone else out in the future using this information.  in the meantime, I'll make sure Oracle knows about this little annoyance.

posted on Friday, February 04, 2005 1:47:10 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]

Even though it has some objectionable language, I thought this video was funny enough to link to. Evidently, a group of guys had been playing Halo 2 late into the night, when one of them fell asleep while playing.  To make matters worse, he begins snoring loudly into his headset.  So, his character is just standing there snoring.  One guy fires up the VCR and starts recording.  Then they all begin abusing the snoring guy.  Yelling at him to wake him up, pushing him off cliffs, and surrounding him with explosive fusion cores and setting them off which sends him into the stratosphere.  Again, it does has some objectionable language.

Although I haven't experienced this scenario, playing Halo 2 online is very interesting from a social standpoint.  To me, it's been alot more like playing a sport than a video game.  When you're playing online, there are no AI players.  Every character has a real human controlling it.  Being able to communicate with your teammates adds alot as well.  It's alot like playing paintball or lazertag in really elaborate arenas, only tons cheaper.  If you think about it that way, the XBox is very inexpensive compared to what you'd have to pay for that kind of entertainment.  It's a fantastically easy way for me to get together with my friends and do something without having to get them all in one place. (at least my friends who have XBoxes...hint...hint)  And it's also been an excuse to get to know people I wouldn't otherwise have much in common with.

 

posted on Friday, February 04, 2005 11:20:51 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Thursday, February 03, 2005

Sorry to hear that my friend Jeff is sick.  I'm also under the weather today.  As usual for me, it is the sore throat that is the most bothersome.  One time back in college I had a really bad sore throat and my long-time family doctor asked, "Who removed your tonsils?"  I responded that I had not had them taken out. He remarked, "Oh...I was going to say they had not done a good job."  Although I wasn't exactly sure how to take that, it was clear that my tonsils are not in the best condition.

Hope you get feeling better, Jeff.

posted on Thursday, February 03, 2005 3:57:15 PM (Pacific Standard Time, UTC-08:00)  #    Comments [2]
 Tuesday, February 01, 2005

I use a dynamic DNS service to host my DNS entries.  Back when I started hosting my blog, I was using marklio.dnsalias.com instead of www.marklio.com.  Since I still have that name pointed at this server, some search engines still have not let go of that old dns name.  In a few months, I'm going to have to move this to a hosted environment (it's currently just running on a server at my house), at which point the two names will point to different places.  I've been strategizing the move for a while now, and I've just implemented step 1, which is to ween http traffic from the old alias.

I've done that by implementing a permanent redirect for any request to the old name.  I created a little IHttpModule that hooks into the BeginRequest event, and looks for the old dns name.  If found, it returns the status 301 (permanent redirect), and dynamically builds the appropriate request to www.marklio.com.  It seems to work well.  Hopefully the search engines will handle this appropriately.

For any interested, here's the relevant code:

public class RedirectModule : IHttpModule
{
#region IHttpModule Members
public void Dispose()
{
//do nothing
}

public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
#endregion

void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
HttpContext context = application.Context;
Uri url = context.Request.Url;
if (url.Host == "marklio.dnsalias.com")
{
context.Response.AddHeader("Location",
url.ToString().Replace("marklio.dnsalias.com", "www.marklio.com"));
context.Response.StatusCode = 301;
context.Response.End();
}
}

The whole pluggable nature of ASP.net is really sweet, although this really got me wishing there was a way to "script" this class rather than have to build it and add it to the web.config.

posted on Tuesday, February 01, 2005 6:29:04 PM (Pacific Standard Time, UTC-08:00)  #    Comments [2]

I very often bring my lunch to work and supplement it with some items from the vending machine depending on my mood.  Typically, this is just a can of Diet Dr. Pepper (the only diet drink I can stand), for which I pay the outlandish price of $.65.  Sometimes, when I am a bit more hungry, I will get a bag of delicious Harvest Cheddar Sun Chips, or yummy Baked Doritos (or any of the other baked chips that taste better than the originals...even Fritos).  Anyway, the chips used to be $.75.  Today, much to my surprise, I discovered the chips are now $.90.  And no way am I paying $1.50 for some fruit juice.

I've always been frustrated by the price of things "within the walls" here, but this is ridiculous.  I feel like I'm at Disney World or something.  Ideally, I don't think anyone should make money off of selling things like food to employees at their place of work, but that can be impractical for a business to provide such services "at cost". But, under no circumstances should I have to pay more for something here than I would within a reasonable distance from here. 

posted on Tuesday, February 01, 2005 9:47:24 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]