Skip to content

Instantly share code, notes, and snippets.

View asasine's full-sized avatar

Adam Sasine asasine

View GitHub Profile
@asasine
asasine / lib.rs
Created July 13, 2024 18:03
Multiplayer scoring in Pong + Bevy
//! An abbreviated setup for associating colliders that increment scores.
//!
//! This is missing many systems to actually be a functioning Pong game but demonstrates a way to relate multiple entities.
/// A component that marks an entity as a player's score.
#[derive(Component, Deref, DerefMut, Default)]
pub struct Score(pub u32);
/// A component that marks an entity as a text label for a player's score.
///
@asasine
asasine / README.md
Last active January 29, 2024 16:56
Backchained PPA

Backchained PPA

An example of a postcondition-precondition-action (PPA) that is backchained once to create a more capable tree.

Tested with BehaviorTree.CPP v4.5.1 with plain CMake.

  1. Clone the repo.
  2. Check out the same version: git checkout 4.5.1
  3. Set up dependencies according to the repo's README.
  4. Copy the gtest_ppa.cpp file to the tests/ directory.
  5. Modify tests/CMakeLists.txt to include gtest_ppa.cpp in the BT_TESTS variable.
$sw = [System.Diagnostics.Stopwatch]::StartNew()
Write-Host "Started at $((Get-Date).ToUniversalTime().ToString("O"))"
$n = git rev-list --count HEAD
Write-Host "Completed at $((Get-Date).ToUniversalTime().ToString("O"))"
Write-Host "Total elapsed time: $($sw.Elapsed.ToString())"
Write-Host "There are $n commits in the current branch's history"
@asasine
asasine / README.md
Last active May 4, 2018 19:55
ARM Templates

Add a new NSG to an Existing Subnet with security rules for Azure Redis Cache

This template creates a Network Security Group, adds security rules compatible with Azure Redis Cache, and associates it with an existing subnet.

Running the ARM template will ask you for the names of an existing virtual network and subnet and the name of the new NSG. If an NSG with the same name and resource group already exists, it will be replaced with the new NSG.

Deploying

Microsoft Azure PowerShell

PS C:\> New-AzureRmResourceGroupDeployment -ResourceGroupName "my-resource-group" -TemplateUri "https://gist.githubusercontent.com/asasine/51d29134949c72d8ae90d6fa70d5c90d/raw/azuredeploy.json"
@asasine
asasine / .gitignore
Last active August 9, 2017 01:29
Gist for wrangling movie scripts into a more machine-readable format
### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# temporary
*~
import regex
import functools
abbreviations = ['mr', 'ms', 'mrs', 'dr', 'st', 'rd', 'ave', 'av', 'etc']
abbreviation_regex_pattern = '|'.join(map(lambda abbreviation: '[' + abbreviation[0].upper() + abbreviation[0].lower() + ']' + ('' if len(abbreviation) == 1 else abbreviation[1:]), abbreviations))
punctuation_regex_pattern = '[!?.]+'
punctuation_no_abbreviations_regex_pattern = '(?<!{0})({1})'.format(abbreviation_regex_pattern, punctuation_regex_pattern)
with open('boss_baby_v1.txt') as current, open('boss_baby_v3.txt', 'w') as new:
lines = current.readlines() # list of lines
Lornsome night. An' babbits bawlin', wind bitin' the bone. Wind like this... full of voices. It's the ancestry howlin' at ya; yibberin' stories. All voices... tied up into one. One voice different... One voice whisperin' out there; spyin' from 'he dark. That fangy devil, Old Georgie hisself. Now you hear up close and I'll yarn you about the first time we met eye to eye. And thus it was that I made the acquaintance of Dr. Henry Goose, the man I hoped might cure me of my affliction. Have you lost something? Question one: What secret in Sixsmith's report would be worth killing for? Question two: Is it reasonable to believe that they would kill again to protect that secret? And if so, question three: What the fuck am I doing here? While my extensive experience as an editor has led me to a disdain for flashbacks and flash forwards and all such tricksy gimmicks, I believe that if you, dear reader, can extend your patience for just a moment, you will find there is a method to this tale of madness. My dearest Sixsmit
name album artists duration_ms popularity
Spirit In The Sky Music From The Motion Picture Michael [Norman Greenbaum] 239600 72
Signed, Sealed, Delivered (I'm Yours) Number 1's [Stevie Wonder] 158040 65
Rich Girl - Remastered 2003 The Essential Daryl Hall & John Oates [Daryl Hall & John Oates] 144333 72
Walking On Sunshine Katrina & The Waves [Katrina & The Waves] 238733 75
Ain't No Mountain High Enough - Stereo Version The Very Best Of Marvin Gaye [Marvin Gaye,Tammi Terrell] 146160 30
Here Comes The Sun - Remastered Abbey Road (Remastered) [The Beatles] 185733 73
Jessie's Girl The Best Of Rick Springfield [Rick Springfield] 192866 71
My Girl The Temptations Sing Smokey [The Temptations] 165000 72
Put Your Records On Corinne Bailey Rae [Corinne Bailey Rae] 215360 74
@asasine
asasine / bee_movie_transcript.txt
Last active July 21, 2017 01:05
Bee wranglerzzz
According to all known laws
of aviation,
there is no way a bee
should be able to fly.
Its wings are too small to get
its fat little body off the ground.
"""
Copyright (c) 2017 Adam Sasine
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: