Skip to content

Instantly share code, notes, and snippets.

@NZSmartie
NZSmartie / drop_stream.rs
Last active April 26, 2021 01:22
Pass a callback into a Stream that will be called when the Stream is dropped
use ::pin_project::{pin_project, pinned_drop};
use futures::{stream::Fuse, StreamExt};
use std::pin::Pin;
#[pin_project(PinnedDrop)]
pub struct DropStream<St, Item, C>
where
St: futures::Stream<Item = Item>,
C: FnMut(),
{
@NZSmartie
NZSmartie / ec2.sh
Created September 5, 2019 19:06
ec2 inventory bootstrap for ansbile
#!/bin/bash
set -e
# Discover the current version of ansible
ANSILBE_VERSION=$(ansible --version | sed -rn 's/.*ansible ([0-9.]+).*/\1/p')
# If 'region = auto' is set in ec2.ini, then we need to export the region from the local aws configutation
export AWS_DEFAULT_REGION=$(aws configure get region)
@NZSmartie
NZSmartie / starmade-mod-proposal.md
Created April 7, 2019 01:13
StarMade Modding proposal with StarMade Dock integration.

Mod Proposal

Goals

  • Lay foundation to protect players against malicious/unwanted mods that may degrade game experience.
    • By allowing 3rd party mods to run on player's PCs, we're literary offering Remote Code Execution As A Service.
  • Minimise effort for players to join servers using mods.
  • Provide clear documentation with simple processes for creating, developing, uploading and using mods.

Glossary

@NZSmartie
NZSmartie / git-ps1-snippit.bashrc
Created October 5, 2018 02:22
PS1 with __git_ps1
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[38;5;9m\]$(__git_ps1 " [%s]")\[\033[00m\]\n\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 " [%s]")\n\$ '
fi
@NZSmartie
NZSmartie / winrm-test.py
Created October 5, 2018 02:16
Test WinRM command from a python2 script
#! /usr/bin/env python2
from __future__ import print_function
import getpass
from winrm.protocol import Protocol
conn = Protocol(
endpoint='https://dc.example.com:5986/wsman',
@NZSmartie
NZSmartie / esp-env.sh
Created October 3, 2018 22:02
Sets up your IDF_PATH and PATH for use with ESP32 development. also provides `deactivate` function to cleanup
#!/bin/bash
_PRE_IDF_PATH=$PATH
_PRE_IDF_PS1=$PS1
_PWD=$(dirname $(realpath $BASH_SOURCE))
export PATH=$PATH:$_PWD/xtensa-esp32-elf/bin
export IDF_PATH=$_PWD/esp-idf
@NZSmartie
NZSmartie / pcbnew_mod_reference_set_layer.py
Last active September 16, 2018 12:48
Set the Module's reference text to Cmts.User layer if their reference value matches
import pcbnew
import re
board = pcbnew.GetBoard()
for item in board.GetModules():
if re.match('D\d+-\d+$',item.GetReference()) is None:
continue
print "found %s" % item.GetReference()
@NZSmartie
NZSmartie / go-dep.sh
Created February 17, 2018 01:33
Becausse Go doesn't support command aliasing... 🤬
# TODO: Get latest release, not aa fixed version
sudo wget https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 -O /usr/bin/go-dep
sudo chmod u=rwx,go=rx /usr/bin/go-dep
cat > $HOME/.bashrc <<EOL
# Alias 'go dep' to go-dep
go() {
if [[ $@ == dep\ * ]]; then
@NZSmartie
NZSmartie / afunix.h
Last active July 2, 2020 07:35
afunix.h (Windows Insiders SDK for the Windows build 17061)
/*++
Copyright (c) Microsoft Corporation
Module Name:
afunix.h
Abstract:
thatClass.OnSomeEvent += async (sender, args) => 
{
await Task.Yield();
throw new Exception();
}