eigenfunction | 10 Feb 11:38
Picon
Favicon

wxerlang

Is there any comprehensive tutorial out there about wxerlang? Or do i
have to go the wxWidget route?
The only thing i could find is http://wxerlang.dougedmunds.com .
Any idea?
Max Bourinov | 10 Feb 08:30
Picon
Gravatar

State in webmachine

I would like to keep time of last call inside page module. I suspect that State which exists in the page module can help me with it - is it correct?


How would you do it in easy way?

The hard way I know is to spawn process that will keep my data.

Best regards,
Max


CGS | 10 Feb 06:26
Picon

crypto:md5/1 vs openssl md5


Hi,

Just for my curiosity, does anybody know if crypto:md5/1 in R14B03 is intentionally different from openssl md5? (The sha matches perfectly.)

Just a short test (Erlang shell):
1> RB = crypto:rand_bytes(16).                                                
<<141,190,84,7,129,230,147,112,200,205,68,80,240,78,68,198>>                   
2> MD5 = crypto:md5(RB).                                                      
<<97,59,0,195,229,254,195,237,238,126,156,14,33,142,206,183>>
3> lists:flatten(lists:map(fun([X,Y])->[case X>64 of true -> X+32; false-> X end,case Y>64 of true -> Y+32; false -> Y end];([X])->[$0,case X>64 of true -> X+32; false -> X end] end, lists:map(fun(X)->integer_to_list(X,16) end, binary_to_list(RB)))).                  
"8dbe540781e69370c8cd4450f04e44c6"
4> lists:flatten(lists:map(fun([X,Y])->[case X>64 of true -> X+32; false-> X end,case Y>64 of true -> Y+32; false -> Y end];([X])->[$0,case X>64 of true -> X+32; false -> X end] end, lists:map(fun(X)->integer_to_list(X,16) end, binary_to_list(MD5)))).
"613b00c3e5fec3edee7e9c0e218eceb7"
5> os:cmd("echo \"8dbe540781e69370c8cd4450f04e44c6\" | openssl md5").         
"(stdin)= 6007d8f36b589078f3565b5c90cedffc\n"                                  

As you can see the same rand number, "8dbe540781e69370c8cd4450f04e44c6", gives in crypto:md5 "613b00c3e5fec3edee7e9c0e218eceb7" while in openssl md5 "6007d8f36b589078f3565b5c90cedffc". Please, let me know if I do something wrong.

CGS

Brian Smith | 9 Feb 22:56
Picon
Gravatar

Performance difference between string and binary data when queried in mnesia?

I have a table to have >1.5 million records in it.

-record(hosts, {hostname,  flags, catmask}).
application:start(mnesia).
mnesia:create_table(hosts, [{ram_copies, [node()]}, {attributes, 
record_info(fields, hosts)}]).

mnesia:dirty_select(hosts, [{#hosts{hostname='$1', _='_'}, [{'=<', '$1', 
SearchParam}], ['$_']}]).

Is there any significant performance difference between: SearchTerm = 
"facebook.com", and SearchTerm = <<8,"facebook", 3, "com", 0>>, ?

Thanks and egger to hear some responses...

--

-- 
-brian

Mark Allen | 9 Feb 21:04
Gravatar

Post and query string parameter validation library?

Hello. I'm relatively new to Erlang programming. My project is an backend
API for a JSON based webservice.

I'm looking for a library which can take a proplist in form of

[{"param_name", "value"}, ...]

and validate the values against a set of specifications for the
parameters.  

I'm pretty open to how specifications are declared or passed.

(The proplist comes from mochiweb post_params() or query_params() calls.)

Before I go reinvent the wheel, I thought I'd ask if there's something
already
out there that does this.

Thanks.

Mark

Mark Allen
Sr. Software Developer
Alert Logic, Inc.
mallen <at> alertlogic.com
Security € Compliance € Cloud

Simon MacMullen | 9 Feb 19:37
Favicon
Gravatar

Character encoding and the Windows command line

Here is a simple test program:

   -module(test).
   -export([test/0]).
   test() -> io:format("Args were ~w~n", [init:get_plain_arguments()]).

If I invoke this on Ubuntu, with the command line:

   $ erl -run test test -- 新

I get:
   Args were [[230,150,176]]

which is the UTF-8 encoding of the character I gave (\u65b0, "new, 
recent, fresh, modern"). Great!

Then I try it on my Chinese language copy of Windows XP:

   C:\>"c:\Program Files\erl5.9\bin\erl" -run test test -- 新
   Args were [[208,194]]

Huh. That's (it turns out) encoded in GB18030. Which would appear to be 
the encoding used by Windows. Better yet, if I try the same thing on a 
UK copy of Windows it tries to use an encoding which can't handle 
Chinese characters.

So this sucks. I would like my application internally to use all UTF-8, 
all the time. It would appear that I can use the Windows command "chcp" 
to detect which encoding Windows will impose on me, then try to use 
erlang-iconv or something to sort myself out but:

a) This seems hideous; does anyone have a better way? (Sorry, "don't 
support Windows" is not a better way).

b) It gets worse: suppose my application is installed to a path which 
includes non-ASCII characters, and we use "-pa" to tell erl.exe where 
that is...

