Skip to content

Instantly share code, notes, and snippets.

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

Yutaka Matsubara mopemope

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am mopemope on github.
  • I am mopemope (https://keybase.io/mopemope) on keybase.
  • I have a public key whose fingerprint is FC78 C29B 617B 2CF1 5EB9 BD7D DE91 BF6D 14CF 8CE7

To claim this, I am signing this object:

@mopemope
mopemope / file0.txt
Created September 18, 2015 09:32
YubiKey NEO で Linux でも 2段階認証しよう! ref: http://qiita.com/mopemope/items/779a5a4da734914b9cd0
$ packer -S yubikey-personalization yubikey-personalization-gui yubikey-neo-manager
@mopemope
mopemope / main.pony
Created August 6, 2015 08:39
http server
use "net/http"
actor Main
new create(env: Env) =>
let service = try env.args(1) else "50000" end
let limit = try env.args(2).u64() else 100 end
Server(Info(env), Handle, CommonLog(env.out) where service = service,
limit = limit)
@mopemope
mopemope / lfe.md
Created May 21, 2015 03:11
LFE入門の進捗

LFE 入門

近年、ネットワークアプリケーションを書くにあたり Erlang/OTP に対する注目が集まっています。 大規模サービスで使わているなどの事例が多く紹介されるようになり、導入を考えている方も多いでしょう。 ですが、Erlang は少々癖があり、難しく感じる方も少なくありません。 今回はそのような人向けに LFE を紹介しようと思います。

LFE とは

LFE とは (lisp (flavored (erlang))) の略です。その名の通り、 Erlang Virtual Machine (BEAM) 上で動く Lisp です。

(defmodule ppool-nagger
(export all)
(behavior gen_server))
(defun start-link (task delay max send-to)
(gen_server:start_link (MODULE) `#(,task ,delay ,max ,send-to) '()))
(defun start_link (task delay max send-to)
(start-link task delay max send-to))
@mopemope
mopemope / band-supervisor.lfe
Last active August 29, 2015 14:19
band supervisor
(defmodule band-supervisor
(export all)
(behavior 'supervisor))
(defun start-link (type)
(supervisor:start_link `#(local ,(MODULE)) (MODULE) type))
(defun start_link (type)
(start-link type))
(defmodule curling-accumulator
(export all)
(behavior 'gen_event))
(defrecord state
(teams (orddict:new))
(round 0))
(defun init
(('()) `#(ok ,(make-state))))
@mopemope
mopemope / trade-call.lfe
Created April 16, 2015 07:06
trade fsm
(defmodule trade-call
(export all))
(defun sync1 (pid)
(! pid (self))
(receive
('ack 'ok)))
(defun sync2 ()
(receive
(defmodule kitty-gen-server
(export all)
(behavior 'gen_server))
(defrecord cat
name
(color 'green)
description)
(defun start-link ()
@mopemope
mopemope / kitty-server2.lfe
Created April 14, 2015 04:36
simple kitty-server
(defmodule kitty-server2
(export all))
(defrecord cat
name
(color 'green)
description)
(defun start-link ()
(my-server:start-link (MODULE) ()))