Skip to content

Instantly share code, notes, and snippets.

Avatar

Bill Wilder codingoutloud

View GitHub Profile
@codingoutloud
codingoutloud / Fail75.js
Created Sep 7, 2017
Code for an Azure Function that sometimes returns failure (on purposes, 75% of the time, useful for testing)
View Fail75.js
module.exports = function (context, req) {
if (Math.random() > 0.75) {
context.log('Azure Function "Fail75" is randomly (25%) returning 200 OK.');
context.res = {
body: "Randomly (25%) returning 200 OK."
}
}
else {
context.log('Azure Function "Fail75" is randomly (75%) returning 500 as a transient error.');
context.res = {
View geo-ip-services.txt
GEO IP SERVICES
FORMAT: URL - LOWEST ACCESS TIER - NOTES
https://ipinfo.io/pricing - 1,000/day free - $50/m for 10,000/day with support
https://freegeoip.net/?q=23.196.102.76 - 15,000/hour free - open source https://github.com/fiorix/freegeoip
https://www.maxmind.com/en/geoip2-precision-demo -
http://geoiplookup.net/ - NO API - interactive only
https://www.ultratools.com/tools/ipWhoisLookupResult - NO API - interactive only
https://geoiptool.com/en/?ip=23.196.102.76 - NO API - interactive only
http://www.hostip.info/index.html - not looking promising - attributed my Boston-area IP as being in LA with Verizon
http://ipinfodb.com/ip_location_api.php - free API, but need API key and single IP address to source requests from - also has a commercial DB dowload ("The IPInfoDB.com has a goal of providing high-quality geolocation service to all users for free.")
@codingoutloud
codingoutloud / show-resourcegroup-contents.sh
Last active Mar 13, 2017
Using Azure CLI 2, show all the resources in a resource group
View show-resourcegroup-contents.sh
#/bin/bash
if [ $1 ]
then
echo "Resources in Azure Resource Group $1"
az resource list --query "[?resourceGroup=='$1'].{ name: name, flavor: kind, resourceType: type, region: location }" --output table
else
echo "usage: $0 [name-of-azure-resource-group]"
fi
View create-vm.py
from azure import *
from azure.servicemanagement import *
subscription_id = '<your_subscription_id>'
certificate_path = '<path_to_.pem_certificate>'
sms = ServiceManagementService(subscription_id, certificate_path)
name = 'myvm'
View azquota.py
from azure.servicemanagement import *
import platform
import os
plat = platform.system()
print("Platform == " + plat)
if plat != 'Windows':
certificate_path = './azquota.pem' # other than Windows
else:
View make-azure-sql-database.ps1
$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?
@codingoutloud
codingoutloud / make-aes256-certificate.sh
Created May 29, 2016
Generate an AES256 certificate for encrypting email, such as with the Outlook client for Mac.
View make-aes256-certificate.sh
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
@codingoutloud
codingoutloud / HttpClient.md
Last active May 8, 2016
HttpClient in .NET
View HttpClient.md
View Get-AzureRmSubscription-Default
(Get-AzureRmSubscription -SubscriptionId (Get-AzureRmContext).Subscription).SubscriptionName
View keybase.md

Keybase proof

I hereby claim:

  • I am codingoutloud on github.
  • I am codingoutloud (https://keybase.io/codingoutloud) on keybase.
  • I have a public key whose fingerprint is DE0B 68FC 8EC6 15A6 7E37 D12A B406 C6B3 FB60 5432

To claim this, I am signing this object:

You can’t perform that action at this time.