A Moose at the Door

imagestyw.jpg
Well I must say MooseX has helped me out again today, You might remember way back to the very first post of this AD&D series I mentioned that I would need all sorts of flavors for the values of my Character Abilities, ie tombstone, present values, magically enhanced values etc.

Well as I was programming along and setting up some playing parts of the game I was continually having to make calls back to the persistence layer (if you can call a YAML file that) for the starting value of an attribute for the current gaming session.

Then while playing with MAP of CPAN(you can tell I really like that site) I found what I think is a solution to this little problem MooseX::BuildArgs

This nifty little gem keeps your build arguments around for you in case you need them.
All I need to do is this

Trivial tools

There are various trivial command-line tools which I (have had to) create because of various reasons. Below are some of them:

norepeat

I didn't want to write this, but couldn't find any existing cli tool on CPAN or Debian. Since I put reminders on my ~/.bash_profile and I open many many terminals in a day, I needed a way to run some scripts just once a day. It's surprising that I couldn't find a tool to let me do it easily, and I hope someone can correct me on this.

exec-if-env

This began when I wanted to do something like:

if [[ "$OFFLINE" =="" ]]; then do-some-thing-that-needs-internet ...; done

in dist.ini to be run by Dist::Zilla::Plugin::Run. But of course you'll have to write something like this instead for it to work:

bash -c 'if [[ "$OFFLINE" =="" ]]; then do-some-thing-that-needs-internet ...; done'

Seeking web conferencing s/w

I’m look for some of the above, /with pre-reqs for my setup/:

  • Debian
  • AMD chip (see below)
  • Can demo s/w running on my laptop

Suggestions most welcome.

Interview tools: "Walk me through this"

I've been experimenting with something in the interviews I've been doing most recently. Turns out it works quite well, so I'm sharing this in the hope that it will help you as much as it has me.

One of the most important things on a software team is code reading comprehension and communication: the ability to read code, whether yours or someone else's, and walk through it, explaining to someone else what it does. Sometimes you'll be reading your code and explaining it to someone else; sometimes you'll be reading someone else's code and explaining it to yourself, sometimes you'll be looking at something brand-new to everyone and trying to puzzle it out.

Getting Cocky With Moose

moose-chase.jpg

In my last AD&D post I was playing with MooseX::SetOnce 'trait' on some of my attributes in order to stop modification after the initial set.

This worked fine for the first few runs but quite quickly I had to add in all sorts of code to set default values stuff like this


my $hps=$character->current_hps()||0
So my code was quickly becoming messy and it was much easier to work when I had default values to work with first. So what I really want is set 'default' and then 'set once' and then 'read only' 'trait'.

Well now that I am getting quite confident with 'Moose' I decided why not discombobulate 'SetOnce' and see if I could make it do what I want.

So into the code I went.

Please Join Gittip

By now you may have heard of gittip and wondering "why should I bother?"

Gittip is a way of donating small amounts of money to people who inspire you. That's an important point here. Peter Rabbitson, the maintainer of DBIx::Class, made a strong plea for people helping one another on gittip, but I'm going to make a slightly different argument for joining gittip, one that won't cost you a penny.

Third-party testing

Unit testing and continuous integration testing are ways to make sure that every change to our code won't break stuffs. We execute our tests after each commit and when we want to release our software.

On the other side of the spectrum, there are things outside our code that change and break our non-changing code. Platforms (like new versions of Perl) and dependencies, for example. Integration testing and CPAN Testers are some of the ways to make sure that dependencies and different versions of Perl still work with our software. We must do this testing regularly even when we're not changing our code, since the changing part is the other party.

There is a specific class of scenarios along this end of the spectrum when we're developing scraping libraries and API clients: source websites and API services change all the time, breaking our otherwise working code. For lack of a better term, I'm going to call this third party testing.

Never Be Afraid To Change Your Design

A few years ago I wrote a little video game in Perl called Lacuna Expanse. Tens of thousands of people have played it, and while I wouldn’t call it a raging success, it has paid for itself and continues to make a modest profit. That said, it wouldn’t have if I hadn’t been willing to make drastic changes to the design of it way late in its development. 

For the first 3 months of its development, Lacuna was storing it’s data in Amazon’s Simple Storage Service. When I had trouble getting that to scale I switched it over to MySQL. Three months into a 12 month development cycle is far, but not that far, for a major change.

About six months into the development cycle we decided to entirely change how space was configured. It was originally modeled in 3D space and the user would be able to see a slice of it at a time.

Acme we are not just 500 Pound Anvils

Well I finally did learned something interesting looking at an Acme modules today.

I spotted Acme::Curse and at first glance it seemed to be just another of those silly play things in this namespace.

However the POD entry intrigued me.

Did you ever want to droo the blessing of an object? Well, now you can: Acme::Curse unblesses reference by returning a shallow, non-blessed copy of the object.

Well I do not know hot to 'droo' something (sounds painful) but the idea of a non-blessed copy is something I have need of.

So I looked inside and I saw this

Off-topic: We still have to put up with name calling?

No, not Perl, but open source developers in general. It seems that FusionCharts is openly mocking open source developers on their front page, but use open source extensively.

So you'd like to ... do offline development and testing

[This post will be imported to cpanlists.org once the service is ready]

