Skip to content

Instantly share code, notes, and snippets.

Kamran Ayub kamranayub

View GitHub Profile
kamranayub / next.config.js
Last active Jul 29, 2020
React Production Profiling Support for Next.js
View next.config.js
// See:
// See:
const TerserPlugin = require('next/dist/compiled/terser-webpack-plugin');
module.exports = {
webpack: (config, options) => {
// Use profiler-enabled React builds
kamranayub / msbuild.js
Last active May 20, 2020
Make MSBuild 2020 player stretch across the window and chat below. Hit F12 and paste into console.
View msbuild.js
// F12 Dev Tools and copy and paste into console!
// Stretches studio player 100% and chat below.
var studioPlayer = document.querySelector("studio-player");
var studioVideo = document.querySelector(
var chat = document.querySelector(".home-page__live-stream__info");
if (studioPlayer && studioVideo && chat) { = "block";
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.
You can’t perform that action at this time.