Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
ChrisMcKee / PredicatableGuid.cs
Last active April 19, 2024 08:49
Namespaced Deterministic Guid - RFC 4122 dotnetcore
using System;
using System.Security.Cryptography;
using System.Text;
namespace Utility
{
/// <summary>
/// Helper methods for working with <see cref="Guid"/>.
/// </summary>
public static class GuidUtility
@ChrisMcKee
ChrisMcKee / AsyncHelper.cs
Last active December 6, 2023 11:37
AsyncHelpers to simplify calling of Async/Task methods from synchronous context. (use https://github.com/aspnet/AspNetIdentity/blob/master/src/Microsoft.AspNet.Identity.Core/AsyncHelper.cs this is ancient code)
namespace My.Common
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
public static class AsyncHelpers
{
/// <summary>
@ChrisMcKee
ChrisMcKee / ignorerules.txt
Created March 6, 2012 10:39
Tortoise SVN Visual Studio Ignore Rules
Applied on svn properties (recursively) using svn:ignore .
build.txt
*.resharper
**.ReSharper**
*.suo
*.user
*.pdb
@ChrisMcKee
ChrisMcKee / GetSiteURLWithProtocol.php
Created October 13, 2011 11:54
Get site url with current protocol
<?php
function siteURL()
{
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$domainName = $_SERVER['HTTP_HOST'].'/';
return $protocol.$domainName;
}
define( 'SITE_URL', siteURL() );
@ChrisMcKee
ChrisMcKee / Base65Encoding.cs
Created January 4, 2013 13:45
Base65 Encoding
namespace Utils
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Base65Encoding
{
private const string Characters = "0123456789AaBbCcDdEeFfGgHhIiJjKklLMmNnOoPpQqRrSsTtUuVvWwXxYyZz._-";

Retrieving Docker Image Sizes

There are two metrics that are important to consider when discussing the size of Docker images.

  1. Compressed size - This is often referred to as the wire size. This affects how fast/slow images can be pulled from a registry. This impacts the first run experience on machines where images are not cached.
  2. Uncompressed size - This is often referred to as the size on disk. This affects how much local storage is required to support your Docker workloads.

The example commands shown below will work on Windows, MacOS, and Linux.

How to Measure the Compressed Size

@ChrisMcKee
ChrisMcKee / biggest_relations.sql
Created May 11, 2023 10:18 — forked from seejee/biggest_relations.sql
Postgres Maintenance Scripts
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 20;
@ChrisMcKee
ChrisMcKee / InstallHaProxy.sh
Created June 26, 2014 14:08
Centos 6.5 Install HAProxy From Source (1.5.1 release pre configured). chmod +x InstallHaProxy.sh then ./InstallHaProxy.sh
#!/bin/bash
### VARIABLES ###
PRE_PACK="openssl-devel pcre-devel make gcc"
VER="1.5.1"
# Setup Colours
black='\E[30;40m'
red='\E[31;40m'
@ChrisMcKee
ChrisMcKee / installpackerterraform.sh
Last active June 6, 2022 18:42
hashicorp terraform packer
#!/bin/bash
cd /tmp
sudo apt-get install --assume-yes jq > /dev/null
terraform_url="https://releases.hashicorp.com/terraform/$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version')/terraform_$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version')_linux_amd64.zip"
packer_url="https://releases.hashicorp.com/packer/$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')/packer_$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')_linux_amd64.zip"
version: '3'
services:
db:
image: mysql:5.7
container_name: db
command: --lower_case_table_names=1
environment:
MYSQL_ROOT_PASSWORD: my_secret_password
MYSQL_DATABASE: capdb