Re: Best practice for unit tests that rely on internet access?

2011-05-05 Thread Mark Morgan
On 29 April 2011 02:15, Toby Wintermute t...@wintrmute.net wrote:

 What is the best practice for writing unit tests that rely on internet
 access?

 ie. You have a CPAN module which is all about talking to a web
 service.. So you have unit tests that do just that.
 What if the system testing it doesn't allow HTTP connections out? The
 tests will fail..

 Should one
 a) Prompt the user for whether to skip the tests? (I hate this
 option.. I dislike interactivity in installers)
 b) Only run the tests if specifically set by AUTHOR_TEST or something,
 otherwise mock the server? (I dislike this.. means few good tests run
 for users)
 c) Try to test if there's a working connection, and silently skip the
 tests if not? (Risks skipping tests if the connect fails for other
 reasons than no outbound HTTP allowed)
 d) ???


If you're using LWP, take a look at LWP::UserAgent::Mockable .  It was
exactly this kind of situation that it was written for.

The main behaviour depends on the mode you're in (controlled by environment
variable when running the script):
  - record - will make all of the LWP calls, and store the request 
response for each to local file
  - playback - will intercept all LWP calls, returning the ones from the
recorded file
  - passthrough - go direct to the the remote end, without any wrapping

For the simple case, there's only a single line change required to your test
files.

It's not an ideal solution, in that you aren't able to confirm that the
responses from the remote system haven't changed, but it's better than
having to rely on integration tests with remote systems that are often down
or unreliable.

Lemme know if you have any issues with interface, and I'll see what I can do
about an update.  It's been a while since I've updated that, and there are a
couple of things I want to modify for it myself.

Take care,
Mark.


Re: Recommendation for simple Web Frameworks

2011-01-12 Thread Mark Morgan
On 10 Jan 2011 22:06, John Imison i...@moe.co.uk wrote:

 Out of interest, does anyone use CGI::Application?  What are the general
thoughts on that?

I've used in past roles, as a relatively simple dispatcher for web
services.  Anything more involved than that, and it becomes a but of a pain,
not for the core system.  Rather due to some plugins for it changing the
dispatch or exception handling needlessly. When using multiple plugins, this
becomes a maintenance headache.

That being said, it's been a couple of years since I last used, so that
situation may have changed.

Mark.


Re: Data recovery

2010-09-03 Thread Mark Morgan
I'd suggest trying to bring up the drive under a couple of different OSs
first.  Different OSs and filesystem drivers have different failure
tolerances.  Linux, FreeBSD and windows are the ones I'd suggest trying.
When I last needed to do that (8+ years ago), FreeBSD had the greatest
failure tolerance, but that's very likely to have changed since then...

Mark.

On 3 September 2010 10:56, Mike Whiting m...@mikejw.co.uk wrote:


 Hey guys,

 Can anyone recommend any good data recovery services?  My friend dropped
 his external hard drive and now it seems to have become my responsibility to
 'fix it' because some of my bands songs are on there.  I'm not sure what
 exactly is wrong.  The drive seems to gets noticed but that's about it.  I
 suspect if there's anything that can be done with it at all it would involve
 removing the platter and rehousing it.

 Any insights appreciated.

 Mike W
 --
 http://www.mikejw.co.uk




Re: Domain acquisition

2009-12-15 Thread Mark Morgan
On Tue, Dec 15, 2009 at 11:16 AM, the hatter london...@bang.meep.org wrote:
 Try dnsaleprice.com - it keeps track of auction prices.  For instance, 4
 letter, 1-word .co.uk's sold in the last year shows 20 words or
 almost-words, with decent words from $900-13 and some other 4-letters
 from $80-900.  Sedo's search tools let you do similar, a 4 or less seatch on
 there shows fixed-price domains available to buy, and also what others are
 up at auction.  It should at least put some hard boundaries on your pricing
 even if it still leaves a wide margin.

There is a danger with some of the domain auction sites though [1][2];
If they see a rise in queries of dead-but-registered domains, they
will assume that there is interest to buy these, and will
speculatively 'bid' on them themselves, in order to jack the price up
and then resell it onto you, pocketing the extra.

Mark.

[1] Not that I'm saying this one is such, I've never had any dealing
with them, so can't make a specific comment on them.
[2] Some of the more unscrupulous registrars are suspected of doing
similar, based on quantity and origin of whois queries.



