Skip to content

Instantly share code, notes, and snippets.

View surgicalcoder's full-sized avatar

surgicalcoder

  • United Kingdom
View GitHub Profile
@surgicalcoder
surgicalcoder / powershell.reg
Created April 25, 2025 20:44
Run a powershell file on windows with double click
Windows Registry Editor Version 5.00
; Register PowerShell Script file type
[HKEY_CLASSES_ROOT\.ps1]
@="Microsoft.PowerShellScript.1"
"Content Type"="text/plain"
; Create the PowerShell Script type
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1]
@="PowerShell 7 Script"
Subject access request
I am writing to formally make a Subject Access Request, for a digital copy of information held about me, for which I am entitled to under the General Data Protection Regulations (GDPR) 2018.
You can identify my records by using the following information:
• Name: CHANGEME
• Address: CHANGEME
Please supply the data about me, that I am entitled to, under the Data Protection Act 2019, including:
• Confirmation that you are processing my personal data
@surgicalcoder
surgicalcoder / file.cs
Created August 10, 2020 12:30
Deterministic "random" number
void Main()
{
// 1000 = Minimum number
// 65536 = maximum number
(1000 + GetInt64HashCode("John Reginald III esq.") % 65536).Dump();
}
static Int64 GetInt64HashCode(string strText)
{
Int64 hashCode = 0;
@surgicalcoder
surgicalcoder / program.cs
Last active August 2, 2020 14:38
Lunr Code Example
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Lunr;
using Index = Lunr.Index;
namespace LunrCodeJsonExample
{
class Program
@surgicalcoder
surgicalcoder / docker-for-windows.md
Created May 26, 2020 10:06 — forked from BretFisher/docker-for-windows.md
Getting a Shell in the Docker for Windows Moby VM

2018 Update: Easiest option is Justin's repo and image

Just run this from your CLI and it'll drop you in a container with full permissions on the Moby VM. Only works for Moby Linux VM (doesn't work for Windows Containers). Note this also works on Docker for Mac.

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1

@surgicalcoder
surgicalcoder / CreateDapperPOCO.groovy
Last active February 1, 2024 08:28
Generate Dapper Contrib from database with DataGrip
import com.intellij.database.model.DasTable
import com.intellij.database.model.ObjectKind
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil
import com.intellij.database.model.DasIndex
import com.intellij.util.ObjectUtils
import groovy.json.*
typeMapping = [
(~/(?i)^bit$/) : "bool",
@surgicalcoder
surgicalcoder / file.cs
Last active August 16, 2017 12:39
JsonToParametersAttribute
public class JsonToParametersAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
var stream = filterContext.HttpContext.Request.Body;
using (var sr = new StreamReader(stream))
using (var jsonTextReader = new JsonTextReader(sr))
{
@surgicalcoder
surgicalcoder / blarg.cs
Created March 20, 2017 14:49
Hack for adding MVC Core modules dynamically
public class Blarg : ApplicationPart, IApplicationPartTypeProvider, ICompilationReferencesProvider
{
public Assembly Assembly { get; }
public Blarg(Assembly assembly)
{
if (assembly == (Assembly)null)
throw new ArgumentNullException("assembly");
this.Assembly = assembly;
}
public override string Name
@surgicalcoder
surgicalcoder / file.cs
Created January 2, 2017 14:25
URL Friendly Base64'ness
public static class Base64Extension
{
static readonly char[] padding = { '=' };
public static string EncodeURLBase64(this string Input)
{
var base64 = Convert.ToBase64String(Encoding.Default.GetBytes(Input)).TrimEnd(padding).Replace('+', '-').Replace('/', '_');
return base64;
}
public static string DecodeURLBase64(this string Input)
@surgicalcoder
surgicalcoder / IPProtocolType.cs
Created July 25, 2016 11:23
C# IP Protocol Type Enum
public enum IPProtocolType
{
[Description("IPv6 Hop-by-Hop Option")]
HOPOPT = 0,
[Description("Internet Control Message")]
ICMP = 1,
[Description("Internet Group Management")]
IGMP = 2,
[Description("Gateway-to-Gateway")]
GGP = 3,