Skip to content

Instantly share code, notes, and snippets.

@nzbart
nzbart / get_lists.py
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****",
authority="https://login.microsoftonline.com/consumers")
scopes = [
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 13:34
Join a Debian/Ubuntu based server to a Windows domain so that users can ssh with domain credentials
# 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 June 29, 2020 07:13
Script to backup minecraft server once a day to mega.nz (needs to be run manually)
#!/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 March 18, 2020 07:31
New Zealand coronavirus/COVID-19 case chart as Shiny app. Published at https://bartj.shinyapps.io/covid19/.
library(shiny)
library(tidyverse)
library(lubridate)
library(plotly)
library(scales)
ui <- shiny::fillPage(
titlePanel("Coronavirus in NZ"),
@nzbart
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.
<Project>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup>
</Project>
@nzbart
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.
<Project>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup>
</Project>
@nzbart
nzbart / join.sh
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\ 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 July 24, 2019 03:31
Download all episodes of Red Hat's Command Line Heroes as MP3 files. Using the command line, of course.
#!/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 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