Not More F'n Dice. Don't you Have Better Things to Do!!

As most of my post of late have been D&D related and my last post one of the major part of the game is simple rolling of dice.

Some of you might be old enough to remember this screen shot

Might and Magic 2 (C-64).jpg

Well if you where playing this on an IMB/XT all you had to do was go into DOS set the clock to 22:22:22 and then you would roll 18s for most of you ability scores?? Well it seems they where seeding the random generator with the time and that time got you the same 'good' results each time. Going back to the Apple ][+ days its randomizer was so bad you could easily see the patterns. The the Hi-Lo guessing game was one I remember transcribing from C64~Basic to AppleSoft. If the first number was 19 then next was 63 then 45.

So basically I was wondering it things are better these days.

Well I stole the code from Ovid's post

Technical Analysis in Finance using PDL - An Introduction.

In early 2013 I came across PDL and was surprised at its quality and applicability to large data sets which exist in the finance/trading world if you consider intra-day data which is stored tick by tick. You can easily run into 100,000 or more ticks in a few hours and tools like R and Excel become really slow for performing complex analysis and researching models.
Inevitably, all work was then done in C/C++ to leverage performance.

I finally found time to learn PDL and to learn to use it to perform Technical Analysis on data such as stock quotes. My aim is to learn how to use PDL efficiently and write a technical analysis library that mirrors what may already be available for C/C++ using say TA-Lib and other custom libraries that may be written in-house.

Create your own Test::Mojo method

Update:

Part of the broader problem of adding test methods in a composable way has been addressed now in the Test::Mojo::WithRoles system. That said, the original post still contains a solution that is easier in one-off scenarios. Keep reading :-)

Original Post:

Perhaps by now you are aware that Mojolicious has a very powerful test framework called Test::Mojo. It wraps most of the Test::More in with Mojo::UserAgent, Mojo::DOM and Mojo::JSON (and probably some things I have forgotten) to let you really test your app in a deep but pleasant way. That said, what if there is some method you wish it had? Should you monkey patch it into Test::Mojo?

No! There’s a better way! The next version of Mojolicious includes one tiny improvement that opens the world of testing as far as your imagination can take you. It just requires a little cleverness.

Storable-like Modules

I need to store some big matrices (Math::MatrixReal objects) to be released on a module that will need to load them every time it is loaded. Therefore, the save time is not important, but I need fast loading. Also, it would be nice if the format would be kind of compressed (zlib or any other). Finally, and less important, it would be also nice if the format, in case it is binary, is platform independent.

Every time I needed something like this I used Storable and/or Data::Dumper. What other interesting options are out there?

Ask Not What your Moose Can Do For You. But What You Can Do For Moose

As most of my recent posts have been looking at what nice little goodies Moose has to offer and I now that I have solved my last role problem I figured it was time to take a little break from coding and look as general Design a little

I could just do like the old days and draw something up like this;

jIY3t.jpg


It think (well know) that there is a mindset out there against this sort of work, I know I have been told many times by 'Pointy Headed Boss Types', to stop that nonsense and get back to work and even once got fired for doing it.

I had mapped out a rather piss poor DB design and hung it on my cube wall. I was told I wasted company time by creating it. At the 'Warning Interview' I had to admit I was distracted, not by doing the diagram but by the steady stream of other developers who come into my cube to consult it.

bulk inserting tens of thousands of rows with DBIx::Class

For some crazy reason my $project had a denormalized database layout. I had a table 'job' with a column 'data' which had a serialized ArrayRef of HashRefs as value.
This design failure resulted in increasing and badly scaling memory consumption and had to be refactored. Now my table 'job' has a has_many relationship with table 'step_result' and each row in 'step_result' represents one of the above mentioned HashRefs.

But performance turned out to be really bad, I did not take any premature measures to take care of that and with the help of channel #dbix-class on irc.perl.org I was able to improve performance by 4200%. Yay!

One issue was that I used create() to insert the rows. For inserting large quantities of rows populate() is a much better choice. The problem was that populate() doesn't work if you are using Ordered.pm because it requires the highest used position value from the RDBMS before inserting a new row.

Perl 5 Optimizing Compiler, Part 11: RPerl v1.0 Beta Released!

Howdy Perl World,

After many months of effort, I'm proud to release the beta version of RPerl v1.0, now available for public download at Github:

https://github.com/wbraswell/rperl/

As we lead up to full RPerl v1.0 official release, I'll continue posting regular status updates on Facebook:

https://www.facebook.com/wnbjr

I say this is "beta" because it can only compile "Hello, World" so far! But we have working data-types support, and it is relatively easy for me to finish up the rest of the control structures and basic operators to get the full RPerl v1.0 release out soon.

This is all thanks to y'all!

Perling,
~ Will the Chill, rperl.org & austin.pm

The CPAN Report 2013

The CPAN Report is a review of CPAN and related activity in 2013. The headlines:

  • 844 people signed up for a new PAUSE account
  • 2840 new dists were released
  • In total, 7440 dists were released
  • 22% of dists saw a release in 2013
  • RJBS released the most dists (230)
  • SHARYANTO made the most releases (769)

Of Moose and Men, well Class really!

I left off on my last post stubbing in a little code to take care of loading my 'Player Class' (Fighter, Thief etc) into my 'Character' class. I did mention that there are some real subtle rules, I will look at just one of them.

