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 / Create-Administrator.ps1
Last active May 22, 2024 09:29
Create a local administrator account using PowerShell
$Username = "su"
$Password = "password"
$group = "Administrators"
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$existing = $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $Username }
if ($existing -eq $null) {
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 and generates
* the appropriate reassignment JSON file for input to
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 / 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 / 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
name: curl-check
app: curl-check
ducas /
Created January 8, 2019 00:20
Upgrade single-node Rancher with data volume
now=`date +%Y%m%d-%H%M%S`
echo "Stop $2 ($1)"
docker stop $1
echo "Create new volume"
ducas / purge.json
Last active June 12, 2018 23:41
Purge an Azure resource group
"$schema": "",
"contentVersion": "",
"parameters": { },
"variables": { },
"resources": [ ],
"outputs": { }
ducas / TodoApiController.cs
Created February 27, 2012 02:55
Validating your model with Web API
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Data;
public class TodoApiController : ApiController
private BetterMobileSpaContext db = new BetterMobileSpaContext();
// GET /api/todoapi
ducas / Set-LocalAccountPassword.ps1
Last active January 19, 2018 15:27
Change a local user account's password using PowerShell
$Username = "su"
$Password = "password"
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$existing = $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $Username }
if ($existing -eq $null) {
Write-Error "User $Username does not exist"
ducas / Setup-VstsAgent.ps1
Last active May 23, 2017 00:19
Setting up a VS2017 Build Agent
$agentUrl = ''
$vstsUrl = '' # TODO: Set URL - e.g.
$pat = '' # TODO: set PAT generated using these instructions -
$pool = 'default'
iwr -UseBasicParsing | iex
# change this or add more steps below to install any other prerequisites
choco install -y `
visualstudio2017community `
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