Skip to content

Instantly share code, notes, and snippets.

View jesperronn's full-sized avatar

Jesper Rønn-Jensen jesperronn

View GitHub Profile
@jesperronn
jesperronn / duplication.sh
Created January 21, 2014 10:32
Duplicate java class finder Finds java classes with same name and counts occurrences
# Find all java classes in tree. (including auto-generated classes in 'target' folders:
find . -name "*.java" | xargs egrep -o "class [A-Z]\w+" | awk '{print $2}' | sort | uniq -c | sort -n | grep -v 1
# Use git (faster).
#Ignores any auto-generated classes since they are typically inside ignored 'target' folders
git grep --extended-regexp --no-index "class [A-Z]\w+" | egrep -o "class [A-Z]\w+" | awk '{print $2}' | sort | uniq -c | sort -n | grep -v 1
@jesperronn
jesperronn / WebService.java
Created September 13, 2013 11:12
EJB annotations and their probable replacement
@Webservice(name="", serviceName="")
package javax.jws;
public @interface WebService {}
maven pom:
<dependency>
@jesperronn
jesperronn / strip_cpr_numbers.rb
Last active December 15, 2015 11:55
Danish CPR numbers: strip ssn dashes from numbers when saving, so that they are used consistently throughout the application
# Formatting and validation of Danish CPR number
# when saving we will throw away the dash "-" in the SSN and show it when retrieving
#
# Custom retrieval of formatted value: This is done by the method
# `formatted_cpr`. Use that in your views if you need it
#
# or in extreme cases you can override the getter method and call `formatted_cpr`
#
# Strategies for saving of unformatted value:
# 1. use either `base.after_validation` to hook into callbacks. This is a little annoying
@jesperronn
jesperronn / GenericCollection.java
Last active December 14, 2015 08:18
Java Generic collection objects, where you can dot them
package com.my.collections;
import java.io.Serializable;
import java.util.*;
/**
* <p/>
* Superclass for handling a collection of objects. He super class contains
@jesperronn
jesperronn / isDefined.sh
Created February 26, 2013 19:11
isDefined() unix method to determined if a variable exists
function isDefined() {
varname=$1;
declare -p $varname >/dev/null 2>&1;
if [ "$?" -eq 0 ]; then
echo Defined;
fi;
}
http://nixcraft.com/shell-scripting/15375-testing-bash-variable-existence.html
MIN_COUNT = 2
# Naïve implementation, just return whatever number I need
def sum_up_a(existing)
return 2 if existing == 0
return 1 if existing == 1
return 0
end
sum_up_a(0) # => 2
package dk.justaddwater.wtf
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by IntelliJ IDEA.
* User: Jesper Rønn-Jensen
<div id="remote">
<input class="typeahead" type="text" placeholder="Oscar winners for Best Picture">
</div>
@jesperronn
jesperronn / laesmere.js
Created December 9, 2012 21:32
"Læs også"-links flyttet til bund af artikel. Jeg var så træt af at der står "LÆS OGSÅ: ..." efter hvert andet afsnit på DRs websider.
// ==UserScript==
// @name 'Læs også'-- men senere
// @namespace jespersscripts
// @version 0.1
// @description "Læs også"-links flyttet til bund af artikel. Jeg var så træt af at der står "LÆS OGSÅ: ..." efter hvert andet afsnit på DRs websider.
// @match http://www.dr.dk/*
// @match http://dr.dk/*
// @copyright 2012+, Jesper Rønn-Jensen
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// ==/UserScript==
@jesperronn
jesperronn / idea.sh
Last active October 13, 2015 16:28
IDEA vmoptions
#Line below added by jesper in idea.sh
IDEA_JDK="/opt/tools/jdk1.7.0_09"
#end line add