Skip to content

Instantly share code, notes, and snippets.

View binarytemple's full-sized avatar

Bryan Hunt binarytemple

  • The mountains of mourne
View GitHub Profile
@binarytemple
binarytemple / erlang.disk_log.module.markdown
Created February 4, 2015 17:16
erlang disk_log module

Two ways to write the logging, halt mode and wrap mode

Firstly, halt mode

31: disk_log:open([{file,"/tmp/ddddd"},
                   {type,halt},
                   {size,1000},
                   {name,dave},
                   {linkto,self()},

{mode,read_write}])

%%% Run with 'escript app_deps.erl'
%%% Change the path in filelib:wildcard/1 as required to capture all
%%% your dependencies.
%%%
%%% Rectangular nodes will represent library apps (no processes involved)
%%% and the circular nodes will represent regular apps. An arrow going from
%%% 'A -> B' means 'A depends on B'.
%%%
%%% This script depends on graphviz being present on the system.
-module(app_deps).

Erlydtl

The template file ( test/files/input/for_list )

I took a sample template file from the erlydtl test directory.

{% for singular, plural, price in fruit_list %}
%%% Run with 'escript app_deps.erl'
%%% Change the path in filelib:wildcard/1 as required to capture all
%%% your dependencies.
%%%
%%% Rectangular nodes will represent library apps (no processes involved)
%%% and the circular nodes will represent regular apps. An arrow going from
%%% 'A -> B' means 'A depends on B'.
%%%
%%% This script depends on graphviz being present on the system.
-module(app_deps).
/*
* This file is provided to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-module(localstream).
-export([load/1, keys/0, bucket/0, map/3]).
-define(QUERY, [{map, {modfun, localstream, map}, none, true}]).
load(HowMany) ->
{ok, Client} = riak:local_client(),
lists:foreach(fun(Index) ->
BIndex = list_to_binary(integer_to_list(Index)),
{ok, C} = riak:local_client().
{ok, Obj} = C:get(<<"bucket">>, <<"key">>).
iolist_size(term_to_binary(Obj)).
{ok, C} = riak:local_client().
{ok, Buckets} = C:list_buckets().
[ lk:fsm(B) || B <- Buckets ].
import urllib
import httplib
import json
import sys
def get_stats(ip, port=80):
url = 'http://%s:%s/stats' % (ip, port)
sock = urllib.urlopen(url)
jsons = sock.read()
obj = json.loads(jsons)