Skip to content

Instantly share code, notes, and snippets.

View tnibert's full-sized avatar

Timothy Nibert tnibert

View GitHub Profile
@tnibert
tnibert / hashmapexample.rs
Created December 10, 2021 10:32
Rust hashmap example usage code
// hashmap example - for reference
let mut sample: HashMap<String, i32> = HashMap::new();
sample.insert("one".to_string(), 1);
sample.insert("two".to_string(), 2);
sample.insert("three".to_string(), 3);
sample.insert("four".to_string(), 4);
for (key, value) in sample.iter() {
println!("{} - {}", key, value);
}
@tnibert
tnibert / seeallevt.js
Created May 31, 2022 07:12
Find all js events fired for given object
function seeAllEvt(myObj) {
for(var key in myObj){
if(key.search('on') === 0) {
myObj.addEventListener(key.slice(2), function (e) {
console.log(e.currentTarget + " " + e.type);
});
}
}
}
@tnibert
tnibert / certbotnotes.sh
Created June 13, 2022 05:10
Notes on certbot usage
certbot delete --cert-name example.com
@tnibert
tnibert / shelltricks.sh
Created August 22, 2022 00:10
shell tricks
# get all lines between two timestamps in a log
sed -n '/2012-08-20 11:34/,/2012-08-22 16:34/p' file
@tnibert
tnibert / sprite.rs
Created July 2, 2025 10:56
dependency injection with lifetimes
pub struct Sprite <'a> {
x: i32,
y: i32,
velocity: i32,
pub object: Object <'a>,
}
impl <'a> Sprite <'a> {
pub fn new(x: i32, y: i32, velocity: i32, object: Object<'a>) -> Sprite<'a>{
Self {