Skip to content

Instantly share code, notes, and snippets.

View kamranayub's full-sized avatar

Kamran Ayub kamranayub

View GitHub Profile
@kamranayub
kamranayub / makefile
Last active August 1, 2017 19:20
Makefile for using ansible-playbook to do syntax checking for YAML playbooks
# 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
kamranayub / Get-TfsGitLfsFile.ps1
Created June 15, 2017 04:29
Download Git LFS file from TFS/VSTS
<#
.SYNOPSIS
Downloads a blob item from TFS Git LFS
.DESCRIPTION
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
kamranayub / Generate-OfflineManifest.ps1
Last active September 21, 2016 20:24
PowerShell script to build an HTML5 application manifest file
<#
.SYNOPSIS
Generates an HTML5 offline app cache manifest file
.DESCRIPTION
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
kamranayub / CassetteConfiguration.cs
Last active March 5, 2016 16:47
Register a CDN URL generator for Cassette. See blog post: http://kamranicus.com/blog/2015/10/10/azure-cdn-cassette/
namespace Website {
/// <summary>
/// Configures Cassette IoC
/// </summary>
public class CassetteContainerConfiguration : IConfiguration<TinyIoCContainer>
{
public void Configure(TinyIoCContainer container)
{
@kamranayub
kamranayub / Pkcs12ProtectedConfigurationProvider.cs
Created February 21, 2016 21:24
A modified PKCS12 provider that can use CurrentUser or LocalMachine store.
/*
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
kamranayub / ConfigSecretsProvider.cs
Created February 24, 2016 00:27
Secrets provider interface
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
kamranayub / removeRoot.js
Created August 29, 2013 14:54
Remove the root element of a JSON object, see: http://jsfiddle.net/kamranayub/72dm2/
var rootElementJson = {
root: {
name: "Foo",
person: true
}
};
var removeRootElement = function (obj) {
var numKeys = 0,
rootKey;
@kamranayub
kamranayub / TransparentButton.cs
Created April 6, 2013 01:21
Transparent button for Windows Phone
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace MyApp.Phone.UI.Controls {
public class TransparentButton : ContentControl {
public TransparentButton() {
HorizontalContentAlignment = HorizontalAlignment.Stretch;
}
@kamranayub
kamranayub / CssClassBinding.js
Last active December 15, 2015 07:38
CSS Class binding for Knockout.js
//
// Observable CSS Class Binding
//
// See Fiddle for usage: http://jsfiddle.net/kamranayub/3ahUA/
//
ko.bindingHandlers['class'] = {
update: function (element, valueAccessor) {
var currentValue = ko.utils.unwrapObservable(valueAccessor()),
prevValue = element['__ko__previousClassValue__'],
@kamranayub
kamranayub / SlideLeftRightTransitions.xaml
Created February 4, 2013 23:39
Slide Left / Right Transitions for `TransitioningContentControl`
<VisualState x:Name="NextTransition">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<ExponentialEase EasingMode="EaseOut" Exponent="6"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>