Skip to content

Instantly share code, notes, and snippets.

View ksauzz's full-sized avatar

Kazuhiro Suzuki ksauzz

View GitHub Profile
@ksauzz
ksauzz / sleep_sort.erl
Created July 9, 2011 05:46
sleep sort by erlang.
-module(sleep_sort).
-export([sort/1, wait/1]).
sort([]) ->
"sleep sort!!";
sort([H|T]) ->
spawn(sleep, wait, [H]),
sort(T).
wait(Time) ->
@ksauzz
ksauzz / pom.xml
Created July 26, 2011 03:18
pom.xml assembly sample. The assembled package includes dependencies and sources.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId></groupId>
<artifactId></artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name></name>
<url></url>
@ksauzz
ksauzz / IP Address to localhost
Created August 10, 2011 05:17
ファイル内のIPアドレスをlocalhostへ一括変換
gsed -i -r 's/([0-9]{1,3}\.){3}[0-9]{1,3}/localhost/' *
@ksauzz
ksauzz / ex.erl
Created August 19, 2011 14:53
お題:文字列を先頭から見て同じところまで除去 http://bit.ly/oby7HE
-module(ex).
-export([drop_starts_same/1]).
drop_starts_same([HList|[]]) ->
[HList];
drop_starts_same(NestedList) ->
ShortList=lists:last(lists:sort(fun(A, B)->length(A)>length(B)end, NestedList)),
MatchCnt=lists:min(lists:map(fun(X)->match_count(ShortList, X) end, NestedList)),
lists:map(fun(Y)-> lists:sublist(Y, MatchCnt+1, length(Y)-MatchCnt) end, NestedList).
@ksauzz
ksauzz / createpdf.py.diff
Created August 28, 2011 13:20
rst2pdfの日本語化で弄ったファイル
--- createpdf.py.org 2011-08-28 22:07:46.000000000 +0900
+++ createpdf.py 2011-08-28 21:37:18.000000000 +0900
@@ -166,11 +166,11 @@
self.basedir=basedir
self.language = language
try:
- get_language (self.language)
+ get_language (self.language, None)
except ImportError:
try:
@ksauzz
ksauzz / homework01.hs
Created September 5, 2011 11:25
第一回スタートhaskell 宿題
-- Start Haskell 01 -- Homework : http://groups.google.com/group/start-haskell/browse_thread/thread/57aeccfd1073ca6
-- problem 1
magComp :: Float -- 地震1のマグニチュード
-> Float -- 地震2のマグニチュード
-> Float -- 地震1が何倍強い
magComp x y = (magCulc x) / (magCulc y)
magCulc :: Float -> Float
magCulc m = 10 ** (4.8 + 1.5 * m)
@ksauzz
ksauzz / erlang-memo.rst
Created September 16, 2011 11:04
erlang development note...

OTP

trace debug

gen_server:start_link({local, ?SERVER}, ?MODULE, [], [{debug,[trace]}])
@ksauzz
ksauzz / in_amqp.rb
Created September 28, 2011 17:57
fluent amqp plugin
module Fluent
class AmqpInput < Input
Fluent::Plugin.register_input('amqp', self)
def initialize
super
require 'amqp'
end
def configure(conf)
@ksauzz
ksauzz / fluent.conf
Created September 29, 2011 16:54
fluent input plugin sample
<source>
type xxxx
host 192.168.x.x
port 1999
</source>
@ksauzz
ksauzz / gist:1267657
Created October 6, 2011 15:17
Java app start/stop script skeleton.
#!/bin/bash
#
# Java app start/stop script skeleton.
#
##########################################################
# value section
##########################################################
USER="***"
MAIN_CLASS="***"