Skip to content

Instantly share code, notes, and snippets.

@troyhunt
troyhunt / Program.cs
Last active December 28, 2015 11:49
Does this code demonstrate the absolute max possible writes per second to an Azure storage table? I'm seeing it return averages of about 900 to 1,000 rows per second by batching inserts into 100 rows a go. Short of running batches async, is this code already optimal? Now revised to run each partition's batches in async. Throughput has jumped up …
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Net;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
namespace AzureSpeedTest
@troyhunt
troyhunt / CreateAzureResources.ps1
Created January 22, 2015 13:12
Full script for provisioning all the resources I typically use for a new Azure website and database back end
# Per project params
$projectName = "TroyPSTest"
$hostName = "troypstest.troyhunt.com"
# Environment constants
$location = "West US"
$webResourceGroup = "Default-Web-WestUS"
$webHostingPlan = "DefaultServerFarm"
$dbResourceGroup = "Default-SQL-WestUS"
$dbServerName = "snyb5o1pxk"
@troyhunt
troyhunt / DeleteAzureResources.ps1
Created January 22, 2015 13:14
This one removes all the components I normally create for an Azure website
# Input params
$projectName = "TroyPSTest"
# Constants
$dbServerName = "snyb5o1pxk"
$dbServerLogin = "troyhunt"
$dbServerPassword = "P@ssw0rd"
$apiVersion = "2014-04-01"
# Computed vars

Keybase proof

I hereby claim:

  • I am troyhunt on github.
  • I am troyhunt (https://keybase.io/troyhunt) on keybase.
  • I have a public key whose fingerprint is 78BA 604B 30AA B4DF 818D BB64 01E3 4D93 E69D 9BDA

To claim this, I am signing this object:

@troyhunt
troyhunt / gist:3dc7ced2a53a33f7a72bab2aaa4282f6
Created April 22, 2016 05:59
A complete URL map for the migration of troyhunt.com
http://www.troyhunt.com/2011/06/brief-sony-password-analysis.html,https://www.troyhunt.com/brief-sony-password-analysis/
http://www.troyhunt.com/2013/05/your-login-form-posts-to-https-but-you.html,https://www.troyhunt.com/your-login-form-posts-to-https-but-you/
http://www.troyhunt.com/2014/09/everything-you-need-to-know-about.html,https://www.troyhunt.com/everything-you-need-to-know-about2/
http://www.troyhunt.com/2009/10/25-illustrated-examples-of-visual.html,https://www.troyhunt.com/25-illustrated-examples-of-visual/
http://www.troyhunt.com/2009/10/creating-your-own-custom-subversion.html,https://www.troyhunt.com/creating-your-own-custom-subversion/
http://www.troyhunt.com/2009/10/why-online-identities-are-smart-career.html,https://www.troyhunt.com/why-online-identities-are-smart-career/
http://www.troyhunt.com/2009/11/is-software-quality-really-important.html,https://www.troyhunt.com/is-software-quality-really-important/
http://www.troyhunt.com/2009/11/pdc09-roundup.html,https://www.troyhunt.com/pdc09-roun
http://troyhunt.ghost.io/102-simple-steps-for-installing-and/,https://www.troyhunt.com/102-simple-steps-for-installing-and/
http://troyhunt.ghost.io/10-commandments-of-good-source-control/,https://www.troyhunt.com/10-commandments-of-good-source-control/
http://troyhunt.ghost.io/10-email-security-fundamentals-for/,https://www.troyhunt.com/10-email-security-fundamentals-for/
http://troyhunt.ghost.io/10-graphic-examples-of-abomination-that/,https://www.troyhunt.com/10-graphic-examples-of-abomination-that/
http://troyhunt.ghost.io/10-illustrated-examples-of-visual/,https://www.troyhunt.com/10-illustrated-examples-of-visual/
http://troyhunt.ghost.io/10-lessons-for-uncultured-web-developers/,https://www.troyhunt.com/10-lessons-for-uncultured-web-developers/
http://troyhunt.ghost.io/10-tenets-of-pain-free-travel/,https://www.troyhunt.com/10-tenets-of-pain-free-travel/
http://troyhunt.ghost.io/10-things-i-learned-about-rapidly/,https://www.troyhunt.com/10-things-i-learned-about-rapidly/
http://troyhunt.ghost.io/10-wa
@troyhunt
troyhunt / TestCacheController.cs
Created August 20, 2016 21:10
A sliding cache implementation... that still expires after 1 second even with requests every 300ms
using System;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Caching;
using System.Web.Http;
namespace Web.Controllers
{
public class TestCacheController : ApiController
@troyhunt
troyhunt / BlockIpAtCloudFlare.csx
Last active September 25, 2016 08:03
Pick an IP address up off a queue and block it in CloudFlare
using System;
using System.Configuration;
public static void Run(string myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
BlockIp(myQueueItem).Wait();
}
static async Task BlockIp(string ipAddress)
using System;
using System.Configuration;
public static void Run(TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
RemoveIpBlocks(log).Wait();
}
static async Task RemoveIpBlocks(TraceWriter log)
@troyhunt
troyhunt / Build-Troys-Network
Last active February 21, 2024 02:52
Help me spec out a replacement home network using Ubiquiti bits
That's it - I've finally lost it with Linksys and both my WRT 1900ACs that are only a year old are getting chucked. Don't get me started on all the reasons why, but it's primarily down to continued degradation of wifi signal and the constant need for reboots. Going by the responses to this tweet, that's just what they do: https://twitter.com/troyhunt/status/778867707655487488
I’m going all out with Ubiquiti instead. No, I'm not interested in [insert the other thing you think rocks here], there's a really vocal majority in favour of Ubiquiti so that's that. Now I need help speccing out what I need for my house as it’s not quite as straight forward as just chucking in a couple of (dodgy) routers.
Here’s what I’m working with:
- Large multi-level house about 500m2 (needs at least 2 APs, probably more)
- Wired ethernet to every room (I believe Cat 5e, was here when I got here)
- Patch board in the garage and a 100Mbps hub (running patch cables out to a Linksys 8 port gigabit switch instead)
- 4 wired connection