A Little Moose Help

Well I was busily writing some tests for a large processor interface where you would pass an object too it and it will merrily process away on it. Well all of the object I was passing into it are written in Moose and I did not need to test the 'State' or 'values' of these object, what I needed to tests where some of the lower-level admin functions in the interface, that really had nothing to do with the objects themselves more about reading config files connecting and alike.

The problem I was having was to test the 'Interface' I had to give it a valid 'object' as that was a 'required' attribute. That I could live with it was all the objects I was was going to pass into it needed to be instancates and they all had a large number of 'required' attributes as well.

Why Companies Turn Me Down For Contracts

My current contract is lovely. I'm having a lot of fun and the environment is awesome. However, it's a short contract. I took it, in part, because it was a problem space I wanted to do more work in. Because it's a short contract I'm already working on negotiating my next contract (a perpetual hobby for freelancers), but I thought I'd experiment with a different approach: asking you to reach out to me. If you think I can help your company and you're not in a position to hire me directly, go to those who are and talk to them. If you want to hire me or one of the talented developers who works with me, drop me a line (I can't guarantee that I'm available, but you never know). If this approach works, I can do more work on open source or Veure instead of spending all of my "between" time negotiating contracts.

That being said, I don't always get contracts I negotiate for and sometimes I turn them down. However, if you're an individual considering freelancing, I thought it worth discussing some of the obstacles I've faced.

Dear Perl lazyweb: how to construct read-only data objects out of JSON?

I recently updated a client called WebService::Geocodio for the Geocod.io geocoding service. Traditionally, geocoding means turning a mailing address into latitude/longitude coordinates (or the reverse operation, turning latitude/longitude into a mailing address.)

In a recent update of the upstream service they included the ability to fetch additional data fields including timezone, congressional district, school district and so forth. Is there a good CPAN module (or a recommendation) to take a Perl data structure like a hash and turn it into a Moo(::Lax) object "automagically?" I had a look but I didn't find anything especially suitable.

These data structures are purely informational in nature and just have getters for their attribute names. This would be less difficult to accomplish using Moose (obviously) but I'm wondering if there are any suggestions for something that installs getters for hash keys dynamically and is Moo-friendly.

Thanks!

\r, \n, and ... \R ?

It's common knowledge that on Windows, a line of text generally ends with a \r\n characters sequence, and on a POSIX system a line of text will end with \n.

Less well known is Perl's support for the escape sequence '\R'.

What's \R?

It's definitely not the inverse of \r.

It's a pattern (so for now its only useful in regexes) that matches Unicode's TR-13, The Unicode Consortium's guidelines for what counts as a newline. It's useful in a regular expression to match \r, \n, \r\n, or a few other character sequences that are used to represent newlines, so you don't have to remember them. It's worth noting that it is a character sequence, not a character, so it doesn't really make sense in a bracketed character class.

Over Stuffed Moose

Sometimes being both newbie and a keener can be a dangerous combination. Well today I sort of fell into that trap.

Well I started doing the first refactoring of my Moose classes (not for AD&D this time this is some real world code) I was working with. So I wanted to move all the common bits into a single role then create a few 'base' classes that comsume that base roles and add some other sutff. Finally I was going to 'extend' these classes with some default values and then polish them by adding a few roles to customize the end product.

So like this

Custom DBIx::Class ResultSets

On my personal blog I wrote about Veure, an MMORPG that I'm writing in Perl. I followed that up with a post about the roadmap to an invite-only alpha. It's a lot of work, but my company has now decided to commit to it and figure out how to finance the work. This browser game is huge in intended scope, but fortunately, Perl has given me the power to get much of it done quickly. In fact, according to my private Veure github repo, I now have 17% of the ALPHA tasks done. That's up from 0% when I posted the roadmap a little over a week ago. In short, progress is fast.

Currently I'm working on character combat and that's where custom DBIx::Class resultsets have made my life easier.

List of Running Grants

We maintain a list of the running/completed grants at www.perlfoundation.org.

Looking at the running grants list, there's one thing I can clearly say: We need more grants!

In the next few blog entries, I'd like to discuss the efforts we made and we will make so that the grants program is more useful for the community.

Help needed fixing links leading to CPAN

Do you have a few minutes? Please help fixing links leading to CPAN.

Omnia illa, Quae Exspectant

Or to put in other words if you hang around long enough things will change. Well I actually did not have to wait very long at all about a month only. You may remember this post where I was recursively digging in to a directory of code to pre-load a number of Moose classes.

Well I had a solution to fix this problem


Can't locate object method "new_object" via package "Moose::Meta::Role" at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Moose/Object.pm line 27.

when I was trying to invoke 'new' on a role. My rather quick and dirty solution;


  	return
		unless($a_class->can('blessed') and $a_class->can('new') );	

Carrying (mini)CPAN

Thanks to minicpan, I keep a local copy of the latest versions hosted on CPAN. Running minicpan weekly, I keep it up to date. My .minicpanrc file:
local: /home/netbook/minicpan/miniCPAN_20140405/
remote: http://your.favorite.cpan.mirror/
also_mirror: indices/ls-lR.gz
Now, I want to carry my local minicpan keeping it on a memory stick. Changing .minicpanrc to:
local: /media/USB16GB/miniCPAN_20140405/
remote: file://home/netbook/minicpan/miniCPAN_20140405/
also_mirror: indices/ls-lR.gz

