Skip to content

Instantly share code, notes, and snippets.

@Crydust
Crydust / getQueryStringParam.html
Created February 22, 2010 11:51
getQueryStringParam js
<!doctype html>
<html>
<head>
<script src="jquery-1.4.js"></script>
<script>
/**
* @return null if param not found
* @return string if param found once
* @return array if param found more than once or name ends with "[]"
*/
@Crydust
Crydust / Beeper.java
Created February 26, 2013 14:11
Beeper.java is a replacement for the failing System.out.prinln('\007'); it simply beeps, which is useful for debugging
import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Synthesizer;
public class Beeper {
public static void main(String[] args) throws Exception {
beep();
}
@Crydust
Crydust / _vimrc
Created March 7, 2013 20:27
mi _vimrc file
" set the langmenu before everything else!!!
set langmenu=en
"language messages en
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
@Crydust
Crydust / TransformXml.java
Last active June 24, 2022 13:11
transform xml with an xslt in java
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
jQuery(function ($) {
// detect support for input attribute
var input = document.createElement('input');
if (!('autofocus' in input)) {
$('[autofocus=]').focus(); // http://bugs.jquery.com/ticket/5637
}
});
@Crydust
Crydust / CharacterEncodingFilter.java
Created May 30, 2013 19:01
CharacterEncodingFilter for java EE 6 (I can't believe I'm writing this AGAIN)
package fileupload;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
@Crydust
Crydust / msie-document-mode.html
Created August 9, 2013 10:10
This very imperfect code will give you a fighting chance to determine the actual document mode msie is using. Also see Testing sites with Browser Mode vs. Doc Mode http://blogs.msdn.com/b/ie/archive/2010/10/19/testing-sites-with-browser-mode-vs-doc-mode.aspx
<script>var ccMsie = -1;</script>
<!--[if gte IE 6]><script>ccMsie = 6;</script><![endif]-->
<!--[if gte IE 7]><script>ccMsie = 7;</script><![endif]-->
<!--[if gte IE 8]><script>ccMsie = 8;</script><![endif]-->
<!--[if gte IE 9]><script>ccMsie = 9;</script><![endif]-->
<script>/*@cc_on @if (@_jscript_version == 10) ccMsie = 10; @end @*/</script>
<script>
(function(){
function readVersion(s) {
var ua = navigator.userAgent;
@Crydust
Crydust / CalendarApp.java
Created September 3, 2013 13:08
instantiate a Calendar including timezone, locale and milliseconds
import java.util.Calendar;
import java.util.GregorianCalendar;
public class CalendarApp {
public static void main(String[] args) {
// 2013/09/03 11:46:00.000 UTC
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"), Locale.ENGLISH);
cal.set(2013, 8, 3, 11, 46, 0);
cal.set(Calendar.MILLISECOND, 0);
long epoch = cal.getTimeInMillis();
@Crydust
Crydust / ValidatorFilter.java
Created September 5, 2013 11:21
ValidatorFilter uses local validator.nu to validate html
package be.crydust.validator;
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URL;
@Crydust
Crydust / removeFileFromGit.sh
Created September 19, 2013 07:58
Also see "Removing a File from Every Commit" http://git-scm.com/book/en/Git-Tools-Rewriting-History
# Warning this is a destructive operation.
git ls-tree --abbrev -r -l HEAD | sort +3 | tail
git filter-branch --all --tree-filter 'rm -f blueray.iso' HEAD
# Git keeps track of the original refs which keeps the repo large.
# We remove those now.
# 1) Make sure original refs are gone:
rm -rf .git/refs/original