Syringe.Net.Nz
Irregular Injection of Opinion
RSS 2.0|Atom 1.0|CDF

 Wednesday, February 26, 2014
A Really Good Business Travel Insurance Policy

So I’ve put a few people onto this over the years and we struck up a conversation about it over on Twitter today.

For probably 10 years now I’ve been using ACE Insurance and their business policy. It is very comprehensive and, if you can get over the minimum days requirement, it is pretty damn cheap too. I’m not sure exactly what our details are now at Intergen as we do thousands of days now, but, when it was Kognition we got 100 days for about $700 a year. Pretty damn good.

Key reasons I like it:

  1. Few exclusions and no terrorism exclusion
  2. Good upper limits for electronics and camera gear
  3. VERY (and I mean VERY) broad coverage for sports and adventure sports. It only excludes professional sports, motor racing and flying in an aircraft not licensed to carry passengers (sorry hang gliders!)
    While I don’t propose to provide legal advice here are some of the things that are typically excluded that I believe will be covered*
    1. Off piste skiing
    2. Heli skiing
    3. Kite surfing
    4. Mountain biking
    5. Scuba diving including diving outside PADI recreational limits
    6. Mountaineering including climbing above 8000m

What’s not to love!

Anyway. Talk to your insurance broker. http://www.acegroup.com/nz-en/for-businesses/business-travel-insurance.aspx 

All the above is caveated that it is based on my current policy wording which may or may not be what you get Smile YMMV

Travel|Wednesday, February 26, 2014 2:55:49 AM UTC|Comments [0]|    

 Wednesday, February 12, 2014
The Case for Shopping Cart Abandonment

Interesting how targeted marketing is getting in e-Commerce. I wonder to what extent one can ‘game’ the system.

So I spent a few minutes yesterday at TheClymb putting some stuff into my cart. But, I never checked out. This morning I get a unique code from them to go and knock 30% off everything, I guess to try and get me to complete the purchase. I did and bought a bit more stuff in the process. I hope that they have noticed my behaviour and continue to come running after me when I leave my cart in the virtual aisle in future. With their extra discounts at check-out I think they track a bit cheaper than Steep and Cheap for stuff. Well worth signing up, filling your cart and seeing if they'll lure you back with a big sweetener.

Adventure Sports|Wednesday, February 12, 2014 6:30:52 PM UTC|Comments [0]|    

 Wednesday, June 12, 2013
So you’ve got a new Lenovo and you hate the ‘island keyboard’

So I’m a big Lenovo fan. I own and still use an x61t, x201t and an x301. I waited… and waited… and waited… for the Helix. And then I didn’t like it very much. Some were driver issues and some dumb design decisions* but mostly I hated the ergonomics of the new keyboard.

  1. It’s missing a Right Click Menu key. To me this is essential for mouse free work including things like fixing spelling mistakes in Word
  2. You can’t have the F-keys and the End key working at the same time

So. If you hate this too then here’s the fix.

Grab AutoHotkey then add these lines to your script.

; Remap PrintScreen to be the right hand context menu key
#PrintScreen::PrintScreen ;Print SCreen now requires Windows Modifier
PrintScreen::AppsKey

;Remap End and Insert. Switch them around
Insert::End
End::Insert

Fixed.

* WTF does it not output +5v on the Keyboard USB ports when the power cable is plugged in but the slate is disconnected. Oh and why no +5v out when the machine is powered off.

Lenovo|Wednesday, June 12, 2013 4:23:55 AM UTC|Comments [0]|    

 Monday, September 17, 2012
SQL Azure Federations Deep Dive–TechEd ANZ

So I promised that I’d post all the bits from my TechEd Australia and NZ session on SQL Azure Federations. I have been tardy in delivering on this goal.

If you missed the session they recorded it for me in Auckland so you can take a look at the recording on channel 9: http://channel9.msdn.com/Events/TechEd/NewZealand/TechEd-New-Zealand-2012/AZR304

So here goes.

The first item is the SQL Script that I walked through. This will give you a high level idea of the basics of Federations using a simple eCommerce type scenario (partial AdventureWorks)

--<<<<<<<<<<<<<<<<<<<<< Task 1 – Create Federations Root Database >>>>>>>>>>>>>>>>>>>>>
CREATE DATABASE [TechEd2012]
GO

--<<<<<<<<<<<<<<<<<<<<< Task 2 – Connect directly to Root Database >>>>>>>>>>>>>>>>>>>>>
/*
    Using tooling support in latest release of SQML Management studio    
*/

--<<<<<<<<<<<<<<<<<<<<< Task 3 – Create Federation Object >>>>>>>>>>>>>>>>>>>>>
CREATE FEDERATION CustomerFederation(cid BIGINT RANGE)
GO

