Monday, July 25, 2016

Multiple Google Hangouts Accounts on Desktop

If you're like me, you have many many google apps accounts, for business, personal, or varying other purposes. For me, this works fine on my android device, where the Hangouts app is designed to support as multiple identities just fine. However, on my desktop, where I spend most of my day, the Hangouts Chrome app lacks this support.

There is an official work around suggested by Google's support team. Until recently, this work around was sufficient. By enabling the Chrome app launcher, I could open the Hangouts app from each account by changing profiles from the hamburger menu in the app launcher. However, Google is deprecating the Chrome app launcher.

Without the app launcher, getting Hangouts open with multiple profiles requires opening a chrome window, opening the app page, and finding and clicking the Hangouts app, then repeat for each profile. This is too many steps to feel efficient for me, and since Hangouts is an integral tool for my daily business, I must have it open at all times, and I need a fast way to get it running.

Enter shortcuts.

Today I finally found the best solution so far. Using Chrome app shortcuts. 

Chrome.exe supports two very useful parameters: profile-directory, and app-id. When you choose "Create shortcuts..." from the right click menu on chrome://apps, the shortcuts created include these two parameters so that the resultant app shortcut is bound to the profile from which you created it.

Choosing this option only offers one place to create the shortcut (Desktop) but fortunately, Chrome is smart enough to save an additional copy of the same shortcut in the Start Menu (specifically: AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Chrome Apps) so there is no need to keep the desktop shortcut around. We can rename these shortcuts to help us quickly find and launch a Hangouts app for each profile.

Incidentally, these shortcuts are profile bound not by any logical account id, but rather by account order. They use --profile-directory="Default" and --profile-directory="Profile 1" arguments to launch the app. So if you find yourself disconnecting and reconnecting your profiles in Chrome, your shortcuts may stop working or start launching the app with the wrong profile.

Wednesday, January 14, 2015

SQL: Convert a Hash to a Varchar

For some reason this task always stumps me, so here is the solution:
CONVERT([varchar](512), hashbytes('sha', col), 2)
Thanks to Basit

Friday, October 12, 2012

JQuery Validate: Change Option Value

In my current project I have a default set of options that every form gets validated with. In fact, .validate(options) is called for every form.

Today I needed to change one of the options that my form validator was initialized with. Sounds pretty simple, but for the life of me I couldn't find anything like setOption() or .validate("option", {}) like other plugins have.

Turns out that Validate actually makes it too simple. Where other plugins give you non-standardized functions to update the options, Validate gives you the options object directly... but they call it settings.

I can disable the auto onsubmit validation by doing the following:
$("#myForm").validate().settings.onsubmit = false;
This works because .validate() returns the current validator for the form, and the validator neatly exposes the settings collection.

Wednesday, April 25, 2012

Extending QueryOver With "Or"

QueryOver (introduced in NHibernate 3.0) offers type safe, Linq-esque, syntax for writing Nhibernate queries in your DAO. However, writing a multiple column disjunction with anything other than simple operators can easily become ugly and unwieldy.

Tuesday, March 13, 2012

T-SQL: Aggregate a column to a comma delimited list

I commonly encounter situations where it is useful to select a comma delimited list as an aggregate in a grouped query. This is a well known problem and yet each time I run across it I have to look something up to solve it.

The following is a detailed breakdown of the solution from the msdn archive.

The scenario I'm covering here is the need to aggregate all the IDs in a joined table into a single column on the master table. We'll use a table structure like this:
  Id int NOT NULL identity,
  Name varchar(50) NOT NULL,
  Children varchar(256) NULL,
  Id int NOT NULL identity,
  ParentId int NOT NULL,
  Name varchar(50) NOT NULL
Create some sample data:
INSERT INTO Parent (Name)
VALUES ('Parent 1'), ('Parent 2'), ('Parent 3')
INSERT INTO Child (ParentId, Name)
VALUES (1, 'Child 1'), (1, 'Child 2'), (1, 'Child 3'), (2, 'Child 4'), (2, 'Child 5'), (3, 'Child 6'), (3, 'Child 7'), (3, 'Child 8'), (3, 'Child 9')
Now we can update the Children column on Parent with this:
t AS (SELECT p1.Id, Children = (
    SELECT (',' + convert(varchar, c2.Name ))
    FROM Parent p2
      JOIN Child c2 ON p2.Id = c2.ParentId
    WHERE p2.Id = p1.Id
    ORDER BY c2.Id
    FOR XML PATH( '' )
  ) + ','
  FROM Parent p1
    JOIN Child c1 ON p1.Id = c1.ParentId
  GROUP BY p1.Id)
SET Children = t.Children
FROM Parent p
  JOIN t ON t.Id = p.Id
And the results look like:
Id | Name | Children
1 | Parent 1 | ,Child 1,Child 2,Child 3,
2 | Parent 2 | ,Child 4,Child 5,
3 | Parent 3 | ,Child 6,Child 7,Child 8,Child 9,