Re: Perl Christmas Quiz

2008-12-14 Thread Torsten Knorr
> 3) Write a Perl function that takes two references to arrays and returns the 
> intersect of them. 
> If an entry appears n times in array 1 and m times in array 2, 
> the output should list that entry min(n,m) times. 
> Bonus mark for one line solutions.

#!/usr/bin/perl -w
#*** compare_int_arrays_v001.pl ***#
#-
 use strict;
#-
 my (@i_list1, @i_list2);
 push(@i_list1, int(rand(100))) for(1..200);
 push(@i_list2, int(rand(20))) for(1..10);
 print("value:\tlist 1:\tlist 2:\n");
 print("$_->[0]\t$_->[1]\t$_->[2]\n") for(@{Intersect(\...@i_list1, 
\...@i_list2)});
#-
 sub Intersect
{
my ($rai_1, $rai_2) = @_;
return [] unless(ref($rai_1) eq 'ARRAY' && ref($rai_2) eq 'ARRAY');
my (%i_seen, @i_ret);
$i_seen{$_}[0]++ for(@$rai_1);
$i_seen{$_}[1]++ for(@$rai_2);
@i_ret = map [$_, $i_seen{$_}[0], $i_seen{$_}[1]],
grep $i_seen{$_}[0] && $i_seen{$_}[1],
keys(%i_seen);
return [sort({ $a->[0] <=> $b->[0]} @i_ret)];
}
#-

 Torsten




Re: Perl Christmas Quiz

2008-12-14 Thread Avleen Vig
On Fri, Dec 12, 2008 at 9:50 AM, Chris Jack  wrote:
> 3) Write a Perl function that takes two references to arrays and returns the 
> intersect of them. If an entry appears n times in array 1 and m times in 
> array 2, the output should list that entry min(n,m) times. Bonus mark for one 
> line solutions.

In the spirit of sharing, I offer this solution, from your neighbours
in the Python community:

a = ['m', 'n', 'o', 'o', 'p', 'p', 'q']
b = ['n', 'p', 'q', 'r', 'r', 's']

def FindSetMatches(list1, list2):
  for i in set(list1).intersection(set(list2)):
print '%s min(%s, %s)' % (i, list1.count(i), list2.count(i))


:-)


Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Andy Wardley

Léon Brocard wrote:

Andy, care to put your changes live?


All checked in.  It'll need to be built on the target machine.

I've added 3 more colour schemes (light brown, teal and purple) for those
who find the orange a bit too garish.  I've also added a print stylesheet.

The stylesheet switcher and "Go Large" mode are now sticky and get added
via a bit of JS progressive enhancement voodoo. So everything should degrade
nicely for those without JS.

I kept the design as fixed width because making a fully fluid layout proved
to be too much of a PITA for the time I had available.  However the "Go Large"
mode is fully fluid, albeit a little sparse, so it's a good second best.

Limited preview here:

  http://wardley.org/london.pm.org/

I haven't yet looked at it in IE.  I'm going to go and poke myself in the
eye with a sharp stick first.  :-)

Enjoy!
A




Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Nicholas Clark
On Sun, Dec 14, 2008 at 06:33:34PM +, Andy Wardley wrote:

> I've added 3 more colour schemes (light brown, teal and purple) for those
> who find the orange a bit too garish.  I've also added a print stylesheet.

Heresy!

Whilst we fully support "there's more than one way to do it", the availability
of different hues of orange should provide more than enough alternatives. :-)

> I kept the design as fixed width because making a fully fluid layout proved
> to be too much of a PITA for the time I had available.  However the "Go 

But anyone who desires a fully fluid layout can download the current source
[  svn co https://london.pm.org/svn/website-shiny/  IIRC ]
and then submit patches. And then everyone will be happy. All of the time*

Nicholas Clark

* Your mileage may vary. Warranty not valid in some universes. Emotions are sold
  by weight not volume, and may have settled in transit.


Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Nigel Rantor

Nicholas Clark wrote:

On Sun, Dec 14, 2008 at 06:33:34PM +, Andy Wardley wrote:


I've added 3 more colour schemes (light brown, teal and purple) for those
who find the orange a bit too garish.  I've also added a print stylesheet.


Heresy!

Whilst we fully support "there's more than one way to do it", the availability
of different hues of orange should provide more than enough alternatives. :-)


