Category: Technology

A Bit Scatterbrained…

Lately I find myself mixing my PascalCase with my camelCase, calling alloc init instead of new, using [ ] instead of (), and writing awfully verbose method names all over the place. I justify my errors with a glimpse at my average day here lately:

Not to scale. Some margin of error. I focus on my family all day. I promise!

The Value of Documentation

Having been reared as a developer in Microsoft’s cozy little .NET world, I didn’t really appreciate the value of quality documentation until I ventured out into the wild jungle.

I’ve been using Appcelerator’s Titanium Mobile SDK for the past few months. It’s kind of become my Shere Khan here in the jungle. Theoretically, using Titanium Mobile is easier and faster than writing native code. This might be true if I didn’t waste so much time deciphering their documentation.

I made a button to toggle my table view’s editable status. The object had a property called editable, so that seemed to be what I wanted. After testing, however, all this did was toggle whether or not swipe-to-delete worked. What I really wanted was the little red minus sign to appear, and have the contents of each row shifted to the right to make room. After 30 minutes of trial and error, looking through TableViewRow properties, and searching their Q&A section (because Appcelerator has no official forums) I found that TableView actually has two properties: editable and editing.

 

image

 

Even after discovering this other property, I still had to actually test each one to see what they did. Apparently, “editable” toggles the swipe-to-delete, whereas “editing” toggles the minus-button-on-the-left thing. The two are independent of each other.

Thanks for saving me time, web based application framework!

Signed,

Bitter in Bossier

Enterprise Library Sometimes Chops XML into 2033 Characters

This morning I began what I thought would be an uneventful task in .NET: connect to one database, download as XML some rows from a table that have changed since a given time, then pass that XML to a stored procedure in another database so that the changes can be merged. Just two tables: one relatively small, the other just a 2-column relationship table for the first table. Here’s a contrived snippet to serve the same purpose:

The SQL:

CREATE PROCEDURE dbo.GetXmlValue

AS

SELECT TOP 100
 *
 FROM sys.all_columns
 FOR XML AUTO, ROOT('Root')

The Code:

Database db = GetDatabase();

DataSet set;

using (DbCommand cmd = db.GetStoredProcCommand("dbo.GetXmlValue"))
 {
     set = db.ExecuteDataSet(cmd);
 }

In my application, it was this second table that tripped me a bit. The first only had a few changed rows, so the XML was only 500-1000 characters. The second table generated a much longer XML string – 3864 characters long. My initial plan was to return two tables, each 1 column and 1 row. When using Database.ExecuteDataSet to fetch the results, however, the second table yielded two rows. I backtracked, second guessed myself, and even grabbed a couple of guys in the hall to double check my code. No one could explain it. It seemed odd that this hasn’t come up before for someone here. I did a bit of Googling and only found a couple of results. This Microsoft Knowledgebase Article just says it’s “by design” and to use SQLCommand.ExecuteXmlReader.

The next question that came up was “Well, what does it do if I return a long XML value among other values in the same row?” I tested this out and everything worked as expected. All of the XML was in a single column value as it should be.

I still can’t exactly explain it. ExecuteScalar has a character limit of 2033 characters. I suspect that because each table in my result set is just a single column value, something somewhere is relying on ExecuteScalar.

My solution? In my stored procedure I just stored each of my table results as an XML typed variable, then returned the two together in the same row.

GTIN 12 UPC Check Digit Calculation in SQL Server 2008

I recently needed to generate the check digit for a GTIN-12 UPC code in SQL. The calculation method for the check digit varies depending on what kind of barcode you’re implementing, so I popped on over to Google to get the necessary algorithm. Naturally, and regardless of simplicity, I checked for any available code snippets. The only I found weren’t GTIN-12, and were in C or C++. So for anyone looking to do it (or something similar) in T-SQL, here’s a scalar function to do just that.

