Skip to content

Instantly share code, notes, and snippets.

@davidw
davidw / flatten.erl
Created August 5, 2018 03:19
flatten.erl
-module(flatten).
-export([flatten/1]).
flatten(List) ->
lists:reverse(flatten_helper(List, [])).
flatten_helper([], Flat) ->
Flat;
Please use davidw@dedasys.com for the hex.pm maintainers for epgsql, rather than the gmail.com address
@davidw
davidw / codesize.erl
Created February 13, 2015 13:43
Get a sorted list of the largest .beam files in use by your Erlang system
%%%-------------------------------------------------------------------
%%% @author David N. Welton <davidw@dedasys.com>
%%% @copyright (C) 2015, David N. Welton
%%% @doc
%%%
%%% @end
%%% Created : 13 Feb 2015 by David N. Welton <davidw@dedasys.com>
%%%-------------------------------------------------------------------
-module(codesize).
-module(walkapp).
-export([walk/1]).
walk(AppName) ->
Pid = application_controller:get_master(AppName),
walk_internal([Pid], sets:new()).
walk_internal([], Seen) ->
error_logger:info_msg("done!"),
def Version.clean_duplicates
Document.all.each do |d|
puts "document #{d.id}"
oldv = nil
toreap = []
d.versions.select([:id, :created_at]).each do |v|
v.reload
if !oldv.nil? && !oldv.content.nil? && !v.content.nil? &&
oldv.content.size == v.content.size && oldv.content == v.content
start() ->
loop(0, 0, 0, right, down).
loop(200, _, _, _, _) ->
ok;
loop(Counter, LastX, LastY, DirX, DirY) ->
{ok, Cols} = io:columns(),
{ok, Rows} = io:rows(),
{NewX, NewY, NewDirX, NewDirY} = move(LastX, LastY, DirX, DirY, Cols, Rows),
all: priv/report_templates/*_report_template/dist/prefixed.css
priv/report_templates/foo_report_template/dist/all.css: $(wildcard priv/report_templates/foo_report_template/stylesheets/*.css) $(wildcard priv/report_templates/common/stylesheets/*.css)
cat $^ > $@
priv/report_templates/bar_report_template/dist/all.css: $(wildcard priv/report_templates/bar_report_template/stylesheets/*.css) $(wildcard priv/report_templates/common/stylesheets/*.css)
cat $^ > $@
priv/report_templates/foo_report_template/dist/prefixed.css: priv/report_templates/foo_report_template/dist/all.css
priv/autoprefixer/node_modules/autoprefixer/bin/autoprefixer --browsers ${AUTOPREFIXER_BROWSERS} -o $@ priv/report_templates/foo_report_template/dist/all.css
-heart
-setcookie mycookie
-name myweb@localhost.localdomain
-kernel net_ticktime 10
-env ERL_CRASH_DUMP_SECONDS=-1
@davidw
davidw / gist:3b22a30bc84a652085bc
Last active August 29, 2015 14:03
erlang crash
=proc:<0.6.0>
State: Running
Name: error_logger
Spawned as: proc_lib:init_p/5
Last scheduled in for: gen_event:handle_msg/5
Spawned by: <0.2.0>
Started: Wed Jul 2 11:45:41 2014
Message queue length: 1
Number of heap fragments: 0
Heap fragment data: 0
lager:info("Running migration: ~p~n", [Tag]),
try
Res = Fun(Direction),
error_logger:info_msg("Result is ~p~n", [Res])
catch
Error ->
error_logger:error_msg("Error in ~p ~p~n", [Tag, Error])
%% throw(Error)
end,