I kept the design as fixed width because making a fully fluid layout proved
to be too much of a PITA for the time I had available.  However the "Go 


But anyone who desires a fully fluid layout can download the current source
[  svn co https://london.pm.org/svn/website-shiny/  IIRC ]
and then submit patches. And then everyone will be happy. All of the time*


If it was a site I actively used I would complain loudly and vociferously.

As it is, I don't. So I won't.

I've already poked Andy about this when he put up the initial version.

  n


Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Jonathan Stowe
On Sun, 2008-12-14 at 19:35 +, Nigel Rantor wrote:
> Nicholas Clark wrote:
> > On Sun, Dec 14, 2008 at 06:33:34PM +, Andy Wardley wrote:
> > 
> >> I've added 3 more colour schemes (light brown, teal and purple) for those
> >> who find the orange a bit too garish.  I've also added a print stylesheet.
> > 
> > Heresy!
> > 
> > Whilst we fully support "there's more than one way to do it", the 
> > availability
> > of different hues of orange should provide more than enough alternatives. 
> > :-)
> > 
> >> I kept the design as fixed width because making a fully fluid layout proved
> >> to be too much of a PITA for the time I had available.  However the "Go 
> > 
> > But anyone who desires a fully fluid layout can download the current source
> > [  svn co https://london.pm.org/svn/website-shiny/  IIRC ]
> > and then submit patches. And then everyone will be happy. All of the time*
> 
> If it was a site I actively used I would complain loudly and vociferously.
> 

I think you meant "I would submit patches" - strange how sometimes your
keyboard goes wrong like that.

/J\


I think you meant... (was Re: london.pm.org web site - facelifted (v2))

2008-12-14 Thread Nigel Rantor

Jonathan Stowe wrote:


I think you meant "I would submit patches" - strange how sometimes your
keyboard goes wrong like that.


No Jonathan, I don't mean that.

At all.

If I meant that I would have said it. Do you see?

And I object to this attitude that one is not allowed to voice their 
opinion on a subject if the subject in question is some form of 
open/collaborative effort that one has not contributed to.


There are plenty of things I'm good at. Web design isn't one of them. 
And at the same time that does not invalidate my opinion when it comes 
to usability of sites. I am, after all, a user. One who cares about 
ergonomics.


People are, and should be allowed to say "I don't like it." as feedback 
to the people who are doing the work, otherwise, how do they know if the 
people they're making things for like the results?


Since we all know there is more than one way to do it I would encourage 
you to remember that there is more than one way of helping to build 
something. And if you don't regard testing and feedback as worthwhile in 
that regard then I pity your customers and/or employer.


This attitude is also, in my opinion, another reason the l.pm is 
sometimes a less-than-friendly place.


Yours Sincerely,

   Nigel



Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Andy Wardley

Nigel Rantor wrote:

I've already poked Andy about this when he put up the initial version.


Here's my reply to Nigel, for the benefit of anyone else interested.



Yes.  I've always been a fluid-layout kinda guy.  800x600 is annoyingly
narrow when you've got a large monitor, so a fluid layout was a big win when
you had to assume a minimum width of 800px.

But these days, it's considered "officially" OK to assume that 1024x768 is
the lowest common denominator for screen width, which gives you a nicely sized
bit of content-space to play with.  Making it fluid upwards of that tends to
result in wide wide columns that are hard to read.  So although I used to be
staunchly anti-fixed width, I guess I've now been swayed towards them.

Making it fluid might be a bit tricky, but probably do-able.  I'll have a
think about it.



I did have a play with it, but it was hard to make it look half-decent with
the non-repeating header.  So it was a case of junking the header (which
I really liked) or spending a lot of time creating separate layers and
building up a sliding doors effect.  That would have been really nice if I
could have got the parallax effect to work (like on badgerpower.com - resize
the window and watch the clouds), but I couldn't.  At least not in the time
I had.

Anyway, the site *does* have both fixed and fluid layouts.  It's just that
the fluid layout doesn't have the non-repeating header or the sidebars.  :-)

A


Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Nicholas Clark
On Sun, Dec 14, 2008 at 07:35:42PM +, Nigel Rantor wrote:

> If it was a site I actively used I would complain loudly and vociferously.
> 
> As it is, I don't. So I won't.
> 
> I've already poked Andy about this when he put up the initial version.

On Sun, Dec 14, 2008 at 08:48:43PM +, Nigel Rantor wrote:

> Jonathan Stowe wrote:

> And I object to this attitude that one is not allowed to voice their 
> opinion on a subject if the subject in question is some form of 
> open/collaborative effort that one has not contributed to.


> This attitude is also, in my opinion, another reason the l.pm is 
> sometimes a less-than-friendly place.

Whilst constructive feedback is useful, may I suggest that (specifically, and
not obviously in jest) complaining vociferously about something others did
for free, that you are not paying for, is also less-than-friendly.

And is specifically something that annoys the list admins.

And I forgot say in my previous message joking about heresy by colour,
big thanks to Andy for a large wod of JFDI.

Nicholas Clark


Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Andy Wardley

Nicholas Clark wrote:

Whilst we fully support "there's more than one way to do it", the availability
of different hues of orange should provide more than enough alternatives. :-)