In that case we *still* pass through the path in GB18030 or whatever, 
and erl.exe fails to even find it as it expects UTF-8. Is there any 
solution to this *at all*?

Cheers, Simon

--

-- 
Simon MacMullen
RabbitMQ, VMware
_______________________________________________
erlang-questions mailing list
erlang-questions <at> erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Motiejus Jakštys | 9 Feb 19:37
Picon
Gravatar

is empty catch statement possible?

Hello,
consider this macro:

-define(silent(Level, Expr), (fun() ->
                __Lager_OldLevel = lager:get_loglevel(lager_console_backend),
                try 
                    fun() -> Expr end 
                catch
                    throw:'$__should_never_be_thrown' -> ok
                after
                    leger:set_loglevel(lager_console_backend, __Lager_OldLevel)
                end 
        end)()).

1) does it do what I expect? I want log level to be restored in _any_ case.
2) Is there a way to avoid the stub throw:Atom statement?

Thanks
Motiejus
Martin Dimitrov | 9 Feb 17:35
Picon

How to convert UTF8 string to lowercase?

Hello,

In the string module no word is mentioned about Unicode. Can to_lower/1
be used to covert Utf8 encoded string to lowercase?

I remember I read somewhere that these functions are not Unicode safe.
So what else can be used?

Regards,

Martin
Martin Dimitrov | 9 Feb 16:37
Picon

searching in an ETS table for substring

Hello,

Is it possible to search in an ETS table for a key that starts with
certain characters?
Something equivalent to:

SELECT * FROM table WHERE name LIKE 'some%'

I read the documentation for select/2 and it says we can use as guards
functions as is_* and the like.

Best regards,

Martin
Vinod H G | 9 Feb 16:02
Picon
Gravatar

Starting erl with unicode hostname

Hi,


When trying to support erl running on different language OS got an issue with the hostname. The hostname had Unicode characters.
I used short name and got following error.

Can’t set short node name. please check your configuration. registered_name,   { error, badarg}

If i use long name ex: 
erl -name abc <at> my_host

vm starts but cnode communication (using ei_connect) is breaking in receive with {error, einval}.

Please help.


Thanks & Regards,
Vinod H. G.
Bengt Kleberg | 9 Feb 14:53
Picon
Favicon

beginner: How make reltool handle multiple versions of libs?

Greetings,

The Erlang/OTP installation I use(*) overwhelms reltool(**). At least
that is what I think, since dialyzer gave me a similar error until I
switched to use "-r lib/*-0".
Can I tell reltool to ignore all but the *-0 versions, too?

bengt

(*)
lib/appmon-0
lib/appmon-2.1.12
lib/appmon-2.1.13
lib/asn1-0
lib/asn1-1.6.14
lib/asn1-1.6.14.1
lib/asn1-1.6.15
lib/asn1-1.6.16
...
lib/wx-0.98.8
lib/wx-0.98.9
lib/wx-0.99
lib/xmerl-0
lib/xmerl-1.2.10
lib/xmerl-1.2.5
lib/xmerl-1.2.6
lib/xmerl-1.2.7
lib/xmerl-1.2.8
lib/xmerl-1.2.9

(**)
4> {ok, Pid} = reltool:start_server([{config, "reltool.config"}]).
{ok,<0.51.0>}

=CRASH REPORT==== 9-Feb-2012::14:43:17 ===
  crasher:
    initial call: reltool_server:init/1
    pid: <0.51.0>
    registered_name: []
    exception exit: "hipe: Application version clash. Multiple
directories contains version \"3.8.1\"."
      in function  reltool_server:do_init/1
      in call from reltool_server:init/1
    ancestors: [<0.47.0>]
    messages: []
    links: [<0.47.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 317811
    stack_size: 24
    reductions: 1762187
  neighbours:
    neighbour: [{pid,<0.47.0>},
                  {registered_name,[]},
                  {initial_call,{erlang,apply,2}},
                  {current_function,{shell,eval_loop,3}},
                  {ancestors,[]},
                  {messages,[]},
                  {links,[<0.26.0>,<0.51.0>]},
                  {dictionary,[]},
                  {trap_exit,false},
                  {status,waiting},
                  {heap_size,2584},
                  {stack_size,7},
                  {reductions,5367}]
** exception error: "hipe: Application version clash. Multiple
directories contains version \"3.8.1\"."


Gmane