Skip to content

Instantly share code, notes, and snippets.

@cooldaemon
cooldaemon / README.markdown
Created September 30, 2008 08:42
Made a calculator using the yecc and leex.

Building from Source

% /path/to/reia/bin/leex calc_scan.xrl
% /path/to/reia/bin/yecc calc_parse.yrl
% erlc calc_scan.erl
% erlc calc_parse.erl
% erlc calc_eval.erl

How to Use

@cooldaemon
cooldaemon / erle.erl
Created October 9, 2008 07:35
This command is wrapper for file:eval/1.
#!/usr/bin/env escript
main([]) ->
usage();
main(["-h"]) ->
usage();
main(["--help"]) ->
usage();
main([File]) ->
say_error(file:eval(File)).
@cooldaemon
cooldaemon / Makefile.in
Created October 28, 2008 09:02
This gist is template for using autoconf for erlang source compiling.
@SET_MAKE@
ERLC = @ERLC@
ERL = @ERL@
RUN_TEST = @ERLANG_LIB_DIR_common_test@/priv/bin/run_test
DIALYZER = @ERLANG_ROOT_DIR@/bin/dialyzer
ROOT = @ROOT@
all:
@cooldaemon
cooldaemon / deploy.rb
Created October 30, 2008 08:55
This recipe is used by the Webistrano.
set(:shared_children){
(exists?(:shared_dirs) ? shared_dirs.split(/\s/).push("log") : %w(log))
}
namespace :deploy do
desc "finalize update."
task :finalize_update, :except => { :no_release => true } do
run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
package MIME::Lite::TT::JP::Mobile;
use strict;
use warnings;
use version; our $VERSION = qv('0.0.1');
use Carp;
use English qw(-no_match_vars);
setlocal makeprg=~/bin/ttlint.pl\ %
@cooldaemon
cooldaemon / keep_state.erl
Created April 7, 2009 16:00
Restore state on supervisor restart.
-module(keep_state).
-author('cooldaemon@gmail.com').
-export([test/0]).
test() ->
keep_state_sup:start_link(),
{} = keep_state_server:get_state(),
keep_state_server:put_state(foo),
foo = keep_state_server:get_state(),
@cooldaemon
cooldaemon / Makefile
Created May 5, 2009 06:51
libxml2 sax sample.
xml2_sax_sample: xml2_sax_sample.c
gcc -o xml2_sax_sample `xml2-config --cflags --libs` xml2_sax_sample.c
clean:
rm xml2_sax_sample
@cooldaemon
cooldaemon / Makefile
Created July 11, 2009 14:31
Asynchronous test in Objective-C.
CC = gcc
SOURCES = $(wildcard *.m)
OBJECTS = $(SOURCES:%.m=%.o)
TARGET = test
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -o $@ -framework Foundation
.m.o:
@cooldaemon
cooldaemon / Makefile
Created July 16, 2009 02:22
This is a sample for Tokyo Cabinet.
CC = gcc
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:%.c=%.o)
TARGET = test
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -o $@ \
-ltokyocabinet -lz -lbz2 -lpthread -lm -lc