Graeme Defty | 25 May 2013 07:03
Picon

Rounding Floats : Beware

General erlang point, rather than CB-specific, but . . .

I made a casual google search on erlang rounding and turned up the following:

  "round/1 returns the closest integer to x, rounding to even when x is halfway between two integers."

(TrapExit http://www.trapexit.org/Floating_Point_Rounding - though the error is repeated in several other places)

NOT TRUE ( well not on my system anyway)

ROUND HALF TO EVEN is a very common standard practice, particularly in bookkeeping applications (and according to Wikipedia, "This is the default rounding mode used in IEEE 754 computing functions and operators").

However, erlang uses ROUND HALF AWAY FROM ZERO.

From my shell:

(eg <at> testhost)12> round (3.5).
4
(eg <at> testhost)13> round (4.5).
5
(eg <at> testhost)14> round(-3.5).
-4
(eg <at> testhost)15> round(-4.5).
-5
(eg <at> testhost)16>

This may catch some by surprise - it certainly did me. It happens that for this application neither is what I need (I want ROUND HALF UP, but that is a different story).

The official documentation is characteristically coy on the subject, not commenting on the strategy used. But how hard is it to start up an erlang shell and try it for goodness sake?

Anyway - a word to the wise.  ;-)   Dont believe all you read

graeme

PS
(With my generous hat on . . . Perhaps the behaviour was different in the past.  ;-) )

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Evgeny M | 24 May 2013 22:45
Picon

Turn off sessions for controller(s)

How can I turn off sessions altogether for some controllers?

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
David Welton | 23 May 2013 16:28
Picon
Gravatar

"class methods" for models

Hi,

I'd like to do something like

student:some_utility_function(Foo, Bar) without it being fiddled with
in the parse transform stuff.

Ideas?

--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

--

-- 
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@...
For more options, visit https://groups.google.com/groups/opt_out.

Evgeny M | 22 May 2013 23:02
Picon

start gen_server module

Hi,

How can i start my own gen_server module in CB on startup? I can only think of creating a new app and addding it into boss.config file. Any other ways to do this?

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Picon
Gravatar

Enum sessions

Hi all!


How I can enumerate all opened sessions? Does CB have any foldl-iterator for this?

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Nchy Raghav | 21 May 2013 12:30
Picon

Creating a page within a page

I have a controller named 'some_controller'.

I have displayed a html page named '/some_controller/display' by adding a function 'display' to the 'some_controller'.

display('GET',[])

Now, i want to create a page with URL ='/some_controller/display/another_page'.
The on ly option which seems to me is to pass a parameter to the display like this

display('GET',[param])

But, it would lead to redefinition of function.
Moreover i am also using display('POST',[]). So, that option is also ruled out.

Any help is appreciated.

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Nchy Raghav | 21 May 2013 12:17
Picon

Creating multiple pages associated with a controller.

I have a controller named 'some_controller'.

I have displayed a page  '/some_controller/display' by creating a function 'display' in some_controller.

Now, i want to add another page with URL as '/some_controller/display/another_page'.

The only option which seems to me is to pass 'another_page' as parameter to the 'display' function but it would lead to redefinition of the function.

Any help is appreciated.

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
David Welton | 21 May 2013 14:28
Picon
Gravatar

redefined function error

Here's a weird one...

Model 'student':

-has({exams, many}).

first_exam() ->
    lists:nth(1, completed_exams()).

That doesn't complain on my computer, but on my colleague's computer,
it does.  Same erlang version, same code.  Actually, to be more
precise, it does not compile for him, but he made a new account for me
on the computer, and it compiles fine.

==> myapp_web (pre_compile)
ERROR: pre_compile failed while processing
/home/albert64/projects64/myapp/myapp_web:
{'EXIT',{{badmatch,{error,[{"/home/albert64/projects64/myapp/myapp_web/src/model/student.erl",
                            [{0,erl_lint,{redefine_function,{first_exam,1}}},
                             {0,erl_lint,
                              {redefine_function,{last_exam,1}}}]}]}},
         [{boss_load,load_all_modules,3,
                     [{file,"src/boss/boss_load.erl"},{line,30}]},
          {boss_load,load_all_modules_and_emit_app_file,2,
                     [{file,"src/boss/boss_load.erl"},{line,44}]},
          {boss_rebar,compile,4,

[{file,"/home/albert64/projects64/ChicagoBoss/priv/rebar/boss_rebar.erl"},
                       {line,85}]},
          {boss_plugin,pre_compile,2,
                       [{file,"priv/rebar/boss_plugin.erl"},{line,105}]},
          {rebar_core,run_modules,4,[]},
          {rebar_core,execute,5,[]},
          {rebar_core,process_dir1,6,[]},
          {rebar_core,process_commands,2,[]}]}}

