Saturday, May 04, 2013

Yarn Year Six!

So, for the sixth year in a row the better half and I are shacked up near (well, fairly near) to the Howard County Fairgrounds in West Friendship, MD, in order to visit the Maryland Sheep and Wool Fair tomorrow. This year we're at the Holiday Inn Express at BWI airport. A very friendly hotel, with an attached Dennys.

There will be some photos up here tomorrow evening, assuming that the wi-fi here at the hotel cooperates. This evening we got here at about half-past eight and the hotel net was pretty much totally overwhelmed!

Tech

The obligatory Tech content this post is to remind you that SQL Saturday #200 will be happening on June 1st at Microsoft's offices in Malvern, PA, just outside Philadelphia. The home page is here and you should definitely go if you possibly can, as it will be full of interesting info. Technically-minded business people should also seriously consider going, as there'll be a lot of business-orientated content.

TTFN

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:
||Bob|74993|BA
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
@@identity

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.

Non-Tech
Just a quick cat-pic.
TTFN






Wednesday, November 14, 2012

Knubbelchen

Little knobbly beings :)

In answer to a knitter's call.
(They were escaping from their box!).



Friday, October 26, 2012

Changing Time!

For those wondering if their jobs will run twice (or not at all) because of the daylight time changes in the next few months, here are a couple of links to help

Daylight Time and SQL Server Jobs

and for those using SQL Server 2005 and 2000,

Preparing for Time Changes

TTFN


Friday, October 19, 2012

I'm counting out time, hoping it goes like I planned it

Title courtesy of Genesis ("The Lamb Lies Down On Broadway").
[Tech Stuff]
A somewhat strange title, you might think, but I just had the task of re-writing a couple of T-SQL functions that calculate times. Numbers of days in an interval, to be more precise. Someone had either written or copied a solution that was kind-of working; I needed the real right answers.

Here's the version for calculating weekdays inclusive between two dates. The "inclusive" means that if you're asking "how many days from Tuesday to Thursday" you really mean "how many days work from the instant that Tuesday begins to the very last moment in Thursday - all 72 hours of it. It may be a little difficult to read - use [Ctrl] & [+] to make it bigger in your browser - but I didn't want to get lots of line-wraps.


ALTER function [dbo].[fnCalcWeekdaysInPeriod]

@daStartDate date, 
@daEndDate date 

returns int 
as
/*
select dbo.fnCalcWeekdaysInPeriod('9/29/2012', '9/30/2012')
*/
Begin 
-- ---------------------------------
if @daStartDate > @daEndDate return 0
declare @intDays int, @intWeeks int, @intResDays int
-- ---------------------------------
-- We're only interested in Mon - through -  Fri, 
-- so adjust boundary weekends out of the calculation
-- Push the start date on two for Sat, one for Sun.
-- Pull the end date back two for Sun, one for Sat.
-- ---------------------------------
if (datepart(dw, @daStartDate) = 7) set @daStartDate = dateadd(d, 2, @daStartDate)
if (datepart(dw, @daStartDate) = 1) set @daStartDate = dateadd(d, 1, @daStartDate)
if (datepart(dw, @daEndDate) = 1) set @daEndDate = dateadd(d, -2, @daEndDate)
if (datepart(dw, @daEndDate) = 7)  set @daEndDate = dateadd(d, -1, @daEndDate)
-- ---------------------------------
-- Get the days  --  plus one to make the count inclusive.
-- ---------------------------------
set @intDays = datediff(d, @daStartDate, @daEndDate) + 1
-- ---------------------------------
-- If negative then start date has met end date - which shouldn't happen unless they're very close
-- ---------------------------------
if @intDays < 1 set @intDays = 0
-- ---------------------------------
-- Find out how many weekends there are between the dates
-- ---------------------------------
set @intWeeks = cast((cast(@intDays as float) / 7) as int)
-- ---------------------------------
-- Subtract 2 for every internal weekend
-- ---------------------------------
set @intResDays = @intDays - (@intWeeks * 2)
-- ---------------------------------
return abs(@intResDays)
End

If anyone can find a problem with it then I'd be happy to buy the first few people a beer each! The next post will be for the same thing but for work days - i.e. the days people work after taking company holidays off. It depends on this, though, so this needs to be correct!
--------------------------------

On a more personal note, my cousin Edward now has a berth on the Queen Mary II. Congratulations and best wishes to him!

Go here for information on the ship.

Go here for booking information (shameless plug!).




--------------------------
[Food]
My darling wife and I collaborated on dinner last night. This isn't a cause for a blog in and of itself, but it turned out more successfully than we'd expected. It was a very simple meal - chicken breast, couscous, and some sauce, with a few veggies - but it turned out to be very nice indeed, and pretty low-effort.

Ingredients
Two (or more!) chicken breasts Chicken broth
Dried Basil and Bay Leaf, crushed up  Salt and Pepper
Spring Onion, chopped small Celery, chopped fairly small
CousCous Cream Cheese
Roast Garlic Jelly Butter

Instructions
1. Clean the chicken breasts well, trimming off any fat you don't want to serve.
2. Lay each breast on a piece of aluminium foil big enough to fold up loosely around the whole breast.
3. Turn up the foil around the edges  and pour in some broth, enough  to reach about a centimetre
    up the breast.
4. Strew the breast with the herbs.
5. Fold up the foil over the breasts to close them in, put them all on a baking tray, and bake
    for 35-40 minutes at between 380F and 400F.
6. For the sauce, take about 10 oz of cheese, about the same of the roast garlic jelly, and some
    chicken broth to help thin it out. Put it all into a saucepan and whisk gently to mix while heating through.
7. For the couscous, heat some butter (maybe a quarter of a stick) in a pot, then pour in about 3/4 cup of
    courcous per person. Stir while still heating, so that the couscous is a little fried in butter. When you can
    hear the mixture start to sizzle a little, add a cup of chicken broth and stir well. Stir in some more celery
    and spring onion, and any aromatics that catch your eye - such as a little Rosemary or Thyme for
    flavouring to your taste.

Eat well!
TTFN
--------------------------

Thursday, September 06, 2012

Experts Exchange

Experts Exchange is a site where you go to get help. Yes, I know there are many of these, but this is a really technical one, mainly for programmers, DBAs, and the like, although there are other sides to it too, like areas for operating systems where you could ask questions about things like MS' Office-365.

I've been a member for quite a few years, but only recently started answering more "seriously", if you can put it that way, and today I got a reward:



along with a certificate. Hopefully some more will follow.

Now to go prepare Jambalaya (I think!).

TTFN

Tuesday, June 26, 2012

On Getting a Cat

I was sitting calmly in work a couple of months ago when the cell phone rings. "Hello darling" the voice at the other end purrs, "please get some cat food on the way home". My thought process went something like "Well ok ... we don't have a cat ... well maybe we do now!"




So I stop on the way home and get some cat food. When I get home I find the wife with a very emaciated cat.


Here she is curled up inside a jam pan.




So I was sent out to get all the bare necessities (tray, litter, scoop, more food, bed ... )

The bed seems to be popular!




Then there's housing for the needy!








and here she is gazing intently at the squirrels feeding noisily outside the window!







TTFN




Found Food

I have published quite a few recipes here on my blog over the last few years, and I hope that all my readers have tried at least some of the...