Skip to content

Instantly share code, notes, and snippets.

Michael Simons michael-simons

Block or report user

Report or block michael-simons

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ExtendedAntPathMatcher.java
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 Mar 9, 2011
Configuration for replacing Spring 3 mvc:annotation-driven
View gist:861863
<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 Dec 21, 2011
Enables automatic embedding of pictures from dailyfratze.de through oEmbed
View enable_dailyfratze_oembed.php
<?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 Dec 21, 2011
Enables automatic embedding of twitter updates through oembed
View enable_twitter_oembed.php
<?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 Oct 20, 2012
Sicherer MySQL Dump mehrerer Datenbanken
View gist:3924630
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 Dec 12, 2012
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.
View jquery.fancybox-1.3.4.with_touch_support.js
/*
* 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 May 25, 2018
Java and handling of UTF-8 codepoints in the supplementary range
View UTF8.java
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 Feb 12, 2013
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.
View fitbit_archiver.rb
# encoding: UTF-8
require 'rubygems'
require 'date'
require 'optparse'
require 'ostruct'
require 'oauth'
require 'json'
class FitbitArchiver
@michael-simons
michael-simons / gist:5299398
Created Apr 3, 2013
Move some specific files from one git repository into a new one preserving the history
View gist:5299398
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 Dec 17, 2015
This code "unchecks" checked exceptions without wrapping them in RuntimeException and polluting the stacktrace.
View Unchecker.java
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(){}
You can’t perform that action at this time.