--<<<<<<<<<<<<<<<<<<<<< Task 4 – View Federations Metadata >>>>>>>>>>>>>>>>>>>>>
-- Route connection to the Federation Root
USE FEDERATION ROOT WITH RESET
GO
SELECT db_name() [db_name], db_id() [db_id]
SELECT * FROM sys.federations
SELECT * FROM sys.federation_distributions
SELECT * FROM sys.federation_member_distributions ORDER BY federation_id, range_low;
SELECT * FROM sys.databases;
GO
-- Route connection to the 1 Federation Member (aka shard)
USE FEDERATION CustomerFederation(cid=100) WITH RESET, FILTERING=OFF
GO
SELECT db_name() [db_name], db_id() [db_id]
SELECT * FROM sys.federations
SELECT * FROM sys.federation_distributions
SELECT * FROM sys.federation_member_distributions
GO
SELECT f.name, fmc.federation_id, fmc.member_id, fmc.range_low, fmc.range_high 
FROM sys.federations f
JOIN sys.federation_member_distributions fmc
ON f.federation_id=fmc.federation_id
ORDER BY fmc.federation_id, fmc.range_low;
GO

--<<<<<<<<<<<<<<<<<<<<< Task 5 – Create Federated Tables >>>>>>>>>>>>>>>>>>>>>
-- Route connection to the 1 Federation Member (aka shard). 
-- Filtering OFF so we can make DDL operations
USE FEDERATION CustomerFederation(cid=10) WITH RESET, FILTERING=OFF
GO
-- Table [dbo].[Customer]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customer](
    [CustomerID] [bigint] NOT NULL,
    [Title] [nvarchar](8) NULL,
    [FirstName] [nvarchar](50) NOT NULL,
    [MiddleName] [nvarchar](50) NULL,
    [LastName] [nvarchar](50) NOT NULL,
    [Suffix] [nvarchar](10) NULL,
    [CompanyName] [nvarchar](128) NULL,
    [SalesPerson] [nvarchar](256) NULL,
    [EmailAddress] [nvarchar](50) NULL,
    [Phone] [nvarchar](25) NULL,
 CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED 
(
    [CustomerID] ASC
) 
)FEDERATED ON (cid=CustomerID) --Note the use of the FEDERATED ON statement
GO

CREATE TABLE [dbo].[Order](
    [OrderID] [uniqueidentifier] NOT NULL DEFAULT newid(),
    [CustomerID] [bigint] NOT NULL,
    [OrderTotal] [money] NULL,
CONSTRAINT [PK_Order] PRIMARY KEY CLUSTERED 
(
    [OrderID],[CustomerID] ASC
) 
)FEDERATED ON (cid=CustomerID) --Note the use of the FEDERATED ON statement
GO

--<<<<<<<<<<<<<<<<<<<<< Task 6 – Insert Dummy Data >>>>>>>>>>>>>>>>>>>>>
-- Route connection to the 1 Federation Member (aka shard). 
-- Filtering OFF so we can insert multiple Atomic Units
USE FEDERATION CustomerFederation(cid=10) WITH RESET, FILTERING=OFF
GO
INSERT INTO [dbo].[Customer]
           ([CustomerID]
           ,[Title]
           ,[FirstName]
           ,[MiddleName]
           ,[LastName]
           ,[Suffix]
           ,[CompanyName]
           ,[SalesPerson]
           ,[EmailAddress]
           ,[Phone])
     VALUES 
