Skip to content

Instantly share code, notes, and snippets.

Kamran Ayub kamranayub

Block or report user

Report or block kamranayub

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kamranayub / makefile
Last active Aug 1, 2017
Makefile for using ansible-playbook to do syntax checking for YAML playbooks
View makefile
# Collect top-level YAML files under plays/ folder
# e.g. plays/upgrade_ansible_tower/upgrade_ansible_tower.yml
# These should only be Ansible playbook files
# i.e. store includes in child includes/ dir
playbooks := $(wildcard plays/*/*.yml)
# Check YAML syntax using ansible-playbook
syntax: $(playbooks)
@GREEN='\033[0;32m'; \
NC='\033[0m'; \
kamranayub / Get-TfsGitLfsFile.ps1
Created Jun 15, 2017
Download Git LFS file from TFS/VSTS
View Get-TfsGitLfsFile.ps1
Downloads a blob item from TFS Git LFS
This script performs a 4-step process to download a LFS-hosted file from TFS. It fetches the item metadata
then downloads the LFS pointer. After it validates the pointer file, it preps a LFS batch download and finally
downloads the file to the specified OutFile. You can use this cmdlet in a pipeline as it passes a Get-Item call
at the end.
kamranayub / ConfigSecretsProvider.cs
Created Feb 24, 2016
Secrets provider interface
View ConfigSecretsProvider.cs
public class ConfigSecretsProvider : ISecretsProvider
private readonly NameValueCollection _secretCollection;
public ConfigSecretsProvider() {
_secretCollection = ConfigurationManager.GetSection("appSecrets") as NameValueCollection;
public string GetSecret(string key) {
return Environment.GetEnvironmentVariable(key) ?? _secretCollection[key];
kamranayub / Pkcs12ProtectedConfigurationProvider.cs
Created Feb 21, 2016
A modified PKCS12 provider that can use CurrentUser or LocalMachine store.
View Pkcs12ProtectedConfigurationProvider.cs
Microsoft Limited Permissive License (Ms-LPL)
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
1. Definitions
The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” have the same meaning here as under U.S. copyright law.
A “contribution” is the original software, or any additions or changes to the software.
A “contributor” is any person that distributes its contribution under this license.
kamranayub / 1_TestingContext.cs
Last active Nov 6, 2015
Example using Ninject and Moq to create a TestingImpersonationContext. All it does is replace the bound dependency with a new impersonated mock and then replaces it once disposed. Relies on a testing context that is available to any test class (could also be a test base class). `UserRepository` is just an example of code that retrieves a user fr…
View 1_TestingContext.cs
public class TestingContext {
private IKernel _kernel;
public TestingContext() {
// create initial Strict mock that can always be setup outside impersonation context
UserContext = new Mock<IUserContext>(MockBehavior.Strict);
// register dependencies
_kernel = CreateKernel();
kamranayub / App.config
Created Nov 5, 2015
Example self-hosting a Web API endpoint in a Windows Service using TopShelf ( and TopShelf.Owin package.
View App.config
<?xml version="1.0" encoding="utf-8"?>
<add key="Port" value="1337"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
View CassetteConfiguration.cs
namespace Website {
/// <summary>
/// Configures Cassette IoC
/// </summary>
public class CassetteContainerConfiguration : IConfiguration<TinyIoCContainer>
public void Configure(TinyIoCContainer container)
kamranayub / Generate-OfflineManifest.ps1
Last active Sep 21, 2016
PowerShell script to build an HTML5 application manifest file
View Generate-OfflineManifest.ps1
Generates an HTML5 offline app cache manifest file
Generates an offline app cache manifest file according to file paths specified
and outputs with MD5 checksums so manifest only changes when dependent files change.
kamranayub / ko.bindingReport.js
Last active Jan 29, 2019
Knockout.js Binding Performance Reporter
View ko.bindingReport.js
* Performance reporting for Knockout binding handlers
* Usage: Include after all bindings are declared, view console for results.
(function () {
var report = [];
var lastReport = 0;
var debounceWait = 500;
kamranayub / ko.extendes.urlSync.js
Created May 11, 2015
Knockout Extender: URLSync - syncs observable value with URL hash
View ko.extendes.urlSync.js
* An extender that syncs the observable with the address
* bar (using hash fragment). Will load from URL hash or
* querystring (at time of creation) and will
* update hash when observable changes.
* Options: string|object
* String: Query parameter key to get/set
* Object:
* - param - Query parameter key to get/set
You can’t perform that action at this time.