Skip to content

Instantly share code, notes, and snippets.

View michael-simons's full-sized avatar

Michael Simons michael-simons

View GitHub Profile
package ac.simons.utils;
import java.util.Comparator;
/**
* @author michael.simons, 2011-02-15
*/
public class ExtendedAntPathMatcher implements PathMatcher {
private final AntPathMatcher delegate = new AntPathMatcher();
@michael-simons
michael-simons / gist:861863
Created March 9, 2011 08:09
Configuration for replacing Spring 3 mvc:annotation-driven
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
<bean id="conversion-service" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />
<bean id="pathMatcher" class="ac.simons.utils.ExtendedAntPathMatcher" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="order" value="0" />
<property name="useDefaultSuffixPattern" value="true" />
<property name="pathMatcher" ref="pathMatcher" />
</bean>
@michael-simons
michael-simons / enable_dailyfratze_oembed.php
Created December 21, 2011 08:43
Enables automatic embedding of pictures from dailyfratze.de through oEmbed
<?php
/*
Plugin Name: Enable dailyfratze.de oEmbed
Description: Enables automatic embedding of pictures from dailyfratze.de through oEmbed
Author: Michael Simons
Version: 1.0
Author URI: http://michael-simons.eu
*/
// Profile
wp_oembed_add_provider('#https?://dailyfratze\.(?:de|com)/([a-z]+\w*)#i', 'https://dailyfratze.de/app/oembed.json', true);
@michael-simons
michael-simons / enable_twitter_oembed.php
Created December 21, 2011 08:45
Enables automatic embedding of twitter updates through oembed
<?php
/*
Plugin Name: Enable Twitter oEmbed
Description: Enables automatic embedding of twitter updates through oembed
Author: Michael Simons
Version: 1.0
Author URI: http://michael-simons.eu
*/
wp_oembed_add_provider('#https?://twitter.com/\#!/[a-z0-9_]{1,20}/status/\d+#i', 'https://api.twitter.com/1/statuses/oembed.json', true);
?>
@michael-simons
michael-simons / gist:3924630
Created October 20, 2012 20:13
Sicherer MySQL Dump mehrerer Datenbanken
mysqldump -uroot -pblah --opt --routines --add-drop-database --default-character-set=utf8 --create-options --databases db1 db2 usw | bzip2 > backup.sql.bz2
@michael-simons
michael-simons / jquery.fancybox-1.3.4.with_touch_support.js
Created December 12, 2012 19:57
This is a patched version of jQuery Fancybox (http://fancybox.net) that supports touch events (wipe left / right). You need http://modernizr.com and http://www.netcu.de/jquery-touchwipe-iphone-ipad-library to use this.
/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright (c) 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
@michael-simons
michael-simons / UTF8.java
Last active November 11, 2020 22:46
Java and handling of UTF-8 codepoints in the supplementary range
public class UTF8 {
public static void main(String[] args) {
// See http://www.fileformat.info/info/unicode/char/1f4a9/index.htm
final String poo = "A pile of poo: 💩.";
System.out.println(poo);
// Length of chars doesn't equals the "real" length, that is: the number of actual codepoints
System.out.println(poo.length() + " vs " + poo.codePointCount(0, poo.length()));
// Iterating over all chars
@michael-simons
michael-simons / fitbit_archiver.rb
Created February 12, 2013 12:33
This script fetches stuff from the fitbit api. You need to register an app (for consumer key and secret) and authorize this script on behalf of your account. One way to do this is with the out of band authentication. Feel free to expand this script to automate this.
# encoding: UTF-8
require 'rubygems'
require 'date'
require 'optparse'
require 'ostruct'
require 'oauth'
require 'json'
class FitbitArchiver
@michael-simons
michael-simons / gist:5299398
Created April 3, 2013 08:17
Move some specific files from one git repository into a new one preserving the history
cd ~/the/old/repo
find -E . -regex ".*(File1|File2)\.java" | xargs git log --pretty=email --patch-with-stat --reverse | (cd ~/the/new/repo && git am)
@michael-simons
michael-simons / Unchecker.java
Last active December 17, 2015 22:19
This code "unchecks" checked exceptions without wrapping them in RuntimeException and polluting the stacktrace.
package ac.simons.utils;
/**
* Use it like throw Unchecker.uncheck(checkedException);
*
* @author Michael J. Simons, 2012-02-03
* http://www.gamlor.info/wordpress/2010/02/throwing-checked-excpetions-like-unchecked-exceptions-in-java/
*/
public final class Unchecker {
private Unchecker(){}