Re: UTF-8 + HTML::Template + CGI::Fast

2009-12-04 Thread Mark Morgan
On Fri, Dec 4, 2009 at 5:15 PM, Peter Corlett ab...@cabal.org.uk wrote:
 As far as I could tell from the last time I had this problem, if you omitted
 the accept-charset attribute from the form tag, the browser would use its
 default character set. Which was UTF-8 in Firefox and Windows-1252 on IE.
 Setting form accept-charset=utf8 ... made IE play nicely.
[...]
 Getting something other than Latin-1, Windows-1252 or UTF-8 posted to your
 web forms is vanishingly unlikely.

The above assertion assumes that the user's default locale is the same
as yours...

Mark.


Re: Perl Christmas Quiz 2009

2009-12-01 Thread Mark Morgan
I recall that as part of technical test I took for a previous role, to
try and interpret and determine what it did.  Quite cool, but the
coolness was definitely exceeded by it's evilness... :)

Mark.

On Tue, Dec 1, 2009 at 11:26 AM, Abigail abig...@abigail.be wrote:
 which would be 'similar' but 'different' to my prime number checker.
 I'd be very interested to see how to do the C {length($1)-1} 
 without (?{ })/(??{ }).


Re: [OT] finding memory hungry bits of my code

2009-04-09 Thread Mark Morgan
On Thu, Apr 9, 2009 at 12:40 PM, Andy Armstrong a...@hexten.net wrote:
 That sounds as if it could just be Perl getting up to cruising (memory)
 altitude. Perl isn't especially keen on giving memory back to the OS once
 it's used it; instead it keeps it hanging around and uses it to satisfy
 future allocations.

You beat me to that.

Also, depending how you're viewing the memory usage, and the OS that
you're under, you may be including a lot of COWed shared memory
multiple times.  I've found that Linux in particular is quite opaque
when trying to determine how much memory is shared, when using
mod_perl.

Mark.


Re: [OT] finding memory hungry bits of my code

2009-04-09 Thread Mark Morgan
On Thu, Apr 9, 2009 at 2:08 PM, Edmund von der Burg
e...@ecclestoad.co.uk wrote:
 Perhaps you're right - but our cruising altitude would seem to be very
 high: our biggest processes according to top:

I'll take a guess that you're using Redhat, or some derivative
thereof.  The perl included with that includes a lot of things as
shared modules (the big one, if memory serves me correctly is
locale-related).  `ldd perl` will show if this is the case.  This
amount gets included in the memory info that linux top/ps returns,
which has a tendency to really bloat the figures.

 Do these numbers look reasonable to others? The SHR value seems crazy
 low, but that might be me reading it all wrong.

Yep, that's what we ran into, when trying to do an analysis of memory
usage at a previous company.  You can look at /proc/pid/mem to get
at the memory map, and see what shared libs are being used, size of
stack/heap/etc (though in spending a few minutes now, I couldn't find
anything that tells what the other values in this file represent
off-hand).

 Almost everything gets preloaded in our startup.pl script so it should
 get shared.

A simple (though very limited) determination of memory usage under
apache would be to start up with x processes, check free memory/swap,
kill it, and start with x+1 processes, and see the difference.  Will
give some indication as to the baseline memory usage for each apache
instance.  Doing similar with a couple of requests put through each
may show if some modules aren't being preloaded as you thought.

Mark.


Re: Optimisation

2009-03-03 Thread Mark Morgan
On Mon, Mar 2, 2009 at 9:01 PM, Nigel Peck nigel.p...@miswebdesign.com wrote:

 When the list could be empty, which is faster?

 if ( @list ) { foreach ( @list ) { } }

 - or just -

 foreach ( @list ) { }

 Or is it a pointless question?

Sounds like a definite case of premature optimisation.  If it's not
causing issues for production code, ignore it.  If it is, then there's
very likely much bigger problems

Mark.


Re: Optimisation

2009-03-03 Thread Mark Morgan
On Tue, Mar 3, 2009 at 2:35 PM, Bruce Richardson itsbr...@workshy.org wrote:
 On Tue, Mar 03, 2009 at 12:17:22PM +, Nigel Peck wrote:
 I'm just asking because I try to think about optimisation as I'm writing
 code, rather than going back and doing it later, which I've only done in
 rare cases.

 The most optimal code is maintainable code.  Lay your code out well,
 make it easy to understand.  If you do that, then when the code sees use
 and the actual priorities for optimisation become apparent, it'll be
 much easier to make those improvements (especially if you are not the
 person making them, but even if you are).  It's the only early
 optimisation that works.

