Skip to content

Instantly share code, notes, and snippets.

@kuniyoshi
kuniyoshi / record_util.erl
Created August 17, 2013 04:27
How can i get field from record? The field name is a variable in my case.
-module(record_util).
-export([record_field/2]).
-record(user, {id, username, password}).
% it can not write followfing.
% R = #user{id=10, username="foo", password="bar"}.
% F = username.
% R#user.F.
%
% i saw: http://www.trapexit.org/forum/viewtopic.php?p=43910
@kuniyoshi
kuniyoshi / session.erl
Last active December 22, 2015 22:29
Get digest value as hex string... In perl; [kouji:~]% perl -MDigest -E 'say(Digest->new("SHA-256")->add(rand())->hexdigest)' # ~ [Fri 1:30:53] 9d609484f63971292f4d0f2558501f4badd87899e548ad23de55fc2acf058cb4 hum, i need to know some more erlang modules.
-module(session).
-export([gen_id/0]).
-define(MAX, 100000000000000000000000000000000).
dec_to_hexstr(Digit) when Digit >= 0 andalso Digit < 10 -> $0 + Digit;
dec_to_hexstr(Digits) when Digits >= 10 andalso Digits < 16 -> $a + Digits - 10.
%% dec_to_hexstr(0) -> "0";
%% dec_to_hexstr(1) -> "1";
%% dec_to_hexstr(2) -> "2";
@kuniyoshi
kuniyoshi / mysqlnesia.erl
Created September 29, 2013 13:39
Is for making textfile dump for mnesia from MySQL.
-module(mysqlnesia).
-export([start/0]).
-export([select_all/1]).
-export([decode/2]).
-export([write/1]).
-include("include/autoincrement.hrl").
-include("include/user.hrl").
-include("include/post.hrl").
-include("include/star.hrl").
-define(PKEY, <<"zErsG3DoWVBW1jBhZ0VzaY5dzuwvSgPx">>).
@kuniyoshi
kuniyoshi / inline_test.md
Last active December 24, 2015 20:09
Erlang の Inlining は効果あるかどうか。

compile で inline するかどうか

Inlining とは

inline を使うと関数の中身を置き換えてくれるようです。

Inlining means that a call to a function is replaced with the function body with the arguments replaced with the actual values.

どうなってるのか

@kuniyoshi
kuniyoshi / SSL Makefile
Last active December 27, 2015 22:09
Generate self certificated ssl cry. *NOTE*: this file includes `tab`, and `make` will fail when it has been changed `white space`.
.PHONY: all install
SERVER=purasi-bo.me
all: $(SERVER).key $(SERVER).csr $(SERVER).crt install
###
### *NOTE*
### When use this via copy and paste, care command line should starts `tab`.
###
@kuniyoshi
kuniyoshi / my.aliases
Last active December 28, 2015 22:59
my aliases
# Default Options
alias ll='ls -l'
alias ls='ls --color=auto'
alias la='ls -A'
alias grep='grep --color=auto'
alias history=' history'
alias difference='awk '\''NR == 1 { previous = $1 } NR > 1 { print $1 - previous; previous = $1 }'\'
# Two Chars Aliases
alias pd='perldoc -i'
@kuniyoshi
kuniyoshi / my.vimrc
Created November 21, 2013 02:42
my vimrc
set list listchars=tab:_\ ,trail:_
set noautoindent nocindent smartindent
set tabstop=4 shiftwidth=4 expandtab
set number ruler
noremap <Esc><Esc> <Esc>:nohlsearch<Cr>
nnoremap ZS :w<Cr>
nnoremap ZX :w<Cr>:sus<Cr>
@kuniyoshi
kuniyoshi / my.screenrc
Created November 21, 2013 02:43
my screenrc
defscrollback 10000
defbce on
attrcolor b .I
term xterm-256color
vbell off
autodetach on
startup_message off
hardstatus alwayslastline "%w"
#termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'
escape ^Ta
#!/bin/sh
ALIASES=https://gist.github.com/kuniyoshi/7575243/raw/
SCREENRC=https://gist.github.com/kuniyoshi/7575257/raw/
VIMRC=https://gist.github.com/kuniyoshi/7575248/raw/
curl "$CURL_OPTS" -L $ALIASES | tee ~/.aliases.kuniyoshi
curl "$CURL_OPTS" -L $SCREENRC | tee ~/.screenrc.kuniyoshi
curl "$CURL_OPTS" -L $VIMRC | tee ~/.vimrc.kuniyoshi
#wget --no-check-certificate $ALIASES -O ~/.aliases.kuniyoshi
@kuniyoshi
kuniyoshi / バッドデータハンドブック
Created December 1, 2013 16:01
Q. Ethan McCallum 著 『バッドデータハンドブック』(オライリー・ジャパン刊)
"ここで問題になるのおは、最終的にはいつも、そのデータを使っていろいろとやりたくなるということです。つまり、ソフトウェアを使ってデータを扱いたくなるのです。", 3 章, 機械ではなく人間が使うことを意図したデータ, Paul Murrell, p33
"トレーニングベースの機械学習には「ゴミを入れたら、ゴミが出てくる (garbage in, garbage out) 」という原理が働きます。", 6 章, オンラインレビューから嘘つきと混乱した人を発見する, Jacob Perkins, p96
"ハイカーや山登りの間には、こういう言葉があります。「悪天候なんてものはない、服装がふさわしくないだけだ」", 7 章, バッドデータは起立して, Philipp K. Janert, p107
"どんな分布にも裾はあります。収入や所得の場合、裾はかなり広がります。そこで回答者の身元を保護するため、調査を実施する企業や団体が極めて高い値や極めて低い値を特定の値に置き換えることがあります。", 10 章, バイアスとエラーの源, Jonathan A. Schwabish, p153
"政治ブログは非常に活発です。ブログはソーシャルメディアの成熟とともに質と深さが低下していますが、熱心な人は進んで、政治的議論の火中に飛び込んでいるようです。", 12 章, ファイルにこだわる, Tim McNamara, p171