Skip to content

Instantly share code, notes, and snippets.

View stand-sure's full-sized avatar
💭
why do the developers go broke? they use up all of their cache

Christopher J. Anderson stand-sure

💭
why do the developers go broke? they use up all of their cache
View GitHub Profile
@stand-sure
stand-sure / get-server-cert-chain.sh
Created June 5, 2023 18:28
openssl s_client # get cert chain
openssl s_client -showcerts -connect SERVER_NAME:443 -showcerts </dev/null 2>/dev/null|openssl x509 -outform PEM >mycertfile.pem
@stand-sure
stand-sure / route.ts
Created June 18, 2023 16:44
nextjs prometheus metrics
import {collectDefaultMetrics, register} from 'prom-client';
collectDefaultMetrics({ register });
export async function GET() {
const metrics : string = await register.metrics();
return new Response(metrics, {
status: 200,
headers: {
"Content-Type": register.contentType,
#! /usr/bin/env bash
brew services list | grep started | cut -f 1 -d ' ' | xargs -n 1 brew services restart
@stand-sure
stand-sure / brew-reinstall-all.sh
Created August 9, 2023 20:36
reinstall all brew apps -- useful if links get fouled up
#! /usr/bin/env bash
brew list | xargs brew reinstall
@stand-sure
stand-sure / get-secrets.sh
Created August 18, 2023 18:49
get and decode all k8s secrets
#! /usr/bin/env bash
kubectl get secret --output yaml | /usr/local/bin/yq '.items[] | { (.metadata.name): (.data | to_entries) | map_values({ (.key): (.value | @base64d )}) }'
echo
@stand-sure
stand-sure / ServiceCollectionExtensions {.cs
Created October 17, 2023 21:19
POCO Config w/o IOptions
// found at https://www.strathweb.com/2016/09/strongly-typed-configuration-in-asp-net-core-without-ioptionst/
public static class ServiceCollectionExtensions
{
public static TConfig ConfigurePOCO<TConfig>(this IServiceCollection services, IConfiguration configuration, Func<TConfig> pocoProvider) where TConfig : class
{
if (services == null) throw new ArgumentNullException(nameof(services));
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
if (pocoProvider == null) throw new ArgumentNullException(nameof(pocoProvider));
@stand-sure
stand-sure / verify-opentelemetry-trace.cs
Created November 14, 2023 13:58
How to Verify that an OpenTelemetry Trace is produced in a unit test
[Fact]
public async Task InterceptShouldTrace()
{
IList<Activity> exportedActivities = new List<Activity>();
IHostBuilder hostBuilder = Host.CreateDefaultBuilder();
var source = Guid.NewGuid().ToString("N");
hostBuilder.ConfigureServices((_, serviceCollection) =>
@stand-sure
stand-sure / my.gitsign-credential-cache.plist
Created November 21, 2023 21:48
run gitsign-credential-cache at login on macos
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>my.gitsign-credential-cache</string>
<key>ProgramArguments</key>
<array>
@stand-sure
stand-sure / get-package-refs.sh
Last active December 1, 2023 18:53
scripts for getting package and project references from csproj files
#! /usr/bin/env bash
for file in src/**/*.csproj
do
cat $file | \
xq '[(try(.Project.ItemGroup[].PackageReference) // [])] | flatten' | \
jq '[.[].["@Include"]]' | \
jq --arg file ${file} '{"file":$file, "refs":.}' | \
yq eval --prettyPrint '[.]';
done
### Keybase proof
I hereby claim:
* I am stand-sure on github.
* I am stand_sure (https://keybase.io/stand_sure) on keybase.
* I have a public key ASCyW_dmVCsEDjWTcomieNrIhS2NJrkfRyww-S2qFc7K2Ao
To claim this, I am signing this object: