Intro to Mojolicious

Glen Hinkle will be giving a talk at YAPC::NA 2012 described as:

Get an overview of what Mojolicious has to offer, and what makes it unique in the Perl community.  Learn how to quickly make and deploy a web app (even if you have no web development experience) and know what resources are available to you going forward.

Best served with beginners, intermediates looking for direction, and those curious to see what this whole mojo thing is all about.

Get on the bus!

[From the YAPC::NA Blog.]

Breaking the Perl Debugger for Fun and Profit

Before I cover the main topic of this entry, here are some short news and action items:

  1. If you have not acted against SOPA - the proposed online blacklist/censorship bill, you should. Follow the link for information on how to act against it.

  2. I have announced the next Tel Aviv Perl Mongers meeting on my technical journal on LiveJournal.com. It will take place this Wednesday, on 28 December, 2011. More information in the link.

  3. Anarchy Golf is a new server for Code Golf, which are online programming competitions for implementing code as shortly as possible. It supports Perl 5, Perl 6 and many other languages. There is an active challenge, where the only Perl 5 submission so far is mine, so I could use some competition.

Now for the main topic of the post. Recently, three patches were integrated into the perl-5 core implementing new features in the perl debugger:

A new web site for Marpa

I have created an official web site for Marpa. Marpa is attracting new users, to the point where I thought it might be useful to have a site to act as a central directory. The official web site won't have much in the way of new content. With new content, I plan to continue to do what I've been doing -- post it to this blog.

I've started the site with an annotated list of the most important Marpa-related posts in this blog. I hope this will help people newly interested in Marpa figure out where they want to start. Those who've been following this blog for a while might also want to check the list to see if they've missed anything worthwhile.

Convert perl var to yaml

I like yaml so use some idea from Devel-Refactor
I write converter perl var to
yaml

#!/usr/bin/env perl
######################################
# $URL: http://mishin.narod.ru $
# $Date: 2011-12-23 19:53:20 +0300 (Web, 14 Sep 2011) $
# $Author: mishin nikolay $
# $Revision: 1.02 $
# $Source: convert_var_to_yaml.pl $
# $Description: convert perl variables to yaml format $
##############################################################################
#use YAML::Tiny;
#use FindBin '$Bin';
#my $config_name = 'config.yml';
#my $yaml = YAML::Tiny::LoadFile( $Bin . qq{/} . $config_name );
#use Smart::Comments;
my @input_data = ;
#my $self;

#print ext('my $count_xml = 10000;');
my @data_in_yaml = map { extract_var($_) } @input_data;
print join '', @data_in_yaml;
my @data_get_yaml = map { invoke_yaml($_) } @input_data;
print join '', @data_get_yaml;

sub extract_var {
my ($string) = @_;
$reg = '\s*my\s*[\$\@]+(\w+)\s*=\s*([^; ]+)\s*;';
if ( $string =~ /$reg/g ) {
$var = $1;
$value = $2;
}
return $var . ': ' . $value . "\n";
}

sub invoke_yaml {
my ($string) = @_;
my $yaml_row;
$reg = '\s*(my\s*[\$\@](\w+)\s*=)\s*([^; ]+)\s*;';
if ( $string =~ /$reg/g ) {
$var = $1;
$val_name = $2;
$yaml_row = $var . '$yaml->{' . $val_name . '};';
}
return $yaml_row . "\n";
}

__DATA__
my $count_xml = 10000;
my $test_file = 'test_message.xml';
my $orig_idx_file = 'orig_test_message.xml.idx';
my $commit_size = 1000;

Fight Night

Guest poster brian d foy writes:

YAPC::NA is hosting a deathmatch that will finally settle the editor question, do you settle for vim or emacs when you are stubborn enough to not use something good. The advocates of either side are sure to point to the many ways they are able to modify their editor (probably using something that most people will agree is even uglier than Perl) so they can use weird, private incantations to do things that only work on their local system. You might notice these people wasting half a day setting up their inferior editor when they get a new system, or being unable to follow what they are doing in their primitive editors during their presentations.

Mojocast #5: Mojo::UserAgent