Do you want to develop your Perl project on your PC or laptop, without having to be constantly connected to the Internet? Then follow this simple guide.

Creating a CPAN mirror

First you'll want an offline CPAN mirror, where most of the useful Perl modules reside. There is already a document explaining how to do this, so go read it. At the time of this writing (Feb 2014), a full CPAN mirror stands at +- 16GB. Chances are you don't need a full mirror, but a mini one, which contains only the latest version of each module and currently stands at about 2.5GB. You can then update your offline mirror every so often (I do this about once a week).

Next, you'll also want App::cpanminus, if you don't already have it. This CPAN client makes it easy to install from an offline CPAN or DarkPAN mirror.

Now to install a module from your local mirror, you can simply do:

% cpanm --mirror /path/to/your/cpan --mirror-only Module::Name

Perl and Me, Part 11: Please Mr. Perl, Will You DWIM?

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

This week we look at trade-offs in expressivity.

Last week I told a story about a CS professor who was inexplicably afraid of recursion.  Other than the obvious moral of “don’t be afraid of things that use underlying complexity to make your external code simpler,”1 what exactly does this have to do with Perl?

YAMADDP (Yet Another Moose ADD Post)

Well there is always more things to post on and today I found yet another.
You might remember this post where I was setting starting money for player characters and you might remember this post where I pinched the idea from.

There was a flaw with this as it is true I was not longer able to set starting gold or hit points by doing something this


 return $self->current_gp()
          if ($self->current_gp());

or

Timm Murray made this recording of my Stupid CPAN Tricks talk at...



Timm Murray made this recording of my Stupid CPAN Tricks talk at MadMongers. He thinks he may record all MadMongers talks going forward.

[From my blog.]

Reflecting on the DFW.pm winter hackathon competion

I know it has been a while, but I’m finally getting around to posting my reflections on the Dallas-Ft. Worth Perl Mongers Winter Hackathon. Better late than never right? I will talk about my solution, but I also want to comment on the hackathon itself, which I thought was an excellent bit of fun.

Next DBD::SQLite to be released in early March

DBD::SQLite 1.41_06 is a release candidate of the next production release of DBD::SQLite. I'm planning to release it around the QA Hackathon in March if there's no blocking report. I suppose upgrading won't break your software, but please test it with 1.41_06 and post anything new you find to RT/GitHub/Mailing List.

Here're notable changes since the last stable release:

  • SQLite's query planner has been rewritten since SQLite 3.8.0 (bundled in DBD::SQLite 1.41_01). According to the upstream author, the new query planner should give exactly the same result (though perhaps with a little less CPU time spent planning) for simple queries, and for complex queries, it can in many cases provide a much faster answer.
  • DBD::SQLite now supports URI filenames to control read/write mode and/or shared cache mode.
  • DBD::SQLite now respects explicit data type specification of bind values (via bind_param() etc) even if "sqlite_see_if_its_a_number" handle attribute is set to true.

Life is good

Well you might remember the few post I did on my little pet mod Orignal and how its tests where broken how I fixed that and made it more broken!

But now the good news it I 100% Green well I known I am not going to win any prize for this module as a matter of fact the only review pan it. Hey but at least people are looking at it

Anyway it is what it is. A simple way to get accessors that worked for me in a very restricted development environment and I though it might help some-one else and really every ones should have at least one mod on CPAN they wrote themselves from scratch..

Funny I also like to look at it every once and a while on the CPAN MAP but I doubt it will ever make the top 100 there? Btw the way I find this a much faster way to search on CPAN and most likely the only good thing you will take away from this post.

Still no-one has gotten the joke behind the name that I do find funny.

Things we don't have #2

About this posting series. Previous episodes: #1.

This time we're going to look at virtual filesystems. Perl currently seems to lack in this area compared to some other languages. There are no support for accessing or creating the various VFS's out there from Perl, except for Fuse.

First, KDE's KIO (KIO slaves). There are many slaves available, from accessing devices like Camera and Bluetooh, to the usual network protocols (HTTP, FTP, WebDAV, IMAP), to various settings and applications. One can create a KIO slave from, say Python and Ruby, but currently we lack a library to do so, even for accessing resources using KIO. The KDE4 Perl bindings project seems to lag or stop.

Second, the GNOME project's GVFS/GIO library. Perl does have a couple of libraries (VFS::Gnome, Gnome2::VFS) for the older GNOME VFS though.

Easy Fixtures With DBIx::Class

As part of my rewriting of my testing classes (tired of hearing about it yet?), I found myself at the part where I needed to explain test fixtures. A fixture, in this context, is simply a particular known state that you can test against. In particular, I'm focusing on using database fixtures in tests. There's not a lot of good discussion about this and that's unfortunate because fixtures can really benefit your test suite.

Seeking 3d graphics lib for JS

My client especially wishes to display clustered stacked bar charts with and without a 3d effect, via JS.

I do realize the 'clustered stacked' and '3d' requirements are both very limiting.

AFAIK the d3 package has no 3d option, but is otherwise fascinating.

JS libs I know of are:

o JSPowered. It's a commercial product, very nice, and is called via their PHP programs. It even supports clustered stacked bar charts, making it special in that way. Currently this seems to be the only option.

o InfoVis. It looks nice, but has no 3d effect available, not clustered stacked, apparently.

This summary is rather impressive, but does not mention 3d.

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.