A WebSocket Mojolicious/DBI Example

Building on my (second) example from my recent post A Simple Mojolicious/DBI Example, I thought I would take it just a little bit futher. One of my favorite features of Mojolicious is that it comes with WebSockets out of the box! In this example I show how you can take the example script and allow it to run without refreshing the window.

Configuring the Ruby Slippers for HTML

[ This is cross-posted from the new home of the Ocean of Awareness blog. ]

This post is part of a series describing Marpa::R2::HTML, a configurable HTML parser. The last two posts described how to change the context and contents of the HTML elements, both new and existing. This post describes how to configure optional start tags: how to change which start tags are optional, and how to specify the circumstances in which they will be supplied.

How the parser works

In the first posts in this series I went into some detail describing my Marpa-based approach to HTML parsing. Briefly, it combines a parse engine using a "wishful thinking" grammar with a Ruby Slippers lexer. The "wishful thinking" grammar expects all elements, without exception, to have both start and end tags. This overstrict grammar demands tags even in cases where the HTML 4.01 Strict DTD mandates that they be treated as optional.

German Perl-Workshop 2013 - Call for Papers

The 15th German Perlworkshop is taking place from March 13th to 15th 2013 in Berlin. The main workshop language is german, but we also welcome talks in english.
The venue is located in the center of Berlin-Kreuzberg at the Betahaus.

We are ready to accept talk proposals. Usually we have 20 and 40 minute talks and Lightning talks (5 minutes).

To submit a talk, go to http://act.yapc.eu/gpw2013/newtalk. The deadline is December 13th 2012. You can also contact us via gpw2013@froggs.de or at #dpw2013 on irc.perl.org.

We thank the $foo-Magazin for being our first sponsor.

Announcing TheGameCrafter::Client

I've been publishing simple web service wrappers on CPAN for other people's web services for years, but for some reason I never got around to writing a wrapper for my own web services until now. I'm pleased to announce TheGameCrafter::Client. It is just a light-weight wrapper around The Game Crafter's web service API so that you can get down to the business of writing your app and not worrying about how to make requests and serialize/deserialize data.

Testing for HTTP compression

How do I determine what the content-encoding of a web page is? A simple question which after doing a little searching did not turn up a simple answer. A stackoverflow question lead me to the solution but did not answer the question directly so here I am writing it up. We will need to install these modules first:


cpan Compress::Zlib LWP::UserAgent

A Simple Plack/DBI Example

In A Simple Mojolicious/DBI Example Joel Berger demonstrates how to build a very simple CRUD web app (well, a CR one anyway) using Mojolicious and DBI. I was impressed at how concise it was, and wondered how my preferred technology stack would compare.

I'm not a fan of template languages, preferring DOM manipulation. And rather than Mojo, I'm using Plack here. Anyway, this is what I came up with...

A Simple Mojolicious/DBI Example

A friend of mine is learning database administration, but for the first time needs to connect it to a webapp. Having done most of his work in MS Access, he has no idea what a web framework is, nor how one would connect a database to it. To help him learn I wrote up a little application using Mojolicious and SQLite.

YAPC::Brasil 2012 Starts Tomorrow

The 2012 edition of the YAPC::Brasil will start tomorrow. We will have lots of good subjects being presented covering different areas as big data, open data, data journalism, Perl hacking and bioinformatics. There are already representants from 4 local Perl Mongers groups and from 10 different countries, including Brazil. Check the website for more informations.

Perl Success Story - Managing PHP apps with Perl

WebPub helps install and manage popular web apps. We currently are doing WordPress, Drupal, MODX and phpBB. While the web UI is in PHP (decided before I came onboard) the backend is all Perl.

Some of the major components being used are: Mojolicious, Moose, DBIx::Class and Gearman.
Mojolicious provides the REST interface for the PHP front end and will be used in the near future by at least one other company we are working with. That company will write their client in Ruby.
Moose is used heavily for meta method creation, mapping various before / after 'method' to validation and DB update_or_create and the installer system loads the appropriate role (each app has its own role for things that are app specific - an install of Drupal needs more fixup than WP) at runtime.
DBIx::Class - no explaination needed
Gearman - actual interaction with remote systems happens from workers.

Please Publish Perl Events on the LWN.net Calendar

As I read last week's LWN.net's Announcement Page (LWN.net is a news site for open-source-related news, formerly standing for "Linux Weekly News"), I noticed that there were few if any Perl events featured in its upcoming events calendar. However, these events appear in the Perl Weekly, and there are many upcoming Python events featured in LWN.net.

So, please, if you are organising a Perl-related event (or any other major open-source event), make sure you put it on the LWN.net calendar.

My IPW afterthoughts

This will be just partially about the just ended Italian Perl Workshop in Bologna, because frankly most of the talks I did not not understand, even if I would like to improve my Italian. So why even bother being one of a hand full not Italian?

Building Your First App with MongoDB and Perl at MongoDB Boston

I'll be speaking on October 24th at MongoDB Boston 2012, taking place at the lovely Marriot Courtyard Tremont/Downtown.