Amen.  Bruce for President. :)

Mark.



Re: London.pm Dim sum Thursday 1pm: Bamboo Basket

2009-01-29 Thread Mark Morgan
What time are folks looking to arrive there?

Mark.

On Mon, Jan 26, 2009 at 1:43 PM, Léon Brocard a...@astray.com wrote:
 There are many Perl hackers at the BBC, and it's time to go see them
 again. Westfield London has opened in Shepherd's Bush. It's a large
 shopping centre and it has a dim sum restaurant (in a large food
 court).

 London.pm dim sum is a social event where we meet up every Thursday at
 a different Chinese restaurant, spend about an hour (and about £10
 cash) eating tasty dim sum (steamed and fried dumplings), then go our
 separate ways.

 Bamboo Basket
 Westfield London
 Shephard's Bush Tube Station
 http://maps.google.co.uk/maps?q=W127SL
 http://uk.westfield.com/london/find/detail/dining?category=2020retailer=35482
 http://uk.westfield.com/london/find/map/dining?category=2020retailer=35482

 See you there!

 Léon, London.pm Dim Sum Mandarin





Re: London.pm Dim sum Thursday 1pm: Bamboo Basket

2009-01-29 Thread Mark Morgan
D'oh.  I read the message a number of times, to see if I missed it
Obviously didn't look at the subject... :)

Mark.

On Thu, Jan 29, 2009 at 11:55 AM, Léon Brocard a...@astray.com wrote:
 2009/1/29 Mark Morgan makk...@gmail.com:
 What time are folks looking to arrive there?

 We'll meet there at 1pm, like the subject of the email says ;-)

 Leon



Re: DBD::Pg - insert_id

2003-06-25 Thread Mark Morgan
Not sure if postgres is similar to oracle, in this respect, but in Oracle,
it's illegal to do a currval call until nextval has been called at least
once on a sequence.  Something that may come to bite you...

Take care,
Mark.

On Mon, 23 Jun 2003, Toby Corkindale wrote:

 Date: Mon, 23 Jun 2003 08:50:41 -0700
 From: Toby Corkindale [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Re: DBD::Pg - insert_id

 On Fri, Jun 20, 2003 at 10:53:47AM +0100, Chisel Wright wrote:
  One piece of functionality I can't find in the postgres database
  interface is the equivalent of:
 
$sth-{'mysql_insertid'}
 
  It would just be really nice to be able to do something like:
 
$sql = q[INSERT INTO foo (foofield1) VALUES (?)];
$sth = $dbh-prepare($sql);
$sth-execute($barbaz);
 
return $sth-{'pg_insertid'};
 
  Can anyone offer some clues?

 as above, except then
 return last_inserted_id($tablename);

 Note that this is quite safe and the value returned is the current value for
 YOUR session only; so no need to worry about someone else inserting something
 or other such race conditions. :)

 # Returns the last ID resulting from an INSERT command
 sub last_inserted_id
 {
 my $self = shift;
 my $table = shift; #should be safe, but check anyway
 if ($table =~ /(\w[\w\d\_]+)/) {
 $table = $1;
 }
 else {
 die(LBHF.pm/last_inserted_id: Invalid table name: $table\n);
 }
 my $query = $self-{db}-prepare(SELECT currval(' . $table . _id_seq'));
 $query-execute
 or mydie($self, 'SQL Error occured:' . $self-{db}-errstr);
 return($query-fetchrow_arrayref-[0]);
 }

 hope this helps,

 Toby

 --
 Turning and turning in the widening gyre
 The falcon cannot hear the falconer;
 Things fall apart, the centre cannot hold;
 Mere anarchy is loosed upon the world.






Re: Net::Whois::RIPE

2003-05-29 Thread Mark Morgan
On Thu, 29 May 2003, Chris Andrews wrote:

snip

 There's a couple of modules which know about gTLDs and a handful of
 ccTLDs, and Net::Domain::ExpireDate seems to know about quite a few
 for the expiry date only, but a comprehensive module will be a
 maintenance nightmare.


 Chris.

Very much so.  I have to do minimal parsing of whois information as part
of my work for OpenSRS, and even for that, I run into maintainance
problems.  The biggest cause is that many of the registrars alter their
whois formats on a semi-regular basis, presumably to avoid easy parsing of
em for transfer information.