Aha!  Well the brown design *is* actually orange!  It's exactly the same hue
as the orange (30 deg), but de-saturated and washed out a bit.  But it really
is officially orange.

The teal version is also orange.  It's just been shifted a teensy-weensy bit
towards the green end of the spectrum (approx 107 degrees if memory serves).
Surprisingly, the purple is also orange, but shifted an ickle-bickle bit in
the other direction.

A





Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Dominic Thoreau
2008/12/14 Andy Wardley :
> But these days, it's considered "officially" OK to assume that 1024x768 is
> the lowest common denominator for screen width, which gives you a nicely
> sized
> bit of content-space to play with.  Making it fluid upwards of that tends to
> result in wide wide columns that are hard to read.  So although I used to be
> staunchly anti-fixed width, I guess I've now been swayed towards them.

Can I please point out (if just for my own personal feeling of
self-justification), that no, it isn't always appropriate to do this?

On ultra-portable netbooks (like my Eee) and on mobile phones, this
sort of approach can make navigation impossible.

If you could guarantee that full-blown machines would be all  that was
ever used, maybe. But this is simply not true. Plus the dot pitch is
different, which can really screw up some layouts.


Dominic
-- 
No train here, but still:
The sign says: "Ready to Leave"
Normal service, yes?


Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread David Cantrell
On Sun, Dec 14, 2008 at 09:17:12PM +, Dominic Thoreau wrote:

> On ultra-portable netbooks (like my Eee) and on mobile phones, this
> sort of approach can make navigation impossible.
> 
> If you could guarantee that full-blown machines would be all  that was
> ever used, maybe. But this is simply not true. Plus the dot pitch is
> different, which can really screw up some layouts.

Also there's this weird assumption some designers have that browsers
will fill the whole screen.  This is, of course, a silly assumption.

-- 
David Cantrell | Minister for Arbitrary Justice

  On the bright side, if sendmail is tied up routing spam and pointless
  uknot posts, it's not waving its arse around saying "root me!"
  -- Peter Corlett, in uknot


Re: I think you meant... (was Re: london.pm.org web site - facelifted (v2))

2008-12-14 Thread Andy Wardley

Nigel Rantor wrote:
And I object to this attitude that one is not allowed to voice their 
opinion on a subject if the subject in question is some form of 
open/collaborative effort that one has not contributed to.


I have no objection to you voicing your objections.

And at the same time that does not invalidate my opinion when it comes 
to usability of sites. I am, after all, a user. One who cares about 
ergonomics.


I also care about usability and ergonimcs.  But that's one of the reasons
why I'm leaning more towards fixed width designs.  Readability drops off
quickly when columns get wider than 12-15 words.  So a liquid design that
expands to 1600+ pixels is neat from the "cramming content into every bit
of available real estate" perspective, but it really sucks from the
usability side of things.

Of course, typographers have know these things for 100 years or so and we
in the web world are only just figuring it out.

