Skip to content

Instantly share code, notes, and snippets.

@DarrenTsung
DarrenTsung / imds_v2.rs
Created February 10, 2021 19:39
A forked version of rusoto_credential::InstanceMetadataProvider that supports IMDSv2
//! The Credentials Provider for an AWS Resource's IAM Role (using IMDSv2).
use async_trait::async_trait;
use futures::TryFutureExt;
use std::time::Duration;
use rusoto_core::credential::{AwsCredentials, CredentialsError, ProvideAwsCredentials};
const AWS_CREDENTIALS_PROVIDER_IP: &str = "169.254.169.254";
const AWS_CREDENTIALS_PROVIDER_PATH: &str = "latest/meta-data/iam/security-credentials";
@DarrenTsung
DarrenTsung / cargo_watch_logs.txt
Created July 18, 2020 16:15
Full Cargo Watch Logs
root@bd89e931d176:/app# cargo watch --debug -x run
2020-07-18T16:03:00.476+00:00 - DEBUG - Load Git/VCS ignores: true
2020-07-18T16:03:00.476+00:00 - DEBUG - Load .ignore ignores: true
2020-07-18T16:03:00.476+00:00 - DEBUG - Default ignores: ["*/.DS_Store", "*.sw?", "*.sw?x", "#*#", ".#*", ".*.kate-swp", "*/.hg/**", "*/.git/**", "*/.svn/**", "*.db", "*.db-*", "*/*.db-journal/**", "*/target/**"]
2020-07-18T16:03:00.476+00:00 - DEBUG - All ignores: ["*/.DS_Store", "*.sw?", "*.sw?x", "#*#", ".#*", ".*.kate-swp", "*/.hg/**", "*/.git/**", "*/.svn/**", "*.db", "*.db-*", "*/*.db-journal/**", "*/target/**"]
2020-07-18T16:03:00.476+00:00 - DEBUG - File updates debounce: 0.5 seconds
2020-07-18T16:03:00.476+00:00 - DEBUG - Watches: ["."]
2020-07-18T16:03:00.476+00:00 - DEBUG - Commands: ["cargo run"]
2020-07-18T16:03:00.476+00:00 - DEBUG - Watchexec arguments: Args { cmd: ["cargo run"], paths: ["."], filters: [], ignores: ["*/.DS_Store", "*.sw?", "*.sw?x", "#*#", ".#*", ".*.kate-swp", "*/.hg/**", "*/.git/**", "*/.svn/**
5979 Oct 17 09:48:13
1820 Oct 17 09:48:14
25 Oct 17 09:48:21
29031 Oct 17 09:48:22
17973 Oct 17 09:48:23
31946 Oct 17 09:48:24
57835 Oct 17 09:48:25
51283 Oct 17 09:48:26
39697 Oct 17 09:48:27
32205 Oct 17 09:48:28
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
void BeOnTheLookout(float radius) {
Collider[] hitColliders = Physics.OverlapSphere(transform.position, radius);
int highestBounty = 0;
Collider mostWantedCriminal = null;
foreach (Collider criminal in hitColliders) {
var bounty = criminal.GetComponent<Bounty>();
if (bounty == null) {
continue;
}
@DarrenTsung
DarrenTsung / ValidationTests.cs
Created June 4, 2017 21:57
Validation tests that you can copy into your project - see DTValidator (https://github.com/DarrenTsung/DTValidator)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEngine.Events;
using NUnit.Framework;
@DarrenTsung
DarrenTsung / StateBehaviourExtensions.cs
Last active May 15, 2017 17:53
Example on how I configure my StateMachineBehaviours
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DTAnimatorStateMachine {
public static class StateBehaviourExtensions {
public static IEnumerable<IStateBehaviour<TStateMachine>> GetStateBehaviours<TStateMachine>(this TStateMachine stateMachine, Animator animator) {
StateMachineBehaviour[] behaviours = animator.GetBehaviours<StateMachineBehaviour>();
foreach (StateMachineBehaviour behaviour in behaviours) {
@DarrenTsung
DarrenTsung / LogicalStateMachineBehaviour.cs
Created August 30, 2016 17:24
Encapsulated class I use instead of StateMachineBehaviour
using System;
using System.Collections;
using UnityEngine;
namespace DT {
public class LogicalStateMachineBehaviour : StateMachineBehaviour {
// PRAGMA MARK - StateMachineBehaviour Lifecycle
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
this.Animator = animator;
@DarrenTsung
DarrenTsung / AngryPufferfishExample3.cs
Last active August 29, 2016 17:31
Third example in my StateMachineBehaviour article
class MoveInFacingDirection : LogicalStateMachineBehaviour {
[SerializeField] private float _speed = 5.0f;
void OnStateUpdate() {
this.MoveInFacingDirection();
}
...
}
@DarrenTsung
DarrenTsung / AngryPufferfishExample2.cs
Last active April 14, 2018 08:20
Second example in my StateMachineBehaviour article
class TriggerContinueAfterDelay : LogicalStateMachineBehaviour {
[SerializeField] private float _delay = 1.0f;
void OnStateEntered() {
this.DoAfterDelay(this._delay, () => {
this.Animator.SetTrigger("Continue");
}
}
}