Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@niaher
niaher / test-sql-server-connectivity
Created October 25, 2021 00:51
Test connectivity to a local or remote SQL Server database using PowerShell
function Test-SqlConnection {
param(
[Parameter(Mandatory)]
[string]$ConnectionString
)
$ErrorActionPreference = 'Stop'
try {
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $ConnectionString
@niaher
niaher / deploy-sqlproj
Last active April 2, 2019 08:16
MSDeploy script
msbuild "MyApp.Database/MyApp.Database.sqlproj" `
/t:"Build;Publish" `
/p:SqlPublishProfilePath="MyApp.Database.automated-tests.publish.xml" `
/p:UpdateDatabase=True `
/p:PublishScriptFileName="publish-script.sql"

Keybase proof

I hereby claim:

  • I am niaher on github.
  • I am niaher (https://keybase.io/niaher) on keybase.
  • I have a public key ASBktBkUBBhH4rZTMKTq-GQt26QcxCoLnnj4-F9hNkQK5go

To claim this, I am signing this object:

@niaher
niaher / excel-download-images-from-url
Last active July 16, 2023 00:22
Excel macro (VBA script) to download images based on the URL specified in the cells
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Public Sub GURoL(url As String, FileName As String)
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, url, FileName, 0, 0)
@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++) {
# This script configures IIS application pool and app.
# example usage:
# PS> init-server.ps1 -AppName MyApp -TargetComputers computer1,computer2 -PSSessionUser $(PSSessionUser) -PSSessionPassword $(PSSessionPassword) -AppPoolUser $(AppPoolUser) -AppPoolPassword $(AppPoolPassword)
param(
[Parameter(Mandatory=$true)][string]$AppName,
[string]$TargetComputers,
[string]$PSSessionUser,
[string]$PSSessionPassword,
[string]$AppPoolUser,
@niaher
niaher / server-setup.ps1
Last active April 2, 2019 08:17
This script configures IIS application pool and site. It needs to be run once on each machine where the app is deployed. Run it in powershell with admin rights. For example to deploy release config run `server-setup.ps1 -Target release`
# This script configures IIS application pool and site.
# This script needs to be run once on each machine where the app is deployed.
# Run this file in powershell with admin rights. For example to deploy release config:
# PS > server-setup.ps1 -Target release
param (
[Parameter(Mandatory=$true,
HelpMessage="Name of the build (e.g. - local, debug, release, etc)")]
[string]$Target
)
.list-csl {
display: inline;
list-style: none;
padding:0;
li {
display: inline;
}
li:after {
@niaher
niaher / Resources.tt
Last active January 11, 2024 16:00
T4 template to generate list of files that are part of the project. This template is useful for generating list of css/js resources to be put in bundle. The value comes from the fact that files which are not part of the project (e.g. - excluded files) will not actually be included in the resulting list.
// This is an auto-generated file.
<#@ template language="C#" hostSpecific="true" debug="True" #>
<#@ output extension="cs" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="EnvDte" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ import namespace="System" #>
@niaher
niaher / gist:cccc35ae58076095784e
Created July 9, 2015 11:19
Update column counter per group
;with Counters as (
select Id,
row_number() over (partition by GroupingColumn order by GroupingColumn asc) as [Counter]
from RequisitionLine
)
update T
set T.[Counter] = C.[Counter]
from MyTable T inner join Counters C on T.Id = C.Id