Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonas Berlin xkr47

View GitHub Profile
@xkr47
xkr47 / flowdock-new.css
Created Dec 12, 2012 — forked from anonymous/flowdock-new.css
New flowdock line-compress css for use with "Stylish" plugin in Firefox, v2
View flowdock-new.css
@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 Dec 12, 2015
Colorify "diff -u" output
View diff_-u_colors
#!/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 Jun 17, 2013
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
View PPFConfig.xml
<botConfig>
<irc-settings>
<encoding>utf-8</encoding>
<fallbackEncoding>iso-8859-15</fallbackEncoding>
@xkr47
xkr47 / pom.xml
Created Aug 13, 2013
pom.xml: When using slf4j, make sure we don't accidentally depend on commons-logging
View pom.xml
<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 Aug 29, 2013
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/
View log4j.properties
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 Dec 28, 2015
~/bin/firefox wrapper script for using custom (older) firefox version only when running Robot Framework tests
View firefox
#!/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 Jul 6, 2018
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".
View setup-readonly-git-remote-with-checkout
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
Make Tomcat shut down automatically if any component fails to start up (written for tomcat version 7.0.47)
View StartTomcat.java
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 Feb 24, 2014
Rename all *.sh files to *.pl: git mvs 's/\.sh$/.pl/' *.sh
View git-mvs
#!/bin/bash
if [ $# -lt 1 ]; then
echo usage: "$0 <perl> [<file1> ...]"
exit 1
fi
sed="$1"
shift
@xkr47
xkr47 / CustomWebdriverDisplay.java
Created Mar 14, 2014
How to set up webdriver to optionally use alternative DISPLAY setting for browser
View CustomWebdriverDisplay.java
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);
You can’t perform that action at this time.