And if you don't regard testing and feedback as worthwhile in 
that regard then I pity your customers and/or employer.


I welcome testing, feedback and comments, both good and bad.  But it is
worth bearing in mind that this is voluntary work and any complaints that are
*too* vociferous may fall on deaf ears.  Or be met with directions to the
subversion repository :-)

My customers are, of course, encouraged to complain as loudly as they like,
and demand any kind of colour scheme, layout, or any other feature that they
care for.  But then, that's what they're paying for.  Business vs pleasure.

A


Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Andy Wardley

Dominic Thoreau wrote:

If you could guarantee that full-blown machines would be all  that was
ever used, maybe. But this is simply not true. Plus the dot pitch is
different, which can really screw up some layouts.


True.  I should have quantified that a bit better as referring to typical
desktop machines.  Doing the job properly for mobile content usually requires
targeting them with a different stylesheet altogether and a bit of WURFL
magic. Trying to make one design work on all platforms is usually a lost
cause in my experience (but I know a man who can sell you a very nice mobile
content management and delivery platform if you're interested in that kind
of thing).

So yes, I accept that it's sub-optimal, but it's Good Enough[tm] for a Sunday 
afternoon hack (especially seeing as there *is* a fluid layout in there that

you can use if you want it).

A






Re: london.pm.org web site - facelifted (v2)

2008-12-14 Thread Dirk Koopman

Andy Wardley wrote:

Nigel Rantor wrote:

I've already poked Andy about this when he put up the initial version.


Here's my reply to Nigel, for the benefit of anyone else interested.



Yes.  I've always been a fluid-layout kinda guy.  800x600 is annoyingly
narrow when you've got a large monitor, so a fluid layout was a big win 
when

you had to assume a minimum width of 800px.

But these days, it's considered "officially" OK to assume that 1024x768 is
the lowest common denominator for screen width, which gives you a nicely 
sized
bit of content-space to play with.  Making it fluid upwards of that 
tends to
result in wide wide columns that are hard to read.  So although I used 
to be

staunchly anti-fixed width, I guess I've now been swayed towards them.

Making it fluid might be a bit tricky, but probably do-able.  I'll have a
think about it.





I think that if one wants to have a fixed layout then one (probably) 
need to also have a limit on the size of the borders. Particularly if 
one has chosen a strong border colour (which includes white BTW). A 
example would be news.bbc.co.uk, where they have deliberately chosen a 
(very) neutral colour for "filling in" the sides of wider monitors.


Perhaps this is a way forwards?

Dirk


be excellent to each other (was Re: I think you meant... (was Re: london.pm.org web site - facelifted (v2)))

2008-12-14 Thread Nicholas Clark
On Sun, Dec 14, 2008 at 09:24:05PM +, Andy Wardley wrote:

> I welcome testing, feedback and comments, both good and bad.  But it is
> worth bearing in mind that this is voluntary work and any complaints that 
> are
> *too* vociferous may fall on deaf ears.  Or be met with directions to the
> subversion repository :-)
> 
> My customers are, of course, encouraged to complain as loudly as they like,
> and demand any kind of colour scheme, layout, or any other feature that they
> care for.  But then, that's what they're paying for.  Business vs pleasure.

In September, I went to the memorial service for the head of music from my
school, who died from cancer earlier in the year. One of the things that
stuck in my mind was another teacher saying that "one of the most important
things Colin taught me was that you can never say 'thank-you' enough". In
this context it was thank-you to the other teachers, for volunteering their
spare time to help organise and participate in extra-curricular
activities. Things that they didn't need to do; things that they got no
payment for. But a choice that they made that benefited everyone greatly,
and something you didn't want them to stop doing.


The issue is that if the first contact you get from a complete stranger
seems to be implying that "your software sucks", *and* that they want help
for free, it doesn't really endear them to you. It doesn't help that e-mail
is plain text, and doesn't have the emotions or nuances of tone of voice,
let alone facial expressions or body language, so it's very hard to know how
tongue-in- cheek someone's comments are. Smileys, love 'em or loathe 'em,
are actually important. But so is phrasing things carefully, so that people
can't misinterpret your intent.


