Skip to content

Instantly share code, notes, and snippets.

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 = [
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
ssh-keyscan localhost | ssh-keygen -lf -
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 /
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"
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'">
nzbart / Directory.Build.props
Created February 26, 2020 23:16
Disable Roslyn analysis for debug builds, but keep real-time analysis in IDEs and release mode builds.
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
nzbart /
Created January 21, 2020 20:26
Join Ubuntu Server to Active Directory (AD) domain
#Optional steps:
#apt update && apt full-upgrade -y && apt auto-remove -y
#apt install -y vim-nox
apt install -y packagekit realmd
pam-auth-update --enable mkhomedir
echo '%domain\ ALL=(ALL:ALL) ALL' > /etc/sudoers.d/example
realm join -v -U domain_admin_user_name
nzbart /
Last active July 24, 2019 03:31
Download all episodes of Red Hat's Command Line Heroes as MP3 files. Using the command line, of course.
curl -Ss | hxnormalize -ex | hxselect "enclosure[url\$='.mp3']::attr(url)" -c -s '\n' | xargs -n 1 curl -LO
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 &amp;&amp; apt full-upgrade -y