Monday, April 22, 2013

All Sorts of Tech!

Yes, it's quite a while since I was here! In that time I've move house and moved jobs - now working for an internet company in Center City, Philadelphia. Many of the problems are familiar, although the resolutions can be different, because of the different environment. Being a contractor offers so much freedom !

Tech 1 - SQL Server
Anyhow, the first snippets of tech are from Microsoft's SQL Server.
There are a number of things that you should build into your code that I still see missed in many people's work. One is checking that the data you get from outside is actually worth having. I saw an offering of a CSV file the other day that started off looking like this:
""""""|""""""""|""""Bob""""|"""74993""""|""""BA""""|" .... .
The content providers had received instructions to delimit all text fields with """ and use "|" as a separator. Of course, they had not realised that the outside quotes were being used as delimiters by the person making the definition, so used the whole lot. In fact, simply separating the fields with pipes would have been enough:
and far more understandable!

Next, when you perform some operations keeping a log is a good idea. For example, writing to a log whenever a report is run, or from each of the procedures that are used in reporting, can be amazingly useful in finding out just where delays and errors are occurring. Just keep a log table with a key identity, a datetime field, and a couple of string fields for info. Write a procedure to execute when you want to write to it, and have that code include the logged in user too! That brings me to my next point:

Getting your identity. Use this for logging who did something. Also use this for deciding whether a user is allowed to do something (although you should really be using roles and groups!).
select suser_sname()

Finally, here's one you should already know. If you're going to get the value of the identity column that you just forced to generate that value by inserting into a table, use
select scope_identity()
and not

Tech 2 - Ubuntu
I recently decided (finally!) to upgrade my Ubuntu from version 11.10 (Oct 2011) to 12.04 (April 2012). Nothing daring, you understand! Of course, I haven't been running the standard desktop interface - Unity - on my system, so when I moved on it didn't get upgraded (why should it!). Instead of which I got a semi-functional GNOME desktop (most of GNOME, but with some bits missing!). Well, nobody's perfect, so I decided to try something completely different and go back to the minimal desktop - XFCE - that I'd tried out and liked on a very underpowered Asus book-sized machine that I currently have bolted to the back of a monitor!
So I looked up the procedure, found a good description here, opened up a terminal window and entered
sudo apt-get install xfce4
and watched as about a million instructions whizzed by! Eventually it all came to an end, but nothing seemed diffferent, so I re-booted, got the logon screen, clicked on a small button and selected XFCE, and then logged on as normal.
Wow! What a difference! Aside from the fact that all the broken bits now worked, and all my programs were still there, and none of my data had vanished, it now looks totally different

If you zoom in you'll see the top bar has about a dozen icons for programs I run a lot, followed by seven that are actually running in this workspace right now.
Next come four pairs of minimised screens, showing the four workspaces, a clock, the Dropbox icon, and the indicator that I'm connected by wire to the web.

The workspace selector shows four workspaces - each with two screens for me because I have two screens! - and a greeked-down representation of what's going on. The furthest-left is what's in the larger screen-grab - nothing much except VirtualBox running. The second workspace is running a copy of Windows XP/64, and the furthest right shows a virtual machine running Windows 7, itself with two screens.
So XFCE fixed my problems and is a very functional GUI for Ubuntu. Of course, it helps to have gobs of memory in your machine, but that was my Christmas present - upgrading from 12 GB to 32 GB of RAM, and it really didn't break  the bank!

Tech 3 - Android and SQL Server
Sorry, no! You can't run SQL Server on Android (I'm not sure Android runs VirtualBox yet!), but if you have an android tablet and subscribe to SQL Server Pro magazine, you should definitely think of getting Texterity's application for reading your magazine - on- or off-line. I read it on the train in to work, and don't need a link, so who cares about tunnels! Check out the app here.

Just a quick cat-pic.