Skip to content

Instantly share code, notes, and snippets.

@kungfoo
kungfoo / SpecialEclipsePlugin.groovy
Last active August 29, 2015 14:05
Creating and updating the eclipse line break and encoding in Gradle build
class SpecialEclipsePlugin extends SpecialPlugin {
@Override
public void apply(Project project) {
eggExtension(project).create("eclipse", EclipseExtension)
project.apply(plugin: 'eclipse')
project.afterEvaluate {
configureEclipseClasspath(it)
@kungfoo
kungfoo / gist:8a507b1657c82ae51d7b
Created February 10, 2015 13:54
FileDownloader
public class FileDownloader extends AbstractExtension {
private boolean overrideContentType = true;
/**
* Creates a new file downloader for the given resource. To use the
* downloader, you should also {@link #extend(AbstractClientConnector)} the
* component.
*
* @param resource
@kungfoo
kungfoo / gtk.css
Last active August 29, 2015 14:20
Fixing broken window shadows in GTK 3.16 and a tiling window manager
.window-frame, .window-frame:backdrop {
box-shadow: 0 0 0 black;
border-style: none;
margin: 0;
border-radius: 0;
}
.titlebar {
border-radius: 0;
}
package ch.hsr.geohash;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import ch.hsr.geohash.queries.GeoHashCircleQuery;
require File.join(File.dirname(__FILE__), "..", "spec_helper")
require File.join(File.dirname(__FILE__), "fake_document")
include Redcar
describe AutoIndenter::Analyzer do
scala = <<-SCALA
package ch.mollusca.stomp.frame
@kungfoo
kungfoo / gist:703511
Created November 17, 2010 15:29
Objects.equal() and hashCode()
@Override
public int hashCode() {
return Objects.hashCode(describe(), markerType());
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
@kungfoo
kungfoo / .bashrc
Last active September 25, 2015 02:48 — forked from henrik/.bashrc
Updated to new output with git 1.8.0.2
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@kungfoo
kungfoo / gist:964107
Last active September 25, 2015 18:18
Show git branch and dirty state on prompt
# Display the current git branch and wether its dirty
# https://gist.github.com/964107/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
# username@Machine ~/dev/dir[master](1↑2↓)$ # clean working directory, but changes incoming and outgoing
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function git_ahead_behind {
@kungfoo
kungfoo / 1.8.7-p358-with-rogue-stdout-patch
Created March 22, 2012 15:44
Installing 1.8.7-p358 with rbenv, when glibc >= 2.14 is installed
build_package_stdout_patch() {
wget 'http://bugs.ruby-lang.org/attachments/download/1931/stdout-rouge-fix.patch'
patch -p1 < stdout-rouge-fix.patch
}
require_gcc
install_package "ruby-1.8.7-p358" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p358.tar.gz" stdout_patch standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby
#!/usr/bin/env ruby
status = `git status -sbz 2> /dev/null`
ahead = (status.match /ahead (\d+)/)
behind = (status.match /behind (\d+)/)
print "[" if ahead || behind
print "↑#{ahead[1]}" if ahead
print "↓#{behind[1]}" if behind
print "]" if ahead || behind