Skip to content

Instantly share code, notes, and snippets.

View mrichman's full-sized avatar

Mark Richman mrichman

View GitHub Profile
@mrichman
mrichman / main.go
Last active July 19, 2020 12:32
Invoking AWS SDK using WaitGroup of configurable size
// Run N workers in a WaitGroup until they complete
package main
import (
"flag"
"fmt"
"os"
"sync"
@mrichman
mrichman / Cloud9_bootstrap.yaml
Created July 8, 2020 19:05 — forked from richardhboyd/Cloud9_bootstrap.yaml
StepFunction that bootstraps a Cloud9 environment
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Parameters:
BucketName:
Description: "Region-specific assets S3 bucket name (e.g. ee-assets-prod-us-east-1)"
Type: String
Default: "cf-templates-1xnac3rwgtxo7-us-west-2"
EBSVolumeSize:
Description: "Size of EBS Volume (in GB)"
Type: Number
@mrichman
mrichman / table.js
Created January 30, 2020 11:41
Sort any HTML table by clicking a header
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
// do the work...
document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => {
const table = th.closest('table');
Array.from(table.querySelectorAll('tr:nth-child(n+2)'))
.sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
.forEach(tr => table.appendChild(tr) );
@mrichman
mrichman / MySqlSessionStateStore.cs
Created May 18, 2010 13:52
MySQL Session State Provider for ASP.NET
#region Directives
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Configuration.Provider;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Web;
@mrichman
mrichman / Brewfile
Created March 25, 2019 21:28
brew bundle dump
tap "aws/tap"
tap "buo/cask-upgrade"
tap "cjbassi/gotop"
tap "garethr/kubeval"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "homebrew/services"
@mrichman
mrichman / gist:7201688
Created October 28, 2013 18:10
Building wxWidgets 2.9.5 on OS X 10.9 Mavericks
mkdir build-release
cd build-release
configure --with-opengl --enable-unicode --enable-shared --enable-static --enable-dynamic --with-osx_cocoa --with-macosx-version-min=10.9 --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
make
{snip}
@mrichman
mrichman / create-params.py
Created October 31, 2018 13:52
Lambda Function to Create SSM Parameters using SecureString
import boto3
import json
from botocore.vendored import requests
def lambda_handler(event, context):
kms_client = boto3.client('kms')
ssm_client = boto3.client('ssm')
@mrichman
mrichman / main.go
Created July 17, 2018 12:28
Beat up your CPU for 10 seconds
package main
import (
"runtime"
"time"
)
func main() {
n := runtime.NumCPU()
runtime.GOMAXPROCS(n)
@mrichman
mrichman / brake.rb
Last active June 20, 2018 14:41
Batch convert videos into MP4 format using HandBrakeCLI
#!/usr/bin/env ruby
require 'optparse'
# Default options
options = {
verbose: false,
preset: "Fast 1080p30"
}
OptionParser.new do |opt|