I ran into this issue at work; I needed to repeat the same data 500 times or so, with each row being exactly the same. After an unsuccessful Googling, I thought I’d share my solution to the problem using Common Table Expression (CTEs).
NOTE: CTEs are not necessarily the best solution for this problem, as they rely on the MAX_RECURSION value being greater than or equal to the number of rows needed.

Basing my solution on @generating a sequence of numbers@, I simply created a sequence of numbers in one column; the other columns I filled with my repeated data. Then in the SELECT statement I ignore the column with the sequential number.


WITH RepeatingValues
(
SequenceNum,
Value1,
Value2,
Value3
)
AS
(
SELECT 1,
@Value1,
@Value2,
@Value3
UNION ALL
SELECT SequenceNum + 1,
Value1,
Value2,
Value3
FROM NewValues
WHERE SequenceNum < @RepeatCount
)
SELECT Value1,
Value2,
Value3
FROM NewValues
OPTION (MAXRECURSION 500);
 | Posted by | Categories: Blog |

Provisioning certificates

14 January 2010

I am happy to now be the proud owner of an iPhone developer certificate from Apple, which will let me load and debug the iPhone applications I’m developing on my device itself.  I hadn’t actually planned to sign up to the developer program just yet, but I discovered something after my previous post:  VNC updates the screen too slowly for me to be able to play the game I’m developing full-speed!!  So without a spare monitor to plus into the Mini I’m left having to do most of my testing on-device.  Took a bit of stuffing around with the certificates, though.

When I first followed the instructions for provisioning Screen shot 2010-01-28 at 10.41.09 PMa device it all went fine.  Until I finished the instructions.  After completing the last instruction there was a very flagrant error on my screen: “A valid signing identity matching this profile could not be found in your keychain”. 

Turns out that the KeyChain has to have certificates for both the developer and the issuing authority for XCode to wanScreen shot 2010-01-28 at 10.45.45 PMt to play nice.  Without it I was prevented from selecting the certificate to use to sign my project, instead giving me the message:
“profile doesn’t match an valid certificate/private key pair in the default keychain”.

Turns out this is a pretty common issue for first-time developers, and some are still waiting for word back from Apple to help them with the issue!  The call for “delete all certificates and try again” was all over the forums, so I gave that a shot, with no success.

In the end, it turned out that when the original certificate had been signed, the Apple WWDC certifier certificate had ended up under my system keychain while the Developer certificate provided ended up in my user keychain.  A simple drag-and-drop of the Apple WWDC into the user keychain was all that was needed to get the show on the road.Before After

 | Posted by | Categories: Blog |

Developing remotely

7 January 2010

Okay, not ‘truly’ remotely.  My dev box isn’t out in the desert, or sitting on the Moon.  It’s not even in a different room.  In fact, Winston the Mac Mini sits not two feet away from my normal laptop, lacking only his own monitor.  The default Snow Leopard installed makes it quite easy to turn on OSX’s Screen Sharing – essentially a slightly customised version of VNC.

After that, it’s a pretty easy task to use any VNC client to connect to and control the Mini.  Apple Remote Desktop seems to be inexplicably expensive when any client such as Chicken of the VNC (Mac) or TightVNC (Windows) will do, so I recommend steering well clear of it.  I chose to use TightVNC on my Windows laptop to connect, and it’s here that the issues begin…

To start with, VNC shares the whole screen.  Unlike the Remote Desktop natively built into Windows computers, which uses its heavy integration with Windows system to selectively update only the active areas of the screen when needed, VNC always updates the entire screen1, whether it needs to or not.  Over a wifi connection, this can chew up a lot of bandwidth for some choppy screen refresh rates, but for the purposes of just writing code it’s not too bad.  There’s a few milliseconds improvement in reaction time when I link the computers using Gigabit wired ethernet, so I tend to prefer that option when I can.

The next issue is directly related to Interface Builder on the Mac.  All the tutorials, all the early videos from CS193P say “Control-click and drag to connect interface elements to their actions.”  VNC does not allow ctrl+click+drag to be sent over the network.  No version of VNC will send simultaneous Ctrl+drag events.  It makes it quite difficult to follow tutorials in the beginning.  Luckily the Ctrl+drag functionality is not the only way to create  connection between the elements: A right click brings up a list of delegates/events for an interface element, and clicking and dragging the circle to the right of those events to the appropriate delegate objects allows me to link elements with Outlets, Events with Actions, delegates with responders etc.  At first, all these links were just confusing and all I wanted to do was follow the tutorial.  In retrospect though, I actually think it was a positive that I needed to learn about Actions, Outlets and Delegates before I could use them properly :)

Probably the most important issue is the lack of an Option key though.  Testing things like multitouch in the iPhone simulator requires holding down the Option key to create a ‘mirrored’ cursor.  This gets pretty difficult when there *is* no option key.  When attaching a Windows keyboard to a Mac, the Alt key becomes Option and the Windows key becomes the Apple key.  Over VNC however, the Alt key is the Apple key (because it’s in the same location as the Apple key on the keyboard), but the Windows key….well, it’s still the windows key.  So for the moment testing multitouch is done by attaching my keyboard directly to the Mac.

Overall, writing code using XCode over VNC is slow and there’s a few small issues to get over – but overall it’s a lot cheaper than buying a separate monitor, and all the problems with it so far can be overcome with a bit of ingenuity.

 | Posted by | Categories: Blog |