(55, 'Mr.', 'Frank', '', 'Campbell', '', 'Rally Master Company Inc', 'adventure-works\shu0', 'frank4@adventure-works.com', '491-555-0132'),
(56, 'Mr.', 'Brian', '', 'Groth', '', 'Latest Accessories Sales', 'adventure-works\david8', 'brian5@adventure-works.com', '461-555-0118'),
(57, 'Ms.', 'Judy', 'R.', 'Lundahl', '', 'Leading Sales & Repair', 'adventure-works\jillian0', 'judy1@adventure-works.com', '260-555-0130'),
(58, 'Mr.', 'Peter', '', 'Kurniawan', '', 'Largest Bike Store', 'adventure-works\jillian0', 'peter4@adventure-works.com', '436-555-0160'),
(59, 'Mr.', 'Douglas', '', 'Groncki', '', 'Locks Company', 'adventure-works\shu0', 'douglas2@adventure-works.com', '385-555-0140'),
(60, 'Mr.', 'Sean', 'J.', 'Lunt', '', 'Main Bicycle Services', 'adventure-works\linda3', 'sean4@adventure-works.com', '183-555-0111'),
(61, 'Mr.', 'Jeffrey', '', 'Kurtz', '', 'Many Bikes Store', 'adventure-works\shu0', 'jeffrey3@adventure-works.com', '452-555-0179'),
(64, 'Mr.', 'Vamsi', '', 'Kuppa', '', 'Metal Clearing House', 'adventure-works\jos‚1', 'vamsi1@adventure-works.com', '290-555-0196'),
(65, 'Ms.', 'Jane', 'P.', 'Greer', '', 'Metro Manufacturing', 'adventure-works\jos‚1', 'jane2@adventure-works.com', '737-555-0163'),
(66, 'Mr.', 'Alexander', 'J.', 'Deborde', '', 'Neighborhood Store', 'adventure-works\garrett1', 'alexander1@adventure-works.com', '394-555-0176'),
(70, 'Mr.', 'Deepak', '', 'Kumar', '', 'Outdoor Aerobic Systems Company', 'adventure-works\jae0', 'deepak0@adventure-works.com', '1 (11) 500 555-0122'),
(73, 'Ms.', 'Margaret', 'T.', 'Krupka', '', 'Outdoor Sports Supply', 'adventure-works\pamela0', 'margaret1@adventure-works.com', '107-555-0132'),
(74, 'Mr.', 'Christopher', 'M.', 'Bright', '', 'Parcel Express Delivery Service', 'adventure-works\david8', 'christopher2@adventure-works.com', '162-555-0166'),
(75, 'Ms.', 'Aidan', '', 'Delaney', '', 'Paint Supply', 'adventure-works\jillian0', 'aidan0@adventure-works.com', '358-555-0188'),
(76, 'Mr.', 'James', 'J.', 'Krow', '', 'Out-of-the-Way Hotels', 'adventure-works\jillian0', 'james11@adventure-works.com', '265-555-0190'),
(77, 'Mr.', 'Michael', '', 'Brundage', '', 'Mechanical Products Ltd.', 'adventure-works\shu0', 'michael13@adventure-works.com', '128-555-0148'),
(78, 'Mr.', 'Stefan', '', 'Delmarco', '', 'Preferred Bikes', 'adventure-works\linda3', 'stefan0@adventure-works.com', '819-555-0186'),
(79, 'Mr.', 'Mitch', '', 'Kennedy', '', 'Reasonable Bicycle Sales', 'adventure-works\shu0', 'mitch0@adventure-works.com', '996-555-0192'),
(82, 'Mr.', 'James', 'D.', 'Kramer', '', 'Refined Department Stores', 'adventure-works\jos‚1', 'james10@adventure-works.com', '814-555-0130'),
(83, 'Mr.', 'Eric', 'J.', 'Brumfield', '', 'Requisite Part Supply', 'adventure-works\jos‚1', 'eric3@adventure-works.com', '644-555-0114'),
(84, 'Ms.', 'Della', 'F.', 'Demott Jr', '', 'Rewarding Activities Company', 'adventure-works\garrett1', 'della0@adventure-works.com', '752-555-0185'),
(88, 'Ms.', 'Pamala', 'M.', 'Kotc', '', 'Closest Bicycle Store', 'adventure-works\jae0', 'pamala0@adventure-works.com', '1 (11) 500 555-0173'),
(91, 'Ms.', 'Joy', 'R.', 'Koski', '', 'Scooters and Bikes Store', 'adventure-works\pamela0', 'joy0@adventure-works.com', '810-555-0198'),
(92, 'Ms.', 'Jovita', 'A.', 'Carmody', '', 'Sports Commodities', 'adventure-works\david8', 'jovita0@adventure-works.com', '646-555-0137'),
(93, 'Mr.', 'Prashanth', '', 'Desai', '', 'Stationary Bikes and Stands', 'adventure-works\jillian0', 'prashanth0@adventure-works.com', '138-555-0156'),
(94, 'Mr.', 'Scott', '', 'Konersmann', '', 'Specialty Sports Store', 'adventure-works\jillian0', 'scott6@adventure-works.com', '556-555-0192'),
(96, 'Ms.', 'Jane', 'N.', 'Carmichael', '', 'Rural Department Store', 'adventure-works\shu0', 'jane0@adventure-works.com', '716-555-0167'),
(97, 'Ms.', 'Bonnie', 'B.', 'Lepro', '', 'More Bikes!', 'adventure-works\linda3', 'bonnie2@adventure-works.com', '354-555-0130'),
(99, 'Mr.', 'Eugene', '', 'Kogan', '', 'Mountain Bike Center', 'adventure-works\shu0', 'eugene2@adventure-works.com', '136-555-0134'),
(100, 'Mr.', 'Kirk', 'T', 'King', '', 'Up-To-Date Sports', 'adventure-works\jos‚1', 'kirk2@adventure-works.com', '979-555-0163'),
(101, 'Mr.', 'William', 'J.', 'Conner', '', 'Urban Sports Emporium', 'adventure-works\jos‚1', 'william1@adventure-works.com', '383-555-0111'),
(102, 'Ms.', 'Linda', '', 'Leste', '', 'National Manufacturing', 'adventure-works\garrett1', 'linda7@adventure-works.com', '493-555-0134'),
(106, 'Ms.', 'Andrea', 'A.', 'Thomsen', '', 'West Side Mart', 'adventure-works\jae0', 'andrea1@adventure-works.com', '1 (11) 500 555-0120'),
(109, 'Mr.', 'Daniel', 'P.', 'Thompson', '', 'Travel Sports', 'adventure-works\pamela0', 'daniel2@adventure-works.com', '247-555-0197'),
(110, 'Ms.', 'Kendra', 'N.', 'Thompson', '', 'Vintage Sport Boutique', 'adventure-works\david8', 'kendra0@adventure-works.com', '464-555-0188'),
(111, 'Mr.', 'Scott', 'A.', 'Colvin', '', 'Westside Cycle Store', 'adventure-works\jillian0', 'scott1@adventure-works.com', '119-555-0144'),
(168, 'Sr.', 'Luis', '', 'Bonifaz', '', 'Economy Bikes Company', 'adventure-works\linda3', 'luis0@adventure-works.com', '688-555-0113'),
(169, 'Ms.', 'Brenda', '', 'Diaz', '', 'Downtown Hotel', 'adventure-works\shu0', 'brenda2@adventure-works.com', '147-555-0192'),
(172, 'Ms.', 'Gabriele', '', 'Dickmann', '', 'Certified Sports Supply', 'adventure-works\jos‚1', 'gabriele0@adventure-works.com', '835-555-0116'),
(173, 'Mr.', 'Rudolph', 'J.', 'Dillon', 'Sr.', 'Sundry Sporting Goods', 'adventure-works\jos‚1', 'rudolph0@adventure-works.com', '722-555-0169'),
(174, 'Mr.', 'Michael', 'L.', 'Bohling', '', 'Toy Manufacturing Inc', 'adventure-works\garrett1', 'michael12@adventure-works.com', '838-555-0147'),
(178, 'Mr.', 'Dick', '', 'Dievendorff', '', 'Rampart Amusement Company', 'adventure-works\jae0', 'dick1@adventure-works.com', '1 (11) 500 555-0193'),
(180, 'Ms.', 'Nicky', 'E.', 'Chesnut', '', 'Full-Service Bike Store', 'adventure-works\michael9', 'nicky0@adventure-works.com', '264-555-0164'),
(181, 'Mr.', 'Michael', 'J.', 'Lee', '', 'Family Entertainment Center', 'adventure-works\pamela0', 'michael18@adventure-works.com', '396-555-0139'),
(182, 'Mr.', 'Stanley', 'A.', 'Alan', 'Jr.', 'Another Bicycle Company', 'adventure-works\david8', 'stanley0@adventure-works.com', '156-555-0126'),
(183, 'Mr.', 'Yao-Qiang', '', 'Cheng', '', 'This Area Sporting Goods', 'adventure-works\jillian0', 'yao-qiang0@adventure-works.com', '344-555-0181'),
(184, 'Ms.', 'Marjorie', 'M.', 'Lee', '', 'Go-cart and Bike Specialists', 'adventure-works\jillian0', 'marjorie0@adventure-works.com', '306-555-0166'),
(185, 'Mr.', 'Sandeep', '', 'Kaliyath', '', 'Weekend Bike Tours', 'adventure-works\shu0', 'sandeep1@adventure-works.com', '495-555-0113'),
(186, 'Mr.', 'Pei', '', 'Chow', '', 'Thrilling Bike Tours', 'adventure-works\linda3', 'pei0@adventure-works.com', '789-555-0184'),
(190, 'Mr.', 'Mark', '', 'Lee', '', 'Racing Partners', 'adventure-works\jos‚1', 'mark5@adventure-works.com', '371-555-0112'),
(191, 'Ms.', 'Sandra', 'T.', 'Kitt', '', 'Non-Slip Pedal Company', 'adventure-works\jos‚1', 'sandra2@adventure-works.com', '303-555-0117'),
(192, 'Mr.', 'Hao', '', 'Chen', '', 'Nuts and Bolts Mfg.', 'adventure-works\garrett1', 'hao1@adventure-works.com', '117-555-0173'),
(196, 'Ms.', 'Jolie', '', 'Lenehan', '', 'Exhibition Showroom', 'adventure-works\jae0', 'jolie0@adventure-works.com', '1 (11) 500 555-0126'),
(197, 'Ms.', 'Diane', 'F.', 'Krane', '', 'Fabrikam Inc., West', 'adventure-works\michael9', 'diane4@adventure-works.com', '224-555-0126'),
(198, 'Mr.', 'Payton', 'P.', 'Benson', '', 'Field Trip Inc', 'adventure-works\michael9', 'payton0@adventure-works.com', '528-555-0183'),
(199, 'Mr.', 'Roger', '', 'Lengel', '', 'Authorized Bike Sales and Rental', 'adventure-works\pamela0', 'roger1@adventure-works.com', '947-555-0143'),
(200, 'Ms.', 'Peggy', 'J.', 'Justice', '', 'Basic Bike Company', 'adventure-works\david8', 'peggy0@adventure-works.com', '170-555-0189'),
(201, 'Ms.', 'Edna', 'J.', 'Benson', '', 'Unsurpassed Bikes', 'adventure-works\jillian0', 'edna0@adventure-works.com', '789-555-0189'),
(202, '', 'A.', 'Francesca', 'Leonetti', '', 'Two-Seater Bikes', 'adventure-works\jillian0', 'a0@adventure-works.com', '645-555-0193'),
(203, 'Ms.', 'Jean', '', 'Jordan', '', 'Separate Parts Corporation', 'adventure-works\shu0', 'jean3@adventure-works.com', '207-555-0129'),
(204, 'Mr.', 'Ido', '', 'Ben-Sachar', '', 'Traction Tire Company', 'adventure-works\linda3', 'ido0@adventure-works.com', '973-555-0112'),
(205, 'Mr.', 'Frank', '', 'Mart­nez', '', 'Rally Master Company Inc', 'adventure-works\shu0', 'frank5@adventure-works.com', '171-555-0147'),
(208, 'Mr.', 'Steve', '', 'Masters', '', 'Professional Cyclists', 'adventure-works\jos‚1', 'steve2@adventure-works.com', '154-555-0115'),
(209, 'Mr.', 'Robert', 'E.', 'Jones', '', 'Purple Bicycle Company', 'adventure-works\jos‚1', 'robert6@adventure-works.com', '595-555-0131'),
(210, 'Mr.', 'Josh', '', 'Barnhill', '', 'Gasless Cycle Shop', 'adventure-works\garrett1', 'josh0@adventure-works.com', '584-555-0192');
GO

