Skip to content

Instantly share code, notes, and snippets.

View ducas's full-sized avatar

Ducas Francis ducas

  • Readify
  • Sydney, Australia
View GitHub Profile
@ducas
ducas / curl-check.yaml
Created June 7, 2019 01:47
DaemonSet that queries a web endpoint and prints out timing used for determining where latency may be introduced
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: curl-check
labels:
app: curl-check
spec:
template:
metadata:
labels:
@ducas
ducas / upgrade-rancher.sh
Created January 8, 2019 00:20
Upgrade single-node Rancher with data volume
#!/bin/bash
old_id=$1
old_version=$2
new_version=$3
now=`date +%Y%m%d-%H%M%S`
echo "Stop $2 ($1)"
docker stop $1
echo "Create new volume"
@ducas
ducas / purge.json
Last active June 12, 2018 23:41
Purge an Azure resource group
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": { },
"resources": [ ],
"outputs": { }
}
@ducas
ducas / Setup-VstsAgent.ps1
Last active May 23, 2017 00:19
Setting up a VS2017 Build Agent
$agentUrl = 'https://github.com/Microsoft/vsts-agent/releases/download/v2.112.0/vsts-agent-win7-x64-2.112.0.zip'
$vstsUrl = '' # TODO: Set URL - e.g. https://mytenant.visualstudio.com
$pat = '' # TODO: set PAT generated using these instructions - https://www.visualstudio.com/en-us/docs/build/actions/agents/v2-windows
$pool = 'default'
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
# change this or add more steps below to install any other prerequisites
choco install -y `
visualstudio2017community `
@ducas
ducas / increase-replication-factor.js
Last active November 8, 2021 14:42
Increase Replication Factor for Kafka Topics
/*
* This script reads the existing partition assignments in JSON (exported using kafka-reassign-partitions.sh) and generates
* the appropriate reassignment JSON file for input to kafka-reassign-partitions.sh.
*
*/
var usage = `
Usage: node increase-replication-factory.js (brokers) (replication factor) (current assignment file) (output file) [-f]
* brokers: comma separated list of brokers
* replication factor: the new replication factor to use
@ducas
ducas / kafka-run-class.bat
Created April 6, 2016 01:36
A working version of kafka-run-class.bat for confluent-1.0.1
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
@ducas
ducas / Vagrantfile
Last active February 5, 2016 06:00
Vagrant machine for Confluent 2.0
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.50"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
@ducas
ducas / Get-References.ps1
Created May 12, 2015 05:04
Find project references and determine whether they're local or GAC
ls -Recurse -Filter *.csproj | %{
$filename = $_.FullName
$ns = @{ msbuild = "http://schemas.microsoft.com/developer/msbuild/2003" }
#[xml]$proj = Get-Content $filename
$proj = Get-Content $filename | Out-String
Select-Xml -Xml $proj -XPath "//msbuild:Reference" -Namespace $ns | %{
$item = $_.Node.Include
$hintPath = $_.Node.HintPath
$isGac = $hintPath -eq $null
@ducas
ducas / Configure-UrlRewriteRules.ps1
Last active July 11, 2021 14:13
Common configuration for IIS sites behind a load balancer to propagate HTTPS flag and avoid ports in generated URLs
$SiteName = "Default Web Site"
Import-Module WebAdministration
Write-Host "Getting allowed server variables..."
$allowedServerVariables = Get-WebConfigurationProperty -PSPath "MACHINE/WEBROOT/APPHOST" -filter "system.webServer/rewrite/allowedServerVariables/add" -Name name
Write-Host "Found $($allowedServerVariables.Length)..."
if ( ($allowedServerVariables -eq $null) -or ( $allowedServerVariables | ?{ $_.Value -eq "HTTPS" } ).Length -eq 0 ) {
#Configure IIS To Allow 'HTTPS' as a server variable - Must be done at a applicationhosts.config level
@ducas
ducas / Set-TcpDefaults.ps1
Last active August 29, 2015 14:15
Set TCP properties in the Windows registry to avoid ephemeral port exhaustion
# https://msdn.microsoft.com/en-us/library/cc296845(v=bts.10).aspx
param (
[switch]$Fix = $false
)
function Set-RegistryProperty ($name, $value) {
$changed = $false