Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
ChrisMcKee / ShortIds.cs
Created Aug 24, 2020
Sizeable seed based ID
View ShortIds.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace HashTime
{
class Program
{
@ChrisMcKee
ChrisMcKee / pack-man.ps1
Last active Jul 31, 2020 — forked from rjmurillo/pack-man.ps1
Useful Package Manager console commands
View pack-man.ps1
Get-Project –All | Add-BindingRedirect
# On large projects commands like `Update-Package -Reinstall` can take HOURS
# If the updates are broken up, then don't lock up the IDE and complete much faster (minutes vs hours)
# Reinstall all packages that match a specific targetFramework
# Useful when retargeting
gci -recurse packages.config | % { [xml]$XmlDocument = Get-Content -Path $_.FullName; $XmlDocument.packages.package | ? { $_.targetFramework -eq 'net462' } | select id | sort-object -unique | % { update-package -reinstall $_.id } }
# Reinstall all packages that have been marked with requireReinstallation
@ChrisMcKee
ChrisMcKee / upgrade-docker.sh
Created Jun 23, 2020
Upgrade docker to a specific version
View upgrade-docker.sh
#!/bin/bash
docker_version=19.03.11
pkg_version=$(apt-cache madison docker-ce | grep ${docker_version} | head -n 1 | cut -d ' ' -f 4)
apt-get install -y -q docker-ce=${pkg_version} docker-ce-cli=${pkg_version}
@ChrisMcKee
ChrisMcKee / uk-number-plate-validation.md
Created Apr 9, 2020 — forked from danielrbradley/uk-number-plate-validation.md
Regular Expression to Validate UK Number Plates
View uk-number-plate-validation.md

Regular Expression to Validate UK Number Plates

Regular Expression

(?<Current>^[A-Z]{2}[0-9]{2}[A-Z]{3}$)|(?<Prefix>^[A-Z][0-9]{1,3}[A-Z]{3}$)|(?<Suffix>^[A-Z]{3}[0-9]{1,3}[A-Z]$)|(?<DatelessLongNumberPrefix>^[0-9]{1,4}[A-Z]{1,2}$)|(?<DatelessShortNumberPrefix>^[0-9]{1,3}[A-Z]{1,3}$)|(?<DatelessLongNumberSuffix>^[A-Z]{1,2}[0-9]{1,4}$)|(?<DatelessShortNumberSufix>^[A-Z]{1,3}[0-9]{1,3}$)|(?<DatelessNorthernIreland>^[A-Z]{1,3}[0-9]{1,4}$)|(?<DiplomaticPlate>^[0-9]{3}[DX]{1}[0-9]{3}$)

For use in JavaScript (with named groups removed):

(^[A-Z]{2}[0-9]{2}\s?[A-Z]{3}$)|(^[A-Z][0-9]{1,3}[A-Z]{3}$)|(^[A-Z]{3}[0-9]{1,3}[A-Z]$)|(^[0-9]{1,4}[A-Z]{1,2}$)|(^[0-9]{1,3}[A-Z]{1,3}$)|(^[A-Z]{1,2}[0-9]{1,4}$)|(^[A-Z]{1,3}[0-9]{1,3}$)|(^[A-Z]{1,3}[0-9]{1,4}$)|(^[0-9]{3}[DX]{1}[0-9]{3}$)
@ChrisMcKee
ChrisMcKee / generate_new_kubeconfig.sh
Created Mar 29, 2019 — forked from Oats87/generate_new_kubeconfig.sh
This bash script will sign an x509 certificate using the kube-ca located on any rancher node. This allows you to gain access back to your RKE-created kubernetes cluster should you lose the kube_config and cluster.yml for it, but still have SSH access to the hosts.
View generate_new_kubeconfig.sh
#!/bin/bash
echo "This will generate a new kube config for accessing your RKE-created kubernetes cluster. This script MUST be run on a Kubernetes node."
echo "Please enter the IP of one of your control plane hosts, followed by [ENTER]:"
read cphost
openssl genrsa -out kube-admin.key 2048
openssl req -new -sha256 -key kube-admin.key -subj "/O=system:masters/CN=kube-admin" -out kube-admin.csr
sudo openssl x509 -req -in kube-admin.csr -CA /etc/kubernetes/ssl/kube-ca.pem -CAcreateserial -CAkey /etc/kubernetes/ssl/kube-ca-key.pem -out kube-admin.crt -days 365 -sha256
sudo rm -f /etc/kubernetes/ssl/kube-ca.srl
View Setup Rancher K8.rm
Follow the first few steps of https://rancher.com/blog/2018/2018-05-18-how-to-run-rancher-2-0-on-your-desktop/ in the docker-for-X UI to setup docker for kubernetes.
Pick a folder, open command prompt/terminal.
git clone git@github.com:jgreat/server-chart.git
kubectl -n kube-system create serviceaccount tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
@ChrisMcKee
ChrisMcKee / kubernetes-dashboard.md
Last active Oct 30, 2018 — forked from superseb/README.md
Deploy kubernetes-dashboard on Rancher 2.0 cluster exposed using NodePort
View kubernetes-dashboard.md

Deploy kubernetes-dashboard on Rancher 2.0 cluster exposed using NodePort

Requirements

Step 1: Generate kubeconfig from the UI

Generate the kubeconfig file for your cluster using the Kubeconfig File button in the Cluster view of your cluster. Save the generated file as $HOME/.kube/config and run kubectl get nodes to verify it works.

@ChrisMcKee
ChrisMcKee / Breach Compilation (1.4 billion credentials) in Postgres.md This gist is a simple guide of effective storing 1.4 billion email and password pairs in PostgreSQL for fast searching and reducing required storage space
View Breach Compilation (1.4 billion credentials) in Postgres.md

What would you need:

Hardware requirements

View perfcollect.sh
#!/bin/bash
#############################################################################################################
# .NET Performance Data Collection Script
#############################################################################################################
#############################################################################################################
#
# ***** HOW TO USE THIS SCRIPT *****
#
@ChrisMcKee
ChrisMcKee / BuildWarningReportGenerator.ps1
Last active Aug 2, 2019 — forked from tarwn/BuildWarningReportGenerator.ps1
Powershell script for TeamCity build warnings (fixed for 2018 / removed guest from end of urls used to fetch last builds log file)
View BuildWarningReportGenerator.ps1
Param
(
[parameter(Mandatory=$true)][string]
$BuildLogPath,
[parameter(Mandatory=$true)][string]
$BuildCheckoutDirectoryPath,
[parameter()][string]
$BuildArtifactRepositoryUrl