INSERT INTO [dbo].[Order](
    [CustomerID],
    [OrderTotal])
VALUES
(55,213.56),
(55,31.56),
(55,3412.56),
(78,312.56),
(78,255.78),
(79,112.12),
(79,555.00),
(79,765.12),
(79,967.88),
(101,903.04),
(101,512.43),
(110,1250.00),
(110,325.68),
(204,112.99),
(205,107.43),
(205,895.21)
GO

--<<<<<<<<<<<<<<<<<<<<< Task 7 – Query Federation Data with Filtering off >>>>>>>>>>>>>>>>>>>>>
-- Route connection to the 1 Federation Member (aka shard)
USE FEDERATION CustomerFederation(cid=100) WITH RESET, FILTERING=OFF
GO
SELECT db_name() [db_name], db_id() [db_id]
SELECT * FROM sys.federation_member_distributions
-- Federatation ranges
SELECT f.name, fmc.federation_id, fmc.member_id, fmc.range_low, fmc.range_high 
FROM sys.federations f
JOIN sys.federation_member_distributions fmc
ON f.federation_id=fmc.federation_id
ORDER BY fmc.federation_id, fmc.range_low;
-- User tables count (federated & reference)
SELECT fmc.member_id,fmc.range_low,fmc.range_high,'[' + s.name + '].[' + t.name + ']' [name],
p.row_count FROM sys.tables t 
JOIN sys.schemas s ON t.schema_id=s.schema_id 
JOIN sys.dm_db_partition_stats p ON t.object_id=p.object_id  
JOIN sys.federation_member_distributions fmc ON 1=1 
WHERE p.index_id=1 ORDER BY s.name, t.name
GO
-- Query customer table for high/low Federated Keys
SELECT MIN(CustomerID) [CustomerID Low], MAX(CustomerID) [CustomerID High] FROM Customer
GO



