View pre-commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Pre-commit hook that crushes PNG files in order to reduce their size. | |
if ! which -s pngcrush | |
then | |
echo "Please install pngcrush to reduce png images size before commit" | |
exit 1; | |
fi | |
for file in `git diff --cached --name-only | grep ".png\$"` |
View release.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PWD=`pwd` | |
CURRENT=`grep "<version>" -i pom.xml --max-count 1 | sed -e "s/.*<version>\(.*\)<\/version>/\1/" | sed -e "s/-SNAPSHOT//"` | |
MAJOR_VERSION=`echo $CURRENT | sed -e "s/\([0-9]*\.[0-9]*\.\)\([0-9]*\)/\1/"` | |
MINOR_VERSION=`echo $CURRENT | sed -e "s/\([0-9]*\.[0-9]*\.\)\([0-9]*\)/\2/"` | |
NEXT=$MAJOR_VERSION`expr $MINOR_VERSION + 1`-SNAPSHOT | |
TAG=VERSION$CURRENT | |
echo "=== RELEASING $CURRENT ===" |
View push.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
if [ 0 -eq `git remote -v | grep -c push` ]; then | |
REMOTE_REPO=`git remote -v | sed 's/origin//'` | |
else | |
REMOTE_REPO=`git remote -v | grep "(push)" | sed 's/origin//' | sed 's/(push)//'` |
View gist:372289
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --name-only | awk -F ';' '{printf "%s %-28s %30-s %s\\n",$1,$2,$3,$4}' |
View Show unreachable commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git fsck | awk '/dangling commit/ {print $3}' | git show --format='SHA1: %C(yellow)%h%Creset %f' --stdin | awk '/SHA1/ {sub("SHA1: ", ""); print}' |
View ConsoleRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.algodeal.test.rules; | |
import static com.algodeal.test.rules.ConsoleRecorder.ConsoleType.*; | |
import java.io.*; | |
import org.junit.rules.ExternalResource; | |
/** | |
* JUnit Rule to record System.out or System.err output. | |
*/ | |
public class ConsoleRecorder extends ExternalResource { |
View nloc.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LAST=$(date -j "+%Y-%m-%d") | |
FIRST=$(date -j -f "%Y-%m-%d" 2008-10-01 "+%Y-%m-%d") | |
CURRENT=${LAST} | |
git reset -q --hard origin/master; git clean -q -xdf | |
echo "Date;Lines of code;Lines of test" |
View .gitconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
wip = !"git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m \"wip\"" | |
unwip = !"git log -n 1 | grep -q -c wip && git reset HEAD~1" | |
rb = !"git wip;git rebase -i origin/master;git unwip" | |
pr = !"git fetch;git wip;git rebase --stat origin;git unwip;git heads" | |
head = !"git log -n1" | |
lost = !"git fsck | awk '/dangling commit/ {print $3}' | git show --format='SHA1: %C(yellow)%h%Creset %f' --stdin | awk '/SHA1/ {sub(\"SHA1: \", \"\"); print}'" | |
heads = !"git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --always --name-only | column -t -s';'" |
View RPN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foldingFunction=method(sum, x, | |
case(x, | |
"+", [sum pop! + sum pop!], | |
"*", [sum pop! * sum pop!], | |
"-", [sum pop! - sum pop!], | |
"/", [sum pop! / sum pop!], | |
[x toRational] | |
) + sum | |
) | |
"8 1 2 + 5 * +" split fold([], sum, x, foldingFunction(sum, x)) println |
View gist:598981
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void forceOutOfMemoryError() { | |
try { | |
Object[] ignored = new Object[(int) Runtime.getRuntime().maxMemory()]; | |
} catch (Throwable e) { | |
} | |
// All softReferences are cleared! | |
} |
OlderNewer