Skip to content

Instantly share code, notes, and snippets.

View osamingo's full-sized avatar
🧑‍💻

Osamu TONOMORI osamingo

🧑‍💻
View GitHub Profile
@osamingo
osamingo / MapValueSort.java
Created February 2, 2012 02:23
MapのValueでSortしたい
Map<String, Integer> scores = new HashMap<String, Integer>();
List<Map.Entry<String, Integer>> entries = new ArrayList<Map.Entry<String, Integer>>(scores .entrySet());
// Valueの降順(大きい順)に並べる
Collections.sort(entries, new Comparator<Object>() {
@Override
@SuppressWarnings("unchecked")
public int compare(Object o1, Object o2) {
Map.Entry<String, Integer> e1 = (Map.Entry<String, Integer>) o1;
@osamingo
osamingo / JobEnum.java
Created February 2, 2012 02:34
Enumを逆引きしたい
public enum JobEnum {
MUSICIAN(1, "ミュージシャン"),
MODEL(2, "モデル"),
private Integer jobId;
private String jobName;
JobEnum(Integer jobId, String jobName) {
this.jobId= jobId;
this.jobName= jobName;
public enum RoutesEnum {
TOP("/", "portal/top"),
DETAIL("/{mediaId}", "media/detail");
private String urlPath;
private String filePath;
RoutesEnum(String urlPath, String filePath) {
@osamingo
osamingo / gist:5908328
Created July 2, 2013 10:40
svn2git用のauthors.txtを自動作成するワンライナー - checkoutしたディレクトリ内で実行
svn log --xml | grep -P "^<author" | sort -u | perl -pe 's/<author>(.*?)<\/author>/$1 = $1 <$1\@hoge.jp>/' | sed -e "s/_/-/2" > authors.txt
@osamingo
osamingo / file0.txt
Created October 17, 2013 02:44
JRubyでRuby on Rails4を動かす ref: http://qiita.com/osamingo/items/f330ce361c8604fd98ea
$ jruby -S bundle exec rails server