CREATE FUNCTION dbo.CalculateBarcodeGTIN12CheckDigit(@input CHAR(11))
RETURNS INT
AS
BEGIN
	DECLARE @evenDigitSum INT = 0
		,@oddDigitSum INT = 0
		,@i TINYINT = 0
		,@result INT;

	-- check if given Barcode is Numeric , if not return error status -1
	IF(ISNUMERIC(@input) = 0
		OR LEN(RTRIM(LTRIM(@input))) != 11)
		RETURN -1

	-- start the compute BarCode checksum algorithm
	SET @i = 1
	WHILE (@i <= 11)
		BEGIN
		 --Add odd and even digits separately;
		 IF((@i % 2) = 0)
			 SET @evenDigitSum += CONVERT(TINYINT, SUBSTRING(@input,@i,1))
		 ELSE
			 SET @oddDigitSum += CONVERT(TINYINT, SUBSTRING(@input,@i,1))
		 SET @i += 1
		END

	--As per: http://en.wikipedia.org/wiki/Universal_Product_Code
	--Multiply odd sum by 3, add to even sum, and mod 10.
	SET @result = ((@oddDigitSum * 3) + @evenDigitSum) % 10;
	IF(@result = 0)
		RETURN 0
	ELSE
		RETURN 10 - @result;

	RETURN -1
END
GO

Scalar functions are killer, but I’ll only ever be using it for a single record.

360 Panorama – Occip.It View After Saving

Per the comment thread on Occipital’s blog:

This took me a while to find. As I’m in Berlin right now, my phone doesn’t work. I’ve pulled the SIM and I am just using it like an iPod touch. This has been a frustrating experience with regard to 360 Panorama because I rarely have an internet connection at the time that I take the panorama. All I can do is “Save”, and not having it in their nifty “Immersively stunning way” is a bit of a letdown.

The good news is twofold: They’re going to address it in an update AND there’s a way to manually recreate them with your saved image. First, upload them to www.yfrog.com. Luckily, they allow batch uploads. So if you’re like me and took 52 of them, it’s not too much trouble to upload them all.

Then the tedious part: making a list of all of the URLs created by the newly uploaded images. Once you make a list, just replace “yfrog.com/” with  ”occip.it/py” and voila! you have an Occipital magic view of your 360 panorama after saving it.

If anyone has any quick way of creating a list of all of your yfrog images, I’d love to know.

It’s not an elegant solution, but it should work until they update the app.

UPDATE: See comment for some of mine from my trip.

UPDATE 2: Checked for an app store update the very next day and it looks like they’ve addressed the problem.

Further Proof That Any “Win an Apple XYZ Product” Is A Scam

I have this theory that contests via which you win a free Apple product are all a myth. Until I win something first hand, I will maintain this theory. This morning I had an email from Sci-Port letting me know they’re having a contest to win an Apple iPad:

WTFScipPortiPad

 

Anyone else notice something a bit… um, fabricated about this? Do they know something about the next iPad that we don’t?

SSMS “Connect to Database Engine” Prompt Every Time A Saved Query Is Opened

About two weeks ago, I noticed Sql Server Management Studio’s behavior changed on me. I often use saved SSMS_screenshotqueries for deployment, so I’m saving/opening them all day long. For as long as I’ve been using SSMS, it has always just used my existing connection in Object Explorer as the connection context for the saved file. Something changed, and I now have to react to this dialog every time I open a file. It doesn’t matter if I have a connection established in object explorer or not.

My irritation level finally rose to the point this morning that I decided to address it. I’d given Googling it a solid 25-35 minutes worth of effort before I decided to bother anyone else about it. All I saw were people complaining of the same problem with no real solutions. Most of the responses were justifications for the new behavior, but they just didn’t seem to get the OP’s problem: The behavior used to be different! Something changed!

Dave’s installation was acting exactly like mine used to – the way I want it to. Chris Benard simply “rarely uses saved queries.” Has anyone ever experienced this and know the solution? It’s driving me nuts!

OnLive: Initial Impressions

