Categories
Computing Java

Generating Short Alphanumeric Identifiers in Java

I will make it short and sweet, for a change: suppose you have a large number that you want to distribute to users, and you want to instead to give them a shorter, easier to share string of characters.  220p9 instead of 3453453. Neat, no?

I grappled with this, being a moron, for way too long – looking into Apache Commons Id. The issue is that I also needed to use this ID with a database, and that means that there could be issues of concurrent requests for identifiers and other messy situations. I also did not need something overly fancy, just alphanumeric identifiers. The problem was that I was too stressed to think, if I may be excused. Anyway, the solution is just silly:

Let the database generate the usual integer unique identifiers that grow with time. Whenever you need to use a short, alphanumeric identifier, simply use base conversion, to base 36, on that number. How easy is that? The conversion, in Java is done using the Long or Integer objects’ toString(number, radix) methods. To convert back use the valueOf() method.

Pretty bad of me.

Share
Categories
Computing

Enabling Tags in Windows Live Writer for WordPress

I started using Windows Live Writer about 6 months ago as it was a surprisingly useful tool coming from the most surprising source, Microsoft. It actually worked, see. One feature that I was missing though, and made me stop using it was the fact that I could not get it to tag posts. I love tagging, well, I fell in love with tagging and I was willing to bear the awful editors WordPress provides in order to just do that, tag. So today I updated the version of Live Writer to the latest release candidate. Never mind the totally awful classic Microsoft uber uber bloatware (to download one update you end up with almost 200MB of unrelated crap) – the fail machine cannot change, can it? – and voila, I have the new Live Writer. And it still cannot tag the way WordPress does it. Its tagging is meant to correlate your posts to sites like Delicious and Technorati. Not what I wanted. Luckily I found this awesome tool that turns on a setting in Live Writer to do that. Run the downloadable program, restart Live Writer and press F2 to show an additional form, that includes tags for your own blog. Yay!

This is how it looks in the end. Yay useful. Thanks Microsoft!

tags-enabled

Share
Categories
Daily Summary

Daily summary

I hate forgetting what I did because in a way it takes the fun out of well, living.  So as to start a possibly mundane but personal journey, I am going to try and sum up the previous day in brief sentences. Pardon the potential tardiness. Memiary does a similar thing but sadly, cannot describe the previous day. So here goes my list for 12/30/2008:

  • Worked further on my thesis, adding 10+ pages
  • Had hot water finally repaired at home after 5 long days
  • Conversed with entire family in Israel
Share
Share