Skip to content

Instantly share code, notes, and snippets.

View codingoutloud's full-sized avatar

Bill Wilder codingoutloud

View GitHub Profile
@codingoutloud
codingoutloud / which.ps1
Last active December 24, 2015 10:19
Implements the Unix shell 'which' command using PowerShell
<#
Implements the Unix shell 'which' command using PowerShell.
original: https://gist.github.com/codingoutloud/6782961
#>
function WhichOnes
{
if ($args.Count -eq 0)
{
# obviously use of 'which' in usage text is a hack (since it is chosen to match the alias)
@codingoutloud
codingoutloud / azure-service-management.py
Last active December 25, 2015 20:19
Run Windows Azure Service Management operation through Python. This requires access to a certificate. Under Windows this certificate must be in the certificate store. On Mac or Linux, this certificate must accessible in a .pem file. In either case, the specified certificate must be uploaded to the Windows Azure portal as a management certificate…
from azure.servicemanagement import *
import platform
import os
###
print("CHANGE THE VALUE of 'subscription_id' and create the correct certificate or this will NOT WORK")
###
plat = platform.system()
print("Platform == " + plat)
@codingoutloud
codingoutloud / python-history.txt
Created October 21, 2013 15:05
Useful Python hacks I've encountered
# http://stackoverflow.com/questions/192109/is-there-a-function-in-python-to-print-all-the-current-properties-and-values-of
dir(somevariable) -- shows the properties available
@codingoutloud
codingoutloud / 0_reuse_code.js
Created January 23, 2014 20:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
(Get-AzureRmSubscription -SubscriptionId (Get-AzureRmContext).Subscription).SubscriptionName
@codingoutloud
codingoutloud / HttpClient.md
Last active May 8, 2016 13:49
HttpClient in .NET
@codingoutloud
codingoutloud / DumpAllWindowsCerts.cs
Created November 3, 2012 03:03
Dump all digital certificates in Windows certificate store to stdout
// Iterates through all of the X.509 digital certificates installed in the certificate store
// on a Windows operating system, dumping out some metadata about each. Each certificate, in
// each Certificate Store, from each Certificate Location is included.
//
// Bill Wilder | @codingoutloud | Oct 2012
// Original: https://gist.github.com/4005661
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
@codingoutloud
codingoutloud / GenerateCryptographicallyStrongUrlSafeRandomToken.cs
Last active May 11, 2016 22:24
Generate a random(ish) token that is safe to be used in a URL. Allow caller to specify strength though number of generated random chars.
// Bill Wilder | @codingoutloud | http://www.cloudarchitecturepatterns.com | Nov 2012
// Original: https://gist.github.com/4121999
// Similar GenerateUrlSafeRandomToken.cs, except upgraded to use crypto-strength RNG
// Add reference to System.Web.dll
public static string GenerateUrlSafeCryptographicallyStrongRandomToken(int strength = 16)
{
using (var rng = new RNGCryptoServiceProvider())
{
var randomBytes = new byte[strength];
rng.GetBytes(randomBytes);
@codingoutloud
codingoutloud / make-aes256-certificate.sh
Created May 29, 2016 18:25
Generate an AES256 certificate for encrypting email, such as with the Outlook client for Mac.
password="SomeTopSecretPassword"
email="bill.wilder@example.com"
# openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem -subj "/CN=DevPartners/emailAddress=$email"
# generate .pem (full public/private certificate)
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem -subj "/emailAddress=$email"
# generate .pfx (full public/private certificate) from .pem
openssl pkcs12 -export -out mycert.pfx -inkey mycert.pem -in mycert.pem -passout pass:$password
# generate .cer (public key) from .pem
openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer
$subName = 'my azure subscription name here'
$rgName = 'nesql-june24-demo2'
$region = "East US"
$serverName = 'billwilder911'
$myIp = "107.92.120.203" #### CHANGES A LOT!
Add-AzureRmAccount # then log in interactively, including with 2FA
Select-AzureRmSubscription -SubscriptionName $subName
# How many regions am I allowed to deploy SQL to?