Skip to content

Instantly share code, notes, and snippets.

View xkr47's full-sized avatar

Jonas Berlin xkr47

View GitHub Profile
@xkr47
xkr47 / flowdock-new.css
Created December 12, 2012 12:20 — forked from anonymous/flowdock-new.css
New flowdock line-compress css for use with "Stylish" plugin in Firefox, v2
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("flowdock.com") {
.chat-message, .comment-message, .action-message, .line-message, .status-message, .file-message, .error-message {
padding-top: 0 !important;
padding-bottom: 0 !important;
font-family: Ubuntu,Tahoma,sans-serif !important;
font-size: 10px !important;
}
}
@xkr47
xkr47 / diff_-u_colors
Last active December 12, 2015 05:29
Colorify "diff -u" output
#!/usr/bin/perl
use File::Temp qw/ :mktemp /;
my @params = grep(/^-/,@ARGV);
@ARGV = grep(!/^-/,@ARGV);
my $tmp = $ENV{"TMP"};
$tmp = "/tmp" unless(defined($tmp));
($tmpfh, $tmpfile) = mkstemp($tmp."/diff_u.XXXXXX");
@xkr47
xkr47 / PPFConfig.xml
Created June 17, 2013 11:29
snippet for configuring PPF 1.0.0 and newer to use UTF-8 for output and input, falling back to some other charset if utf-8 decoding fails
<botConfig>
<irc-settings>
<encoding>utf-8</encoding>
<fallbackEncoding>iso-8859-15</fallbackEncoding>
@xkr47
xkr47 / pom.xml
Created August 13, 2013 08:28
pom.xml: When using slf4j, make sure we don't accidentally depend on commons-logging
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>ban-unwanted-dependencies</id>
<goals>
<goal>enforce</goal>
</goals>
@xkr47
xkr47 / log4j.properties
Created August 29, 2013 19:02
log4j configuration with different colors for different log levels - also works with Eclipse Ansi Console: http://mihai-nita.net/2013/06/03/eclipse-plugin-ansi-in-console/
log4j.debug=false
# Default level is INFO
log4j.rootLogger=INFO,StdoutErrorFatal,StdoutWarn,StdoutInfo,StdoutDebug,StdoutTrace
# and for com.some.package.* log everything
log4j.logger.com.some.package=TRACE
log4j.appender.StdoutErrorFatal=org.apache.log4j.ConsoleAppender
log4j.appender.StdoutErrorFatal.layout=org.apache.log4j.PatternLayout
@xkr47
xkr47 / firefox
Last active December 28, 2015 18:49
~/bin/firefox wrapper script for using custom (older) firefox version only when running Robot Framework tests
#!/bin/bash
if [ "$1" = "-profile" ]; then
exec ${HOME}/firefox-20.0/firefox "$@"
echo Failed to start Firefox
exit 1
fi
exec /usr/bin/firefox "$@"
@xkr47
xkr47 / setup-readonly-git-remote-with-checkout
Last active July 6, 2018 20:39
How to set up a remote (non-bare) Git repository with read-only checkout of some branch to automatically update on push. This assumes you have already created a regular repository in the remote location already; typically just "git init".
cat > .git/hooks/post-receive <<EOF
#!/bin/bash
set -e
cd ..
unset GIT_DIR
git reset --hard HEAD --
# put any additional cleanup/reload commands here
EOF
chmod ug+rx .git/hooks/post-receive
@xkr47
xkr47 / StartTomcat.java
Last active May 13, 2019 10:33
Make Tomcat shut down automatically if any component fails to start up (written for tomcat version 7.0.47)
import static org.apache.catalina.Lifecycle.*;
import static org.apache.catalina.LifecycleState.*;
import org.apache.catalina.*;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
// ...
tomcat.getServer().addLifecycleListener(new LifecycleListener() {
@Override
public void lifecycleEvent(final LifecycleEvent event) {
@xkr47
xkr47 / git-mvs
Created February 24, 2014 08:44
Rename all *.sh files to *.pl: git mvs 's/\.sh$/.pl/' *.sh
#!/bin/bash
if [ $# -lt 1 ]; then
echo usage: "$0 <perl> [<file1> ...]"
exit 1
fi
sed="$1"
shift
@xkr47
xkr47 / CustomWebdriverDisplay.java
Created March 14, 2014 06:45
How to set up webdriver to optionally use alternative DISPLAY setting for browser
FirefoxBinary firefox = new FirefoxBinary();
// allow user to specify which DISPLAY to use if running e.g. Xephyr
String display = System.getProperty("firefoxDisplay");
if (display != null) {
firefox.setEnvironmentProperty("DISPLAY", display);
}
WebDriver driver = new FirefoxDriver(firefox, null);