Skip to content

Instantly share code, notes, and snippets.

Avatar

Søren Lund soren

View GitHub Profile
View StaticInitialization.java
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 Sep 24, 2014
Getting UTF-8 to work in GNU/Emacs
View utf8.el
(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 Oct 1, 2014
Simple Perl script that adds colors to e.g. log files using ANSI escape codes
View colorize.pl
#!/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
View listtrimdemo.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 Feb 4, 2015
Simple example of CSS that shows/hides elements based on the browser
View open_in_ie.html
<!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 Dec 6, 2011
An init script for the default "shell" on windows: cmd.
View dev_setup.bat
@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 Mar 5, 2012
Create a new JSPWiki instance
View jspwiki-add.sh
#!/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 Mar 17, 2012
Perl script that can determine the version of a java class file
View java_class_version.pl
#!/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
View PrintOS.java
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 Oct 10, 2014
Password Composer 2.04
View pwdcomposer.user.js
/* 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