Skip to content

Instantly share code, notes, and snippets.

View jj1bdx's full-sized avatar
🏠
Working from home

Kenji Rikitake jj1bdx

🏠
Working from home
View GitHub Profile
@jj1bdx
jj1bdx / bignum_root.erl
Created February 2, 2010 23:28 — forked from pichi/bignum_root.erl
Power function (X ^ Y) and root function (X ^ (1/Y)) for integers in Erlang
%% Power function (X ^ Y) and root function (X ^ (1/Y)) for
%% integers in Erlang
%% by Kenji Rikitake <kenji.rikitake@acm.org> 26-JAN-2010
%% modified by Hynek Vychodil <vychodil.hynek@gmail.com> 2-FEB-2010
%% modified by Kenji Rikitake <kenji.rikitake@acm.org> 3-FEB-2010
%% Distributed under MIT license at the end of the source code.
-module(bignum_root).
-export([power/2, root/2, sqrt/1]).
@jj1bdx
jj1bdx / gist:738946
Created December 13, 2010 12:31 — forked from voluntas/gist:737963
Corporations using Erlang/OTP
* Bluetail/Alteon/Nortel (distributed, fault tolerant email system, SSL accelerator)
* Cellpoint (Location-based Mobile Services)
* Corelatus (SS7 monitoring).
* dqdp.net (in Latvian) (Web Services).
* Facebook (Facebook chat backend)
* Finnish Meteorological Institute (Data acquisition and real-time monitoring)
* IDT corp. (Real-time least-cost routing expert systems)
* Kreditor (Electronic payment systems)
* Mobilearts (GSM and UMTS services)
{erl_opts, [fail_on_warning, debug_info]}.
{xref_checks, [undefined_function_calls]}.
%% {eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
{cover_enabled, true}.
{clean_files, [".eunit", "ebin/*.beam"]}.
{dialyzer_opts,
[{warnings,
[no_return,
no_unused,
no_improper_lists,
@jj1bdx
jj1bdx / riak.md
Created May 30, 2012 13:09 — forked from taichi/riak.md
some suggestion to riak.

(Note: this is a rough translation added to the original Japanese. No warranty.)

RpbErrorResp の errcode はより適切な値が設定されるべきである。(The errcode of RpbErrorResp should be set to more appropriate value.)

PBC API ではエラーが起きると、RpbErrorRespが返るがRIAKC_ERR_GENERALが常に設定されており意味がないのでREST APIと同等の値が設定されているべきです。 (When an error occurs on the PBC API, the value of RpbErrorResp is returned, though RpbErrorResp is always set to RIAKC_ERR_GENERAL so that the recipient cannot find what the real cause is. The value should be set the same as with the REST API.)

例えば、get operation において、notfound が返るのは多くの場合クライアント側にとって特に問題ないので、コストの高い例外処理がトリガーされない事が望ましい。
一方で、modifiedが返る場合、データのリペアをトリガするべきか、単に再度getするべきかはアプリケーションの設計の問題である。 (For example, on get operation the clients will find no problem when notfound is returned - exceptions of higher cost should not be triggered. On the other hand, if modified is returned, it is up to how the application is designed to trigger the repairment of the data, or to re-execute the get operation.)

errmsgフィールドの様にHum

@jj1bdx
jj1bdx / emacs_indent.sh
Created November 6, 2012 05:21 — forked from andrzejsliwa/emacs_indent.sh
erlang emacs-style formatting for vim
#!/usr/bin/env bash
emacs --batch --eval "
(progn (find-file \"$1\")
(if (string-equal \"darwin\" (symbol-name system-type))
(setq erlang-root-dir (car (file-expand-wildcards \"/usr/local/Cellar/erlang/R*\")))
(setq erlang-root-dir \"/usr/lib/erlang/\"))
(setq load-path (cons (car (file-expand-wildcards (concat erlang-root-dir \"/lib/erlang/lib/tools-*/emacs\"))) load-path))
(require 'erlang-start)
(erlang-mode)
(untabify (point-min) (point-max))
@jj1bdx
jj1bdx / re.md
Created March 5, 2013 07:35 — forked from yukim/re.md

@oranie さんのブログ記事への返信です。 たいへん遅くなりました。申し訳ないです。

repairとcompactionのコストが高すぎる

Cassandraにノードを追加する(Bootstrap)と、そのノードが担当するレプリカのデータを他のノードから取得します。 Repairはノードが保持するレプリカの整合性を検証して修復します。

どちらもデータを他のノードから取得しますが、ファイルを1つづつやり取りするため時間がかかるのは事実です。 この部分にまだまだ改善の余地があります。次のメジャーバージョンで抜本的に見直します

#compdef riak riak-admin
(( $+functions[_riak_commands] )) ||
_riak_commands () {
_values 'riak commands' \
'start[Starts the Riak node in the background]' \
'stop[Stops the running Riak node]' \
'restart[Stops and then starts the running Riak node without exiting Erlang VM]' \
'reboot[Stops and then starts the running Riak node, exiting Erlang VM]' \
'ping[Checks that the Riak node is running]' \

When you build Erlang/OTP on OS X, it unfortunately defaults to handling a maximum of 1024 file descriptors. You can get around this limitation with the right combination of configuration options and manual changes to a generated config file.

First, go into your unpacked Erlang/OTP source directory and run the following command, replacing the value 10000 with whatever value you want for max file descriptors:

perl -i -pe 's/(define\s+FD_SETSIZE\s+)\d+/\1 10000/' erts/config.h.in 

Next, when you run configure in your Erlang/OTP source directory, be sure to include the right CFLAGS setting, as shown below:

CFLAGS='-DREDEFINE_FD_SETSIZE -DFD_SETSIZE=15000 -D_DARWIN_UNLIMITED_SELECT' ./configure --enable-kernel-poll <other options>
% $R16B03_1_hipe/bin/erlc utf8_with_magic_comment.erl
% $R16B03_1_hipe/bin/erl -noshell -s utf8_with_magic_comment start -s init stop
===== format by 's'
[bytes]: あ
===== format by 'ts'
[codepoint]: \x{3042}
[bytes]: あ
[string_literal]: \x{3042}
===== format by 'ts' with io:setopts([{encoding, utf8}])
[codepoint]: あ
@jj1bdx
jj1bdx / csv2tsv.py
Last active November 18, 2018 21:49 — forked from netj/csv2tsv.py
#!/usr/bin/env python
import sys,csv
for row in csv.reader(sys.stdin):
print "\t".join(row)