For example, here's a spectacularly bad way of doing it:
http://rt.perl.org/rt3/Public/Bug/Display.html?id=38744

Perl 5.8.8 contains an incompatible and undetectable change to the
public, documented POPpx macro--the macro no longer assigns the length
of the popped value to n_a. This ChangeLog entry appears to be the
relevant one:

[ 25525] By: nicholas on 2005/09/21 09:32:33
Log: Integrate:
[ 24748]
Convert POPpx POPpconstx and POPpbytex to use nolen macros.
Elminate a lot of Cs

Our code was calling POPpx then using the value assigned to n_a to
allocate a buffer into which the returned value was copied. After
upgrading to Perl 5.8.8, the code still compiled, but due to the POPpx
change then passed the now-uninitialized value of n_a to the allocation
routine. Fortunately, the value that happened to be in that memory
location caused the allocator to throw an exception, but it could just
as well have allocated a short buffer.

It was highly irresponsible for someone to make an incompatible change
to a documented, public API without ensuring that code depending on the
old API caused the compile to fail. The macros should have been renamed
or they should have been changed to take a different number of
arguments. There is no telling what third party code might now have
buffer overflow security bugs due to this incompatible change.


Then read my reply. It starts "Thanks for reporting this bug."

This was not the first phrase that sprang to mind on reading it. But it's
important to remember that we're in this for the long term, and that you may
have misinterpreted the sentiment of the tone of the message.

Now, most people are not that inconsiderate (including the individual
responsible for that report in all his other bug reports), but the
cumulative effect of a lot of people turning up with reports that are 100%
bug and 0% thanks wears you down. It's one thing if they come from someone
you recognise as giving something back to the community, be it software,
organisation [eg Kake brings us pubs, MDK brought us the LPW], or just
donations [Venda and AntibodyMX brought us beer*]. But most seem to just be
"take", and you start to wonder why you're doing it, and why instead you
shouldn't go any do something else that might be more fun, but less
altruistic.

Hence partly why 5.8.9 [now wending its way to CPAN - you read it here
second] brings you a brand new utility - perlthanks. It lets you send bug
report antidotes as easily as bug reports, if you are so inclined.

If people want to use it send thank-you message to perl-tha...@perl.org
that's great. If people want to say thank-you to me for 5.8.9 by buying me
beer, that's great too** (although I can't drink that much, and actually I'd
prefer sashimi - mackerel sashimi - I'm a cheap date).

But if you like Perl, and want to say "thanks", probably the most useful way
to say it is to do something no-one else can do. Write about your own Perl
Success Story. Counter the "Perl is specialist biologist word for stable"
zombie-meme that wants to eat everyone's BRANES***. It doesn't matter if it's
an informal chat to some colleagues, a lightning talk a