onlive_logoI’ve been following OnLive since it was first announced in March of 2009. The idea is straightforward: The OnLive app is just a video stream of a server. The server processes your  input, renders the video, and then sends it back to your screen. A few of the less technical people I’ve described the concept to didn’t quite “get it” at first. They didn’t catch the major and minor ways this would change gaming.

Why bother?

The standout reason is the idea of no longer needing a “gaming” PC. You just need a computer that can play back video and a speedy internet connection. No $150-300 video card every year or two. No need for a new motherboard/processor/memory upgrade every year or two. A rinky-dink laptop will work to play the latest games.

Sure, I do have a gaming PC. I’m still interested. Regular PC upgrades have been a way of life for me since I was a kid, so it’s not something I’m necessarily dying to stop doing. It interests me because it puts my #1 form of entertainment in the cloud. It allows me to pick up where I left off in any of my games from any computer that has a fast internet connection. I just log onto OnLive.com, download an app that’s just a couple of megabytes, and I’m gaming. Awesome.

Why else?

Initially, I didn’t really catch how gaming via this technology would change the experience. Because they’re already streaming video to you, processing video has very little overhead. This really shines via their interface:

onlive_menu

Each one of those rectangles is an actual video. In theory, each one is also live video of someone playing. The reality is that right now some are prerecorded due to the limited user base, particularly before release when it was still in beta.

This allows for some more subtle features – players don’t have profile pictures, they have profile videos. You can see what one of your buddies is doing in-game at this very moment. Players can create “brag clips” while playing, which are immediately available for other players to view and rate.

No way it works

If you’re anything like me and find yourself still pausing a damn YouTube video to wait for it to buffer even though you have a 16 mbps connection, you’ll scoff at the idea and call it “silly” smoke and mirrors. “There’s no way it will work.”

It works, and it works surprisingly well. When you launch the app, it analyzes your connection and determines the most appropriate flavor of their algorithm to use. So far, I’ve only spent about an hour and a half using it. This was around 7 in the evening on a 16 mbps down / 1.5 mbps up connection. I played 20 minutes or so of AaaaaAAaaaAAAaaAAAAaAAAAA!!!, dabbled in the Splinter Cell Conviction demo, and spent the rest of the time playing Just Cause 2. I played full screen on a 1680×1050 22” LCD. I started off using the keyboard and mouse, but when I began playing Just Cause 2 I turned on my wireless Xbox 360 controller and it just worked. I had previously already used it on my PC, but there was no configuration needed for OnLive.

Don’t lie, it’s laggy!

Yep, definitely laggy. I immediately noticed it. The time it took for the app to process my input, send it to the server farm (probably in Dallas), process it, render the video, and send it back to my computer (in Northwest Louisiana) was noticeable. Of course it was noticeable. I was hypersensitive to it because i was logging on to OnLive for the first time and testing to see if it was laggy.

But the question is this: Does it matter? In a first person shooter, it could definitely matter. In the three games I played, it kind of mattered. After about 20-30 minutes of playing them, it didn’t matter. None of the problems mattered. I had the game running full screen, I was playing with my 360 controller, and I was having fun. I genuinely quit thinking about the technology and I was just playing the games (mostly Just Cause 2). I’m a relatively hardcore FPS player. I play to try some Unreal 3 and F.E.A.R. and see how much of a problem it is, but I will honestly be surprised if it’s not something I get used to pretty quickly.

onlive

How much?

$5 per month plus the cost of the games. Less than Xbox Live. Free for the first year due to some bizarre AT&T sponsorship that I haven’t cared enough to understand. How much for the games? Brand new games are as much as you would pay on Steam. Games that are a couple of months old are $20-40. Indie games are around $10ish. You can “demo” most games, which is 30 minutes of time to play the full game. I’d take that over a normal demo in most cases. Many of the games have rental options. Pay a few bucks to play the game for 3 or 5 or maybe 7 days. For your typical AAA action game with just 8-14 hours of gameplay, this could be an amazing weekend value. I kind of forgot about renting years ago. It’s only ever been an option for consoles.

