Skip to content

Instantly share code, notes, and snippets.

View ksauzz's full-sized avatar

Kazuhiro Suzuki ksauzz

View GitHub Profile
@ksauzz
ksauzz / gist:1269546
Created October 7, 2011 05:37
compless log
#!/bin/bash
PLAIN_TIME=10
LOG_DIR=/var/log/hoge
find $LOG_DIR -maxdepth 1 -name \*.log.\* -type f -mtime +$PLAIN_TIME | sort | egrep -v "gz$"|xargs gzip
@ksauzz
ksauzz / active_record_sample.rb
Created November 8, 2011 06:09
Using ActiveRecord without Rails
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:pool => 5,
:adapter => "mysql",
:host => "xxx.xxx.xxx.xxx",
:username => "db_user",
:password => "db_pass",
:database => "db_name",
@ksauzz
ksauzz / FizzBuzz.java
Created November 9, 2011 10:08
Fizz Buzz
// fizzbuzz without if statement and % operator.
class FizzBuzz {
public static void main (String [] args) {
for(int i=1; i<100; i++){ test(i); }
}
private static void test(int num) {
System.out.println(num+":"+bark(isMultiple(num)));
}
@ksauzz
ksauzz / CGLibProxySample.java
Created January 5, 2012 02:52
Proxy sample code with java.lang.reflect.Proxy and CGLib
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
public class CGLibProxySample {
@SuppressWarnings("unchecked")
@ksauzz
ksauzz / git-memo.rst
Created January 10, 2012 11:17
Git memo

git memo

commit

git commit -m msg
@ksauzz
ksauzz / template.rst
Created January 14, 2012 06:30
rst pdf sample

title

Date

YYYY/MM/dd

Author

name

Contact

email

@ksauzz
ksauzz / Controller.java
Created January 26, 2012 11:04
Spring MVC 3.x @Valid (JSR 303) Annotation Support
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ksauzz
ksauzz / gist:1688146
Created January 27, 2012 10:14
JVM remote debugging option.
# JVM options on a server side.
# see http://docs.oracle.com/javase/1.4.2/docs/guide/jpda/conninv.html
JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
java $JAVA_OPTS .....
@ksauzz
ksauzz / akka-memo.rst
Created February 10, 2012 02:49
akka memo

akkaメモ(ver 1.2)

並列処理

並列処理を行うためにはスレッド数(core-pool-size-factor, max-pool-size-factor)を増やした上でActorも複数生成する必要がある。 1つのActorは複数スレッドで同時に実行されることはない。

設定ファイル

@ksauzz
ksauzz / gizzard_memo.rst
Created March 5, 2012 13:06
Gizzard memo

gizzard memo

flush command remove all error jobs with no operation.

def flush(): Unit = {                                                                                                                                                                                                                     
  while (remove(false).isDefined) { }
}