Skip to content

Instantly share code, notes, and snippets.

View horvand's full-sized avatar

Andras Horvath horvand

View GitHub Profile
@horvand
horvand / _reader-macros.md
Created December 27, 2018 19:14 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

defmodule WhiteList do
import Enum,
only: [
reverse: 1,
concat: 1,
filter: 2,
map: 2,
map_reduce: 3,
split_while: 2,
join: 2
@horvand
horvand / majom.ex
Created October 2, 2018 13:41
elixir-@
defmodule Majom do
@constseq :lists.seq(1,10,2)
def f() do
IO.inspect(quote do
@constseq
end)
IO.inspect(@constseq)
end
@horvand
horvand / erlang-release-init.d.md
Created October 1, 2018 14:57 — forked from ostinelli/erlang-release-init.d.md
Erlang Release init.d script

Erlang Release init.d script

If you have packaged your application into a release generated with Rebar, you might want to have the following:

  • The release started on system boot.
  • The VM monitored and restarted it if it crashes.

Use HEART

HEART is the Heartbeat Monitoring of an Erlang Runtime System. The purpose of the heart port program is to check that the Erlang runtime system it is supervising is still running, so that if the VM crashes or becomes unresponsive, it is restarted.

@horvand
horvand / my_app.ex
Created August 24, 2018 16:01 — forked from alanpeabody/my_app.ex
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@horvand
horvand / dummy-web-server.py
Created December 21, 2016 15:35 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
@horvand
horvand / teleport.el
Last active August 29, 2015 14:07 — forked from mhssler/teleport.el
;;; teleport.el -- explore a program by jumping to random parts.
;; Version 1.0.
;; Written by Luke Gorrie <l...@bluetail.com> in September 2003.
;;
;; This program is released under the terms of the GNU General Public
;; License.
;;
;; Compatibile with GNU Emacs 20 and 21, but requires the CL library
;; in Emacs 20. Not compatible with XEmacs -- what's their