Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0"?><DTS:Executable xmlns:DTS="www.microsoft.com/SqlServer/Dts" DTS:ExecutableType="SSIS.Package.2">
<DTS:Property DTS:Name="PackageFormatVersion">3</DTS:Property>
<DTS:Property DTS:Name="VersionComments"></DTS:Property>
<DTS:Property DTS:Name="CreatorName">JSNAPEHOME\James</DTS:Property>
<DTS:Property DTS:Name="CreatorComputerName">JSNAPEHOME</DTS:Property>
<DTS:Property DTS:Name="CreationDate" DTS:DataType="7">4/16/2009 6:58:04 PM</DTS:Property>
<DTS:Property DTS:Name="PackageType">5</DTS:Property>
<DTS:Property DTS:Name="ProtectionLevel">1</DTS:Property>
<DTS:Property DTS:Name="MaxConcurrentExecutables">-1</DTS:Property>
<DTS:Property DTS:Name="PackagePriorityClass">0</DTS:Property>
#region Copyright (c) Microsoft Limited, all rights reserved.
// Copyright (c) Microsoft Limited, all rights reserved.
// THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
#endregion
using System;
using System.Collections.Generic;
using System.Text;
@jsnape
jsnape / git-functions.ps1
Last active February 1, 2023 21:29
Git PowerShell Functions
# This one fetches the latest, prunes remote tracking branches,
# updates main and returns to your current branch ready for you
# to merge from main/origin
function gitrefresh {
param ([string] $mainline = 'main')
## Save the current branch
$gitBranch = & git rev-parse --abbrev-ref HEAD
git checkout $mainline
<#
.SYNOPSIS
Configures the repo permissions to restrict branch names.
.DESCRIPTION
Branches should be master, release/, hotfix/, feature/ etc
This script ensures that they are.
#>
[CmdletBinding(PositionalBinding)]
param(
@jsnape
jsnape / Get-ResourceOwner.ps1
Created February 25, 2021 09:42
Cmdlet to list resource groups and owners so you can track down who is using your Azure credit
[CmdletBinding()]
param ([switch] $Recurse)
$users = @{}
function GetRoles {
param($assignments, $RoleDefinitionName)
$roles = $assignments |
Where-Object { $_.RoleDefinitionName -eq $RoleDefinitionName} |
@jsnape
jsnape / IWorkerPermitPolicy.cs
Last active March 25, 2021 11:52
Snowflake Sequence Generator
using System.Threading.Tasks;
/// <summary>
/// IWorkerLeasePolicy interface definition.
/// </summary>
public interface IWorkerPermitPolicy
{
/// <summary>Initializes the specified maximum workers.</summary>
/// <param name="maxWorkers">The maximum number workers.</param>
/// <param name="sequenceSizeBytes">The sequence size in bytes.</param>
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
namespace Foo
{
using System;
using System.Linq;
using System.Linq.Expressions;
Import-Module posh-git
Set-StrictMode -Off
# Get Account for the logged on user
function Get-WhoIAm {
$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
# Create a new object
Write-Output (New-Object -TypeName PSCustomObject -Property ([ordered] @{
Account = $windowsIdentity.Name
@jsnape
jsnape / EnumerableDataReader.cs
Created April 16, 2020 10:36
EnumerableDataReader.cs
// Copyright 2013 James Snape
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@jsnape
jsnape / extract.ps1
Created December 7, 2019 13:47
Script to Web scrape BCP Council Election results
Install-Module -Name PowerHTML -Scope CurrentUser
Import-Module PowerHTML
$resultPages = @(
'alderney-bourne-valley-results.aspx'
'bearwood-merley-results.aspx'
'boscombe-east-pokesdown.aspx'
'boscombe-west-results.aspx'
'bournemouth-central-results.aspx'
'broadstone-results.aspx'