Skip to content

Instantly share code, notes, and snippets.

View johnbender's full-sized avatar

John Bender johnbender

View GitHub Profile
ERROR erlang code crashed:
File: appmod:0
Reason: {undef,[{grove_mnesia,action2,["object",[]]},
{grove_appmod,get_query,3},
{yaws_server,deliver_dyn_part,8},
{yaws_server,aloop,3},
{yaws_server,acceptor0,2},
{proc_lib,init_p_do_apply,3}]}
try
{ok, Final} = smerl:add_func(Init, Fun),
smerl:compile(Final),
content(add_fun:run_fun(Object, Params))
catch
{error, _Something} -> ?ERROR_STATUS;
{undef, _Something} -> ?ERROR_STATUS;
_Other -> ?ERROR_STATUS
end.
deal_with_strings() ->
Result = string:format("~s ~s", ["very" , "simple"]),
%% is much cleaner than
Result2 = lists:flatten(io_lib:format(("~s ~s", ["very" , "simple"])).
{parts,
{table, "item"},
{columns, all},
{operations, [eq(column("item", name), "apple")]},
{order, []}}
[Item || Item <- mnesia:table(item) ,Item#item.name =:= apple]
format_query({parts, {table, Name}, {columns, Columns}, Op, Ord}) ->
ColStr = format_columns(Name, Columns),
format_query({parts, {table, Name}, ColStr, Op, Ord});
format_query({parts, {table, Name}, Col, {operations, Ops}, Ord}) ->
OpStr = format_ops(Name, Ops),
format_query({parts, {table, Name}, Col, OpStr, Ord});
format_query({parts, {table, Name}, Col, Op, Ord}) ->
TableGen = format_generator(Name),
format_query({parts, Table, Columns, Op, Ord})->
case {Table, Columns, Op, Ord} of
{{table, Name}, {columns, all}, Op, Ord} ->
format_query({parts, {Table, initcap(Name) ++ " || ", Op, Ord}});
{{table, Name}, Columns, Op, Ord} ->
format_query({parts,
{initcap(Name) ++ " <- mnesia:table(" ++ string:to_lower(Name) ++ ")",
Columns,
Op,
Ord}})
%%---------------------------------------------------------------------------------------
%%Function: find/2
%%Description: finds the given object based on id
%%---------------------------------------------------------------------------------------
find(Object, [ID]) ->
Result = ?ADAPT:run_query({qry,
{table, Object},
{columns, all},
{operations, [?OPS:eq(?ADAPT:column(Object, item), ID)]},
{order, []}}),
<form method="POST" action="http://localhost:2000/grove/shop/">
<input type="hidden" name="query" id="query"
value ='{ "query" :
[ {"columns" : [ "item" ]},
{"operations" : [{"eq" : {"item": { "atom" : "apple"}}}]},
{"order" : "ascending" }
]
}'
/>
<input type="Submit" value="Query Shop" />
class MailTruck
@@trucks = []
def MailTruck.add( truck )
@@trucks << truck
end
def say_hi
puts "Hi, I'm one of #{@@trucks.length} trucks!"
end
end