Skip to content

Instantly share code, notes, and snippets.

View kamranayub's full-sized avatar

Kamran Ayub kamranayub

View GitHub Profile
@kamranayub
kamranayub / DbContext.cs
Last active December 18, 2025 05:25
RavenDB Embedded Faster Tests
using Newtonsoft.Json;
using Raven.Client.Documents;
using Raven.Client.Documents.Conventions;
using Raven.Client.Documents.Indexes;
using Raven.Client.Documents.Session;
using Raven.Client.Json.Serialization.NewtonsoftJson;
using Raven.Embedded;
using Reqnroll;
using System;
using System.Collections.Generic;
@kamranayub
kamranayub / DebugDockerBuildContext.md
Last active November 13, 2025 15:53
Debug your Docker build context by displaying a sorted tree of largest directories

Debug Docker Build Context

Goal: Understand what the heck is eating up your large Docker build context! Then, use that to update your .dockerignore and improve the performance of your builds.

Agent Mode 🤖

You can add the DebugDockerContext.prompt.md file to .github/prompts folder and then run the prompt with GitHub Copilot. It will use this first method and analyze your context directory structure to summarize the results.

image
@kamranayub
kamranayub / tf.log
Created September 25, 2024 14:51
TF Debug output for cloudflare_turnstile_widget
2024-09-25T14:44:09.381Z [INFO] OpenTofu version: 1.8.2
2024-09-25T14:44:09.381Z [DEBUG] using github.com/hashicorp/go-tfe v1.36.0
2024-09-25T14:44:09.381Z [DEBUG] using github.com/opentofu/hcl/v2 v2.0.0-20240416130056-03228b26f391
2024-09-25T14:44:09.382Z [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-09-25T14:44:09.382Z [DEBUG] using github.com/zclconf/go-cty v1.14.4
2024-09-25T14:44:09.382Z [INFO] Go runtime version: go1.21.11
2024-09-25T14:44:09.382Z [INFO] CLI args: []string{"tofu", "plan", "-input=false", "-lock=false", "-out=spacelift.plan"}
2024-09-25T14:44:09.383Z [INFO] Loading CLI configuration from /home/spacelift/.terraformrc
2024-09-25T14:44:09.384Z [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-09-25T14:44:09.384Z [DEBUG] ignoring non-existing provider search directory /home/spacelift/.terraform.d/plugins
@kamranayub
kamranayub / machine.js
Created April 28, 2021 13:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@kamranayub
kamranayub / README.md
Last active March 11, 2021 19:05
Enable Grammarly on Ghost Blog Admin Editor
@kamranayub
kamranayub / next.config.js
Last active October 15, 2025 13:41
React Production Profiling Support for Next.js
//
// See: https://kentcdodds.com/blog/profile-a-react-app-for-performance#build-and-measure-the-production-app
// See: https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config
const TerserPlugin = require('next/dist/compiled/terser-webpack-plugin');
module.exports = {
webpack: (config, options) => {
//
// Use profiler-enabled React builds
@kamranayub
kamranayub / msbuild.js
Last active May 20, 2020 15:14
Make MSBuild 2020 player stretch across the window and chat below. Hit F12 and paste into console.
// 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(
".home-page__live-stream--content__video"
);
var chat = document.querySelector(".home-page__live-stream__info");
if (studioPlayer && studioVideo && chat) {
studioPlayer.style.display = "block";
@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 / 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];