Unfortunately 'Mordol the Moose' rolled a '1' and failed his 'Saving Throw' vs traps and ended up like this;

moose_fail.jpg

Like 'Player Class' at first glance it looks very simple thing to do '4 Player Classes' and '5 types of saving throws' for each. Well what happens if you player is 'Mutil-Classed' such as 'Gutboy Barlehouse' a 9th/8th level Dwarf Fighter/Thief. In the game saving throws for a muti-classed player always use the most favorable result from the tables. So there are times when 'Gutboy' saves as a thief or saves as a fighter.

Introducing Sub::Trigger::Lock

Sub::Trigger::Lock is a workaround for the problem that Moose read-only attributes aren't really read-only; at least, not in the way that people might expect them to be. Here's an example:

   package Foo {
      use Moose;
      
      has bar => (is => 'ro', isa => 'ArrayRef');
   }
   
   my $foo = Foo->new( bar => [1,2,3] );
   push @{ $foo->bar }, 4;   # does not die!

Anyone else get personal URL from Google Plus?

Back in about September Google Plus send me an email offering:

google.com/+RonSavage

as my entry point into Google Plus. I.e.: That visible text is all I need to type into Chrome or FF.

Also, you can use this text (instead of your long Google id digit string) when indicating you're a contributor to MetaCPAN, etc.

So, did anyone else get such an offer?

Perl Reverse Dictionary / Hash

I translated Perl Reverse Dictionary / Hash

Perl Reverse Dictionary / Hash

If 'at is a moose Ah woods hate tae see a rat

In my last D&D post I had at least the first problems worked out for Character race. Now I think I will move into the most challenging of all the 'Class' of a character.

In D&D a 'Class' is the role (JOB) a character plays in the game ie fighter, thief, mage etc. There are 5 primary Classes and 5 sub classes which is easy enough to model with Moose a 'Role' for each of the 10 and we are done.

5509980361_487e13de4c_b.jpg

Unlike the epic adventures above a character's 'Class' is not that easy to nail down. The rules around class are a mix subtle complexities, there may be only 5 basic 'Character' 'Classes' for 'Players' and 'NPCs' but each Character falls into one of these types

  • NPC with no class ie (0 level human farmer, Halfling barkeep, etc)
  • NPC or Player with a single class (Fighter, MU, Cleric)
  • NPC or Player with multi-classes (Fighter/MU, Cleric/Assassin)
  • NPC or Player with two Classes (Fighter-MU, Cleric-Fighter)

Planet Moose - December 2013

Happy new year, and welcome to Planet Moose, a brief write up on what's been happening in the world of Moose in the past month, for the benefit of those of you who don't have their eyes permanently glued to the #moose IRC channel, or the MetaCPAN recent uploads page.

If you'd like to contribute some news for next month's issue, you can do so on the wiki.

Perl Advent Calendar

There were a handful of Moose/Moo-related articles in the 2013 Perl Advent Calendar:

Sereal v2 Finally Released as Stable

Just now, I've uploaded three distributions to PAUSE: Sereal-Encoder-2.01, Sereal-Decoder-2.01, and Sereal-2.01.

This means that version 2 of the Sereal serialization protocol is finally considered public, stable, and ready for production use. There was a long article about Sereal v2 on the Booking.com blog a few months ago. Since then, at least one major new feature was added to Sereal version 2: Object serialization hooks (FREEZE/THAW). Let me summarize the two major user-visible new features.

The perils of & (and prototypes too!)

In a recent post, Chris K asks, why do I recommend using function() rather than &function() or &function. I happened to see it right before heading to bed, but I wanted to respond, so who knows if this is a good example or not. Anyway here goes, look at this code (seen below if you have javascript), it prints 6 lines, do you know what they will be?

God hath given you one face and you make yourselves another.

In the continuing story of Moose and D&D I left off with what I think was a slick use of Moose:Util to load in a Character's race.

As all long term D&D players now you will eventually run into a player who says the following;

image013.jpg

Well in my present 'Character' class I allow this as my race is just a string.


  has 'race' =>(
	is		=>'ro',
	isa		=>'Str',
);

So this post will look into how to handle this sort of sin against nature.

In the old days it was simple, each race was a class and if you tried something like this

Any Perl code for circular dendrograms?

As seen here.

The vague plan is to write a front-end to GraphViz2 (which is a front-end to Graphviz) to do this sort of stuff, unless someone beat me to it.

And yes, I know Graphviz contains 'twopi'.

TIA.

Subroutine Calling Conventions

Hello everyone.

In trying to find places that I might be able to exchange links to get traffic to my tutorial site, I found an article about how one should determine if a tutorial is good. One of the things that they mention is that a tutorial that teaches

&subname()

as a valid subroutine calling convention is out of date. It continues to explain that this does do something, but not what people think it does.

As a matter of fact, I just finished writing a major tutorial on subroutines myself last night. I have looked at numerous resources, all of which say

&subname;
(I know that's slightly different, but similar enough to cause alarm) and
subname ()

are both acceptable. I looked again today, and found the same information. So could someone please clear this up...what (if any) difference is there between these two conventions, and am I making some major mistake if I write tutorials with the ampersand method?

Eating my own dogfood (parallel tests)

I'm relatively pleased with my work in creating parallel testing with Test::Class::Moose, but I wanted to make sure that it worked with a real world example, so today I took a small, but real test suite and converted it and tried out my parallel testing code. The results were interesting.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.