Mojocast Monday brings you a high-level overview of Mojo::UserAgent, the client side of Mojolicious. DOM Walking, CSS selectors, and watching live requests are just a couple of the things you'll see.

Mojocast #5: Mojo::UserAgent

If this is your first exposure to mojocasts, you might want to start with the first episode.

Merry Christmas and Happy Unicorns!

Google helps me fight Firefox

Every since I started work on GraphViz2 and Graph::Easy::Marpa I was frustrated by Firefox in that it would display an SVG image in isolation by not when I used a 'img' style link to the image, i.e. from within a web page.

But googling eventually led me to a site where the author said he had better results with 'embed'.

So, I switched to embed and it worked. Chrome of course had never had such a problem.

This means I no longer have to produce 2 sets of demos, PNG and SVG, since I can now assume Firefox users will have no problem displaying the images.

If anyone can tell me definitively why this should be the case, I love to know...

The demo pages are at GraphViz2 demo and at Graph::Easy::Marpa demo.

Perldoc and I Would Like to Wish You a...

perldoc perlsyn | perl -ne 's/^.*?"|\\.*$//g,print if/1\.\.15/'

YAPC::NA 2012 Schedule Final

As of now we have approved the list of talks for YAPC::NA 2012. You made it tough. We had 150 talks submitted, and only had room in the schedule for 95! So we had to make some tough choices.

If your talk was chosen you have until April 19th to confirm it on the site. If you do not confirm it by April 19th then your talk will be removed from the schedule, and a replacement talk will be scheduled. Likewise, if for any reason you no longer want to or cannot give the talk, please let us know

If your talk was not chosen, fear not, there is still hope. Your best bet for getting your talk on the schedule is to convert it into a 5 minute lightening talk. There is room at the end of each day for 10+ lightening talks, and none of them have been scheduled yet. Also, some people will definitely drop out from the list that was chosen. When they do, a spot opens up for those talks that have been submitted but not chosen. 

The YAPC::NA 2012 staff would like to thank you all for your talk submissions. You have ensured that we will have a spectacular conference in Madison this year!

[From the YAPC::NA Blog.]

Beginning Perl - Sneak Peek

In my chapter on subroutines, I need to explain recursion. One example program I give draws mazes recursively. Here's a variation of the program, somewhat expanded beyond the book example.

Trying Marpa to parse CSS

Some days ago, Marpa::XS reached version 1.0. Jeffrey Kegler, Marpa's godfather already wrote a some blogs about the algorithm operating behind.

In order to get a feeling on how to use Marpa, I decided to try it for parsing CSS. Thankfully, the official grammar for CSS is available. So I tried to become a friend of Marpa::XS. I was used to work with Parse::RecDescent in the past, so I could not imagine to get into trouble. However, using both modules is different. Parse::RecDescent handles the scanning process by itself and allows various shortcuts for repeating elements inside a grammar. Marpa on the other hand needs a separate scanner to feed it with tokens and only allows very simple grammar rules. Parse::RecDescent combines parser code and grammar rules in one string. Marpa keeps the grammar clean and calls action methods based on rules defined inside the grammar.

Sending a simple email: the current "modern" way