--<<<<<<<<<<<<<<<<<<<<< Task 8 – Perform Federations Split Operation >>>>>>>>>>>>>>>>>>>>>
USE FEDERATION ROOT WITH RESET
GO
ALTER FEDERATION CustomerFederation SPLIT AT (cid=100)
GO

--<<<<<<<<<<<<<<<<<<<<< Task 9 – Wait for Split to complete >>>>>>>>>>>>>>>>>>>>>
--View the background Federation operations table (Rinse and Repeat Until Complete)
SELECT percent_complete, * FROM sys.dm_federation_operations
GO


--<<<<<<<<<<<<<<<<<<<<< Task 10 – Query Federation Members (again) >>>>>>>>>>>>>>>>>>>>>
-- Route connection to the Federation Root
USE FEDERATION ROOT WITH RESET
GO
SELECT * FROM sys.federations
SELECT * FROM sys.federation_member_distributions ORDER BY federation_id, range_low;
GO

-- Route connection to the 2nd Federation Member (aka shard)
USE FEDERATION CustomerFederation(cid=100) WITH RESET, FILTERING=OFF
GO

--Query metadata
SELECT db_name() [db_name], db_id() [db_id]
SELECT * FROM sys.federation_member_distributions

-- Query customer table for high/low Federated Keys
SELECT MIN(CustomerID) [CustomerID Low], MAX(CustomerID) [CustomerID High] FROM Customer

