Skip to content

Instantly share code, notes, and snippets.

@niaher
niaher / gist:f09803834dd133d7b215
Created July 2, 2015 11:35
List identical files in 2 folders
$one = Get-ChildItem "C:\x" -Recurse -Include @("*.html", "*.js")
$two = Get-ChildItem "C:\y" -Recurse -Include @("*.html", "*.js")
Compare-Object -ReferenceObject $one -DifferenceObject $two -Property Name,Length -ExcludeDifferent -IncludeEqual
@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);
@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: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 / 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 / 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;
function Read-Query
{
param (
[Parameter(Mandatory=$true)]
[string]$ConnectionString,
[Parameter(Mandatory=$true)]
[string]$Query,
[Parameter(Mandatory=$true)]
function Invoke-Using {
param (
[Parameter(Mandatory=$true)]
[System.IDisposable]$Disposable,
[Parameter(Mandatory=$true)]
[ScriptBlock] $Script
)
Try {
@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 / Create login and user
Created July 25, 2013 08:48
Creates SQL login and user for a database. The user is created with 3 roles: db_executor, db_datareader, db_datawriter.
/*------------------------------------------------------------------------------------
Server login
-----------------------------------------------------------------------------------*/
if not exists (select 1 from sys.server_principals where name = N'MyDatabaseUser')
create login [MyDatabaseUser]
with password = 'password',
default_database = [MyDatabase],
check_policy = off,
check_expiration = off
go