Skip to content

Instantly share code, notes, and snippets.

@leniency
leniency / DebounceAttribute.cs
Created Nov 5, 2018
Job filter for Hangfire.io that throttles executions with a debounce filter. Multiple calls to the action will be ignored and only a single instance queued after the lock timout.
View DebounceAttribute.cs
/// <summary>
/// A debounce rate limitor for Hangfire background jobs. This puts a
/// timeout lock on the action when it is first enqueued and schedules it
/// for the end of the lockout. Any further calls within the lock period are discarded.
/// </summary>
/// <remarks>
/// General references:
/// https://gist.github.com/odinserj/334fdb7d18bd63451f2f34546985f639
/// https://gist.github.com/odinserj/a8332a3f486773baa009
/// </remarks>
View AzureDomainTransfer.ps1
$ResourceLocation = "Global"
$ResourceGroup = "RESOURCE GROUP"
$ResourceName = "DOMAIN NAME"
$PropertiesObject = @{
'Consent' = @{
'AgreementKeys' = @("DNPA","DNTA");
'AgreedBy' = 'IP ADDRESS';
'AgreedAt' = '2017-04-23T04:07:00.0000000Z';
};
'authCode' = 'AUTH CODE';
@leniency
leniency / AutofacServiceLocator.cs
Created Jun 7, 2018
Some extensions for Hangfire and Autofac. Allows multiple background tasks to be queued for Hangfire processing. Simply call the interface method - autofac resolves the concretes and then the extension will queue the method calls.
View AutofacServiceLocator.cs
/// <summary>
/// Implementation of the IServiceLocator.
/// Mostly from https://github.com/autofac/Autofac.Extras.CommonServiceLocator,
/// minus the dependencies.
/// </summary>
public class AutofacServiceLocator : IServiceLocator
{
/// <summary>
/// The <see cref="Autofac.IComponentContext"/> from which services
/// should be located.
@leniency
leniency / kendo.extensions.popup.js
Last active Nov 2, 2015
Extension for kendo popups to automatically append them to Bootstrap modals, if no other append set.
View kendo.extensions.popup.js
;//
// Popup extension.
// Sets up kendo popups (used in all sorts of widgets) to check if the widget
// is being included in a bootstrap modal. If so, the popup should append to
// the modal instead of the page body.
//
// For the most part, popups work fine without this. However, DropdownList with
// a filter option does not. This is because the filter attempts to focus on
// filter input, which is outside the modal By default, Bootstrap modal will
// block this. It has an option to allow, but then it must be remembered to add
View Init-WebServerAzureVM.ps1
##################################################
#
##################################################
param(
[Parameter(Mandatory = $true)][String]$subscriptionId,
[Parameter(Mandatory = $true)][String]$storageAccountName,
[Parameter(Mandatory = $true)][String]$affinityGroupName,
[Parameter(Mandatory = $true)][String]$imageName = 'MSFT__Windows-Server-2012-Datacenter-201208.01-en.us-30GB.vhd',
[Parameter(Mandatory = $true)][String]$adminPassword,
View UploadProcess_All.ps1
# Server and Project configs.
$CollectionUrl = "https://[TEAM FOUNDATION SERVER]/[PROJECT COLLECTION]"
$projects = ("[PROJECT 1]", "PROJECT 2")
# Work Item Locations
$baseLocation = Split-Path -parent $PSCommandPath
$witdLocation = $baseLocation + "\Core.Process\WorkItem Tracking\TypeDefinitions"
# Admin Import Command
$WitAdmin = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 12.0\Common7\IDE\witadmin.exe"
@leniency
leniency / Package.proj
Created Apr 19, 2014
MsBuild proj file to create a Nuget package. Uses msbuildtask library for git stuff. This assumes your git tags are in the form of #.# (ie, 1.2) for versioning.
View Package.proj
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Package">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<Configuration Condition="$(Configuration) == ''">Release</Configuration>
<Platform Condition="$(Platform) == ''">AnyCPU</Platform>
<BuildDir>bin\$(Configuration)\</BuildDir>
<OutputPath>bin\$(Configuration)\</OutputPath>
<ProjectName Condition="$(ProjectName) == ''"></ProjectName>
<ProjectFile>$(ProjectName).csproj</ProjectFile>
@leniency
leniency / core.ts
Created Apr 17, 2014
This creates a global point for KendoUI notifications. Call as core.notify.success('yay!');
View core.ts
/// <reference path="typings/jquery/jquery.d.ts" />
/// <reference path="typings/kendo.all.d.ts" />
interface JQuery {
kendoNotification(options: any): JQuery;
}
module core {
/**
View jquery.storage.js
/* Copyright (c) 2010 Marcus Westin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
View kendo.extensions.grid.js
;//
// Grid extension.
// Adds default grid state perservation via localStorage.
// The grid container can specify a storage location by
// setting the data-store attribute to either:
// - local [default]
// - session
// - false Disables storage for this grid.
//
(function ($, kendo) {