Skip to content

Instantly share code, notes, and snippets.

@reimai
reimai / ConcurrentIndexerTest.java
Created September 11, 2015 10:47
I knew it would fail for ConcurrentHashMap, but I just have to test it
public class ConcurrentIndexerTest {
@Test
public void testUniqueIndexes() throws InterruptedException, ExecutionException {
//would not work for ConcurrentHashMap unless you're extreamly lucky
Map<String, Integer> index = Collections.synchronizedMap(new HashMap<>());
populateIndexer(index);
Collection<Integer> indexes = index.values();
Set<Integer> uniqueIndexes = new HashSet<>(indexes);
@reimai
reimai / home.sh
Last active August 29, 2015 14:14
Brings you to your old home after sudo su
#!/bin/bash
#brings you back home after sudo su
function get_owner {
pid=$1
echo $(ps ouid -p $pid h | tr -d ' ')
}
pid=$$
my_uid=$(get_owner $pid)
@reimai
reimai / vimrc
Last active August 29, 2015 14:13
syntax on
set nu
set title
set titleold=""
set titlestring=VIM:\ %F
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
@reimai
reimai / bashrc
Last active September 19, 2016 17:56
alias ..="cd ../"
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias mvnT='mvn -T 4 -e package'
alias mvnNT='mvn -T 4 -DskipTests -e package'
alias mvnNTA='mvn -T 4 -Dmaven.test.skip=true -e package'
alias mvnTI='mvn -T 4 -e clean install'