Skip to content

Instantly share code, notes, and snippets.

View junkdog's full-sized avatar
🐥

Adrian Papari junkdog

🐥
  • Stockholm
View GitHub Profile
@junkdog
junkdog / gist:8349897
Created January 10, 2014 10:43
.bash_prompt
#!/bin/bash
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
local C="\[\033[0;36m\]" # cyan
local EMC="\[\033[1;36m\]"
import static org.junit.Assert.*;
import com.artemis.Entity;
import com.artemis.World;
import org.junit.Test;
public class Test {
@Test
@junkdog
junkdog / xml formatting
Last active December 26, 2015 09:58
toString-format XML documents for comparison purposes etc.
public final class XmlUtil
{
public static String formatXml(Document document)
throws Exception
{
// the DocumentBuilderFactory can't reliably be configured to produce
// identical output from semantically identical documents, contrary to what
// its methods would suggest. Hence:
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
@junkdog
junkdog / findjar
Created October 15, 2013 10:42
Search jars for specified class, printing jar files that match.
#!/bin/bash
if [[ $# != 1 ]]; then
echo "Usage: `basename $0` <ClassName>"
exit 1
fi
find -name "*.jar"
public static String findCommonPrefix(List<String> strings)
{
if (strings.size() == 0)
return "";
String prefix = strings.get(0);
for (int i = 1, s = strings.size(); s > i; i++)
{
String str = strings.get(i);
for (int j = 0, l = Math.min(prefix.length(), str.length()); l > j; j++)
@junkdog
junkdog / kateopen
Last active December 11, 2015 17:08
Open file inside a running instance of KDE Kate.
#/bin/bash
function full_path()
{
if [[ $1 == /* ]]; then
echo $1
else
echo `pwd`/$1
fi
}