Skip to content

Instantly share code, notes, and snippets.

@nzbart
nzbart / get_lists.py
Created Sep 28, 2021
Microsoft Todo query using Microsoft Graph
View get_lists.py
from msal import PublicClientApplication
import requests
def get_authorisation_token():
app = PublicClientApplication(
"***Your Application (client) ID****",
authority="https://login.microsoftonline.com/consumers")
scopes = [
View Enable SSH on Windows.ps1
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
ssh-keyscan localhost | ssh-keygen -lf -
@nzbart
nzbart / join-domain.sh
Last active May 1, 2020
Join a Debian/Ubuntu based server to a Windows domain so that users can ssh with domain credentials
View join-domain.sh
# Replace example.com with your domain
hostnamectl set-hostname <hostname>.example.com # 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\ admins@example.com ALL=(ALL:ALL) ALL' > /etc/sudoers.d/example.com # 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> example.com # J
@nzbart
nzbart / backup.sh
Last active Jun 29, 2020
Script to backup minecraft server once a day to mega.nz (needs to be run manually)
View backup.sh
#!/bin/bash
set -e
BACKUPDIR="../minecraft-backups"
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
nzbart / app.R
Last active Mar 18, 2020
New Zealand coronavirus/COVID-19 case chart as Shiny app. Published at https://bartj.shinyapps.io/covid19/.
View app.R
library(shiny)
library(tidyverse)
library(lubridate)
library(plotly)
library(scales)
ui <- shiny::fillPage(
titlePanel("Coronavirus in NZ"),
@nzbart
nzbart / Directory.Build.props
Last active Feb 26, 2020
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.
View Directory.Build.props
<Project>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup>
</Project>
@nzbart
nzbart / Directory.Build.props
Created Feb 26, 2020
Disable Roslyn analysis for debug builds, but keep real-time analysis in IDEs and release mode builds.
View Directory.Build.props
<Project>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup>
</Project>
@nzbart
nzbart / join.sh
Created Jan 21, 2020
Join Ubuntu Server to Active Directory (AD) domain
View join.sh
#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\ admins@example.com ALL=(ALL:ALL) ALL' > /etc/sudoers.d/example
realm join -v -U domain_admin_user_name example.com
@nzbart
nzbart / DownloadAllCommandLineHeroesEpisodes.sh
Last active Jul 24, 2019
Download all episodes of Red Hat's Command Line Heroes as MP3 files. Using the command line, of course.
View DownloadAllCommandLineHeroesEpisodes.sh
#!/usr/bin/sh
curl -Ss https://feeds.pacific-content.com/commandlineheroes | hxnormalize -ex | hxselect "enclosure[url\$='.mp3']::attr(url)" -c -s '\n' | xargs -n 1 curl -LO
@nzbart
nzbart / Readme.markdown
Created Jun 2, 2019
Change WSL to debian testing
View Readme.markdown
  1. Replace the existing sources.list with the on in this Gist.
  2. apt update &amp;&amp; apt full-upgrade -y