Skip to content

Instantly share code, notes, and snippets.

View carlin-q-scott's full-sized avatar

Carlin Scott carlin-q-scott

View GitHub Profile
@carlin-q-scott
carlin-q-scott / bash-extensions.sh
Created February 17, 2024 18:52
WSL2 Bash Extensions
echo "setting alias clip-branch to copy the current git branch to the Windows clipboard"
echo "alias clip-branch='git rev-parse --abbrev-ref HEAD | tr -d '\n' | clip.exe'"

Azure Application Insights in Kubernetes for Java

This gist describes how to add Kubernetes customDismensions to the Java agent for Application Insights.

It's supplying the same customDimensions that are provided by the asp.net 6+ instrumentiation, except that not all of those dimensions are available using the Kubernetes Downward API

How it Works

The supplied app-insights-java.yaml patch file configures customDimensions for the app insights agent using the APPLICATIONINSIGHTS_CONFIGURATION_CONTENT env var. This will override your applicationinsights.json configuration file if you were using one.

@carlin-q-scott
carlin-q-scott / access.yaml
Created November 4, 2022 19:39
Lightweight helm-controller providing HelmChart and HelmChartConfig CRDs
apiVersion: v1
kind: ServiceAccount
metadata:
name: helm-controller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: helm-controller
@carlin-q-scott
carlin-q-scott / detect-touch-issues.js
Last active July 31, 2023 20:50
Detect Google Search Ranking Issues
// This script highlights touchable elements on the page that are either too small or too close together according to Google.
// https://support.google.com/webmasters/answer/9063469#touch_elements_too_close
const MinimumSize = 48;
const MinimumMargin = 8;
let clickableNodesList = document.querySelectorAll('a,button');
for (let ia = 0; ia < clickableNodesList.length; ia++){
let aElement = clickableNodesList[ia];
let aBound = aElement.getBoundingClientRect();

Find in Files snippets

These are snippets I use to find text in specific types of files.

CSS

.css;.scss;!*.min.css

@carlin-q-scott
carlin-q-scott / unobtrustive-validation-extensions.js
Last active November 12, 2022 02:51
ASP.NET Unobtrusive Validation for Bootstrap 5
(function ($) {
// Make ASP's unobtrusive validation compatible with Bootstrap 5 styling. See this for more details: https://stackoverflow.com/a/19006517/576153
$.validator.setDefaults({
errorElement: "span",
errorClass: "invalid-feedback",
highlight: function (element, errorClass, validClass) {
// Only validation controls
if (!$(element).hasClass('novalidation')) {
$(element).closest('.form-control').removeClass('is-valid').addClass('is-invalid');
}
@carlin-q-scott
carlin-q-scott / LoremIpsum.cs
Created January 7, 2021 00:54
Lorem Ipsum generator that generates the specified number of words
const string LoremIpsum = @"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
private static readonly Regex WordRegex = new Regex(@"\w+\W+");
private static readonly string[] LoremIpsumWords = WordRegex.Matches(LoremIpsum).Select(m => m.Value).ToArray();
private string LoregmIpsum(int count)
{
var output = new StringBuilder();
if (count > LoremIpsumWords.Length) output.AppendJoin(" ", Enumerable.Repeat(LoremIpsum, count / LoremIpsumWords.Length));
output.Append(" ");
output.AppendJoin(null, LoremIpsumWords.Take(count % LoremIpsumWo
@carlin-q-scott
carlin-q-scott / regexes.txt
Created June 13, 2020 00:46
Localize ASP.NET views
(<a[^>]+>)([\w ]+)</a>
$1@Localizer["$2"]</a>
@carlin-q-scott
carlin-q-scott / regexes.txt
Last active June 3, 2020 21:31
Bootstrap 3 to 4 conversions
Regular Expression
Replacement
col-(\w\w)-(pull|push)-(\d+)
order-$1-$3
col-(\w\w)-offset-(\d+)
offset-$1-$2
hidden-xs
@carlin-q-scott
carlin-q-scott / HtmlHelper to tag-helper regexes.txt
Last active June 9, 2020 23:13
Files for converting from mvc views to razor pages
These are regular expressions for finding and replacing ASP.NET HTML Helpers with tag-helpers.
This could probably be combined with the pagify.py script to run all of these automatically.
@Html.LabelFor\(model => model.([\w_]+), htmlAttributes: new { @class = ("[^"]+") }\)
<label asp-for="$1" class=$2></label>
@Html.LabelFor\(model => model.([\w_]+), "([^"]+)", htmlAttributes: new { @class = ("[^"]+") }\)
<label asp-for="$1" class=$3>$2</label>
@Html.EditorFor\(model => model.([\w_]+), new { htmlAttributes = new { @class = ("[^"]+") } }\)