When is an Org Chart Not an Org Chart

Well continuing on with my AD&D theme am taking another break from Moose Code and looking at design again. Well this time I wanted to see how many common 'roles' I might have between my differing Character Races and Classes and the large number of scribblings I have laying under my desk where getting annoying.

So I started with what I was most familiar with with ye old ULM Object Diagram using a little freeware designer from smartdraw. Well it worked ok for the base attributes of my Character class (name,race, ability scores etc.) as they will be put into a model eventually but it wasn't helping me with my roles as these are, for lack of a better words 'Business rules' and they where just cluttering up my diagram.

Why I Didn't Submit A Patch

Currently RT cannot talk to PAUSE, so I can't submit a bug report for this:

perl -Mutf8::all -MDateTime::Tiny -E \
    'say DateTime::Tiny->from_string("୭୮୯௦-௧௨-௩௪T௫௬:௭௮:௯౦")'
0000-01-01T00:00:00

B::C[C] and rperl

With rperl we have now a second serious perl compiler project, which has distinctive advantages over B::C and B::CC, but also several disadvantages.

Basically we need to define compilation blocks for rperl (restricted perl) - typed and compile-time optimizable syntax - and combine it with unoptimizable dynamic perl5 syntax, to be able to run ordinary perl5 code, partially optimized.

How to upload a perl module on CPAN using Dist::Zilla?

Today, I released my second CPAN module. While writing my first CPAN module, I used Dist::Zilla for uploading my module to CPAN, but when I looked into it today, I had to go through some dzil plugins again. So, I thought that I should write a blog post about this.

Basic directory structured of the module:

Assuming, my module name is X::Y::Z, I need to create a directory with name X-Y-Z. Output of find command should look like this:

lib                 # all code goes in lib/
lib/X              # code for X will go here
lib/X/Y           # code for Y will go here
lib/X/Y/Z.pm  # code for Z will go here
t/                   # all tests will go here
dist.ini           # explained below

For example : see this module.

Writing dist.ini:

Get Out Of My Namespace!!

Do_not_take_his_bone.jpg

If you been around in CPAN for a while and you are a adding the odd module you may or run into the above (well really any code repo ie PyPI, PEAR and the long extinct CJAN) .

Most likely you forgot to read 'On The Naming of Modules' and either put something in the wrong place or didn't notice the fist come first served in the 'Naming' paragraph of the Zen of Cpan.

So going back to my D&D game I know I will have to pick a namespace if I am going to add it to CPAN for others to have a look at. Luckily since I have the book in front of me I have a good Idea what I am going to do maybe like this

Postgres full-text search w/ DBIX::Class

How to pass in a search term to postgres using DBIX::Class while still leveraging bind values to escape your input:

my $search_phrase = "snowden nsa";
my @rows = $rs->search(\[
  'to_tsvector(me.title) @@ plainto_tsquery( ? )',
  $search_phrase
])->all;

As is always the case with SQL::Abstract, TIMTOWTDI. In this case I don't particularly love the ArrayRef instead of the traditional HashRef, but that is how the cookbook had it, and it works. If anyone has a better method please leave it in the comments.

Adapted from the DBIX::Class Cookbook.

booking.com - a toxic company for developers

I have worked for Booking.com for 2+ years in their Amsterdam office as a developer and I need to let the developer community know about what to expect here.

Booking.com as you know is hiring aggressively under the pretext of growth; Yes, the company is growing about 40% YOY but the reason they are hiring developers “always” is due to the high attrition(employee turnover rate). Let me explain why this happens and the real Booking.com secret sauce which you would come to know only after working with the company and having wasted 2 years of your life.

  1. Booking.com treats its employees like dogs. And this is true regardless of the department you work in.
  2. Exploitation is the real secret sauce of Booking.com which has helped it pack a huge cash surplus. Exploitation of employees and hotels is the secret sauce.

Let me explain how exploitation is carried on in Booking.com:

Perl and Me, Part 5: Speaking with the speech of coders

This is part 5 of an ongoing series where I explore my relationship with Perl.  You may wish to begin at the beginning.

This week we look at Perl’s linguistic heritage.

Last week I talked about how good code reads like a story, and how Perl is the best language for writing stories in code.  The reason for this is of course the linguistics that are baked into Perl.

No Moose is a Good Moose

Well after my Dice adventure I had a few bookmarked mods (Acme::Dice, Games::Dice::Loaded, Games::Dice::Advanced, Games::Dice, RPG::Dice, Games::Die::Dice and the one with the coolest name Games::Die that I looked at.

Being a good perl programmer I always like to do things the simple way by stealing I mean borrowing the hard work that others have done by consulting CPAN and as one can see from my little list above there are a good deal of them to choose from, one is written with Moose (Games::Dice::Loaded).

All I need is simple dice rolling so the ones that did other things where out, others allow some sort of 'Cheat' factor and I did not like that so they where out as well those that didn't have an OO interface where out.

That left me with 'Game::Die', 'Games::Die::Dice', and ' RPG::Dice'. 'Game::Die' did too little as it was just a instance of a single 'die', so that would mean more work for me.

Ephemeral methods, or what to call 'dispatch to a variable containing a subref'?

In my last post, I use a Perl dispatch pattern where you store a subroutine reference in a variable and then use that as the method to call on an object. Like so:

my $method = sub { ... };
$invocant->$method(@args);

Is there a name for this pattern? If not I propose to call the “method” an ”ephemeral method”. Does this work for everyone?

Note that you really can’t call it a lexical method for several reasons.

Brainturk Mobile App

Wishing you all a Happy New Year .

We have released Brainturk mobile app on the Various app stores

iOS

Play Store: Free version

Full version on play store

Amazon App store Full Version

Free Version on Amazon

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.

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

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?

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.

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.

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)

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!

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.