Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am timbod7 on github.
  • I am timbod77 (https://keybase.io/timbod77) on keybase.
  • I have a public key ASByGqS9snO0G55GNTafZo8imOe6NCTOCKJPomdnmB88Hgo

To claim this, I am signing this object:

@timbod7
timbod7 / maps.rs
Created July 3, 2018 00:50
maybe create an optional reference inside a map
fn get_or_insert1<'a>(map: &'a mut HashMap<String,String>, key:&String) -> &'a mut String {
map.entry(key.clone()).or_insert_with(|| String::new())
}
fn get_or_insert2<'a>(map: &'a mut HashMap<String,String>, key:&String) -> &'a mut String {
match map.get_mut(key) {
Some(v) => v,
None => {
map.entry(key.clone()).or_insert(String::new())
}
@timbod7
timbod7 / aws-codeworld.sh
Last active August 29, 2015 14:03
Setup an Amazon Linux EC2 instance to run codeworld
# Update and install basic dependencies
sudo yum update -y
sudo yum install -y git
sudo yum install -y zlib-devel
sudo yum install -y ncurses-devel
# Needed for ghcjs-boot --dev