Skip to content

Instantly share code, notes, and snippets.

View stand-sure's full-sized avatar

Christopher J. Anderson stand-sure

View GitHub Profile
@stand-sure
stand-sure / make-gitgnore.sh
Created December 15, 2022 12:52
make .gitignore from untracked
#! /bin/bash
# NB the result will need cleaned
# ADVICE run this from another directory and edit the pathing
git ls-files --others --exclude-standard --directory ./YOUR/PATH > .gitignore
@stand-sure
stand-sure / TypeMaker.cs
Created August 3, 2022 21:04
Make a .net type by name
using System;
using System.Reflection.Emit;
using System.Reflection;
internal static class TypeMaker
{
private const string AssemblyNameForType = "DynamicAssemblyExample";
public static Type? Make(string typeName)
{
@stand-sure
stand-sure / graph.sh
Last active June 1, 2023 15:15
Git graph to HTML
#!/bin/bash
script -q -c "git --no-pager log --decorate --graph --format='%C(auto,#aa5500) %h %C(auto,#55ff55) (%an %GK %G?) %Creset %s %cr %C(auto,#ffff55) %d' --date=relative --all --remotes=* -n 100" ../graph.txt && \
ansi2html < ../graph.txt > ../graph.html
@stand-sure
stand-sure / catch-up-current-branch.sh
Created July 14, 2022 12:30
Git catch up current branch
#! /bin/bash
# checkout-pull-prune.sh
branchName=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
git fetch origin "$branchName:$branchName"
git merge "$branchName"
@stand-sure
stand-sure / delete-merged-branches.sh
Created July 14, 2022 12:29
Git delete merged branches
#! /bin/bash
branchName=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
git checkout "$branchName" \
| git branch --merged \
| grep -E --invert-match "(^\*|master|main|dev)" \
| xargs git branch --delete \
&& git remote prune origin
@stand-sure
stand-sure / checkout-pull-prune.sh
Created July 14, 2022 12:28
Git porcelain repo catch-up
#! /bin/bash
# checkout-pull-prune.sh
branchName=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
git checkout "$branchName" && \
git pull && \
git fetch --prune
@stand-sure
stand-sure / TSDemoInput.cs
Last active July 8, 2022 22:41
HotChocolate trimming strings in inputs
public record TSDemoInput(string Name);
public class TSDemoInputType : InputObjectType<TSDemoInput>
{
protected override void Configure(IInputObjectTypeDescriptor<TSDemoInput> descriptor)
{
descriptor.Field(input => input.Name)
.Type<TrimmedStringType>();
}
}
@stand-sure
stand-sure / ConfigureMvcOptions.cs
Created July 8, 2022 22:35
C# trim string binder (MVC)
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.Options;
public class ConfigureMvcOptions : IConfigureOptions<MvcOptions>
{
private readonly IHttpRequestStreamReaderFactory readerFactory;
public ConfigureMvcOptions(IHttpRequestStreamReaderFactory readerFactory)
{
@stand-sure
stand-sure / additional-config.sh
Last active April 8, 2022 23:00 — forked from davebarnwell/brew-dnsmasq.md
install dnsmasq with brew
cp /usr/local/etc/dnsmasq.conf /usr/local/etc/dnsmasq.conf.orig
echo "conf-dir=/usr/local/etc/dnsmasq.d/,*.conf" | tee /usr/local/etc/dnsmasq.conf
@stand-sure
stand-sure / bot.cs
Created August 25, 2021 23:13
GetBot
public static string GetBot(string message)
{
string bot = $"\n {message}";
bot += @"
__________________
\
\
....
....'
....