A Foolish Manifesto

fREWdiculous!

Archive for the ‘Uncategorized’ Category

Brief Addendum: Send Email

Ok, so for some reason I left out sending email from last nights’ post. Here it is: sometimes people forget about RT, or they have so many RT’s that they don’t know which ones are fixed and broken. Well, a small nudge via email can convince them to fix a longstanding bug. Of course, if it’s reasonable sending a patch wouldn’t hurt either…

  • 0 Comments
  • Filed under: Uncategorized
  • How to Help without being a Rockstar

    I think a lot of people who use perl have the idea that to help the perl ecosystem be they must be rockstars who churn out exorbitant amounts of code that is well tested and well factored. That is just not true!

    The easiest thing one can do to help out in the perl ecosystem is to create tickets for any issues you have with modules on RT. It’s not really that much of a hassle and it can help authors out a lot. Make sure that you include enough information for the authors to at least understand what went wrong. I won’t explain all that as my audience is comprised of programmers.

    in that same vein, sometimes people forget about RT, or they have so many RT’s that they don’t know which ones are fixed and broken. Well, a small nudge via email can convince them to fix a longstanding bug. Of course, if it’s reasonable sending a patch wouldn’t hurt either…

    Another thing which I’ve mentioned before is to use CPAN ratings. Again, this is super easy, but if the module works for you and you have no complaints, 5 stars can really tell other users a lot!

    And then of course there is communication on IRC. Often on IRC, after a user asks for clarification, developers will ask for a doc patch. Although this is easy for the user to add (depending on the subject of course) it will help future users significantly.

    How many RT’s have you submitted this week? CPANRatings? Doc Patches?

  • 3 Comments
  • Filed under: Uncategorized
  • reCAPTCHA

    Normally I opt to eschew metablog post (how meta is that?!) but I figured this deserves a brief explanation.

    I have been getting more and more spam lately. Fortunately Akismet usually keeps humans from seeing it, but Akismet has also kept back plenty of spam too. So I decided to go with the more powerful reCAPTCHA for comments from now on. I know it’s a hassle, but it could be worse. There are lots of bad CAPTCHA plugins out there and in general I like the reCAPTCHA concept. Anyway, sorry!

  • 4 Comments
  • Filed under: Uncategorized
  • Concert of the Month: Bat for Lashes

    Last night (Thursday) I saw Bat for Lashes live. It was a really good concert!

    You may have heard about Bat for Lashes from their awesome, creepy music video from 2007.

    I got the album (Fur and Gold) after hearing that song and was mostly disappointed. The other songs just didn’t seem to have the depth and feel as that song. So then recently this year I heard Daniel on Last.fm.

    Very cool song! Especially when you realize what it’s about!

    Wes: Khan said in an interview with The Sun newspaper that Daniel was based on a fictional character that she fell in love with as a teenager.

    she fell in love with daniel-san?

    The Karate Kid! So then I got that album (Two Suns). It was better than the first one, but I still wasn’t feeling it.

    Well, last night I convinced myself to see the show because the band makes such good music videos that the show could theoretically be really great. Well fortunately I was right, objectively speaking!

    The whole band was spot on with sound. The main thing that I noticed was that the synth was weirder and the drums and bass were louder, giving them that sound I’d always hoped and dreamed for. I have a theory that when the band records, the label (presumably) turns up the sound on the singer’s voice, makes the synth mostly chill, and relegates the D&B to the background so that the music will be more palatable to the masses. I haven’t done any research at all on this, but I can say that their performance was great live, and their albums are mostly mediocre (to me).

    My only complaint was that the concert was at The Loft, which is part of The Palladium. The Palladium has bad sound, is in a sketch part of town, and is just bad in general. Here are some examples comparing The Palladium to The Granada (my favorite venue of all time.)

    1. The Granada, while small, has multiple floor levels, so you never get stuck behind tall people. The Palladium is flat.
    2. The Granada has a bar, but it’s well partitioned from the concert area, so the annoying loud drunk people don’t spoil the show. The Palladium, not so much.
    3. The Granada has a dedicated photographer who will email (and post on flickr) any pictures he takes of the show. With the Palladium that’s not the case, so when you are trying to watch the show you see annoying people taking pictures instead of watching the show.

    Overall though, I’d give the concert 4 stars; and it would be 5 if it weren’t at The Palladium.

  • 0 Comments
  • Filed under: Uncategorized
  • Finding a sweet domain with perl

    So yesterday I spent a few hours trying to find a cool domain for the project I am working on in my free time. (By the way, raptorprey.com is open.) After looking at lots of various options, I decided that it would be really cool to get a domain of a latin work with the .US TLD. Too bad I don’t know latin right?

    (I can't read this)

    (I can't read this)

    So I went online and found some cheesy one page latin dictionary that had a few thousand words. I used vim to clean up the data (after saving as plain text) and turn it into a standard format (JSON.) Next I used vim to filter out all the words that didn’t end in us. To do that I used a command something like the following:

    1
    :g!/^".*us"/d

    That will find all lines that have words that don’t end in us, and then delete them. Then I wrote a perl script which would do it’s best to read in my serialized data, check if the domain was available, and store whether it was or not. Here’s a permutation of it (I changed it a lot and I left out the domain checking, as that’s technically Against The Rules):

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    #!perl
    use Modern::Perl; # just for one-off's in my mind
    use JSON;
    use File::Slurp; # again, just for a one-off

    my $file = shift;
    my $text = read_file($file);
    #format:
    #my $final_data = {
    #   unchecked => \%new_data,
    #   possible  => [],
    #   unpossible => [],
    #};
    my $final_data = from_json($text);

    foreach my $domain (keys %{$final_data->{unchecked}}) {
       warn "checking $domain.us";
       # MAGIC HERE
       if ($exists) {
          push @{$final_data->{unpossible}}, "$domain.us";
       } else {
          push @{$final_data->{possible}}, "$domain.us";
       }
       delete $final_data->{unchecked}->{$domain};
       sleep 1 + rand();
    }

    END {
       my $json = JSON->new->pretty;
       say $json->encode($final_data);
    };

    I have the end block doing the final output because something was killing the program, even if I put an eval around that part of the code, so what I did was basically output the same format that I input. That way I could just manually edit the data that was causing the issues.

    Cool huh?

  • 5 Comments
  • Filed under: Uncategorized
  • Metrics + Debug!

    The project I am working on at work is going to be deployed soon, so today I worked on some of those things that need to be taken care of before the deploy. One of those things was changing our gigantic list of javascript files into a single file with minimal hassle. I actually tried to implement it myself, but that was silly. A simple search on CPAN for catalyst javascript yields two promising results.

    The first is Catalyst::View::JavaScript. While this is an excellent package which does caching and automatically minifies depending on whether the server is in debug mode or not, it expects javascript to be in memory already. Maybe that’s something that’s common and I don’t know about it, but we almost never write javascript on the server.

    So onto the next result: Catalyst::View::JavaScript. It does not do caching, and it always minifies. But heck! That’s not too bad. Before installing it, note my RT that it does not have correct dependencies. Hopefully that will be fixed soon. I also sent another RT. Since I technically write more lines of javascript than perl, I need to be able to turn off minification. So I patched the module to only minify when the server is not in debug mode. Hopefully that will be accepted as well.

    So after doing that I ensured that apache had gzip turned on to reduce the amount of bandwidth required by the clients to download our javascript. Then I got curious. How much of a difference do these things make? So I measured it:

      no gzip gzip
    no minify 807K 212K
    minify 712K 202K

    Wow! Minification really doesn’t help that much, whereas gzip’ing is huge.

    Now, just to be clear, this isn’t a great solution for an externally facing site, because the clients don’t currently cache the minified javascript, because it gets served by Catalyst and it’s probably not worth my time to set that up all the headers to fix that for a site that runs mostly on a LAN. Once the customer does start allowing external access we’ll want to set some last-modified headers and whatnot.

    I also did a few more cool tweaks using debug mode. For example I have the debug version use ext-all-debug.js, which has extra stuff for error messages and whatnot, and ext-all.js, which is preminified and has error checking removed for performance reasons (for the tests above I used ext-all.js the whole time.)

    Furthermore I have the debug switch my server side error messages from actual exceptions to a simple message asking the user to get in touch with the devs and tell us what happened and what time it was when it happened.

    All in all I felt really good about the code I wrote today. It will help me a lot as time goes on and it makes the dev server way faster (1 small download is way faster that 60~ really small ones). Too bad the customer will probably not notice a significant amount of it :-) Anyway, hopefully these tips will help give you some ideas for your webapps.

  • 2 Comments
  • Filed under: Uncategorized
  • Perl 6 in Perl 5 FOR THE WIN

    Today I wanted to generate a list from another list. Typically I would use map for this, but I wanted to iterate over two elements at a time, instead of one at a time. (A lot of people said to use natatime from List::MoreUtils, over and over. They didn’t read my question very carefully, especially since I specifically said I wanted natatime but with map.)

    Anyway, mst pointed out Perl6::Gather, which works perfectly for this situation! Ah the beauty of Perl 6 in Perl 5. Here are the codez:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    my @list = (
      foo => [qw{bar baz biff}],
    );

    my @new_list = gather {
      while (my ($foo, $bar) = splice(@list, 2, 0) ) {
         take map { "$foo/$_" } @list;
      }
    };

    So basically what that does is create an implicit accumulator and every time you call take it adds the arguments to take to the accumulator. In Perl 6 map can iterate over multiple items at once, so this would be silly in that context, but in Perl 5 it’s quite helpful!

  • 0 Comments
  • Filed under: Uncategorized
  • The Beauty of Code Reuse

    I’m probably preaching to the choir here, but it must be said: code reuse is most excellent!

    Today I got a somewhat complex feature working for our customer, and almost all of it was features I’d already written, and due to the organization of our system I could easily reuse most of the code.

    Our customer fixes airplane parts. When they fix a part they need to document every single thing they did to the part. We have each operation (more or less) that can be done already defined so that they can at least save those keystrokes (they are actually operation templates.) But there are a lot of operations and a typical work order will be around 50 operations, so choosing the same operations over and over is a waste of time. So we have a feature that lets them look at other work orders that were fixing the same type of part and copy operations (and materials) from that.

    It was really easy to use the existing view for operations and materials because the front end is entirely comprised of JS classes. I even used an instance of the work scope grid to list all of the work scopes that are for the given part. The nice thing was that so far I’ve written no new server side code yet. And for the classes I didn’t use inheritance; I used a role style object modification by doing what Moose people would see as an after method on new (called a plugin in ExtJS). With the plugins I could simply change the store to ask for a given part-type’s work orders, hide extra columns, and add listeners to update the operations and materials when a user clicked a row.

    Don’t think this is all just JS praise; Perl and Catalyst were help too. But really the benefit here was the use of any web framework in general. Because I’m using a framework I can easily find server side actions that do what I need (which the grids were already tied to in their base classes, but still.) In our other projects I’d be hard pressed to give you a list of all of our “actions,” whereas with CGIApp I can easily make a list of runmodes myself, and with Catalyst the server will make a list for me.

    Excellent!

  • 0 Comments
  • Filed under: Uncategorized
  • CPAN Ratings Day

    You may have noticed that there really aren’t a lot of CPAN Ratings out there currently, but you have a chance to help that. The past couple of weeks I’ve done two or three CPAN ratings every Thursday. Just go to CPAN Ratings, get an account, and rate modules that you are a fan of.

    Generally criticizing modules in active development is a bad idea since bugs should really go to rt. But if the module is “done” and there are bugs, a bad review might be feasible.

    Anyway, Happy CPAN Ratings day!!

  • 2 Comments
  • Filed under: Uncategorized
  • Dallas.p6m: August 2009

    So we had another Dallas.p6m tonight. It was fairly laid back compared to some other ones, but it was still a lot of fun.

    I did a “talk” on the Perl 6 object model, which I didn’t prepare enough for, so it was mostly me asking Patrick some basic questions about stuff I could relate to Moose. So here is the skinny on that stuff:

    has in Moose is a method, that ties a string to some attributes.

    has in Perl 6 is actually the OO version of my. So you do the following:

    1
    2
    3
    4
    # generate method getters and setters and $!foo
    has $.foo;
    # generate private variable for object
    has $!bar;

    And then because Perl 6 has changed to some extent, instead of doing $.bar isa Int, you’d do the following:

    1
    has Int $.foo;

    Also, as far as we could discover in our short meeting, instead of before, after, and around, in Perl 6 you’d use wrap. I *think* it would work like this, but I’m not sure:

    1
    2
    3
    4
    5
    class Foo extends Bar {
       $.method_from_bar.wrap({
          # codez
       });
    };

    After that we had a heated discussion about whether using wrap was monkey patching/violating the Liskov substitution rule. I stand with the majority that it is not.

    We also did some initial planning for a monthly hackathon, which is exciting. The idea is to have the hackathon two weeks after the meeting, so we can kinda plan ahead. We’ll see how well that goes down.

    If you live in the DFW area, you should get in touch and visit!

  • 1 Comment
  • Filed under: Uncategorized