Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# force-one-head
# add the following to <repository>/.hg/hgrc :
# [hooks]
# pretxnchangegroup.forceonehead = /path/to/force-one-head
if [ $(hg heads --template "{branch}\n"|sort|uniq|wc -l) != $(hg heads --template "{branch}\n"|sort|wc -l) ]; then
echo "There are multiple heads."
echo "Please 'hg pull' and get your repository up to date first."
echo "Also, don't 'hg push --force' because that won't work either."
@troter
troter / hgrc
Created September 2, 2011 05:27
hg fix "fixed message" # (hg 1.8.x only)
# hgrc
[extensions]
mq =
hgshelve = $HOME/.mercurial/extensions/hgshelve/hgshelve.py
[alias]
# fix latest commit message (hg 1.8.x only)
fix = ! \
$HG shelve --all -n 'tmp.hg-fix' && \
import java.lang.reflect.InvocationTargetException;
public interface InterfaceName {
String getValue();
int getLength();
/**
* InterfaceName で定義しておいて欲しいクラスメソッドを定義
@troter
troter / update
Created August 1, 2011 16:20
update any repositories.
#!/bin/bash
[ -d .git ] && git pull
[ -d .hg ] && hg pull -u
[ -d .svn ] && svn update
[ -d .bzr ] && bzr update
@troter
troter / araxis-cygwin.hgrc
Created July 25, 2011 11:31
araxis merge with cygwin mercurial
[ui]
# merge=araxis
[extensions]
extdiff =
[extdiff]
cmd.araxisdiff = bash
opts.araxisdiff = -c '"/cygdrive/C/Program Files/Araxis/Araxis Merge/ConsoleCompare.exe" /2 /wait "$(cygpath -w "$0")" "$(cygpath -w "$1")"'
@troter
troter / 00_README.org
Created July 24, 2011 02:20
My eclipse settings.

使い方

plugin_customization.ini

eclipse.iniに次を追加する。 ワークスペースの初回の選択時のみ設定がコピーされる

-pluginCustomization
path/to/plugin_customization.ini
@troter
troter / StringSplit.groovy
Created July 19, 2011 01:36
JavaでのString.splitの挙動の違い
println "commons-lang-2.6:" + org.apache.commons.lang.StringUtils.split("", "\n").size()
println "s2-framework-2.4.44:" + org.seasar.framework.util.StringUtil.split("", "\n").size()
println "String.split:" + "".split("\\n").size()
println "String.tokenize:" + "".tokenize("\n").size()
// -- output
// commons-lang-2.6:0
// s2-framework-2.4.44:0
// String.split:1
// String.tokenize:0
@troter
troter / ExtendedRoutingFilter.java
Created May 31, 2011 06:37
SAStrutsと生Servletを共存させる
package jp.troter.sandbox.seasar.struts.filter;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
public interface PrefixAppender {
String apply(String content);
public static abstract class Builder {
public static PrefixAppender build(final String maker) {
return new PrefixAppender() {
@Override
@troter
troter / pickuphexspeak.rb
Created March 9, 2011 13:15
pickup hexspeak.
# -*- coding: utf-8; mode: ruby -*-
#
# usage:
# hg log --template "{node} {author} {desc|firstline}\n" | ruby pickuphexspeak.rb
first_class = %w[
abadbabe baadf00d baddcafe cafebabe deadbeef defec8ed
facefeed fee1dead badcab1e feedface deaddead beadface
]
second_class = %w[