Skip to content

Instantly share code, notes, and snippets.

View gist:9086538
The following code
(defn do-stuff [msg]
(hmatch msg
[:dog age name] (println "got a dog with age " age " and name " name)
[:cat cute? legs] (println "got a cat that is " cute? " cute and has " legs "legs")
[other] (println "got an unrecognized animal of type " other ))
becomes:
View gist:9410532
PROJECT = websocket
DEPS = cowboy erldn
dep_cowboy = pkg://cowboy master
dep_erldn = https://github.com/txrev319/erldn.git master
View gist:9426556
{application, hello_erlang, [
{description, "Hello world with Cowboy!"},
{vsn, "0.1.0"},
{modules, []},
{registered, [hello_erlang_sup]},
{applications, [
kernel,
stdlib,
cowboy
]},
View gist:9426939
Erlang/OTP 17 [RELEASE CANDIDATE 2] [erts-6.0] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V6.0 (abort with ^G)
(websocket_example@127.0.0.1)1> application:stop(websocket).
=INFO REPORT==== 8-Mar-2014::02:51:11 ===
application: websocket
exited: stopped
type: permanent
ok
View gist:9444104
-module(websocket_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
-export([public_router/0]).
public_router() ->
View gist:9443944
=INFO REPORT==== 9-Mar-2014::03:03:41 ===
application: websocket
exited: {bad_return,
{{websocket_app,start,[normal,[]]},
{'EXIT',
{{badmatch,{error,{already_started,<0.53.0>}}},
[{websocket_app,start,2,
[{file,"src/websocket_app.erl"},{line,26}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,272}]}]}}}}
View gist:9443959
## websocket_app.erl
-module(websocket_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
View gist:10002189
websocket_handle({text, Msg}, Req, State) ->
try _X = lists:flatten(io_lib:format("~p", [erldn:parse_str(Msg)])) of
_ -> {reply, {text, <<"That's what she said! ", Msg/binary >>}, Req, State}
catch
_ -> {reply, {text, <<"ERROR Parsing", Msg/binary >>}, Req, State}
end;
websocket_handle(_Data, Req, State) ->
{ok, Req, State}.
View gist:50ac3fbba4251436abc1
(ns doc.doc-diff
#+clj (:require [clojure.core.typed :as t])
#+cljs (:require-macros [cljs.core.typed :as t]))
(t/defalias Cmd (U Set-Attrs Set-Order Update-Child Swap-Child))
(t/defalias Cmds (t/Seq Cmd))
View gist:b8db01ac91ee5d2805e5
(Rec [x]
(U '{:op (Value :if)
:test x
:then x
:else x}
'{:op (Value :var)
:var clojure.lang.Var}
'{:op (Value :nil)}
'{:op (Value :false)}))))