Mark.




Re: Net::Whois::RIPE

2003-05-29 Thread Mark Morgan
On Thu, 29 May 2003, Lusercop wrote:

 Date: Thu, 29 May 2003 10:26:54 +0100
 From: Lusercop `the.lusercop'@lusercop.net
 Reply-To: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Re: Net::Whois::RIPE

 On Thu, May 29, 2003 at 10:16:19AM +0100, Mark Morgan wrote:
  Very much so.  I have to do minimal parsing of whois information as part
  of my work for OpenSRS, and even for that, I run into maintainance
  problems.  The biggest cause is that many of the registrars alter their
  whois formats on a semi-regular basis, presumably to avoid easy parsing of
  em for transfer information.

 Can't you just ask OpenSRS for the information? that's what we do.

Because OpenSRS is my employer. :)  The minimal parsing that we need to do
is just to get the admin email address for transfers, but even doing that
changes on an all-to-regular basis for many registrars.

Take care,
Mark.




Re: Changing namserver whois record

2003-02-17 Thread Mark Morgan
There's no problem on the registry side for creating/deleting/updating a
.org nameserver.  Just tried creating one here, and doing all the above.

You will run into problems though, if you try to add a new .org nameserver
to Verisign, as they still think they are authorative for em, and don't
allow the change.

Mark.

On Mon, 17 Feb 2003, Paul Makepeace wrote:

 Date: Mon, 17 Feb 2003 18:11:36 +
 From: Paul Makepeace [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 To: London.pm [EMAIL PROTECTED]
 Subject: Changing namserver whois record

 A friend of mine has srl.org which is listed in whois as a nameserver
 with a particular IP. Bulkregister isn't helping with changing the IP
 and is saying it's become much more difficult since the .org
 change-over. Is this smoke  mirrors or is there some truth behind it?
 Anyone know how to change a registered nameserver's IP these days?

 It seems that looking up the address (`host srl.org`) returns the A
 record without consulting the nameservers, presumably since it's
 registered with an A record by dint of being a whois-known nameserver. I
 didn't realise the gTLD servers did that. What a pain in the arse.

 penderel:~$ ns srl.org | perl -ne '/\S+$/  print `host srl.org $`'
 srl.org A   208.44.199.253
 srl.org A   208.44.199.253
 srl.org A   208.44.199.253
 penderel:~$ host srl.org
 srl.org A   64.81.251.171
 penderel:~$

 Either that or I've made a mistake here somewhere :-)

 Paul

 --
 Paul Makepeace ... http://paulm.com/

 What is the difference between symbolism and surrealism? A childish
  retort.
-- http://paulm.com/toys/surrealism/







Re: Ssssilly Ssssilent Ssssysss::Sssyslog

2003-02-17 Thread Mark Morgan
This caught me up the first couple of times I need to use the module...

You'll likely need to call setlogsock with a param of 'unix' before
calling openlog/syslog.  By default, this doesn't use unix sockets for the
connection.  This is documented in the perldoc.

Take care,
Mark.

On Mon, 17 Feb 2003, Luis Campos de Carvalho wrote:

 Date: Mon, 17 Feb 2003 17:01:44 -0300
 From: Luis Campos de Carvalho [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 To: London.pm List [EMAIL PROTECTED]
 Subject: Ssssilly Ssssilent Ssssysss::Sssyslog

   Hello again, list folks.
   Maybe I should upgrade my production system, but I won't take this risk...
 =-]

   Could anybody help me figure out why the Sys::Syslog module is silent?

   Every time I call Sys::Syslog::syslog() method, the call completes
 sucessfuly, but the syslog register nothing.
   I've tryied using the linux logger(1) program and it can write to my
 syslog.

   Attached follows (a) My current perl version; (b) the sample program that
 uses Sys::Syslog (and silently completes without writing the messages to the
 syslog); (c) the Sys::Syslog module that I'm using, gzipped; (d) the
 Sys::Hostname on what the Sys::Syslog depends (in case somebody thinks on
 run diff against the modules); and finally, but not least important, (e) my
 /etc/syslog.conf file.

   Any help, suggestions, complaints, bad names, or solutions would be great.

   Thank you all.
   Regards.
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
   Luis Campos de Carvalho
   Computer Science Student
   OCP DBA Oracle  Unix Sys Admin
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=