One Moose, Many Mooses, or is that Mise?

Now that I am getting into the game play part of AD&D I am finding there are more and more times where I want to keep a record of some attribute not just a running total.

For example after a successful encounter experience for monsters killed or defeated (making them run away is defeating them) and the value of all treasure taken in gold peices is summed and then split evenly across all party members, including henchmen and friendly NPC, who actively engaged in the encounter as Expreriance Points or EP for short.

Well a running tally for each player is needed, as well player always like to look back and see how bad ass they are so a history of encounters is needed, as well players like to know how many monsters they whacked in an encounter and of course the list goes on.

Finding my computer

A couple of days ago I replaced my computer at work with a new one. This morning, working from home, when I tried to log in, it didn't respond.

I realized promptly that I had forgotten to ask the sys admin to update the MAC address on the DHCP server and so it just got some random IP from the pool.

Stupid Lucene Tricks: Storing Non-Documents

Lucene's search capabilities are so powerful that it is tempting to store more than documents -- and that is OK. Here are some hints to make storing non-documents easier:

Const::Exporter Released

A few days ago, I released Const::Exporter to CPAN.

Basically, it's a module that allows you to define a module with exportable constants that:

  • can be read-only scalars, arrays, or hashes (as well as the standard constant functions);
  • can refer to each other;
  • can be grouped into export tags, and added to multiple tags without repeating the value;
  • and easily interspersed with POD describing the constants.

A more detailed discussion of it is on my blog here.

Well More Little Helpers

Had a power outage for most of the day today so just a short post carrying on from where my last post left off.

Again I figured I might as well add in a second function into my little mod this one parses a directory listing (very badly) and then prints out the English for it

I do not usually have much of a problem with file entries but I figure some people might be worse at it than me so here goes.

So I exposed 'parse_file_listing' in my mod and here is a sample

New module Path::Iterator::Rule::RT

I use Request Tracker (RT) all the time for work and home projects. What this means is I am left with ticket litter--lots of directories with names like test, examples, ETL, Proof of Concepts, foo, bar, baz, x. It all adds up to lots of ticket litter. Now I have a ticket for everything I do. (More on that later.)

That left me with a new problem. I had directories full of ticket numbers. It became overwhelming, and I needed a solution.

And so was born Path::Iterator::Rule::RT.

Using two packages from CPAN this was easy work.
Path::Iterator::Rule
RT::Client::REST

Path::Iterator::Rule is extendable with custom rule subroutines. Using this with RT::Client::REST made it very easy to add RT ticket information into a rule to select directories.

Here are some examples using Path::Iterator::Rule::RT.

# This will print all tickets in the directory that have resolved tickets.

Moose Dying With "Invalid version format (version required)"

I'm putting this here in case anyone else sees this or hits a search engine looking for the problem.

This morning I had to restart my iMac thanks to the lovely security hole Apple patched and my default perlbrew was set to version 5.18.1, though I was developing in 5.18.2. I ran a test and immediately had the following mysterious error:

Invalid version format (version required) at ... /5.18.1/Module/Runtime.pm line 386.

The fix is both simple and complicated.

Significant newlines? Or semicolons?

[ Cross-posted by invitation, from its home on the Ocean of Awareness blog. ]

Should statements have explicit terminators, like the semicolon of Perl and the C language? Or should they avoid the clutter, and separate statements by giving whitespace syntactic significance and a real effect on the semantics, as is done in Python and Javascript?

Actually we don't have to go either way. As an example, let's look at some BNF-ish DSL. It defines a small calculator. At first glance, it looks as if this language has taken the significant-whitespace route -- there certainly are no explicit statement terminators.

I Was so Impressed I Wrote More Code

I guess I was inspired by by Bradley Andersen's little perl mod 'ParseCron' do a little code writing in the same vain.

Like I mentioned in my last post there many aspects of sys-adm that boggle my little mind and on of the chief ones is how 'chmod' converts a slew of 3 digits into unix style file permissions.

I get the rwx or - part on the files system that is easy enough. It is how 756 does its majik that addles my brain. I know it is just a sum that add to 7 for full access and 0 for none but I never could remember much more than that. So I came up with this little mod (early days yet but might make it to CPAN in a few days)

It is called ParseCHMOD and you can find the first cut here not much to look at and just something I have thrown together in the lats half hour our so but a start.

So here is a sample run

GitPrep 1.5 is released - Improve HTTP repository access, and display README in subdirectory

I released GitPrep 1.5 at 2013/10/09. You can install portable GitHub system into Unix / Linux easily. It is second major release.

Because you can install GitPrep into your own server, you can create users and repositories without limit. You can use GitPrep freely because GitPrep is free software. You can also install GitPrep into shared rental server.

GitPrep (Document and Repository)

Features added in 1.5 are:

- Improve HTTP repository access
- display README in subdirectory

1.4 contain bug that repository access(push and pull) via http, but It is improved in 1.5. Even If the repository is big, you can do push and clone. and README.md(or README) in subdirectory is displayed.

Let's use usufully.

Example

You can try GitPrep example.

GitPrep Example

Download

Download

Document

GitPrep Document and Repositry

Seeking code to find a free TCP/IP port

I know some modules search for a free port during testing, but I can't think of any specific one ATM. Any suggestions?

Bugs in the compiler

After I posted my previous blog entry a couple of things were pointed out to me, to do with my fourth point about ignoring warnings.

It turns out that unreachable code doesn't necessarily produce warnings from Apple-ish compilers like I expected it to. It turns out that in gcc the -Wunreachable-code option doesn't do anything. It's only there because it used to do something but that functionality was removed because it didn't work very well. In Clang, -Wunreachable-code is functional, but isn't enabled under -Wall. All apparently doesn't mean all in Clang-land.

I consider both of these to be compiler bugs.

All the other points I made still hold though, especially the most important one about unit testing and code coverage in tests.

I != SysADMIN

I am very proudly not a sys admin I am so bad in fact I can't even spell it correctly. This of course has its disadvantages in the perl world where it seems every perl knows what this does.


ls | perl -pe 's!([^_]+)_(.)(.*)!mv $1_$2$3 \u$2\E$3!gio'

and at a YAPC I was the only one in the room that did not laugh at this


su root chmod 000 chmod 

I felt very left out.

Announcing Test::mongod

After having done a couple of projects with MongoDB and working on and off on a personal project, I found myself wanting something like Test::mysqld, but alas it did not exist on CPAN. So here it is Test::mongod. It's rough but will get you a throw away instance of MongoDB in a /tmp directory that will be cleaned up when the script ends. The code can also be found on GitHub.

use Test::mongod;

then....

my $mongod = Test::mongod->new;  # get a temp db on a random port.
my $port = $mongod->port; # get the port to feed to your client app.

Be aware that depending on your hardware, this will block till the server is listening and ready to receive queries - which could be instant or take several seconds. To monitor startup get the db path and then tail the log file in another terminal.

diag $mongo->dbpath 

Now to make some sort of fixture loader. Hmmm... what should it be call?

Easier Database Fixtures

I recently posted about DBIx::Class::EasyFixture and I was shocked to receive an email from someone explaining how he uses it in production with Test::Class::Moose. Basically, the ability to write this was the killer feature for him:

sub test_teardown {
    my $test = shift;
    $test->fixtures->unload;
}

Lessons to learn from Apple

Apple's most recent iOS software update which fixes a horrible security flaw has been all over the interwebs recently. This is yet another post about it. Here's the buggy code:

Roleing Along Like a Tumbling Tumbleweed

Well here is a little store from the trenches today that oddly enough does has something to do with Moose and roles.

li-moose-sign-20130412.jpg

Well my very talented colleague of mine came up with a very nice little Moose class that nicely encapsulated connecting to and sending messages to and from a Amazon SQS server.

Well we already had a very good application that parsed and assembled messages (Emails, Faxes, PDFs and alike) so I though why not introduce Amazon SQS into the mix so we could send these sorts of messages as well.

Seemed simple enough all I did was change the original module a little

From this

package AmazonSQS;

use Amazon::SQS::Simple qw//;
use Moose;

to this;

Towards Type::Tiny 1.000000

Type::Tiny has been knocking around in some shape or another for almost a year now. It's certainly grown a lot since its first commit. The distribution probably no longer merits the "Tiny" name, though the lead module itself is still fairly lean. There are over 80 distributions that list it as a pre-requisite in some way or another, and more still that depend on those.

So I think it's time to begin planning to stabalize the API. Right now, my plan is:

DC-Baltimore Perl Workshop 2014 - Call For Speakers

(As posted on dcbpw.org)

Attention Speakers! You are invited to submit talks for the 2014 DC-Baltimore Perl Workshop, which will be held on Saturday May 3, 2014, in Silver Spring, MD.

As in previous years, by default talks are 20-25 minutes, which we've found is a sweet spot for most topics. We get a great variety -- enough to get a dose of newness and not overwhelm. We also welcome proposals for more tutorial-style talks of around 50 minutes. We'll take the talks and build out a two-track schedule.

Speakers of all levels are welcome! This regional meetup is great for getting your first taste of giving a community talk, sharing projects or topics that you have experience with, or even doing a first run for a talk you'll be presenting at a larger conference such as YAPC::NA 2014 in Orlando! All Perl-related topics are welcome -- from beginner to advanced, from technical to social.

One of my favorite things*

I mentioned in my last post that I was hoping to be able to give a free public talk in London next month...and now I am happy to be able to confirm that's definitely going ahead.
When: Monday March 10, 7.00pm to 9.00pm
Where: Floor 3, 101 St Martin's Lane, London WC2N 4AZ
What: "A Few Of My Favorite Things"
How: To attend, you'll need to register beforehand

The evening is being sponsored by Venda and the venue provided by Mozilla.
Special thanks to Tom Hukins, who herded the many cats required to make the
event possible.

Damian

* Talking to my fellow Perl Mongers

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.