Skip to content

Instantly share code, notes, and snippets.

nzbart / Readme.markdown
Created June 2, 2019 20:02
Change WSL to debian testing
  1. Replace the existing sources.list with the on in this Gist.
  2. apt update && apt full-upgrade -y
nzbart / Repro.cmd
Last active March 22, 2023 02:19
How to use `git bisect run` with a PowerShell script to reproduce an issue, for example a test that has started failing recently.
powershell -command %~dpn0.ps1
nzbart /
Created September 28, 2021 22:21
Microsoft Todo query using Microsoft Graph
from msal import PublicClientApplication
import requests
def get_authorisation_token():
app = PublicClientApplication(
"***Your Application (client) ID****",
scopes = [
nzbart / CredWriteAndReadWithProfileLoad.cpp
Last active February 26, 2021 03:27
Read / write credentials through CredRead and CredWrite, with a profile load for good measure. Fails under PowerShell remoting.
#include <SDKDDKVer.h>
#include <tchar.h>
#include <Windows.h>
#include <WinCred.h>
#include <Userenv.h>
#include <atlsecurity.h>
#include <Lmcons.h>
#include <iostream>
nzbart /
Last active June 29, 2020 07:13
Script to backup minecraft server once a day to (needs to be run manually)
set -e
set_most_recent_backup_file() {
MOSTRECENTLOCALBACKUPFILE=$(find "$BACKUPDIR" -type f -printf '%f\n' | sort -r | head -1)
echo "Most recent local backup file: $MOSTRECENTLOCALBACKUPFILE"
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
ssh-keyscan localhost | ssh-keygen -lf -
nzbart / NetworkCapture.psm1
Last active May 12, 2020 15:45
Run a network capture on Windows without installing Wireshark or any other tools on your servers.
#requires -version 3
$ErrorActionPreference = 'Stop'
$networkTraceFileName = 'NetworkTrace'
function LaunchSingleRemoteCommand([string][parameter(mandatory)]$ComputerName, [pscredential]$Credential, [System.Management.Automation.Runspaces.AuthenticationMechanism]$Authentication, [scriptblock][parameter(mandatory)]$ScriptBlock)
$args = @{
ComputerName = $ComputerName
nzbart /
Last active May 1, 2020 13:34
Join a Debian/Ubuntu based server to a Windows domain so that users can ssh with domain credentials
# Replace with your domain
hostnamectl set-hostname <hostname> # FQDN required for DNS registrations by realm (not sure why)
mkdir -p /var/log/journal # Persist logs across reboots
apt update && apt full-upgrade -y && apt auto-remove -y # Get software up to date
apt install -y unattended-upgrades packagekit realmd dnsutils sudo # Install required packages
pam-auth-update --enable mkhomedir # Allow automatic creation of home directories for domain users
echo '%domain\ ALL=(ALL:ALL) ALL' > /etc/sudoers.d/ # Allow all domain users to act as root in high-trust environments
ssh-keyscan localhost | ssh-keygen -lf - # Take a record of the SSH keys for secure login
realm join -v -U <your unqualified domain user name> # J
nzbart / app.R
Last active March 18, 2020 07:31
New Zealand coronavirus/COVID-19 case chart as Shiny app. Published at
ui <- shiny::fillPage(
titlePanel("Coronavirus in NZ"),
nzbart / Directory.Build.props
Last active February 26, 2020 23:16
Disable Roslyn analysis for debug builds, but keep real-time analysis in IDEs and release mode builds. Simply put this file in the project root.
<PropertyGroup Condition="'$(Configuration)'=='Debug'">