This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deal_with_strings() -> | |
Result = string:format("~s ~s", ["very" , "simple"]), | |
%% is much cleaner than | |
Result2 = lists:flatten(io_lib:format(("~s ~s", ["very" , "simple"])). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{parts, | |
{table, "item"}, | |
{columns, all}, | |
{operations, [eq(column("item", name), "apple")]}, | |
{order, []}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Item || Item <- mnesia:table(item) ,Item#item.name =:= apple] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%--------------------------------------------------------------------------------------- | |
%%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, []}}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MailTruck | |
@@trucks = [] | |
def MailTruck.add( truck ) | |
@@trucks << truck | |
end | |
def say_hi | |
puts "Hi, I'm one of #{@@trucks.length} trucks!" | |
end | |
end |