Skip to content

Instantly share code, notes, and snippets.

@msilcox
msilcox / git.txt
Last active March 31, 2020 08:37
Git tips
Make a file executable in git on Windows
git update-index --chmod=+x <file-name>
Forces all line endings to LF in your git repo.
https://gist.github.com/ajdruff/16427061a41ca8c08c05992a6c74f59e
@msilcox
msilcox / line-ending.sh
Created March 31, 2020 07:57
Convert windows line endings in unix
sed -i 's/\r$//' <file_path>
@msilcox
msilcox / PowerShell-Git.txt
Created March 27, 2020 10:52
PowerShell Git
First setup PowerShell:
Open PowerShell from start menu or shortcut (windows key + x, i)
Install posh-git module - Install-Module posh-git -Scope CurrentUser
Close PowerShell
Create profile.ps1 in ~/Documents/WindowsPowerShell with Content below
Open PowerShell again
profile.ps1
--------------------------
@msilcox
msilcox / link
Created November 15, 2018 09:51
Java ramdisk
@msilcox
msilcox / gitclean
Created November 12, 2018 09:26
alias to clean all remote deleted git branches
alias gitclean="git fetch -p -t && git branch --merged master | grep -v '^[ *]*master$' | xargs git branch -d"
@msilcox
msilcox / MyBenchmark.java
Last active September 25, 2015 10:43
Google Caliper Microbenchmark
/*
*/
package com.discover.dps.common.logging;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.LoggerFactory;
import com.google.caliper.Benchmark;
@msilcox
msilcox / MyCustomConverter.java
Created September 25, 2015 10:37
Logback Converter
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
public class MyCustomConverter extends ClassicConverter {
private final static Pattern PATTERN = Pattern.compile("\\b(([0-9]{5,8})[0-9]{4}([0-9]{4}))|((0[1-9]|1[0-2])[0-9]{2})\\b");
@msilcox
msilcox / spring-boot.sh
Created July 30, 2015 13:19
Spring Boot init script
#!/bin/bash
#
# Startup script for a spring boot project
#
# chkconfig: - 84 16
# description: Spring Boot project
# Source function library.
[ -f "/etc/rc.d/init.d/functions" ] && . /etc/rc.d/init.d/functions
[ -z "$JAVA_HOME" -a -x /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh
@msilcox
msilcox / LoggingTest.java
Last active February 19, 2019 14:32
Abstract base class for testing logging output from logback
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Logger;
@msilcox
msilcox / gist:88b74cdd8715bff932e5
Created April 17, 2015 11:12
mockito when using parameter
when(mock.myFunction(anyString())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
return (String) args[0];
}
});