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 December 28, 2021 08:20
AWS Lambda function in Go to resize an image uploaded to S3. Uses https://github.com/apex/apex
package main
import (
"bytes"
"image/jpeg"
"log"
"path"
"strings"
apex "github.com/apex/go-apex"
@mrichman
mrichman / main.go
Last active June 5, 2017 11:29
Resize JPEG image in AWS S3
package main
import (
"bytes"
"os"
"path"
"image/jpeg"
log "github.com/Sirupsen/logrus"
@mrichman
mrichman / app.config.xml
Last active January 27, 2023 10:08
Enable WCF Service Trace Logging - view with SvcTraceViwer.exe (i.e. C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- ... -->
<system.serviceModel>
<!-- ... -->
<diagnostics wmiProviderEnabled="true">
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" />
</diagnostics>
</system.serviceModel>
<!-- ... -->
@mrichman
mrichman / main-progress.go
Last active May 24, 2017 11:39
Compute hash of a resource at a URL
package main
import (
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"crypto/tls"
"encoding/hex"
"flag"
@mrichman
mrichman / AzureSetAppSettings.ps1
Created April 26, 2017 14:52
Set Azure app service specific application settings (not web.config)
<#
.SYNOPSIS
Set Azure app service specific application settings (not web.config)
.DESCRIPTION
Set Azure app service specific application settings (not web.config)
.EXAMPLE
AzureSetAppSettings -ResourceGroupName "cmc-scm-tst-us-e-rg" -WebAppName "888888sisclientweb01"
.EXAMPLE
AzureSetAppSettings -ResourceGroupName "cmc-scm-tst-us-e-rg" -WebAppName "888888sisclientweb01" -Slot "qa"
.PARAMETER ResourceGroupName
@mrichman
mrichman / gist:8f4070d45cb190ddd3ab7d34ea568d1e
Created March 9, 2017 14:57
Convert CNG to older CAPI1 (CryptoAPI)
openssl pkcs12 -in mycert-cng.pfx -out mycert.pem
openssl pkcs12 -export -in mycert.pem -out mycert-cryptoapi.pfx
@mrichman
mrichman / modifyConnectionStrings.ps1
Created February 27, 2017 14:53 — forked from jwcarroll/modifyConnectionStrings.ps1
Set Connection String Powershell Function
Function Set-ConnectionString{
[CmdletBinding(SupportsShouldProcess=$True)]
Param(
[string]$fileName="app.config",
[string]$connectionStringName,
[string]$connectionString
)
$config = [xml](Get-Content -LiteralPath $fileName)
@mrichman
mrichman / application.go
Created February 16, 2017 19:23
AWS Elastic Beanstalk Go Demo
package main
import (
"log"
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
@mrichman
mrichman / screenshot.py
Created February 16, 2017 15:44
Download a website screenshot using Google's PageSpeed API
#!/bin/env python
""" Download a website screenshot using Google's PageSpeed API """
import base64
import requests
site = "https://twitter.com/mrichman"
# api = "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?screenshot=true&strategy=mobile"
@mrichman
mrichman / gist:711cf979d8054cba5cc905099b8ad64f
Created October 27, 2016 01:15
Uninstall XQuartz.app from OSX Yosemite/El Capitan/Sierra
launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist && \
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist && \
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz && \
sudo pkgutil --forget org.macosforge.xquartz.pkg && \
rm -rf ~/.serverauth* && rm -rf ~/.Xauthorit* && rm -rf ~/.cache && rm -rf ~/.rnd && \
rm -rf ~/Library/Caches/org.macosforge.xquartz.X11 && rm -rf ~/Library/Logs/X11