Is that too much? The service fee is much less than I was expecting. I’m happy to pay $5 per month for a gaming PC in the cloud. The cost of the games is something I’m a little unsure about. I don’t feel right paying $50-60 for a brand new game which I can only use via their service. However, I feel fine paying $30 for a game like Borderlands and only being able to play it via OnLive.

I haven’t read the terms of use, but I’ve seen some accusations being tossed around of you losing your games if you cancel your account and leave it deactivated for X number days/weeks/months. Should I lose my data and game saves after a certain amount of time? Sure, I think that’s reasonable. Should I lose my rights to play the game again 2 years down the road if I resubscribe? Absolutely not. If that’s the case, OnLive will not succeed. Before I make my first game purchase, I certainly aim to understand this agreement more.

Final thoughts

I really do think OnLive is on to something great here. They’ve got a tough job ahead of them in balancing their pricing. If the users get behind them and really show demand for the service, we’re now looking at the infancy of a major shift in our available options as gamers. Developers will create products for a platform whenever there is enough demand, and the games a developer could create specifically for a platform like this could be very promising. Sure, the video is a little muddier than it might be playing natively. Sure, there is a slightly noticeable latency issue. Sure there’s a limited game selection. For being the launch week of such an incredible technological accomplishment, I’ll take it. It can only get more awesome from here.

An Interesting View of My Day

IOGraphica - 4.3 hours (from 8-18 to 13-09)

Yesterday afternoon for a few hours, I ran a java program called IOGraphica. I’ve seen these types of images done before, but never knew how they went about doing it. Download Squad had an article the other day talking about the app. The lines are a trace of my cursor, the dots represent an idle cursor. The bigger the dot, the longer I was idle. For some reason, it also draws a circle around the dot. I’m not sure what determines the size of this circle. I’d love to know. I’d also like to be able to turn this off. It looks like I drew a lot of perfect arcs with my cursor.

I have three monitors:

    • Left: 4:3 landscape – Pidgin, Chrome, taskbar/start menu.
    • Center: 4:3 portrait – Visual Studio
    • Right: 16:10 landscape – Outlook & SSMS.

Given this odd landscape, IOGraphica seems to have done reasonably well at capturing a rectangular image. It chopped off the top 5% or so of my center monitor, but not much goes on there. As you can see, I spend a lot of time on my left monitor. Or rather, my cursor spends a lot of idle time on my left monitor. I’m not sure how this translates to the distribution of my attention, but the tightness in the right side of my neck seems to validate it.

A couple of hours this morning without the dots for an idle cursor:IOGraphica - 2.6 hours (from 8-06 to 10-43)

I think it stopped reading my cursor shortly after an hour though.

As a result of this little experiment, I might swap my monitors around. I think it proves that the ergonomics of my configuration are less than ideal.

I had  couple of problems. I tried twice to capture a full day, but both times IOGraphica would simply quit drawing after a couple of hours. The interface continued to respond. It also has an option to capture an image of your desktop and set it as the background. It will only take a screenshot of my primary monitor and stretch it to fill the entire image.

If anyone has any better luck with it, let me know. And send me yours!

I want to be an App Store Millionaire, Who’s With Me?

My envy is becoming unbearable. I’m not sure how much more I can take of these mobile app success stories. People are making hundreds and thousands of dollars per month with their relatively simple apps. There’s a gold rush on the mobile frontier, and I’m just now learning how to use a pickaxe.

Honestly, I’d be happy just to have a product on an app store and receive a check for 99¢. One sale, and I’d feel like I’ve accomplished something. I don’t need to make millions of dollars like the guys that made Doodle Jump for the iPhone.

I’ve got a summer without classes. I’m determined to publish something either on the Android app store or maybe an XNA project. A simple gaming project is the most interesting to me, but a lack of artistic direction is always my biggest roadblock. Anyone interested in a little collaboration? I mean, look at Doodle Jump. We can do that!