I think it's good that it complains, but I'm struggling to figure out
what might be different in his environment that makes it do this.

Any ideas?

--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

--

-- 
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@...
For more options, visit https://groups.google.com/groups/opt_out.

Fredrik de Vibe | 20 May 2013 21:05
Picon
Picon

eunit tests won't start with with additional applications

More testing woes..

I have a couple of extra applications being managed by CB (inets and
bcrypt), they are included in src/<appname>.app.src and they have
their own modules under priv/init, namely <appname>_02_inets.erl and
<appname>_03_bcrypt.erl.

As long as those extra applications are included in <appname>.app.src,
eunit tests won't start (rebar and priv/rebar/boss_plugin.erl are from
0.8.4, and the result is the same whether I use CB 0.8.4 or 0.8.6). By
printing out log messages, I get lots and lots of

INFO:  Boss App <appname> still not started, waiting...

so boss_rebar:boss_start_wait() loops forever, as <appname> seemingly
isn't started. If I omit inets and bcrypt from <appname>.app.src,
<appname> starts, but running the tests fails due to missing
dependencies.

The applications list in <appname>.app.src reads

 {applications, [kernel, stdlib, crypto, boss, inets, bcrypt]}

(I've also tried omitting boss here, but the result stays the same)
and the init functions of the inets and bcrypt init modules read,
respectively

init() ->
    inets:start(),
    {ok, []}.

and

init() ->
    bcrypt:start(),
    {ok, []}.

I have had the tests running before, but I don't recall whether this
was before or after I added the extra applications, and I've regularly
updated CB to the latest versions.

Does anybody have any idea what's going on here? Should I start the
applications differently or do I need something extra in
boss.test.config? Or are eunit tests with extra applications broken in
(at least) 0.8.4?

Thanks,

- Fredrik

--

-- 
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@...
For more options, visit https://groups.google.com/groups/opt_out.

Fredrik de Vibe | 20 May 2013 01:29
Picon
Picon

eunit testing broken in 0.8.6?

I can't seem to get eunit tests to run in 0.8.6. With rebar and
priv/rebar/boss_plugin.erl from 0.8.4, they do. Is eunit testing
broken in 0.8.6 or am I doing something wrong?

Freshly set-up CB 0.8.6, Erlang R16B, wholly new app, foo. From what i
can see there seems to be some disagreement regarding rebar's API:

$ ./rebar boss c=test_eunit
==> foo (boss)
ERROR: boss failed while processing /home/fdv/src/tests/cb/foo:
{'EXIT',
 {undef,
  [{rebar_erlc_compiler,doterl_compile,
   ...

Can anybody shed some light on this?

Thanks,
- Fredrik

--

-- 
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@...
For more options, visit https://groups.google.com/groups/opt_out.

Lucas Introne | 18 May 2013 03:02

Using boss_migrate for initial data

Hey all,


I've been reviewing the past discussions that led up to the development of boss_migrate, and it looks like it actually started with the desire to be able to initialize a database.  Along those lines, I was wondering if db migrations were a smart way to initialize data as well as schema.  It's certainly possible to do, but I know boss_migrate is far from complete, and I don't want to commit to it if I'll encounter problems down the roadmap...

In my particular use case, (probably quite common,) my application is going to launch with a number of predefined user roles, and surely there will be other production data.  I'd rather that data lived in code, so I can be free to fill my development database with test data, and I can dump and recreate my development database at any time with the initial data in place.

Any thoughts?

Also, boss_migrate only seems to be fully supported on pgsql at the moment, but I managed to get it working on mongo.  Migrations currently use transactions, which are not supported by mongo, and which I didn't even attempt to implement, but it's otherwise completely working.  Evan, let me know if you want me to submit a pull request for this...

Thanks,
-Lucas- 

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gmane