Skip to content

Instantly share code, notes, and snippets.

View soren's full-sized avatar

Søren Lund soren

View GitHub Profile
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
// There's more than one way to do it
public class StaticInitialization {
private static final Map<String, String> MAP_ONE = new HashMap<String, String>() {{
put("one", "1. first");
}};
@soren
soren / utf8.el
Created September 24, 2014 13:47
Getting UTF-8 to work in GNU/Emacs
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(if (eq window-system 'x)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
(if (eq system-type 'windows-nt)
@soren
soren / colorize.pl
Created October 1, 2014 07:57
Simple Perl script that adds colors to e.g. log files using ANSI escape codes
#!/usr/bin/env perl
=head1 NAME
colorize.pl - adds colors to e.g. log files using ANSI escape codes
=head1 SYNOPSIS
colorize.pl LOGFILE
some_command | colorize.pl
#!/bin/env perl
use warnings;
use strict;
my $line = "one,two, three, four , five ";
sub print_list {
printf "[%s]\n", join(', ', @_);
}
@soren
soren / open_in_ie.html
Created February 4, 2015 08:11
Simple example of CSS that shows/hides elements based on the browser
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Open Link in IE</title>
<meta name="author" content="Søren Lund">
<!-- We expect IE browser -->
<style>span.showIE { display: inline } span.hideIE { display: none }</style>
@soren
soren / dev_setup.bat
Created December 6, 2011 09:38
An init script for the default "shell" on windows: cmd.
@echo off
rem This is an init script for the default "shell" on windows: cmd.
rem
rem You can try it out by calling cmd /k c:\path\to\file\.cmdrc.bat
rem
rem For a more permanent solution do the following:
rem
rem 1) copy this file to %USERPROFILE%
rem 2) Set the AutoRun key like this:
@soren
soren / jspwiki-add.sh
Created March 5, 2012 09:57
Create a new JSPWiki instance
#!/bin/bash
SRCDIR=/root/build/JSPWiki
WIKIDIR=/jspwiki
CONFDIR=/etc/jspwiki
DEPLOYDIR=/opt/java/tomcat/conf/Catalina/localhost
test -z $1 && echo "USAGE: $(basename $0) wikiname" && exit 1
test -d $WIKIDIR/$1 && echo "The name $1 is already used" && exit 1
@soren
soren / java_class_version.pl
Created March 17, 2012 11:19
Perl script that can determine the version of a java class file
#!/usr/bin/env perl
use warnings;
use strict;
use Pod::Usage;
=head1 NAME
java_class_version.pl - determines the version of a java class file
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
public class PrintOS {
private static final Map<String, String> MSG = ImmutableMap
.of("unix", "This is a UNIX box and therefore good.",
"windows", "This is a Windows box and therefore bad.",
@soren
soren / pwdcomposer.user.js
Created October 10, 2014 09:01
Password Composer 2.04
/* vim: ts=4 noet ai :
$Id: pwdcomposer.user.js 79 2006-09-08 07:44:01Z joe $
CREDITS
=======
Inspired by Nick Wolff's bookmarklet "Generate Password"
http://angel.net/~nic/passwdlet.html
MD5 hash functions (c) Paul Johnston