He ist lead dev of Scintilla the edit component, Kephra, Padre and Kommodo are using. And I was very happy to read that he will open up the internal API. So Perl editors will be able to do even more.
You can do some fun stuff with this module - it allows easy preparation of data for use with the Google Visualization API - ie: any data source you can access in Perl, you can easily spit out as one of a number of awesome and often interactive graphs and charts.
If you make something pretty with it, let me know!
Yesterday we had some troubles setting up a client that should post some utf8 JSON to a web API. The problem was, that the data kept showing up as latin-1. After lots of "fun" with hexdump, wireshark, the debugger and Devel::Peek we verified that we were in fact passing a properly utf8 encoded JSON to LWP::UserAgent like so:
After adding encode_utf8 in random places, it worked. So I dug into google and found this posting containing this advice:
If you want the string UTF8 encoded, then say so explicitly:
$req = HTTP::Request->new(POST => $endpoint);
$req->content_type("text/plain; charset='utf8'");
$req->content(Encode::encode_utf8($utf8));
It seems that HTTP::Request, when stitching together the actual text representation of the request, will downgrade the content to latin1, no matter what you say in Content-Type, unless one explicitly calls encode_utf8 on the content.
Mistake #4, "Use of Adhoc Queries", seems to be true only when you have a large, heterogenous development staff (like 10+ developers). Smaller development groups don't seem to suffer from allowing ad hoc queries by developers. (Perhaps it is mainly a communications problem, rather than just an allowing ad hoc queries problem?)
I've always been an avid hater of uninitialized variables. I'll hunt them down, catch them and beat them to a bloody pulp and then shoot the remains.
Too much, you say? No need for the bat AND the gun, you say? Oh, quite the contrary.
Here is an example of a recently discovered Linux kernel issue. An uninitialized memory segment. The fix is really simple: to initialize it with zeros. This was done in a patch that only adds the following command:
+ memset(mem, 0, sizeof(mem));
Oh, but I can hear you snicker behind your monitor "this won't happen in Perl because Perl protects you from such stuff!"
You're right, this won't happen in Perl. But here's a Perl example:
At $work I've written a program that runs checks on servers (rest assured, it's not a Nagios replacement) and creates an array of the results of each server that was tested. The array contains timing and whenever there's a timeout, it contains an "undef" to indicate a penalty.
I'm looking for a Catalyst or other Perl based application framework that will do standard CRUDS (CReate, Update, Delete, Search) functions. I've seen a few of the online writeups about how different people put these together in as few lines as possible, but I'm more looking for one that I can just install via CPAN, configure a database connection, and start the server.
(This is a long time overdue post in Ubic series. Previous posts can be found here.)
Last time I explained how any kind of service start/stop/status behavior can be encapsulated in an Ubic::Service subclass. But what if you have many similar services, and want to generate the service list dynamically?
For example, sometimes you already have a directory with daemon configs, and want to run them all without creating additional "service description" file per daemon.
Or you may wish to start ten instances of one processing script.
Or maybe you keep the list of your services in SQL database on another host.
In all these cases, multiservices come to the rescue. Multiservice is a container object which provides part of the service tree.
For example, let's assume you have a dir /usr/share/psgi-apps/ with some psgi apps in it:
I was doing a lot of work on Dancer lately. We've been experiencing a few test failures on Windows with the upcoming big release. I'll admit we are usually reluctant to go to Windows-land and fix issues, but Alias sure made it clear how important it really is, so it was something that had to be done at some point.
While investigating this situation, I've noticed Cwd's realpath() function was complaining a path for a test did not exist. The path did not exist for Linux or BSD either but the test wasn't failing there.
After checking out Cwd more closely, I've noticed it had an XS version for Linux, BSD and other operating systems and a few Pure-Perl implementations of realpath() for some (OS2, MSWin32, DOS, VMS, for example). Upon inspecting the XS code and the Pure-Perl code it was apparent that the versions were not exactly the same. On Windows if a path does not exist, it will croak but on Linux it will continue running.
Blessed are the CPAN Testers, for they show us the bugs!
Playing games can be useful too. While playing "Lacuna Expanse" and using a bot to find a good asteroid to mine, I found a bug in YAML and fixed it. Later I found out that this bug was already reported 4 years ago.
as the next release 0.4.4 is about basic editing, I filles there several feature holes.
like e.g. inserting rectangular selections properly, making the brace nav more consistant (jumping from inside to inside matching braces or from outside to outside). then i also added left and right to moving text(line/block) to indend/dedend tabwise which makes refactoring easier. Now im working on the proper DND of rectangular selections, which isnt delt properly even in kommodo 5.
here on austrian perl workshop the friendly guys helped me to fixe an issue with Module::Install and thanks to jizef kutej the debian package is also ready (jejky!).
but there is much more to come but i want to sanatize the basics first befor we start next bigger chapters like plugins and extentions ....
There's another Raw Array idea from Leon, for which I wrote Tie::CArray ages ago, but this can be made better of course. Tie::CArray does not need to do its own memory management.
That's what we have magic for. The array of I32/U32/NV/char[12]/.. can reside in the PVX and the getters/setters/... are just magic callbacks as in Tie::Array.
I just talked about some obvious illguts observations at the vienna perl workshop and was asked to eloborate.
Leave off xpv* structs
If you don't need any xpv struct, e.g. for short strings, you can leave it off. This will need a flag bit and can be set if MAGIC and STASH is empty.
I ran into some trouble when combining tainting with the Encode module. Recently, I've been using the Encode module to decode from binary to text as soon as possible and encode back to binary as late as possible. Unfortunately, this completely kills the protection that -T grants, presumably b/c the Encode module uses a regular expression to do it's work.
my ($home) = Encode::encode('UTF-8', $ENV{'HOME'});
system("echo $home");
This can be beaten by wrapping calls to the Encode module (and others such as Getopt::Long with calls to the Taint module to make sure that if a variable is tainted before it goes through the Encode module, it stays tainted after it comes out of the Encode module.
However, for me, an unexpected result of combining two great parts of Perl
On Stackoverflow, someone asks how to get 100 random numbers without a loop. It's one of those dumb homework problems that tries to forbid only one of many things instead of specifying the technique it really wants the student to practice. In Perl land, that leaves the door open for the sick and twisted minds of people such as Tom Christiansen and Sinan Ünür. I wonder if the teacher would even understand their solutions, much less accept them.
Many of the answers went to great pains to avoid certain Perl keywords while still creating loops. Some people debated if map is a loop. Some people used recursion, forgetting that every time you recurse in Perl, God kills a kitten. Maybe someday people will realize that recursion in Perl isn't the same kung fu they see in other languages. Perl actually must recurse because it has no way of knowing if it's going to call the same function definition.
Most of the solutions used Perl's built-in rand, which I think ignores half of the problem, the random numbers themselves. I use rand too, but I replace its definition to use the random.org web service to get lists of random numbers generated from atmospheric noise. Not only that, but I change rand in very sick and twisted ways, adding a list context.
I'm doing a lot of jQuery of one of my current clients. Along the way I'm learning fun Javascript gotchas. Here's a demonstration of one scoping difference. Below the .change() event tied to bar works as I expected, but baz is a global variable.
function addARow() {
var i = $('#next_id').val();
var d = $("div"), //COMMA then foo
foo = $("<input>",{id:"foo" + i,size:"3"}).appendTo(d)
.change(function() { bar.val($(this).val() * 2); })
.change(function() { baz.val($(this).val() * 2); }), //COMMA then bar
bar = $("<input>",{id:"bar" + i,size:"3"}).appendTo(d);//SEMICOLON then baz
baz = $("<input>",{id:"baz" + i,size:"3"}).appendTo(d);
$("<br>").appendTo(d);
$('#next_id').val(i - 1 + 2); // + 1 would concat 1 onto the string :)
};
See it in action here. jQuery creates a set of 3 input fields (foo, bar, baz) on each click of "add". When foo is changed by the user, bar and baz are updated. But the wrong baz gets the update.
Day one was good. I learned about GUCS, sharding, backups and recovery. We met at Cafe Royale last night for a drink, courtesy of PostgreSQL Experts Inc and the San Francisco PostgreSQL Users Group.
Day 2 just came to a close. I got to hear Scott McNealy speak about a variety of topics. I learned about performance pitfalls, Node.js/Postgres.js, database-driven cache invalidation and the system tables. Lots of good info.
This evening EnterpriseDB is providing dinner and drinks at Harry Denton's Starlight Room this evening.
I write a lot of apps that need a simple database. I tend to use SQLite, but I found I was implementing the same things over and over again. I finally started wrapping it up in a role that I can reuse, but now I'm stuck on a name. The role provides the following:
Database connect/disconnect
Automatic creation of db if it doesn't already exist
Transactions
Blocking locks (SQLite's locking kept biting me, so I worked around it using flock)
The name I picked out of the blue was DBIx::Cradle. It sort of makes sense, but I don't really like it. It is hardly an extension of DBI, so DBIx doesn't feel right, even though it does provide some general purpose database goodness. The Cradle part is supposed to mean it makes life easy and comfortable, but again, doesn't feel quite right.
Any suggestions? Any other similar modules I should look at?
PS: In case anyone remembers my earlier post about database abstraction, you might notice I'm backtracking a bit. These things happen. The comments pushed me away from that course of action, and this role has simplified things enough that I'm a lot happier now.
Imagine you have an employee base class, but you know that the salary calculation will be different per employee type. You might decide to do this:
package Employee;
use strict;
use warnings;
use Carp 'croak';
sub new { bless {} => shift }
sub salary { croak 'You must override salary() in a subclass' }
1;