Skip to content

Instantly share code, notes, and snippets.

View ktoso's full-sized avatar
🗻
Life is Study!

Konrad `ktoso` Malawski ktoso

🗻
Life is Study!
View GitHub Profile
#!/bin/env python
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
@ktoso
ktoso / gist:708972
Created November 21, 2010 18:09
eclipse formatter pre-commit hook
#!/bin/sh
#
# This hook will run the eclipse code formatter before any commit
# to make the source look as it's supposed to look like in the repo.
ECLIPSE_HOME=$HOME/eclipse
STYLE_FILE=$HOME/org.eclipse.jdt.core.prefs
echo "Running pre-commit hook: run-eclipse-formatter---------------------"
echo "Will run eclipse formatter, using: $STYLE_FILE"
echo "Listing folders to run formatter on… "
@ktoso
ktoso / gist:708976
Created November 21, 2010 18:13
test run
[ktoso@homunculus tesujegit]$ git commit -a -m test
Running pre-commit hook: eclipse-format---------------------------------
Will run eclipse formatter, using: /home/ktoso/org.eclipse.jdt.core.prefs
Listing folders to run formatter on...
./project/src/test
./project/src/main
Launching eclipse code formatter...
Configuration Name: /home/ktoso/org.eclipse.jdt.core.prefs
Starting format job ...
Formatting: /home/ktoso/coding/xsolve/tesujegit/./project/src/test/Main.java
@ktoso
ktoso / gist:708977
Created November 21, 2010 18:14
what did this change?
[ktoso@homunculus tesujegit]$ cat ~/.gitconfig | tail -n2
[alias]
eclipse-formatter = !~/run-eclipse-formatter
[ktoso@homunculus tesujegit]$ git [tab][tab]
#...
bundle eclipse-formatter instaweb repack submodule
#...
[ktoso@homunculus tesujegit]$ git eclipse-formatter
@ktoso
ktoso / gist:708981
Created November 21, 2010 18:18
after eclipse formatting
package example;
import pl.xsolve.example.*;
class MyClazz {
public static void doStuff(Stuff stuff) {
for (int i = 0; i < 15; i++) {
ekhem();
}
return;
@ktoso
ktoso / gist:708982
Created November 21, 2010 18:20
the source file we want to format
/* located in: project/src/main/Main.java */
package example;
import pl.xsolve.example.*;
class MyClazz{
public static void
doStuff(Stuff stuff)
{
for(int i=0;i<15;i++)
{
ekhem();
@ktoso
ktoso / better-tdd.java
Created December 6, 2010 10:28
An cleaner
package pl.pragmatists;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
package pl.xlab.doc.banana;
import com.google.java.contract.Ensures;
import com.google.java.contract.Invariant;
import com.google.java.contract.Requires;
import com.google.java.contract.ThrowEnsures;
import pl.xlab.doc.banana.exceptions.NotEnoughBananasException;
import java.util.Collection;
@ktoso
ktoso / gist:817695
Created February 9, 2011 01:23
które wolisz?
// obecnie
@ThrowEnsures({
"NotEnoughBananasException", "countBananas() == 0"
})
// wolałbym tak, "normalniej":
@ThrowEnsures(thrown = {
@Thrown(exception = NotEnoughBananasException.class, when = "countBananas() == 0")
})
@ktoso
ktoso / gist:873312
Created March 16, 2011 21:09
A simple showcase of how you can use git bisect and maven to find a commit that introduced a bug.
ktoso@dynames breakMe $ mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DartifactId=bisectfun -DgroupId=pl.project13
#.........................
ktoso@dynames breakMe $ ls
bisectfun mavenbisect.sh
ktoso@dynames breakMe $ cd bisectfun/
ktoso@dynames bisectfun $ mkdir src/test/resources/
ktoso@dynames bisectfun $ git init .
Initialized empty Git repository in /tmp/breakMe/bisectfun/.git/
ktoso@dynames bisectfun $ git commit ^C
ktoso@dynames bisectfun $ vim .gitignore