Conference registration is a mere $100 ($30 for students). There are three tracks, covering everything from beginner topics presented by 10gen staff to advanced, detailed MongoDB presentations by industry leaders. Here's the abstract for my talk:

This talk introduces the features of MongoDB by demonstrating how one can build a simple library application. The talk will cover the basics of MongoDB's document model, query language, and API. In addition, we will learn how to use MongoDB within a typical web application framework.

If you're in Boston and you've never used MongoDB before, or are thinking of trying it out, I'd highly recommend stopping by. The demo application for the talk is written with Mojolicious::Lite and will soon be available on GitHub for you to experiment with.

(Crossposted from my blog here.)

A configurable HTML parser, part 2

[ I have succumbed to the sirens of static blogging. This is cross-posted from the new home of the Ocean of Awareness blog. ]

My last post introduced Marpa::R2::HTML, a configurable HTML parser. By editing a configuration file, the user can change the variant of HTML being parsed. The changes allowed are very wide ranging. The previous post started with simple changes -- the ability to specify the contents of new tags, and the context in which they can appear.

In this post the changes get more aggressive. I change the contents of an existing HTML element -- and not just any element, but one of the HTML's three "structural" elements. Marpa::R2::HTML allows the configuration file to change the contents of all pre-existing elements, with the exception of the highest level of the three structural elements: the <html> element itself.

Can text appear directly in an HTML body?

More Ocaml and Unicode

I was wondering how you would do string encoding translation in Camomile (the Ocaml Unicode library). Why would you want to do this? Well, for instance, if you get a UTF-16 encoded string and you need to use PCRE on it, which only takes UTF-8 input. This means that you need to translate your string downward so you can match against it.

As Camomile uses functors extensively, you need to know how they work so you can follow the code example below. However, it is fairly straight forward once you get your head around it (it took me a while to figure this out which is why I am putting this here).

Korean Perl Workshop on October 20

Just in case you happen to be in the area, the Korean Perl Workshop will take place on October 20, 2012 in Seoul, Korea.

(They also have a nice banner to the Perl Weekly)

Perl 5 Porters Weekly: October 1-October 6, 2012

[ cross posted from its original blog ]

Welcome to Perl 5 Porters Weekly, a summary of the email traffic on the perl5-porters email list. I was in San Francisco this past week at RICON 2012, a conference about distributed systems for developers. It was organized by Basho who wrote and support the "NoSQL" Riak data store. I was there mostly in my capacity as an Erlang developer, but kept a finely tuned ear out for Perl. Unfortunately, there wasn't any discussion of Perl (or Python for that matter.) Most of the developers there work on Rails, Scala/Clojure, Erlang or node.js and it was a little disappointing to my inner Perl nerd that there wasn't much consideration of implementations outside of these 5 programming languages.

Topics this week:

  • TPF Grants (DAVEM / NWCLARK)
  • Security Issues in perl-5.16.x
  • Rounding a floating point number
  • Taking CPANPLUS out of core
  • a2p/s2p

Chicago.PM Report - Project Night: Alien::Base

This month's project night focused on Joel Berger's Alien::Base module. The final bugs are either squashed or very close, and we got an introduction to how the whole thing works.

I learned some interesting things about DynaLoader that helped cement the idea that it's an interface on to the system's dynamic linker. I've never dealt with DynaLoader from the Perl side of things, except when it broke, and I would solve those problems in system-specific ways. I learned that DynaLoader could solve those problems in a cross-platform way.

I started writing my own Alien::Base module for libusb, but unfortunately ran out of time. We had some interesting side-discussion on human interface devices and augmented reality.

In two weeks, I'll be giving a talk on scripting Git with Perl. Come on down and check it out!

... I like to push the pramalot ...

During a recent trip to Sydney I visited the Camelot Lounge . Nothing to do with small children, or arthurian legends, it contains much camel memorabilia. Being a very short train ride (two stops) from the OSDC venue , I thought it might be a good place to have a perl gathering as part of the conference. Apologies for poor quality of the the photos below, but you get thie idea. By the way their food is reasonably priced (pizza and pides), and tasty.
Created with Admarket's flickrSLiDR.

YAPC::Europe 2013 in Kiev, week minus 44. Air tickets

This week we explored another two venues and went to a small vacations: one of the organisers is at his honeymoon and another one goes to YAPC::Brasil. So let's talk a bit about travelling and see the prices to Kiev from different European cities for mid-August 2013, in Euro.

Counter-productive over time

Ovid wrote a post recently on an unexpected result of Mojolicious' "no dependency" policy.

I won't go into the horror stories of people getting yelled at for saying Mojo doesn't support dependencies. Instead, I'll give my opinion on the concept of no dependency, and you could decide for yourself if it relates to Mojolicious or not. I honestly don't care. Obviously, this is not a "don't use Mojolicious" post. In fact, I think it's a cool framework and you should try it out. This post is about my general opinion on the "no dependency" idea. Mojolicious is an example, DBI is another, and there are definitely others (Moose, anyone)?

The whole "NO DEPENDENCY HEAVEN!11" approach to me seems like the PHP "we embedded the code in your HTML!11" approach. Basically, doing something that tries to handle the current situation but in a way that actually ends up counter-productive when technology advances.

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.