--Get all rows from Customers in this member
SELECT * FROM Customer
GO




--<<<<<<<<<<<<<<<<<<<<< Task 11 – Query data from Federation member with Filtering On >>>>>>>>>>>>>>>>>>>>>

--Route to the 2nd federation but with filtering on
USE FEDERATION CustomerFederation(cid=100) WITH RESET, FILTERING=ON
GO

-- Query customer table for high/low Federated Keys
SELECT MIN(CustomerID) [CustomerID Low], MAX(CustomerID) [CustomerID High] FROM Customer
--Get all rows from Customers
SELECT * FROM Customer
GO


--<<<<<<<<<<<<<<<<<<<<< Task 12 – Using the SSMS Tooling >>>>>>>>>>>>>>>>>>>>>
-- List federation members

--<<<<<<<<<<<<<<<<<<<<< Perform Additional Split Operation >>>>>>>>>>>>>>>>>>>>>
USE FEDERATION ROOT WITH RESET
GO
ALTER FEDERATION CustomerFederation SPLIT AT (cid=150)
GO

--<<<<<<<<<<Return to Deck>>>>>>>>>>>--








The next item are the fan-out queries I showed. These should be used in conjunction with the Fan Out Query demo tool that can be found at: http://federationsutility-scus.cloudapp.net/





-- FANOUT SAMPLES. Execute using Fanout tool

--Simple Count in each member
SELECT count(*) from Customer

--Simple Select *
SELECT * FROM Customer

-- ALIGNED QUERY with ALIGNED AGGREGATES
-- get total orders value by customer having > $1000
SELECT [order].customerid, SUM(ordertotal) 
FROM customer inner join [order] on customer.customerid=[order].customerid
GROUP BY [order].customerid
HAVING SUM(ordertotal)>1000

--OK to add some more detail from customer table. 
SELECT firstname,lastname,companyname,[order].customerid, SUM(ordertotal) 
FROM customer inner join [order] on customer.customerid=[order].customerid
GROUP BY [order].customerid,firstname,lastname,companyname
HAVING SUM(ordertotal)>1000


--So now to group by Company name. i.e. Non Aligned query
SELECT companyname, SUM(ordertotal) as ordertotal
FROM customer inner join [order] on customer.customerid=[order].customerid
GROUP BY companyname
HAVING SUM(ordertotal)>1000

--We need a post processing step to aggregate the aggregates
SELECT companyname, SUM(ordertotal) 
FROM #Table
GROUP BY companyname


-- ALIGNED QUERY with NONE-ADDITIVE AGGREGATES
-- avg order size per customer
-- OK because we are aggregating within the attomic unit
SELECT firstname,lastname,companyname,[order].customerid, AVG(ordertotal) 
FROM customer inner join [order] on customer.customerid=[order].customerid
GROUP BY [order].customerid,firstname,lastname,companyname

--NON-ALIGNED QUERY with NON-ADDITIVE AGGREGATE
--avg order size
--#FAIL
SELECT AVG(ordertotal) 
FROM [order]

-- success -- 
-- Average: get sum and count instead of avg
SELECT SUM(ordertotal) tot, 
    COUNT(*) cnt
FROM [order]

-- Summary Query: 
SELECT SUM(tot)/SUM(cnt) average 
FROM #Table 


--<<<<<<<<<<<<Back to Deck>>>>>>>>>>>>>>>--

-- deploy a new reference table and add some data
CREATE TABLE tab1(dbname nvarchar(128), secs int, msecs int, primary key (dbname, secs, msecs));
INSERT INTO tab1 values(db_name(), datepart(ss, getdate()), datepart(ms, getdate()));
SELECT * FROM tab1;

-- update stats on all members
EXEC sp_updatestats

-- #session per member
SELECT db_name() dbname, count(a.session_id) session_count
FROM sys.dm_exec_sessions a

