Skip to content

Instantly share code, notes, and snippets.

function Invoke-Using {
param (
[Parameter(Mandatory=$true)]
[System.IDisposable]$Disposable,
[Parameter(Mandatory=$true)]
[ScriptBlock] $Script
)
Try {
function Read-Query
{
param (
[Parameter(Mandatory=$true)]
[string]$ConnectionString,
[Parameter(Mandatory=$true)]
[string]$Query,
[Parameter(Mandatory=$true)]
@niaher
niaher / Ladda - angular directive
Last active August 29, 2015 14:05
Angular directive for Ladda (http://lab.hakim.se/ladda/). There are other variations, but this one provides the automatic progress increment which looks natural.
// https://gist.github.com/niaher/8b7925c2584182127f53
'use strict';
angular.module('ui.ladda', []).directive('laddaButton', ["$q", function ($q) {
function run(ladda) {
ladda.start();
var progress = 0;
var timeout = null;
@niaher
niaher / Coderful.Persona.js
Created September 1, 2014 07:00
Mozilla Persona - Angular directive
angular.module("coderful.persona", [])
.constant("navigator", window.navigator)
.provider("persona", [
"navigator", function(navigator) {
var loginUrl;
var logoutUrl;
var getUser = angular.noop;
this.init = function(options) {
options = options || {};
@niaher
niaher / gist:15613cb141be76d83ce3
Last active August 29, 2015 14:05
sp-blog-markdown
(function(){
function loadGist(element, gistId) {
var callbackName = "gist" + gistId;
var script = document.createElement("script");
script.src = "https://gist.github.com/" + gistId + ".json?callback=" + callbackName;
window[callbackName] = function (gistData) {
delete window[callbackName];
var html = '<link rel="stylesheet" href="' + gistData.stylesheet + '"></link>';
html += gistData.div;
@niaher
niaher / gist:45ff5cae879eaa1d38c0
Last active August 29, 2015 14:05
blog-sample-gist
// This is a simple github gist.
console.log("hello world!");
@niaher
niaher / gist:7e1ea413646d4f5a438a
Last active August 29, 2015 14:13
TFS website: add support for links to backlog/buglist
<style>
.link {padding:2px 3px; border-radius:3px; display:inline-block; margin:0 5px; border:1px solid}
.link.story {background:#A7EEFF; border-color:#8EC7D8}
.link.issue {background:#4CFF85; border-color:#6DC295}
</style>
<script>
(function() {
$(document).ajaxComplete(initTags);
.list-csl {
display: inline;
list-style: none;
padding:0;
li {
display: inline;
}
li:after {
@niaher
niaher / Print row values
Created November 14, 2013 11:43
Here is the SQL code to print a row of from any table. All you have to do is modify the @tableName and @whereClause variables. Works only in MS SQL 2005+
DECLARE @tableName varchar(100)
DECLARE @whereClause varchar(100)
SET @tableName = 'Customers'
SET @whereClause = 'WHERE id = 999'
DECLARE @table TABLE(id int identity(1, 1), name varchar(100))
INSERT INTO @table (name)
SELECT name FROM sys.columns WHERE object_id = OBJECT_ID(@tableName)
@niaher
niaher / paginator.js
Created May 6, 2016 05:17
"pagination" factory for angular
angular.module("paginator", [])
.service("base64", function() {
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function utf8Encode(string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {