Nice web pages for git/JS/jQuery/CSS APIs

jQuery

JS

git

CSS

Well only 359 Pages and 4 Edtions to go.

Well I have a good deal of post on my AD&D and Moose and looking at the time line below

Ages_of_DnD.jpg

I could be at this for a 'very, ' x 5; long time.

So I think a little post to review what I have done so far is in order,

Test Suite Organization

I've written about this before, but now I want to show some slides from my new testing class because I think it's easier to show test suite organization rather than describe it.

Years ago I wrote HTML::TokeParser::Simple, an OO interface to HTML::TokeParser. The latter is a great module, but you are typically working with a bunch of array references like this:

["S",  $tag, $attr, $attrseq, $text]
["E",  $tag, $text]
["T",  $text, $is_data]
["C",  $text]
["D",  $text]
["PI", $token0, $text]

That can be confusing and you often have to write code that is hard to immediately understand. For example, here's the code to strip all comments from an HTML document:

Writing Non-Blocking Applications with Mojolicious: Part 3

This the the third part in an on-going series about using Mojolicious to write non-blockging applications (with an eye towards the web, obviously). In part 1 I demonstrated the how it can improve the number of requests/clients served when the application uses high-latency backends (in that case a database). In part 2 I showed how each request can be sped up when that request needs multiple resources from a high-latency service (e.g. external web services).

In each, I showed a blocking example, then a non-blocking example. I then gave the usual warning that you had to use a Mojolicious server for the nonblocking version. While its true that you need a Mojolicious server to get the benefits of the nonblocking architecture, in this post I will show how with a little care in construction, you can build your application so that it will run correctly on any supported server and the nonblocking benefits will be evident where possible.

Is Perl really short of newbies?

Before writing about the main topic, let me tell you a little bit about myself, my peers & why I am writing this blog post etc.

Git with it.

I always surprises me how much one can get out out of the perl community without asking. Something like 3 years ago I had my first git-hub account not really for myself but for a 'job' interview that required it.

Long story short, in the interview they said they couldn't find my twitter feed and I hadn't friend-ed them on facebook yet. I said tweets are for budgies and I don't have a facebook account and have never even been to that site in my life (and still have never been there). The interview went down hill from there, especially as I said why would I wast my valuable time on such fluff. Anyway at least I got a gitgub account out of the process.

What I have found nice about github is people like to make it better and so I think today I will do my first clean up of my very few repos.

Seem there are a few things I have to clean up but never bothered to till today.

Perl and Me, Part 7: The Most Powerful Weapon Which You Can Use to Change the World

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

This week we meander around the topic of education hoping to come to a point about Perl.

So far we’ve learned that I’m an English major, that Perl has a lot of linguistics baked into it, and that (at least in my opinion) creativity is good for programmers.  What does all that mean?  Well, for me, one of the things it means is that I lack some of the computer science background of my peers.  I never had to take a class in compiler design, for instance.1  In fact, there’s a lot of stuff that CS majors had to learn that I never did.  Oh, sure—I picked some of it up along the way.  But it’s still true that when I read certain very technical programming blogs (like Jeffrey Kegler’s excellent articles on Marpa), I have to skim over a bunch of parts.  But I also have an analogy I’m fond of breaking out:

You don’t have to understand how the internal combustion engine works in order to drive a car.

Support the Perl QA Hackathon 2014 in Lyon

Since it was announced in November 2013, Laurent Boivin and I have been busy with the organization of the Perl QA Hackathon 2014, securing venue, accommodation, catering, sponsors, invitations, etc.

During this seventh edition, as usual, the participants will be giving their time, knowledge and experience to the Perl community for four days, hacking and arguing about QA (quality assurance) and CPAN toolchain. In return for their time and valued experience, we want to make this event as cheap as possible for them to attend, by covering their travel, accommodation and food to the best of our abilities.

ZMQ::FFI and FFI::Raw

A few months ago I released ZMQ::FFI, zeromq bindings for Perl that use FFI::Raw instead of XS. There's been some interest, so I thought I would write a short post to announce the module beyond the zeromq mailing list.

In another post I'll discuss FFI::Raw itself, what it currently provides, as well as some advanced use cases that came up during the development of ZMQ::FFI. If reverse depends on metacpan is anything to go by, it seems many people aren't aware of this module. In fact, at the time of this writing ZMQ::FFI is the only module using it:

ffi-raw-reverse-depends.png That's a shame, as it's a terrific module which finally makes FFI in Perl feasible. It effectively eliminates the need for XS in many cases, and it's sufficiently baked to be considered "production ready."

Back on the Moose Track

Well with my last post I managed to get a little closer to my original goal of selecting a 'Character Class' after I have selected a 'Race' as the image below explains

add.jpg

I sometimes have a Hobbit (well Halfling in A D&D) of doing that.

Well in this post I centralized all of the 'Race' rules under one namespace and so I though I might as well do that for 'Character Class' rules as well.

So for each of my 'Character Classes' I could just add a new role like this

Tech Tip: Opening a file for read/write without clobbering it.

The Tip

perlopentut gives several options for opening a file for read and write, and I opted to use '+>' for Maniac Downloader, but as it turned out, it caused the existing file to be clobbered (= its length to be set to zero and all of its contents deleted).

After asking on Freenode's #perl channel, we reached this solution for opening a filehandle so that: 1) it will be opened for read/write. 2) it can open both an existing file or create a new file that does not exist. 3) If the file exists, its contents will be retained, and it won't be clobbered. and 4) it will overwrite existing contents, and not append everything at the end of the file.

The code is as follows:

A repl site for a lot of languages

repl.it

Source code available on GitHub. Who will add Perl support to it?

Testing Random Dice Rolls

I've decided to rewrite my Perl testing course from scratch and hit upon an interesting problem that is outside of the scope of the course, but is a perfect fit for this site: testing dice rolls. I have the the following function as part of a student lesson in the course:

Keep Calm, Roll on.

In my last post I left off with asking myself a whole lot of design questions after I decided to centralize most if not all of my 'Game/Business Rules' into 'Roles' under the logical namespaces. In the end I can just live with what I came up with even if there is some duplication of code I don't think I am in anti-pattern land yet.

kkrac.jpg

Well now I think I will get back on track from where I left on with this post and that is filtering out 'Player Classes' once I select a 'Race'. I had the basics done but now there are a few more little things to add in and we will start with a cool one racial adjustment.

Some races get an adjustment to their ability scores and these adjustments are used when selecting a 'Class' So an 'Elf' with '8' dexterity roll get a +1 so they will be able to become a thief.

Regular Expression Library

Regular Expression Library :

[From my blog.]

Lexical closures with END blocks warn, but Just Work

I was just impressed by the awesomeness of Perl. More testing revealed to me that "use 5.018" does not invoke "use warnings", which dampened my enthusiasm a little. But Perl is still pretty awesome. Here's the situation.

I write lots of Prima GUI applications. In this one (a presentation if you can believe that), I wanted a timer so I could see how long my talk was going. I had just run through part of my lecture and meant to check my time before closing (the clock is discretely placed in a separate window), but forgot to check before quitting the talk. Frustrated, I decided that I wanted my program to print the talk duration when it was finished.

My normal approach would have been to declare a file-scope lexical that gets initialized at startup, and refer to that in my END block. But instead, I decided to embed the END block within the initialization function itself.

Tie::File don't while(<>)

Consider the common case where you want to take a text file and walk it doing various operations such as stripping whitespace, looking for duplicates, sorting or other common operations. I was recently asked to work on a program where part of the process is 'cleaning' uploaded files before doing other things with it. This process was over 40 lines of subs opening old and new filehandles, doing the standard while(<>) {} and then renaming new file to old file. If you find yourself wanting to do something you would normally do on an array, but on a file and often in place, consider Tie::File before while()ing away at it. The documentation has many examples and there are several examples on the web including at Perl Monks. In this case I was able to whittle this down to this:

Rule Role's or Role's Rule?

In my last post I used a role called 'MaxLevel' to define a small set of game rules that define both the 'Player Classes' and 'Maximum Player Level' a race can obtain. That got me thinking that perhaps I could improve my 'Race' class a little by getting rid of the 'ability_mins' attribute and moving it into a role.

player-character-deaths-d-amp-d-dungeons-dragons-character-d-demotivational-poster-1242486691.jpg

After a little more head scratching what I decided on was to reorganize my namespace a little so all the 'Game Rules' or 'Business Rules' if you like will be in logical places. So all rules for a 'Race' are in its folder and all 'Races' have the same set of rules but with slightly different code.

So step one I converted my 'ability_mins' into a role like this.

My Vim setup

People keep asking for my vim setup, so I've put it on github.

Note that it's crappy, poorly documented, and does what I need it to do. I've also cleaned it up slightly to remove some older cruft. It's only there because others have asked for it and for many people, it won't be all that useful.

TPF Grant Progress Report: January 2014

This past May, The Perl Foundation awarded a grant to fund development of a couple features in Pinto. Pinto is a robust tool for curating a private repository of CPAN modules, so you can build your application with the right modules every time. This is my fourth progress report on that work.

I've done quite a lot of work on Pinto the last few weeks. And today, I pushed a development release to CPAN that has a lot of really cool features and improvements. However, none of this work is tied to the TPF grant.

But now the backlog is cleared up a bit, so I hope to finally finish off the grant work. Look for another update next month.

PS: I'll have a lot more to say about the new Pinto features when I make a production release in a week or so. For a sneak peek, look at the change log.

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.