Posts

Showing posts from 2014

Determine the column types returned from a Stored Procedure

Say you have a stored procedure that does something like this: SELECT A.id, 10.0 * A.number / B.number AS Computed FROM Table1 A JOIN Table2 B on A.id = B.id What is the resulting type of the "Computed" column? Decimal? Float? The following SQL 2012 will tell you the data types of the columns from the first returned data set of a stored procedure: SELECT name, system_type_name FROM sys.dm_exec_describe_first_result_set_for_object (OBJECT_ID('myNamespace.mySPROC') NULL ); This will give a nice table that contains the column name and system data type name system_type_name --------------------- ---------------------- Id bigint Computed float

Getting Git Code Management

I am now the code manager for the public repository of a project that takes pull requests from several active forks and has tagged releases. The problem is, that I've not found any single resource that covers advanced code management using Git. My local repository has multiple upstream sources that I synchronize. All are hosted at github.com. This post is going to be a collection of little Git recipes. Many of them are collected from somewhere else, but others are more specific to the code management processes Configure git for certificate-based credentials for multiple logins Generate certificate I was able to get this working by following the instructions  here . However, I also needed to add some commands to my "~/.basrc" file to provide my SSH credentials to the git/bash shell window. Each ssh-add command adds one certificate to the identity store. #! /bin/bash eval `ssh-agent -s` ssh-add ~/.ssh/github_rsa ssh-add ~/.ssh/github_admin_rsa Make the local co...

MSSQL Statistical Z-Score

Computing the z-score of individual values in SQL Server is not a built in function (although average and standard deviation are). The z-score tells us how far off from the average value the individual values are. The following function computes the z-score: for a table named [data] having an [objectId] and [score] fields. SELECT [D].[objectId], [D].[score], [E].[avg_score], [E].[stdev_score], ([D].[score] - [E].[avg_score]) / [E].[stdev_score] as zvalue FROM [data] D CROSS JOIN (SELECT Avg(CAST([score] as float)) as [avg_score], StDevP([score]) as [stdev_score] FROM [data] ) E ;

Bootstrap Menus and EmberJS

Image
I love Bootstrap. Mostly because I'm not a very good graphic designer; but also because I'm lazy. I like the things it does for me that make my websites suck less. One of those things is the Bootstrap menu. One of the nice features of the Bootstrap menu is that you get a gradient highlight when the menu has a "selected" css class applied to it. I am looking at EmberJS . Ember has lots of nifty features as well. As a Single Page Application (SPA) framework, it likes to handle URL routing, and does something especially nifty with links that it manages: It applies a "selected" class to the current URL. Did the stars just align? Is this too good to be true? "Um, yea. Why?" Well, they almost align. It turns out that Bootstrap wants to have a "selected" css class applied to the list item that contains the anchor tag for the menu item while Ember's linkTo helper applies it directly to the anchor tag . Ouch. In other words, th...

Access web.config settings from your JavaScript

When you create a set of interconnected web applications, or a mobile application that accesses a web service back-end, you have different service addresses that need to make their way into your JavaScript. Visual studio has XML transformations that apply to the app.config or web.config files, depending upon your build configuration, but that doesn't do you a lot of good if your client-side JavaScript is looking for the appropriate settings. You can isolate those settings in a single JavaScript file, but that file needs to change when you deploy to the web or the cloud. Here is a simple solution: Create an IHTTPHandler that reads all the application settings from your web.config file and transforms them into a constant object (named appSettings) containing all the application settings. Add the reference to this "dynamic" JavaScript in your master page template. As a HTTP Handler, it is fast, and because IsReusable is set, it is cached too. /// /// Summary de...

KnockoutJS, WebAPI, and TypeScript

Image
JavaScript is not Java As Brent so famously once said "JavaScript is not Java". My reply was "Dynamic, loosely typed, AND case sensitive...yea, that'll work". I tried to ignore JavaScript, hoping it would go away. jQuery helped a lot, but it still felt loose and dirty. Somebody out there heard my complaints. My biggest complaint with JavaScript has always been that it didn't have any concept of types, and you got very poor build-time support from development environments. Enter TypeScript I believe that Anders Hejlsberg would have been one of the great contributors to software developers productivity just for TurboPascal, Delphi, or C#, or .NET, but his work to modernize without breaking JavaScript through TypeScript , I predict will be far more reaching than any of the others. Add to that the fact that Microsoft has made TypeScript open source, and that it has IDE support in Eclipse and Visual Studio (among others), and you have the makings of a perfe...