Skip to content

Instantly share code, notes, and snippets.

View camsteffen's full-sized avatar
💭
Building software for days

Cameron Steffen camsteffen

💭
Building software for days
View GitHub Profile
@camsteffen
camsteffen / maplit-hashmap-options.rs
Last active August 12, 2020 19:40
Proposal hashmap! macro with options
macro_rules! hashmap {
(@opts nocap $hash:tt capacity: $cap:expr $(, $($tail:tt)*)?) => (hashmap!(@opts $cap $hash $($($tail)*)?));
(@opts $cap:tt nohash S: $hash:ty $(, $($tail:tt)*)?) => (hashmap!(@opts $cap (<$hash>::default()) $($($tail)*)?));
(@opts $cap:tt nohash hasher: $hash:expr $(, $($tail:tt)*)?) => (hashmap!(@opts $cap $hash $($($tail)*)?));
(@opts $cap:tt $hash:tt $name:ident: $($tail:tt)*) => (compile_error!(concat!("Invalid option: ", stringify!($name))));
(@opts $cap:tt $hash:tt) => (hashmap!(@init $cap $hash));
(@opts $cap:tt $hash:tt $($key:expr => $value:expr),+ $(,)?) => {
{
let mut map = hashmap!(@init $cap $hash $($key)*);
@camsteffen
camsteffen / git-clean-merged.zsh
Last active April 6, 2020 16:56
Deletes all merged branches with an option to edit the list
#!/usr/bin/env zsh
setopt EXTENDED_GLOB
# get list of all merged branches
branches=(${(f)"$(git branch --format '%(refname:short)' --merged)"})
# remove current branch
current=("$(git branch --show-current)")
branches=(${branches:|current})
# remove master|develop branches
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software