GitPrep 1.6 is released - Time zone support, Charset support, and improvement of markdown

I released GitPrep 1.6. 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.6 are:

-Time zone support
-Charset support
-Improvement of markdown

1.6 support time zone. You can specify time zone in config file. and support multiple charset. If you specify charset suspecting order in config file, you can see files which contains multiple charsets. Markdown syntax is improved, and support fence code syntax.

Let's use usufully.

Example

You can try GitPrep example.

GitPrep Example

Download

Download

Document

GitPrep Document and Repositry

Grant votes: New announcement format

The Grants Committee has completed the first round of this year. It was my first one as the committee Secretary too. I learned a number of lessons but overall it was smooth thanks to the help from the committee and the community.

As you may have noticed, we have disclosed the voting results in a more detailed way. The motivation is to add more transparency in the process. I hope this will add clarity on what we want to support and what we don't want to use the community resources on.

The voting result of this round consists of the two factors:

  • The number of Yes/No votes
  • The total score given to Yes votes

For each grant proposal, the committee members are required to say:

  • Yes, No, or Abstain
  • Score from 1 (lowest) to 5 (highest) if they vote Yes

Here is the actual statement from our rules:

Are They taking over?

Well after I intercepted this recording secret meeting of the order of Cats (sorry for the commercials but it is a public broadcaster) and as part of their evil plan they
have invaded the world of Perl.

Seem they have some sort of strange influence over PACKMAN and he has recently released 'Acme::CatFS'. Now anyone can do this Cat and embed these annoying creatures anywhere any time.

Well how to counter this take over?? Well I tried to find some other namespaces like thedogapi seems those cats got there first and reserved the name space. I think we are all doomed.

Well all joking aside I did get something useful out of this little ACME
as many are the times where I had to fudge a whole lot of code so I could display some sort of random image or random embedded image without loading it someplace first.

Do not use each

The each hash iterator has two problems which almost nobody is aware of, and which might lead to unexpected and hard to detect problems. We were using the perl-compiler since 12 years in production and just recently found out that the B function walksymtable will miss random symbols from time to time. It entirely depends on hash randomization. I cannot predict what each did to your code.

First problem: Do not change the data

Adding or deleting a key might lead to rehashing, which will re-order the keys. The iterator will just continue and then either miss keys or get keys again a second time.

perldoc -f each:

If you add or delete a hash's elements while iterating over it, entries may be skipped or duplicated--so don't do that. Exception: It is always safe to delete the item most recently returned by "each()", so the following code works properly:

Planet Moose - March 2014

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.

Moo

Although no new version of Moo has been released so far in 2014, there have been updates in March to a few of the modules it depends on:

A smaller, faster, more agile Perl

I've been working on a secret project lately, and I wasn't quite sure it was going work out. Most forks of Perl don't, but because they try to go bigger. I needed something that went smaller. Miniperl and microperl, both parts of the core distribution, weren't enough.

It started with a customer who wanted to limit what could happen, but the Safe compartments weren't sufficient to limit that. I had advised against Perl for this situation, but they were adamant that it had to be Perl. So, I and some of their programmers set about removing or disabling parts from core.

Some stuff was easy. Smart-matching and overloading were gone the first day, but that was only a warm up.

Still Cold eh!

Well you might of read my recent post on 'Temperature-Windchill' and as I have a few mins I think I will use this post to create and send in a patch to this mod so us Canuck's can us it to on near calm days.

Well I should first provide a little background to justify my patch so here is a link NOAA Wind chill calculatior

and the formula as stolen from the Canadian website

wind <= 5 ) ) {
chill=(temp +((-1.59+0.1345*temp)/5)*wind) ;

and for good measure checking the the US version seem they are a little more lazy and just set the wind chill to be the Ambient temperature if it is about that like this

WindChill = ( 35.74 + 0.6215*TempF - 35.75*Math.pow(WindMph,0.16) + 0.4275*TempF*Math.pow(WindMph,0.16) );
if ( WindChill > Temp) WindChill = Temp;

So as this is Canadian wind chill I will add it in (with some pod as I love that part) as its own function

Counting

Did you know that there is a short sound played when you install Win32::MultiMedia::Joystick?

I knew the song, but I had to search a bit. Interestingly, I even had to search the module itself on metacpan (search.cpan.org doesn't provide it as search result). While searching for the song, I realized that I have no program that searches for a short WAV file in a set of MP3 files.

Does anyone has such a piece of code?

Python's decorators in Perl

Python's decorator is some syntax sugar for wrapping functions by another functions:

Google@Home - Remote Control of your home

Google@Home aim is to let control your home in your own way: could be with android device or for example your voice, with the feature of an easy installation on every kind of device that have GPIO inteface and could run Linux.

This is an example of environment setup:

Let's suppose that we are an electronic/computer enthusiast that want to enhance our home with some domotics control, but in non-expansive way. Then probably our choise would be to take some RaspberryPi and relay boards, then link the relayboards to the interested points (shutters, lights, dim lights, etc...) we plan to control: maybe a raspberry for floor it's enough, maybe not, but that doesn't matter. Then we install G@H and we can control those points using the voice, web interface, or even mobile device.

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.