Skip to content

Instantly share code, notes, and snippets.

View Nitecon's full-sized avatar
💭
The unicorns don't look realistic enough!

Will Nitecon

💭
The unicorns don't look realistic enough!
View GitHub Profile
@Nitecon
Nitecon / bruce-ec2
Created January 31, 2025 19:58
Quick example using bruce.tools 1.5 to standup a new ec2 instance, run a command and then terminate the instance.
---
variables:
INSTANCE_TYPE: t2.micro
steps:
# Create a new aws ec2 instance, but only if none already exist (notIf)
- cmd: aws ec2 run-instances --image-id ami-0c614dee691cbbf37 --count 1 --instance-type {{.INSTANCE_TYPE}} --key-name YourKey --subnet-id subnet-07317935cd9123d --tag-specifications 'ResourceType=instance,Tags=[{Key=BoxType,Value=TestMe}]'
notIf: INSTANCE_IP=$(aws ec2 describe-instances --filters Name=tag:BoxType,Values=TestMe --query "Reservations[*].Instances[0].PublicIpAddress" --output text); if [ ! -z "$INSTANCE_IP" ] && [ "$INSTANCE_IP" != "None" ]; then echo "instance up"; fi
setEnv: NEW_INSTANCE
# Get the ip address of the instance so we can connect
- cmd: 'for i in {1..12}; do INSTANCE_IP=$(aws ec2 describe-instances --filters Name=tag:BoxType,Values=TestMe --query "Reservations[*].Instances[0].PublicIpAddress" --output text); if [ -n "$INSTANCE_IP" ] && [ "$INSTANCE_IP" != "None" ]; then echo "$INSTANCE_IP"; break; fi; sleep 5; done'
@Nitecon
Nitecon / depinstall.sh
Created August 24, 2024 20:52
One line dep installer for fedora
sudo dnf install htop 'dnf-command(config-manager)' git curl @development-tools dkms perl wget gcc make libglvnd-egl libglvnd-devel
@Nitecon
Nitecon / NeuralData.cpp
Created January 17, 2024 03:20
Neural Data Subsystem for unreal engine.
#include "NeuralData.h"
#include "NNE.h"
UNeuralData::UNeuralData(): SelectedRuntimeType(ERuntimeType::CPU)
{
}
bool UNeuralData::InitModel(const FString& ModelPath, const FString& RuntimeType)
{
@Nitecon
Nitecon / Nginx Vhost Example
Created March 31, 2023 17:23
This vhost example is for use with golang text/template and exposes 2 variables to be replaced.
server {
listen 80;
server_name {{.Domain}};
root {{.VHOST_ROOT}};
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
@Nitecon
Nitecon / sensorActivatedLights.yaml
Last active December 15, 2022 00:22
Use a broader sensor type for motion activated lights
blueprint:
name: Sensor-activated Light
description: Turn on a light when motion is detected.
domain: automation
source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
input:
motion_entity:
name: Motion Sensor
selector:
entity:
# This takes an owner of a repo, the repo name iteself and then looks up latest tag and gets the tarball url downloads the file.
# then extracts it to /tmp/$REPO
OWNER=iMicknl;REPO=ha-nest-protect; curl -o ${REPO}.tar.gz -L $(curl -s https://api.github.com/repos/${OWNER}/${REPO}/releases/latest | grep "tarball_url" | cut -d : -f 2,3 | tr -d \"|tr -d , | awk '{$1=$1};1') && mkdir -p /tmp/${REPO}; tar -xf ${REPO}.tar.gz --strip-components=1 -C /tmp/${REPO}
@Nitecon
Nitecon / motion_activated_scenes.yaml
Last active July 26, 2022 01:47
Motion activated scenes for home assistant
blueprint:
name: Motion activated scenes
description: Activate a day/night scene when motion is detected. Without motion an off scene is triggered.
domain: automation
source_url: https://gist.github.com/Nitecon/77b0485080f63550b38d2bd3e91df904
input:
motion_entity:
name: Motion Sensor
selector:
entity:
@Nitecon
Nitecon / panic.go
Created February 20, 2019 21:20
Table driven golang panic test
package main
func addLevelPool(level int) {
if level > 9{
panic("runtime error: index out of range")
}
}
@Nitecon
Nitecon / gov
Last active June 29, 2016 15:31
gov provides a way to create vendor experiment setups directly (Requires mac / linux)
#!/bin/bash
GOSRC="$GOPATH/src/"
CURPATH=`pwd`
if [ -z "$GOPATH" ]; then
echo "Need to set GOPATH"
exit 1
fi
if ! [[ $GOPATH == */ ]]; then