I'm afraid I'm leaving already :(

2008-12-14 Thread bloke
Hey People,
  I'm afraid I leaving this group. I was going to post this 3 days ago, but I 
thought best to let it sit over the weekend to make sure I felt the same way.

There seems to be an air of fear for all the people who lurk on this list. 
For those that are brave enough to post, they soon get shot down and 
discouraged from posting. 
This can be for making simple mistakes, or having an opinion an outspoken Cabal 
member does not agree with.


My second post here was:-
>I have to say I side with Nicholas on this one.
>
>If you find joy in tormenting people who make simple requests, maybe you 
>should be looking at http://yp.direct.gov.uk/cyberbullying/

(my first post was only in desperation as management was breathing down my neck 
and I didn't know where to turn about Perl an UML)

I posted that and started to make and effort to contribute to this group as I 
saw a well known and respected member of this group stand up and say 
"I do not have time for poo flinging simians, nor do they do our image any 
good."

I was wholly impressed by this, and felt a mood of change, so I decided it was 
time to start posting.

All my posts since were aimed to encourage Perl and the community to do good 
things and help Perl grow and evolve.
The Perl is Dead post hurt so much I just had to start a Perl is Alive thread.


The majority of this group, as I read it, are good. They want good things for 
Perl. 

The main problem member for me recently is Jonathan Stowe. Some newer posters 
were trying to put out a good message for this group, reminding people that 
Perl was intended to be for everyone and expressing things about Perl that were 
important to them. It seems that Jonathan has acted quickly to put them in 
'their place' as he appears to see it.

Some recent replies from Jonathan Stowe:-

>>If there is anyone out there who still doubts that London.pm is a
>>place where all things are possible; who still wonders if the dream of
>>our founders is alive in our time; who still questions the power of
>>our democracy...
>
>Nothing in the above should be taken as meaning that London.pm is infact
>a democracy of course ...

Our leader makes a nice inspiring speech, Jonathan is quick to discourage 
people.


>Strange how you seem to be towing exactly the same line as the *thrice*
>banned Lyle Hopkins

I posted a link to a group that is trying to achieve exactly what the previous 
posters were suggesting. It doesn't matter who has taken the time to start the 
group, it was wholly relevant.


>I'll put your attempt to get us to participate in copyright theft down
>to naivete, stupidity or youthful enthusiasm but please do not do this
>again.

This was completely unnecessary, he made a mistake, we are all human. It 
clearly wasn't "an attempt to get us to participate in copyright theft" nor 
were your comments needed.


>> Let's just be nice, mm'kay?
>
>"Nice" doesn't cut it: politeness - that is to say adhering to a set
>of basic community norms and, if one doesn't understand those norms,
>not making up a standard for yourself that is at conflict with them
>and then getting the arse when called on it is the key.  Most of the
>crap that we get in this list is completely down to people not being
>polite.

Pot and kettle... The person was clearly being polite, and asking you nicely to 
do the same. New people aren't going to understand the 'basic community norms' 
as you put it. Much the way a child will not be born knowing everything that 
you expect of it. What it takes it patience and taking a little time now and 
then to tell people what they've done/are doing wrong in a friendly and 
considerate way.


>>> And I said no arguing
>>
>> http://www.xkcd.com/392/ (cartoon portraying one rule for me, another for 
>> you)
>>
>Damn right!

This is a really bad attitude and very damaging to the group.


>So you appear to have some kind of bee in your bonnet about
>
>You are wrong, no-one has a right to be here by default.
>
>Oh get the man a violin and a tear jar.

This is not an acceptable way to talk to someone on or off-line. Seriously "Oh 
get the man a violin and a tear jar", please grow up.


>Whining fuckers, I should ban the lot of you...

So if we don't adhere to exactly what you want then we'll get booted? Certainly 
seems that way.


If I was you Jonathan, I'd probably say something horrid like "ohh look, Davros 
is picking on someone else", but I won't. Because I'm not you. Instead I'll say 
'please don't drag this list down'.

Seems that many people here have the intention of turning this list into the 
friendly supportive place it should be. Please don't stamp on their efforts. 
Really you should be looking at yourself and why you are acting in this way.

To the 'Cabal' you seem to be quite divided on whether this list should be a 
friendly democratic place. Or whether it should be a Cabal led dictatorship, 
where you can do/say/act in whatever way you want, but everyone else must 
conform or keep quiet. May

Re: I'm afraid I'm leaving already :(

2008-12-14 Thread Kake L Pugh
On Mon 15 Dec 2008, bl...@perlbloke.com wrote:
> I'm afraid I leaving this group.

Goodbye, Lyle.  Hopefully the whining quotient of the list will go
down a bit now.  If it doesn't, I'm sending you all to a Harvester for
the next social.

Kake


Clay Shirky on Shinto Shrines, Perl, Love and the Internet

2008-12-14 Thread Andy Wardley

http://www.youtube.com/watch?v=Xe1TZaElTAs


   Perl is a shinto shrine.

   Perl exists not as an edifice but as an act of love. Perl is a viable
   programming option again today because millions of people woke up this
   morning loving Perl.

   And more importantly, they love one another in the context of Perl. They
   love one another enough to stop what they're doing and listen to each
   other. To have a conversation with each other, to answer questions for one
   another, to diagnose things for one another and sometimes even to write
   code for one another - "Oh I think I see what's going on, here, try this".

   No contracts are written, no money changes hands and and the work goes on.


I would just like to say that I love you all and you're my bestist mate ever.

A