Skip to content

Instantly share code, notes, and snippets.

View joakime's full-sized avatar

Joakim Erdfelt joakime

  • Webtide, LLC
  • McAllen, TX
View GitHub Profile
@joakime
joakime / maven_dev_bash_funcs.sh
Created February 8, 2011 03:40
Bash Functions for Maven Development.
droppath()
{
PATTERN="$1"
PATH=$(echo $PATH | \
sed -e "s;:?[^:]*$PATTERN[^:]*;;g" \
-e "s;[^:]*$PATTERN[^:]*:\?;;g" \
-e "s;::;:;g")
}
usemaven()
@joakime
joakime / web.xml
Created December 14, 2011 21:37
Configuring jetty's DefaultServlet's Cache-Control in web.xml
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>cacheControl</param-name>
<param-value>max-age=3600,public</param-value>
</init-param>
</servlet>
@joakime
joakime / webdave-security-constraints-web.xml
Created February 17, 2012 21:09
Security Constraints for WebDAV in web.xml
<security-constraint>
<web-resource-collection>
<!-- from RFC 4918 -->
<web-resource-name>Enabled WebDAV Methods</web-resource-name>
<url-pattern>/*</url-pattern>
<!-- Sec: 9.1 -->
<http-method>PROPFIND</http-method>
<!-- Sec: 9.2 -->
<http-method>PROPPATCH</http-method>
<!-- Sec: 9.3 -->
@joakime
joakime / git_prompt_functions.sh
Last active April 18, 2018 22:58
Functions to present extra git info on bash prompt.
#!/bin/bash
#
# Shows git information in your bash prompt.
# Git Branch Name
# Git Dirty State (uncommitted changes)
# Git "Behind" Count (are you up to date?)
#
# =========================================
# To use:
#
@joakime
joakime / mvn-loop-test.sh
Last active November 8, 2016 17:02
Bash Script to loop mvn test till failure (for intermittent test failures)
#!/bin/bash
let count=0
while mvn test $* 2>&1 > target/lastbuild.log
do
now=`date`
echo "Test Run $count - $now" >> target/looptest.log
let count=$count+1
done
@joakime
joakime / ubuntu-post.txt
Created September 29, 2012 00:11
Post Ubuntu installation Tips
sudo apt-get install nvidia-current
sudo apt-get install vim-gtk
# reboot
sudo apt-get install gnome
# -- Undo global menus
sudo apt-get remove appmenu-gtk3 appmenu-gtk appmenu-qt
# -- Remove overlay scrollbars
sudo apt-get remove liboverlay-scrollbar-0.2-0 liboverlay-scrollbar3-0.2-0 overlay-scrollbar
# logout
# login (using gnome-shell as default)
@joakime
joakime / rewrite-null.xml
Created December 26, 2012 21:29
A jetty rule to strip/trim bad jsp requests
<!-- Trim oddball JSP request URIs -->
<Call name="addRule">
<Arg>
<New class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
<Set name="regex">(.*)\.jsp(\00.*)</Set>
<Set name="replacement">$1.jsp</Set>
</New>
</Arg>
</Call>
package os;
import java.io.File;
import java.io.IOException;
public class FileNullCheck
{
public static void main(String[] args)
{
File tmp = new File("a.jsp");
package os;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class FileNullCheck
{
@joakime
joakime / NaturalSort.java
Created January 4, 2013 23:33
Demonstration of Natural Order Sorting
/*
NaturalOrderComparator.java -- Perform 'natural order' comparisons of strings in Java.
Copyright (C) 2003 by Pierre-Luc Paour <natorder@paour.com>
Based on the C version by Martin Pool, of which this is more or less a straight conversion.
Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.