z_utils (zotonic_core v1.0.0-rc.12)
Link to this section Summary
Functions
Check if two arguments are equal, optionally converting them
Check if an assertion is ok or failed
Ensure that the given string matches an existing module. Used to prevent a denial of service attack where we exhaust the atom space.
Safe erase of process dict, keeps some 'magical' proc_lib vars
Filter all filenames which start with a dot.
Flush all incoming messages, used when receiving timer ticks to prevent multiple ticks.
Return the current universal time in seconds
Get a value from a map or a proplist. Return 'undefined' if The value was not present.
Get a value from a map or a proplist. Return the default value if The value was not present.
Group by a property or m_rsc property, keeps the input list in the same order.
Given a list of proplists, make it a nested list with respect to a property, combining elements with the same property. Assumes the list is sorted on the property you are splitting on For example: [[{a,b}{x}], [{a,b}{z}], [{a,c}{y}]] gives: [ {b, [[{a,b}{x}], [{a,b}{z}]]}, {c, [[{a,c}{y}]]} ]
Hash data and encode into a hex string safe for filenames and texts.
Make a property list based on the value of a property For example: [ [{a,b}], [{a,c}] ] gives [{a, [{a,b}]}, {c, [[{a,c}]]}]
Check if a value is 'empty'
Multinode is_process_alive check
Check if the parameter could represent the logical value of "true"
Javascript escape, see also: http://code.google.com/p/doctype/wiki/ArticleXSSInJavaScript
Create a javascript object from a proplist
Return an abspath to a directory relative to the application root.
Return a list of all files in a directory, recursive depth first search for files not starting with a '.'
Return the name used in the context of a hostname
Scan the props of a proplist, when the prop is a list with a $. characters in it then split the prop.
Return the current tick count
Simple escape function for command line arguments
Simple escape function for filenames as commandline arguments. foo/"bar.jpg -> "foo/\"bar.jpg"; on windows "foo\\\"bar.jpg" (both including quotes!)
Apply a list of functions to a startlist of arguments. All functions must return: ok | {ok, term()} | {error, term()}. Execution stops if a function returns an error tuple. The return value of the last executed function is returned.
Replace a property in a proplist
Simple randomize of a list. Not good quality, but good enough for us
Convert a sorted list of integers to a list of range pairs {From,To}
Take max N elements from a list.
filename:wildcard version which filters dotfiles like unix does
Write a file that is readable by file:consult/1
Link to this section Functions
Link to this function
are_equal(Arg1, Arg2)
Link to this function
assert(_, Error)
Link to this function
checksum(Data, Context)
-spec checksum(Data, Context) -> Checksum when Data :: iodata(), Context :: z:context(), Checksum :: binary().
Link to this function
checksum_assert(Data, Checksum, Context)
-spec checksum_assert(Data, Checksum, Context) -> ok when Data :: iodata(), Checksum :: binary() | string(), Context :: z:context().
Link to this function
coalesce(T)
Link to this function
decode_value(Data, Context)
Link to this function
decode_value_expire(Data, Context)
Link to this function
depickle(Data, Context)
Link to this function
encode_value(Value, Context)
Link to this function
encode_value_expire(Value, Date, Context)
Link to this function
ensure_existing_module(ModuleName)
Link to this function
erase_process_dict()
Link to this function
f(S, Args)
Link to this function
filter_dot_files(Names)
Link to this function
flush_message(Msg)
Link to this function
get_nth(N, L)
Link to this function
get_seconds()
Link to this function
get_value(Key, Map)
-spec get_value(term(), map() | list()) -> term().
Link to this function
get_value(Key, Map, Default)
-spec get_value(term(), map() | list(), term()) -> term().
Link to this function
group_by(L, Prop, Context)
Link to this function
group_proplists(Prop, Rest)
-spec group_proplists(atom(), [{atom(), term()}]) -> [{term(), list()}].
Link to this function
hex_decode(Value)
-spec hex_decode(iodata()) -> binary().
Link to this function
hex_encode(Value)
-spec hex_encode(iodata()) -> binary().
Link to this function
hex_sha(Value)
-spec hex_sha(Value) -> Hash when Value :: iodata(), Hash :: binary().
Link to this function
hmac(Type, Key, Data)
Link to this function
index_proplist(Prop, List)
-spec index_proplist(term(), [{term(), term()}]) -> [{term(), term()}].
Link to this function
is_empty(Trans)
Link to this function
is_iolist(C)
Link to this function
is_process_alive(Pid)
Link to this function
is_proplist(R)
Link to this function
is_true(T)
Link to this function
join_defined(Sep, List)
Link to this function
js_array(L)
Link to this function
js_escape(V)
Link to this function
js_escape(Trans, OptContext)
Link to this function
js_object(L)
Link to this function
js_object(L, OptContext)
Link to this function
js_object(L, T, Context)
Link to this function
lib_dir()
Link to this function
lib_dir(Dir)
Link to this function
list_dir_recursive(Dir)
Link to this function
name_for_site(Name, Context)
-spec name_for_site(Name :: atom(), atom() | #context{}) -> atom().
Link to this function
nested_proplist(Props)
Link to this function
nested_proplist(T, Acc)
Link to this function
now()
Link to this function
now_msec()
Link to this function
only_digits(L)
Link to this function
only_letters(T)
Link to this function
os_escape(S)
-spec os_escape(string() | binary() | undefined) -> string().
Link to this function
os_filename(F)
-spec os_filename(string() | binary()) -> string().
Link to this function
pickle(Data, Context)
Link to this function
pipeline(Fs, As)
-spec pipeline([PipelineFun], list()) -> ok | {ok, term()} | {error, term()}
when PipelineFun :: function() | mfa().
Link to this function
prefix(Sep, List)
Link to this function
prop_delete(Prop, List)
Link to this function
prop_replace(Prop, Value, List)
Link to this function
props_merge(Ps, Xs)
Link to this function
randomize(List)
-spec randomize(list()) -> list().
Link to this function
ranges(Ns)
-spec ranges([integer()]) -> [{integer(), integer()}].
Link to this function
replace1(F, T, L)
Link to this function
set_nth(N, V, L)
Link to this function
split(N, L)
-spec split(integer(), list()) -> {list(), list()}.
Link to this function
split_in(L, N)
Link to this function
vsplit_in(L, N)
Link to this function
wildcard(DirName)
-spec wildcard(DirName :: file:filename_all()) -> [file:filename()].
Link to this function
wildcard(WildCard, DirName)
-spec wildcard(WildCard :: string(), DirName :: file:filename_all()) -> [file:filename()].
Link to this function
wildcard_recursive(WildCard, DirName)
-spec wildcard_recursive(WildCard :: string(), DirName :: file:filename_all()) -> [file:filename()].
Link to this function
write_terms(Filename, List)
-spec write_terms(file:filename_all(), [term()]) -> ok | {error, term()}.