karzilla: a green fist above the word SMASH! (Default)

Bug counts: resolved 246, assigned 15, needs-review 10



I did my first Template Toolkit conversion in bug 3030. It's still counterintuitive to me that the views are linked to the document hierarchy in DW/Controller files that are buried deep in cgi-bin, instead of some sort of top-level HEY LOOKEE HERE easy to find place, but hey, whatever works.

I also defined my first hook, because I noticed that the index page only linked to the files in dw-free, and there were a bunch more in the same directory in dw-nonfree that needed to be linked as well. Hooks are the simplest way to tell a program: "Whoops, hey, if that code over there is loaded, pass this here data through it. If not, forget I said anything." It's also a good example of a concept I learned years ago from customizing Tinyfugue; I learned most of my basic programming skills on MU*s before I ever learned Perl.
karzilla: a green fist above the word SMASH! (Default)

Bug counts: resolved 229, assigned 23, needs-review 19



Continuing on the subject of things that weren't as hard as I feared: making a gearman worker.

Here's your basic gearman worker in its entirety:
use LJ::Worker::Gearman;
gearman_decl( 'name-of-worker'  => \&worker );
gearman_work();
sub worker {
    # stuff what needs doing
}

And then you call it with something like LJ::gearman_client()->dispatch_background( 'name-of-worker', ...) (at least for my purposes, which were "go do this other time-consuming thing somewhere else and don't tell me what happens.")

The only real voodoo, AFAICT, is that you have to use Storable methods (freeze/thaw) for passing the function arguments from the web execution to the worker execution. I just did a copy and paste of code from someone else's worker script and it worked like a charm.

Later on I get to either write more gearman workers or overcome my fear of TheSchwartz, depending on whether or not gearman can do everything I need for delivering vgifts.
karzilla: a green fist above the word SMASH! (Default)

Bug counts: resolved 228, assigned 23, needs-review 21



I figured out how to bend S2 to my will! Well, a bit anyway.

I was all "um there's no sort function here wtf" and then I saw this bit of wiki that described how to make a Perl subroutine load into S2. So that's what I did.

function builtin keys_alpha(string{} elements) : string[]
"Return the keys of the array in alphabetically sorted order.";


That's it. keys_alpha is a regular Perl subroutine in LJ::S2. The only nonintuitive part (for me, because I don't like languages that declare variable types) was figuring out what the input and output type declarations should look like. As near as I can figure, string[] is a regular array reference and string{} is like a hash reference, except unlike a Perl hash it implicitly acts like an array of hash keys in array context. Anyway, I needed an array because in Perl, arrays preserve the ordering of their elements and hashes do not.

So yeah, that wasn't as hard as I feared.
karzilla: a green fist above the word SMASH! (Default)

Bug counts: resolved 201, assigned 10, needs-review 6



I have to remind myself that not everyone is as fearless about rearranging the guts of the code as I am.

Hence, I just changed my mind and accepted a patch from a new contributor that I had rejected a few days ago as being too small in scope. I'll open a new bug for the gut rearranging and probably do it myself.

I hope I didn't scare the newbie away!
Page generated Mar. 26th, 2017 05:20 am
Powered by Dreamwidth Studios