-- #session per member
SELECT TOP 5 db_name(),query_stats.query_hash AS "Query Hash", 
    SUM(query_stats.total_worker_time) / SUM(query_stats.execution_count) AS "Avg CPU Time",
    MIN(query_stats.statement_text) AS "Statement Text"
FROM 
    (SELECT QS.*, 
    SUBSTRING(ST.text, (QS.statement_start_offset/2) + 1,
    ((CASE statement_end_offset 
        WHEN -1 THEN DATALENGTH(ST.text)
        ELSE QS.statement_end_offset END 
            - QS.statement_start_offset)/2) + 1) AS statement_text
     FROM sys.dm_exec_query_stats AS QS
     CROSS APPLY sys.dm_exec_sql_text(QS.sql_handle) as ST) as query_stats
GROUP BY query_stats.query_hash
ORDER BY 2 DESC;

As always… feel free to flick across comments or questions.

|Monday, September 17, 2012 4:51:04 AM UTC|Comments [0]|    

 Wednesday, May 02, 2012
Microsoft Dynamics Connector “Unable to Connect”

Just a quick post for those who make strike the error with the Dynamics Connector. There is a issue if you have installed the WIndows Azure AppFabric SDK on the same box. Uninstall the AppFabric SDK and you will be golden.

Dynamics AX | Dynamics CRM|Wednesday, May 02, 2012 8:04:01 PM UTC|Comments [0]|    

 Tuesday, December 13, 2011
Taking Nice Party Photos


So I’m a big fan of taking available light photos. This is particularly good fun at Wedding parties and Christmas parties.

I took a bunch of photos at the Intergen Office Christmas party last Friday night and I’ve had a bunch of people ask “what camera etc… were you using”. SO I thought I’d take a few minutes and write up a post with some notes on taking available light party photos.

So the trick to taking nice party photos is not using a flash. To do this you need a couple of things;

  1. A camera that has a decent High ISO noise level.
    ISO is an interesting term in that it goes back to the film days. The ISO (International Standards Organization) measure basically set a standard for the sensitivity of film to light. A high ISO film required less light to create an image, but, a high ISO film also typically produced photos with much more noticeable film grain. In the digital age we still use the term ISO but this time it’s basically referring to the amount of light required by the sensor in order to create an image; while the ISO of a roll of film was fixed we can change the camera ISO (sensitivity) at will because it’s basically just turning up the Gain (a camera sensor is effectively an analog-digital interface). If you’ve ever played with other things that have a Gain knob you’ll know if you put a small signal in and try and use the gain knob to boost it things can get a bit ugly- so it is with camera ISO if you turn the gain up too much things get noisy.
    So to get the nice party photos with available light (no flash and as such relying on not much light) you need a camera that lets you turn the gain up with out getting too noisy. The original ‘super amazing’ low light Camera was probably the Canon EOS 5D Mk II which is now about 3 years old. Indeed it is this camera that I used for most of the shots. It’s an expensive ($5k) body, but, over the past few years that super high ISO technology has filtered down such that you can get pretty decent looking shots from most $1000 bodies at ISO of 1600-6400 (to give you an idea of how revolutionary this is it would be very rare for anyone other than a professional to shoot film higher than ISO400 back in the day. Thus the modern digital cameras are several times more sensitive for the same level of noise than film was ever able to achieve)
    I’m a Canon person so that’s where my recommendations will sit and I think there’s not a lot wrong with the Canon 600D body in the $1000 price point. Take a look at these high ISO shots from DPReview. There will be similarly good options from Nikon in the price point which people can point out in the comments. The benefit of getting the $1000 body is you have more moolah to spend on lenses…
  2. The second thing you’ll need is a lens with a large maximum aperture.
    You can tell the maximum aperture of your lens by reading it off the lens. It will be expressed as a ratio on the front ring e.g. 1:1.8 but it’s typically shortened in conversation and marketing to just the denominator. For the tech boffins the F-Stop (Aperture) is basically expressed as a ratio of the focal length of the lens. The lower the F stop number the larger the aperture- a bit counter-intuitive I know.
    For a zoom lens about the largest F stop you’ll get is F2.8 and even then you’ll be paying big bikkies and they weight a ton. There are a few shots in the party photos that are taken using an 70-200mm F2.8 lens.
    What you really want is a ‘prime’ lens. This is a lens with no zoom. Most of the shots taken in the party set above were taken with a Sigma 50mm F1.4 lens (this is a mid-range prime lens in terms of cost) but, for the most part I have it ‘stopped down’ to F1.8. This is for two reasons 1) wide open a mid-range lens like this can lose a bit of sharpness particularly around the edges and 2) A side effect of a large aperture is a very shallow depth-of-field; in the case of F1.4 on a 5D MkII with the subject at 2m only 11cm of depth will be in sharp focus. You’ll see this shallow depth of field in most of the low light photos as either a nice blurry background or as an annoying fact that of two people in the photo only one is in focus.
    So. Which lens to get. This is a place where Canon has a real advantage. If you are not ken to spend much money there is a Canon lens, the 50mm F1.8 MkII (plastic fantastic) that for under $200 will let you take nice party photos too. To me this is almost as good a reason as any to prefer Canon over Nikon at the cheap pricepoint cameras.
    If you have a bit more money to spend both the Canon and Sigma 35mm/50mm/85mm primes are great for under $1000.
    And finally if you have plenty of money go buy a Canon 85m F1.2 for shots like this one I took on a borrowed lens.

