Skip to content

Instantly share code, notes, and snippets.

View todesking's full-sized avatar
💀

todesking todesking

💀
View GitHub Profile
@todesking
todesking / ResourceLeakChecker.java
Created January 21, 2011 04:30
明示的な開放を必要とするリソースが正しく開放されたかチェックする
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details. */
/**
* 明示的な開放が必要なリソースクラスが使用する。
*
* finalizeメソッドにより、開放されていないリソースがあった場合標準エラー出力に警告を出す。
@todesking
todesking / git-now
Created April 28, 2011 11:52 — forked from toshi-kawanishi/git-now
making convenient git commit
#!/bin/sh
set -e
PREFIX="from now"
MESSAGE="[${PREFIX}] `date`"
if [ $# -eq 0 ]
then
git add -u
public enum NamedParam {
A(new Param1(1), new Param2("hoge")), B(new Param1(10), new Param2("fuga"));
X(Param1 p1, Param2 p2) {
this.p1 = p1.value;
this.p2 = p2.value;
}
public final int p1;
public final String p2;
@todesking
todesking / gist:1104073
Created July 25, 2011 13:06
poor java DSL
addBatch(new Batch("hogehoge",new Batch.Serial() {{
add(HogeJob.class);
add(FugaJob.class);
add(new Batch.Parallel() {{
add(FooJob.class);
add(BarJob.class);
}};
}});
@todesking
todesking / gist:1188031
Created September 2, 2011 06:30
my PS1 for bash
function __show_errorcode() {
ERR=$?
if [ $ERR != 0 ]; then
echo -en "\033[31m\$?=$ERR"
fi
}
function __show_jobs() {
JOBS=$(jobs|sed 's/ \+/\t/g'|cut -f1,3|tr \\t :|tr \\n ','|sed 's/,$//'|sed 's/,/, /g')
if [ "$JOBS" != "" ]; then
/* 自分で定義したDateRange型から、where条件を生成したい */
-- before
select * from table
where
update_time between /*range.getStart()*/'2011-01-01' and /*range.getEnd()*/'2011-12-31'
-- after
select * from table
where
public enum A {
Hoge(CONST); // Cannot reference a field before it is defined
private static int CONST = 1;
private A(int x) {
}
}
public enum B { // Syntax error on token "{", ; expected after this token
private static int CONST = 1;
Hoge(CONST);
@todesking
todesking / .gitconfig
Last active September 27, 2015 22:07
my git command alias
[alias]
alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort
a = add
a-i = add -i
a-p = add -p
co = checkout
b = branch
k = !gitk --all --max-count=200 &
s = status -sb
ci = commit
@todesking
todesking / likestorm.rb
Created March 31, 2012 08:11
likestorm
require 'net/http'
def hsv_to_rgb(h, s, v)
h_i = (h*6).to_i
f = h*6 - h_i
p = v * (1 - s)
q = v * (1 - f*s)
t = v * (1 - (1 - f) * s)
r, g, b = v, t, p if h_i==0
r, g, b = q, v, p if h_i==1
r, g, b = p, v, t if h_i==2
@todesking
todesking / svn-cherry-pick.rb
Created August 3, 2012 11:26
svn-cherry-pick
#!/usr/bin/env ruby
# -*- coding:utf-8 -*-
raise <<EOS
MOVED: https://github.com/todesking/svn-cherry-pick
EOS