Archive for August, 2010

Feeds!

The links for the RSS 2 and Atom feeds of this blog are now in the sidebar.

This is really just for convenience; this is a WordPress blog and supports all the built-in formats. Just modify the URL if you need one of the older RSS formats.

Why so curious?

By Skeleton-Boy on deviantArt,

why so curious?

hotspotdot

hotspotdot is my entry into Microsoft’s My App is Better Challenge. In a nutshell, hotspotdot allows you to locate and tag “hot spots” that are important to you, allowing you to create a personal database of hot spots.

It’s a very simple app, utilizing PHP, SQL Server 2008, jQuery, jQuery UI, and the Google Maps API. I wrapped thing up in under 2 weeks, but in order to make the August 25th deadline there were a few features I didn’t get a chance to put in, such as preloaders, icons on the map, and searching by tag. I’ll probably devote some time to these in the coming weeks.

hotspotdot login

The goal of the contest was to create something showing off the power of SQL Server and Microsoft’s new PHP for SQL Server 2.0 drivers. I used the new PDO driver which was pretty sweet – very simple, elegant API. Two things in particular that impressed me were transactions (very nice for doing multiple inserts or deletions) and a consistent and well designed exception model (makes error handling much easier and especially powerful when combined with transactions as failed queries don’t effect the database [code jumps to exception handler before commit() is called], so no chance of junk being inserted). Error messages, in general, were also much more descriptive than those I’ve encountered with MySQL.

Finding a server proved difficult. I got a shared hosting solution, but the host was unable (though I suspect unwilling) to install the PHP for SQL drivers. So I ended up getting a virtual private server, but this only came with SQL Server Express and I used some features (see below) that prevented a migration. In order to avoid purchasing an SQL Server 2008 license (way out of my budget), my final solution was use the shared hosting server for the DB and the VPS for everything else. Hence the reason for the site being located at the my. subdomain, which maps to the IP of the VPS.

SQL Server 2008 is a fine system (despite some annoyances with the management studio)… though it’s really just a solid database system, which isn’t bad, but there’s nothing really impressive or creative about that. It’s not really leaps and bounds above a cheap solution like MySQL. The contest was about SQL Server, so I tried to do something that utilized a fairly unique aspect of the system: the geography data type. I wasn’t too impressed. It simply holds a (longitude, latitude) pair in a certain format, nothing more. The one big advantage of having a vector type like this would be doing comparisons based on distance but, as far as I could tell, this isn’t supported (my queries failed). Worse yet, in SQL Server Management Studio the display of the geography type is in hexadecimal, making things very cryptic… I couldn’t help but wonder why this is any better than using 2 columns and storing the longitude and latitude values independently. That said, the idea of richer/more-complex data types within a relational database is a pretty cool idea and it would interesting to see it taken further and beyond its current, primitive state.

hotspotdot map

hotspotdot map

Leave a comment if you find a bug or have any questions, comments, etc.

Flushing the local DNS cache

If your messing around with DNS records and finding that names are are not resolving to their new locations (this happened to me today), flushing the local DNS resolver cache may help (if not, you probably have to wait for DNS propagation or you configured something incorrectly). I only needed to do this on a Windows server, but I decided to dig a bit deeper to find out how to do this on other systems as well.

On Windows:

ipconfig /flushdns

On Linux it’s a bit more difficult and not as simple as ifconfig /flushdns. You can try to restart the nscd daemon (note the path may be different depending on the distro):

/etc/rc.d/init.d/nscd restart

However, nscd may not be installed on some distros (e.g. Ubuntu) and applications (e.g. Firefox) may keep their own cache. So you’ll need to restart the application in such cases. If your desperate, you can also restart the entire networking subsystem:

/etc/rc.d/init.d/networking restart

On OS X, Leopard and higher

dscacheutil -flushcache

On OS X, Tiger and lower

lookupd -flushcache

Stolen cookies

Excerpt from “The Salmon of Doubt: Hitchhiking the Galaxy One Last Time” by Douglas Adams,

This actually did happen to a real person, and the real person was me. I had gone to catch a train. This was April 1976, in Cambridge, U.K. I was a bit early for the train. I’d gotten the time of the train wrong.

I went to get myself a newspaper to do the crossword, and a cup of coffee and a packet of cookies. I went and sat at a table.

I want you to picture the scene. It’s very important that you get this very clear in your mind.

Here’s the table, newspaper, cup of coffee, packet of cookies. There’s a guy sitting opposite me, perfectly ordinary-looking guy wearing a business suit, carrying a briefcase.

It didn’t look like he was going to do anything weird. What he did was this: he suddenly leaned across, picked up the packet of cookies, tore it open, took one out, and ate it.

Now this, I have to say, is the sort of thing the British are very bad at dealing with. There’s nothing in our background, upbringing, or education that teaches you how to deal with someone who in broad daylight has just stolen your cookies.

You know what would happen if this had been South Central Los Angeles. There would have very quickly been gunfire, helicopters coming in, CNN, you know. . . But in the end, I did what any red-blooded Englishman would do: I ignored it. And I stared at the newspaper, took a sip of coffee, tried to do a clue in the newspaper, couldn’t do anything, and thought, what am I going to do?

In the end I thought, nothing for it, I’ll just have to go for it, and I tried very hard not to notice the fact that the packet was already mysteriously opened. I took out a cookie for myself. I thought, that settled him. But it hadn’t because a moment or two later he did it again. He took another cookie.

Having not mentioned it the first time, it was somehow even harder to raise the subject the second time around. “Excuse me, I couldn’t help but notice . . .” I mean, it doesn’t really work.

We went through the whole packet like this. When I say the whole packet, I mean there were only about eight cookies, but it felt like a lifetime. He took one, I took one, he took one, I took one. Finally, when we got to the end, he stood up and walked away.

