Skip to content

Instantly share code, notes, and snippets.

View BrandonLWhite's full-sized avatar

Brandon White BrandonLWhite

  • Austin, TX
View GitHub Profile
@BrandonLWhite
BrandonLWhite / gist:10509361
Created April 11, 2014 23:26
Mono memory leak using Socket BeginRead
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Net.Sockets;
using System.Net;
namespace FromAsyncLeakTest
@BrandonLWhite
BrandonLWhite / gist:235fa12247f6dc827051
Created October 2, 2014 17:28
Import .cer and .pvk certificate files programmatically in C# for use with `netsh http add sslcert`
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography;
var abyPublicKey = AssemblyUtility.GetEmbeddedFileAsByteArray("WebServer.SslCertificate.cer");
var abyPrivateKey = AssemblyUtility.GetEmbeddedFileAsByteArray("WebServer.SslCertificate.pvk");
var certificate = new X509Certificate2(abyPublicKey, string.Empty,
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
var cspParams = new CspParameters
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace SwitchVsDictionary
{
static class Program
function dayPartToMoment(dayPart) {
return moment(dayPart, 'HHmm');
}
function momentAtDayPart(moment, dayPart) {
return dayPartToMoment(dayPart).set({
year: moment.year(),
month: moment.month(),
date: moment.date()
});
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Brewsheet: $NAME</title>
<style type="text/css">
body {
font-size: 16px;
}
@BrandonLWhite
BrandonLWhite / main.py
Created May 6, 2020 21:25
Python S3 Object Listing Performance
import boto3
import logging
import os
import time
TIER = os.environ.get('TIER')
MAX_OBJECTS = 10000
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
@BrandonLWhite
BrandonLWhite / Function.cs
Created May 6, 2020 21:27
C# .NET Core S3 Object Listing Performance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Amazon.Lambda.Core;
using Amazon.S3;
using Amazon.S3.Model;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
@BrandonLWhite
BrandonLWhite / gitExtensions.sh
Created May 8, 2020 19:34
Bash script to launch GitExtensions (Windowsland) from WSL2 bash path.
#!/bin/bash
LINUX_PATH=$(pwd)
#echo ${LINUX_PATH}
WINDOWS_PATH="\"U:${LINUX_PATH//\//\\}\""
#echo ${WINDOWS_PATH}
GIT_EXTENSIONS_PATH="\"/mnt/c/Program Files (x86)/GitExtensions/GitExtensions.exe\""
GIT_EXTENSIONS_COMMAND="${GIT_EXTENSIONS_PATH} browse ${WINDOWS_PATH}"
echo ${GIT_EXTENSIONS_COMMAND}
eval ${GIT_EXTENSIONS_COMMAND} &
@BrandonLWhite
BrandonLWhite / python_dev_install.sh
Last active January 28, 2022 21:13
Python Dev Install
#!/bin/bash
# To execute this from a command prompt:
# curl https://gist.githubusercontent.com/BrandonLWhite/41b2a16487eef8abd193d9481dfd37f3/raw | bash
# TODO : Determine shell config file. (eg .profile, .zsh, etc). I guess though if we are piping this into bash it is always
# going to be .profile?
# Hell, maybe just add it to both?!
# Create a local user bin folder if one doesn't already exist (recent Linux distros already have this)
# and add it to the PATH if it isn't already there. This is so we don't have to keep adding stuff to the PATH.