Easy way to lock your Mac.
When I switched from a Windows box to a Mac, oddly enough the thing that I missed the most was the Windows+L hotkey to lock my screen. I tend to work in coffee shops and restaurants a lot, and if I get up to get something to drink or stretch my legs, I don’t like to leave my computer wide open. I know, someone could always go for the grab, but I’m just interested in discouraging the idly curious.
After googling around a little, I found out about the Login Window menu item (accessed through your user name in the menu bar), which is nice. But I was poking around with System Preferences (under the apple menu) yesterday and I came across the Exposé feature. It lets you assign actions (like run the screensaver) to “hot corners” of your display. Now, all I have to do is drag my mouse to the lower-right corner of my screen and the screensaver pops up. Almost as good as the old hotkey!
Free Internet at Starbucks (finally)!
Ok, so I’ve ended my long-running (5+ years?!?) feud with Starbucks because I can now get free Internet. In fact, I’m typing this from the Starbucks at the Columbiana Mall right now. The secret steps to getting your free access are:
1) Buy a Starbucks gift card. The minimum amount is $5, so guess how much I paid.
2) Fire up your laptop and look for a link on the free WiFi greeting page about “Complimentary Wifi”.
3) You’ll need to create a free Starbucks.com account using the new gift card # and the secret PIN (which you have to scratch-off).
4) Enjoy the yummy free WiFi!
The mother of all dynamic SQL Crosstab View Builders.
Ok, so maybe it’s not too poetic, but it’s descriptive. As I found myself writing a dynamic crosstab-query builder in MS SQL for probably the fifth time of my career, I decided I’d post it here to save you all just a little time in your day. Make sure you use the saved time for something I’d approve of (smoking a good cigar, playing a little poker, something like that).
This proc is designed for when you have a dynamic set of row-oriented data you want to pivot and show column-wise. It takes four parameters:
@tableName – Name of the source table (or view) that will be queried by the new crosstab view.
@excludeCols – A comma separated list of columns to exclude from the crosstab. In most cases, will be the ID column of the table.
@valueColName – Name of the column in the @tableName table that contains the value in a given row.
@targetViewName – Name of the view that the stored procedure will create. It will *automatically* drop this view before re-creating it, so be warned.
This proc also assumes that the @tableName table (or view) has a column called [colName]. It uses this value to create the corresponding columns across the top of the output view.
Good luck!
ALTER PROCEDURE BuildCrosstabView(
@tableName VARCHAR(100),
@excludeCols VARCHAR(1000),
@valueColName VARCHAR(1000),
@targetViewName VARCHAR(100)
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @cols VARCHAR(4000)
SET @cols = ''
EXEC ('SELECT DISTINCT colName INTO ##colList FROM ' + @tableName)
DECLARE col_cursor CURSOR FOR
SELECT colName
FROM ##colList
OPEN col_cursor
DECLARE @colName VARCHAR(100)
FETCH NEXT FROM col_cursor INTO @colName
WHILE @@FETCH_STATUS = 0
BEGIN
IF @cols <> ''
BEGIN
SET @cols = @cols + ', '
END
SET @cols = @cols + 'MAX(CASE colName WHEN ''' + @colName + ''' THEN ' + @valueColName + ' ELSE NULL END) AS [' + @colName + ']
'
FETCH NEXT FROM col_cursor INTO @colName
END
CLOSE col_cursor
DEALLOCATE col_cursor
DROP TABLE ##colList
DECLARE @sql VARCHAR(3000)
SET @sql = 'SELECT DISTINCT ' + @excludeCols + ', ' + @cols + ' FROM ' + @tableName + ' GROUP BY ' + @excludeCols
PRINT @sql
EXECUTE (@sql)
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[' + @targetViewName + ']'))
EXECUTE ('DROP VIEW ' + @targetViewName)
EXECUTE ('CREATE VIEW ' + @targetViewName + ' AS ' + @sql)
END
GO
The birth of BlinkStory.
As some of you know, I’ve started doing iPhone development recently. Between me and the Mikes (Old and New) we’ve thrown around a couple of hundred possible applications. We’re currently developing one called CashCurrent (in conjunction with another company, GraySail), but while I had some downtime on that project we decided to launch another one.
Yesterday at lunch, New Mike and I were watching O.J. get sentenced and it occurred to us that it would be great if there were a news site that turned everyone with an iPhone into a reporter. We would be seeing news as it actually happened, with millions of eyes out there to catch it on camera. After spending three or four hours going through various names, BlinkStory
I love you Dave!
Ok, that came out a little funny, but I just finished repairing my dryer with a part I got from the Appliance Repair site run by Dave Harnish. When my dryer stopped working last Sunday, I thought “uh-oh, Best Buy here I come”. But times are tight and I thought I’d do a little research before trashing the thing. I’m glad I did.
I found a troubleshooting guide on Dave’s site, and even though I initially mis-diagnosed the problem as a bad heating element, Dave’s prompt email diagnosis got me back on track. One $20 part later and I’m back in business. Thanks Dave!
