Skip to content

Instantly share code, notes, and snippets.


Bill Wilder codingoutloud

View GitHub Profile
codingoutloud / make-keys.bat
Last active Sep 1, 2022
Handy OpenSSL command-line combinations I've used - they might've been hard to find or come up with, so capturing them here.
View make-keys.bat
@echo off
if _%1_==__ goto USAGE
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem -subj "/CN=My Cert Name"
openssl pkcs12 -export -out mycert.pfx -inkey mycert.pem -in mycert.pem -passout pass:%1
openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer
openssl pkcs12 -in mycert.pfx -nodes -passin pass:%1 | openssl x509 -noout -fingerprint
openssl x509 -in mycert.pem -noout -fingerprint
# Mostly this script exists to simply make it possible/simple to do " foo.puml" to create "foo.png" from command line.
# If you want it even simpler - "puml foo.puml" (no ".sh" extension) consider using an alias.
# Here is example for .bash_profile:
# alias puml=~/bin/
for ARG in "$@"
if [ "$ARG" = "v" ]; then
if [ $# -eq 1 ]; then
## Create an Azure Map account in the Azure portal to get a new APIKEY.
## Azure Map API to look up the COUNTRY (two-char ISO) of the IP
View azure-activity-log-security.json
Actual activity-log entry, redacted (...) and anonymized.
category = "Security"
level = "Informational"
The threatName and threatID values under properties match this:!ml&threatid=2147735508
codingoutloud / basicauthwithtoken.ps1
Created Oct 17, 2013
Use PowerShell to call HTTP Endpoint using Basic Auth when you already have a Basic Auth token in hand (not username + password).
View basicauthwithtoken.ps1
## Example explorers hitting a web endpoint with Basic Auth, when you already have a token in hand
$key = "sk_test_mkGsLqEW6SLnZa487HYfJVLf"
$url = ""
# this will work, but the flow in Basic Auth will first ask you for a password to go with the
# value passed in, which serves as the username. You hit enter because the password is null.
# Then the response comes back... BUT - this also involved a round-trip to the server (which
# returns a 401, but also a Response header indicating that is speaks Basic Auth:
# Www-Authenticate: Basic realm="Stripe"
codingoutloud / getRandomInt.js
Created Aug 30, 2020
JavaScript functions for choosing a random integer between 0 and some max value. There are two variants: one where max is supplied, and one where an array is supplied.
View getRandomInt.js
// Return a random integer in [0..max] (inclusive, so 0 and max are valid values).
// Assumes (but does not validate) that max is a non-negative integer less than Number.MAX_SAFE_INTEGER.
// Does not use a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG).
function getRandomInt(max) {
return Math.floor(Math.random() * (max + 1));
// How it works:
// Math.random() → returns a floating point number at least zero but less than one: [0..1)
// Math.random() * (max+1) → returns a floating point number at least 0 but less than (max+1): [0..max+1)
// floor(Math.random() * (max+1)) → returns an integer at least 0 but could be as high as max: [0..max]
codingoutloud / windows-azure-certs.txt
Created Nov 3, 2012
Dump of Windows Azure Certificates from a Web Role instance (output is from
View windows-azure-certs.txt
Store Location: CurrentUser
Store Location/Store Name: CurrentUser/AddressBook
Store Location/Store Name: CurrentUser/AuthRoot
Certificate (some fields): for OU=Security Communication EV RootCA1, O="SECOM Trust Systems CO.,LTD.", C=JP - has private key False by OU=Security Communication EV RootCA1, O="SECOM Trust Systems CO.,LTD.", C=JP
Certificate (some fields): for CN=D-TRUST Root Class 3 CA 2007, O=D-Trust GmbH, C=DE - has private key False by CN=D-TRUST Root Class 3 CA 2007, O=D-Trust GmbH, C=DE
Certificate (some fields): for OU=certSIGN ROOT CA, O=certSIGN, C=RO - has private key False by OU=certSIGN ROOT CA, O=certSIGN, C=RO
Certificate (some fields): for, STREET=Principe de Vergara 72 28006 Madrid, CN=Certificado de la Clave Principal, OU=Certificado Raiz, OU=Certificado Propio, O=Servicio de Certificacion del Colegio de Registradores (SCR), C=es - has private key False by, STREET=Principe de Vergara 72 28006 Madrid, CN=Certificado de la Clave Principal,
codingoutloud /
Created Feb 2, 2020
Command line to get my public IP address by leveraging handy feature in OpenDNS
# OpenDNS resolves "" to the caller's publicly-facing IP.
# To use this feature, resolve that DNS name against an OpenDNS name server.
# pip install dnspython
import dns.resolver
resolver = dns.resolver.Resolver()
codingoutloud / BlobSemaphore.cs
Created Feb 13, 2013
Use Windows Azure Blob to create a semaphore spanning the cloud.
View BlobSemaphore.cs
// intended to be called only ONCE in real installations - or for a clean test run when no Jobs container exists
public static void GloballyInitializeJobManager(bool quiet)
var blobContainer = AzureStorageAccess.GetBlobContainer(JobContainerName);
bool didNotExistCreated = blobContainer.CreateIfNotExist();
if (!quiet) System.Diagnostics.Debug.Assert(didNotExistCreated); // else, we probably should not be calling this method
var blob = blobContainer.GetBlobReference(JobGlobalJobIdSequencePath);
if (!blob.Exists())
codingoutloud / ByteArraySerializer.cs
Created Jul 16, 2012
Serialize/Deserialize an object for passing through Windows Azure Queue
View ByteArraySerializer.cs
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
// Alternative (not related to this code, but in case you want to serialize to XML
// instead):
// Usage example
// NOTE: The Windows Azure CloudQueueMessage constructor accepts either a string
// or a byte array. If a byte array is passed in, it is Base64 encoded.
// Base64 encoding results in approx a 1/3 payload size penalty (so the