So this post became a bit of a ramble. To answer the more direct question of what I used for the party photos.

Canon 7D Body (early evening) with a Canon 24-105 F4 zoom
Canon 5D (low light) with a mixture of Sigma 50mm 1.4, Carl Zeiss 85mm 1.4 and Canon 70-200mm 2.8

  \

Intergen | Photography | Rambles|Tuesday, December 13, 2011 7:40:21 PM UTC|Comments [0]|    

 Thursday, October 27, 2011
What does compulsory Kiwisaver @ 9% do to small business startup capital

I’ll start this post by stating that I am generally supportive of Kiwisaver as a scheme. I deeply regret the decision taken by the national government to remove the ‘carrot’ from the scheme and would much sooner have seen them scrap the bat-shit crazy interest free student loans rort to make their numbers.

So I am a little torn with the new Labour policy for compulsory Kiwisaver. I think there are a few things we can all agree on

  1. It will suppress wage growth. DPF posts on that here including a Labour party admission of such.
  2. Kiwisaver is a "low risk” or conservative investment. Even if you pick the Forsyth Barr build your own scheme and load up on equities you’ll still be buying bluechips and not speccy mining shares.
  3. 9% of pre-tax income is a relative SHITLOAD of money for most people and would, I suspect, represent the entirety of investment income for  the 99% (post written about the time the smelly hippies were occupying Aotea Square)
  4. Saving and investing (rather than spending) is a good thing and as a country we don’t really do enough of it
  5. At 9% of pre-tax income Kiwisaver will impact the common kiwi savings vehicle of the family home. People will be slower at paying off their mortgages (yes even will all the mortgage diversion stuff)
  6. Banks aren’t particularly interested in letting you gear against your Kiwisaver assets

So beyond all the usual stuff that’s been discussed today I have one really major concern with compulsory Kiwisaver

It’s going to knock the stuffing out of small business startup capital. Basically the money that many people would have put into a liquid investment such that they could draw down to start a business will instead be locked away in a conservative investment vehicle until they are 65. Now starting your own business is risky to be sure, but, are we really saying that someone on $80k in a solid job should be denied the opportunity to put their money aside to invest in their own venture?

What do others think?

People will point to the success of compulsory super at these kinds of pre-tax levels in Australia, but, the Australian scheme is quite different to Kiwisaver and in particular their Self Managed Super Funds provide some relief to the above concerns.

The argument about whether small business owners can bear the burden of these Kiwisaver payments is somewhat moot if they were never in a position to start their small business in the first place.

Business Building | Politics|Thursday, October 27, 2011 7:41:04 AM UTC|Comments [0]|    

 Wednesday, September 21, 2011
Nice Cheap Helmet Cameras

So unless you’ve been living in a cave you’ll be aware of how rad helmet cams are for the adventure sports inclined amongst us. I held off buying one for quite a long time because they have been FREAKING expensive. The other issue is that the ‘industry standard’ GoPro HD makes you look like a total mongtard when you are wearing it.


Figure 1: How to look like a gaper mong!

So I really like the look of the cameras from Contour. They have recently announced the Contour ROAM which is their new budget camera at $199. But, this post isn’t about that new camera. It’s nice and all with more waterproofing that the original ContourHD, but, it lacks the 720p 60fps mode which I think is critical to nice footage in fast moving environments.

Instead this post is about the CountourHD; because it’s basically been replaced by these newer models it’s available super cheap. It supports full HD 1080p as well as the important 720p at 60fps mode.

Figure 2: How to not look like a gaper mong!

It can be had at Backcountry at the moment for about US$140 (http://tinyurl.com/contour-backcountry). If you’ve been in the market I think this is the deal to snag! Shipping is a bit to New Zealand but it’s still waaay cheaper than buying locally. Particularly if you get a spare battery and a few other things in the same order and/or order with friends.

Adventure Sports|Wednesday, September 21, 2011 10:18:59 PM UTC|Comments [0]|