Skip to content

Instantly share code, notes, and snippets.

@bcalmac
bcalmac / windows-services-util.sh
Created March 17, 2015 18:18
Bash functions to start/stop/restart multiple services on Windows
# start the services passed as arguments
function nst { for s in "$@"; do net start $s; done }
# stop the services passed as arguments
function nsp { for s in "$@"; do net stop $s; done }
# restart the services passed as arguments
function nrs {
# Stop in reverse order
for ((i=$#; i>0; i--)); do net stop ${!i}; done
@bcalmac
bcalmac / FileTest.java
Created March 15, 2015 16:42
Asserting file content with AssertJ
import java.io.File;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
public class FileTest {
@Test
public void file() {
File actualFile = new File("actual.txt");
@bcalmac
bcalmac / java-7.reg
Created March 11, 2015 23:06
Java registry entry for AdvancedInstaller
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.7]
"JavaHome"="C:\\tools\\java-7"
"MicroVersion"="0"
@bcalmac
bcalmac / junit-live-templates.txt
Last active August 29, 2015 14:16
IntelliJ live templates for JUnit
# Applicable in : Java statement
# Reformat according to style : true
# Use static import if possible: true
# Shorten FQ names : true
#
# Do nothing about "Edit variables". I wasn't able to define defaults like "expected" and "actual".
org.junit.Assert.assertEquals($EXPECTED$, $ACTUAL$);
$END$
@bcalmac
bcalmac / CaseInsensitiveSetMultimap.java
Created March 10, 2015 18:34
Case insensitive SetMultimap using Guava
import com.google.common.collect.ForwardingSetMultimap;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
/** SetMultimap decorator that coverts keys to lower case before delegation */
public class CaseInsensitiveSetMultimap<V> extends ForwardingSetMultimap<String, V> {