Well, we exchanged meaningful looks, then he walked away, and I breathed a sigh of relief and sat back. A moment or two later the train was coming in, so I tossed back the rest of my coffee, stood up, picked up the newspaper, and underneath the newspaper were my cookies.

The thing I like particularly about this story is the sensation that somewhere in England there has been wandering around for the last quarter-century a perfectly ordinary guy who’s had the same exact story, only he doesn’t have the punch line.

h/t to woltermanns.com

“Saving changes is not permitted…” in SQL Server 2008 Management Studio

The issue occurs when saving changes that would require dropping and recreating a table (e.g. messing around with columns). I would think a warning would be sufficient instead of a restriction that requires digging through the app options window (which is not even hinted at in the popup). I also can’t imagine how effective this would be; unless you design your schema perfectly the first time around you’d always encounter this issue and need to disable this “feature” as you made changes.

sql server 2008 management studio error

The fix is to go to Tools » Options » Designers and uncheck “Prevent saving changes that require table re-creation”

h/t to Deems’ Weblog for the solution.

Polish hand magic

From Saturday Morning Breakfast Cereal. When I read this, I spent a considerable portion of my day playing with my fingers. Note, one thing that confused me a bit is that you have to carry, if necessary, from the multiplication result. For example, with 6×6, you have:

  • 4×4 and 1+1
  • 4×4 = 16, take the 6, carry the 1
  • 1+1+1 = 3
  • With the 3 and 6, you get 36
    • smbc - polish hand magic

      Studying neural networks left me with the same sense of wonder and bewilderment.

Bloomberg on the Ground Zero mosque

The Wall Street Journal’s transcription of a speech given by mayor Michael Bloomberg at Governors Island where he addresses the construction plans for a mosque and Islamic center near Ground Zero. There’s a lot of nonsense about God’s love and mercy, but more importantly:

The government has no right whatsoever to deny that right [to construct the mosque and community center] – and if it were tried, the courts would almost certainly strike it down as a violation of the U.S. Constitution. Whatever you may think of the proposed mosque and community center, lost in the heat of the debate has been a basic question – should government attempt to deny private citizens the right to build a house of worship on private property based on their particular religion? That may happen in other countries, but we should never allow it to happen here. This nation was founded on the principle that the government must never choose between religions, or favor one over another.

This shouldn’t be a remarkable statement; unfortunately, in our current political climate, it is.

Website thumbnails

Generating website thumbnails was a pretty hot topic a few years ago with the rise of services like websnapr, thumbalizr, and, perhaps the most well-known, snap shots. The popularity of doing this has faded somewhat, most likely due to the realizations that services like snap shots are not all that helpful and more of an annoyance than anything else.

I did my own thumbnail generator app a few years ago for a CentOS system. It was painful. I believe I was using gtkmozembed and just going through hell to resolve all the dependencies to get things running on a command line system.

With the WebKit stuff I recently put up, I decided to revisit the idea under .NET, and things were surprisingly easy. This is due to the fact that WinForms 2.0 has the Control.DrawToBitmap() method which makes capturing an image of the client area of a control relatively easy. I should mention, .NET 2.0 has the WebBrowser control, but I could never get the Control.DrawToBitmap() method to work; I always got a blank (white) image. The WebBrowser control is also undesirable because it’s based on IE6, so its certainly far from up-to-date or accurate rendering, even more-so than the outdated version of WebKit I’m using.

So let’s say we’re running a WebKit instance in a Panel (panel1), we can capture what’s displayed as follows,

Bitmap bmpOut = new Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(bmpOut, panel1.ClientRectangle);
bmpOut.Save(
"test.png");

Here’s an example of a capture:

website thumbnail reddit.com

There is one critical limitation; only the visible portion of the web page is captured. However, if a component to scroll and capture different portions of the page were implemented, and the final image was pieced together from these portions, a full page would be captured.

Another limitation is there there is no way to tell when the page is finished loading. Figuring this out requires digging into the depths of the WebKit codebase, I’m certainly not up for it, and it’s not for the faint of heart.

Goodbye to Google Wave

Google has announced it will be shutting it down.

I saw the demo of it in the Google I/O webcast last year, it seemed interesting, like Facebook comments but more professional and more generic (not limited to a closed social network); however, the idea of it as a service to replace email left me uneasy. I liked email. Sure it could be better, and Wave was in some ways better, but it didn’t seem substantially better. On a more ideological level, I also liked that email was vendor-free, I wasn’t chained to Google for my most important communication tool.

google wave logo

I was somewhat alone in this opinion. Most outlets were already predicting Wave as the next big thing and the end of email was fast approaching (nice summary from SAI).

Using Wave was disappointing. It was like being in an empty chatroom as no one in my social network was there. Lonely, but I figured that could change, this was, after all, just an early beta. Most striking to me was the 3-column design, which seemed like overkill and placed, IMO, an overload of information on the screen (I don’t think I’ve ever seen a successful app with a 3-column layout). More importantly the actual user interaction seemed quirky. You had your list of waves in the center column, but you replied to and created new waves in the right-most column. The information in the 2 columns were intimately linked, but the layout made the thread and its associated waves seem disconnected. A 2-column layout with a Facebook-comment-esque system in the right-hand column would seem to have been a better design and allowed for user content to claim the majority of screen real estate. One early lesson I learn working on apps: let the user’s content come through.

Beyond my first impressions, nothing brought me back to Wave. It wasn’t significantly better than email and having yet another messaging or social networking tool was a burden for me. It may have been an okay project collaboration tool, but the feature set never blew me away and my misgiving about the UI didn’t compel me to go in that direction.