Some of my scripts are still set in stone age when it comes to the practice of sending emails. They almost invariably use Mail::Sendmail, a module that has not been updated since 2003 (and why should it if it doesn't break, right?). So far there's no complaints. The usual incantation for sending email using this module is:

use Mail::Sendmail;
mail(From=>$rfc_from, Sender=>$env_sender, Subject=>$subject, 
     To=>$rcpt, Cc=>$other_rcpt,
     Message=>$body) or warn "Can't send mail: $Mail::Sendmail::error";

But today I need to switch transport to sendmail. Despite what the name might suggest, Mail::Sendmail uses SMTP for transport and there's no alternative transport. There's also no support for SMTP auth, which my SMTP server now requires even for access from localhost. From what I read and tried once or twice in the past, the current "best practice" or recommended way is to use Email::Sender. Here's the incantation for sending mail using sendmail:

Exceptional Exceptions

Mark Fowler will be giving a talk at YAPC::NA 2012 described as:

This talk attempts to be the definitive guide to current state of exception handling in Perl

This talk will cover:

   * The concept of exceptions and exception flow control

   * throwing errors with die

   *** The final newline oddity

   *** autodie

   * eval (it’s pronounced ‘try’)

   *** The two forms of eval

   *** Dealing with errors

   *** How this sucks

   * A note about %SIG handlers

   *** CGI::Carp

   * Throwing Blessed Objects

   *** Rolling your own exception class

   *** Handy exception object classes on the CPAN

   * The DESTROY problem on legacy Perls

   *** Why this problem occurs

   *** How it’s solved on Perl 5.14 and later

   *** Bad workarounds

   *** Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval

   * Alternative syntax

    *** Try::Tiny

     *** TryCatch

[From the YAPC::NA Blog.]

How should a JSON parser handle character strings?

How should a JSON parser handle character strings with non-ASCII characters? My humble opinion: fatal error. Here's what the JSON parsers on my machine did:

http://pastebin.com/mwui3iDy

STF - A Distributed Object Store

My employer decided to opensource one of their internal tools: STF. STF is a distributed object store, much like MogileFS. The main difference is that STF uses HTTP (as opposed to a custom protocol) as its main protocol, uses components such as Apache/nginx, MySQL, memcached, Q4M/TheSchwartz. It's also new and therefore natively speaks PSGI internally, so you can use all your PSGI aware goodies. We also have an proof of concept setup to deploy STF on dotCloud platform.

Livedoor serves about 300 million objects (which means about 1.4 billion physical entities) using commodity hardware, running Apache 2.2 (+mod_reproxy), Memcached, MySQL 5.1, Q4M. Dispatchers are deployed on Plack + Starlet. We're also wrapping the application processes with Server::Starter for zero-downtime deployment (that means I can deploy to these heavily bombarded servers pretty much any time I want!)

FOSDEM 2012 - Brussels

Hello,

Fosdem 2012 will take place on 4 and 5 February.
You'll find our call for speakers here: Fosdem 2012 call for speakers

Hope to meet you there !

--
erik

Transforming URLs into rich content with Plack, AnyEvent, and Javascript

Lee Aylward will be giving a talk at YAPC::NA 2012 described as:

After investigating oEmbed, I came to the conclusion that oEmbed is a great idea, but difficult to use in practice. oEmbed providers are inconsistent and unreliable. So I built Noembed, a consistent oEmbed gateway to a large list of sites (many that don’t even support oEmbed themselves.)

Noembed was built using a mix of Plack and AnyEvent. It is used by us at Ars Technica, and will soon be used by a fairly popular Twitter client.

I’ll give a quick overview of the oEmbed spec, show some of the Noembed internals, and then do short demo.

 * http://www.oembed.com/

 * http://noembed.com

 * https://github.com/leedo/noembed

[From the YAPC::NA Blog.]

LOLchromatic wonders how to stalk you

No, really. This clown apparently thinks he can make money by stalking you online. The problem, as even he recognizes, is that you're able to prevent creeps like LOLchromatic from stalking you. The solution is that most people don't know that LOLchromatic and his ilk exist.

Never ever trust Ubuntu

Was using an ubuntu virtual machine. Issued "ack" It said to install it using "sudo apt-get install ack". I did it. It didn't install App::Ack :( it is some other stupid tool. So, "sudo apt-get remove ack" followed by "sudo cpan App::Ack".

Personal end-of-year report for 2011

2011 is my most productive year yet in my "CPAN career": 495 releases (compared to 119 in 2010 and 54 in 2009). So far I have 115 distributions listed under my account (compared to around 15-20 in 2010, around 10 in 2009, and 2 before that). It really never occured to me that I would release over a hundred modules to CPAN, but all of a sudden I did. Perhaps next goal should be 1000 :)

Dist::Zilla helps a lot. I can't imagine doing manual tar and updating version numbers and README and all those distribution meta files manually for tens, let alone hundreds of releases. So thanks again to RJBS and other Dist::Zilla contributors!

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.