PreshBlog

Uncategorized

Fair play Amazon

by on Jul.24, 2009, under Uncategorized

You may have seen the news recently about Amazon removing books from many customer’s Amazon Kindle devices, which had been bought in good faith (ironically, including “1984”!).

Amazon boss Jeff Bezos has apologised for the mess:
(continue reading…)

1 Comment more...

Ryanair “standing room only” plans?

by on Jul.06, 2009, under Uncategorized, Wibbles, WTF

Ryanair passengers could soon fly for free – if they want to stand for their journey

Ryanair boss Michael O’Leary told Sky News the low-cost airline was considering ripping out the back few rows of seats on some flights.

Um, what? I’m pretty sure that won’t fly.

The FAA regulations definately require suitable seats with safety belts:

Sec. 121.311 – Seats, safety belts, and shoulder harnesses.

(a) No person may operate an airplane unless there are available during the takeoff, en route flight, and landing —

(1) An approved seat or berth for each person on board the airplane who has reached his second birthday; and

(2) An approved safety belt for separate use by each person on board the airplane who has reached his second birthday, except that two persons occupying a berth may share one approved safety belt and two persons occupying a multiple lounge or divan seat may share one approved safety belt during en route flight only.

(b) Except as provided in this paragraph, each person on board an airplane operated under this part shall occupy an approved seat or berth with a separate safety belt properly secured about him or her during movement on the surface, takeoff, and landing. A safety belt provided for the occupant of a seat may not be used by more than one person who has reached his or her second birthday.

Pretty sure the CAA/JAA will have similar rules.

My first instinct was to check whether this story was published April 1st, but clearly not.

Now, does someone think this will really work, or is it just a PR stunt to get people talking about Ryanair again (much like previous suggestions on charging to use toilets etc)?

5 Comments more...

Looking for phishing scripts, and other strange searches

by on Jun.30, 2009, under Uncategorized

A glance at my web stats reveals that I’m getting fairly regular hits from scumbags searching for phishing scripts, with queries like “where to find phishing scripts”, “php mailer by Mr.Brain”, “phishing script” etc.

I assume it’s all because, ages back, I wrote about the Mr-Brain.php phishing script.

I also get some other quite strange search hits – some of the stranger including:

  • "is ainsley harriot an arsehole"
  • "girls peeing in the sink"
  • "essex girl"
  • "pissed my pants in front of my girlfriend"
  • "i peed in my panties today blog"

There’s some strange people out there. I can only assume the piss-related hits are due to either If you’re having a bad day or Never piss off a JCB driver.

Oh, and the guy searching for “smoke from breather pipe motorcycle”? I’d say you need to get your engine looked at :)

2 Comments more...

Subversion – show commit details when editing commit message

by on May.21, 2009, under Perl, Programming, Uncategorized

Something I’ve wanted to do for a while is get the list of changed files and a diff into the commit message in my editor when I make a commit with Subversion.

With Git, you can pass the -v (verbose) option when committing, and the commit message you edit will include diffs as well as the list of modified files.

Subversion provides no such option, so I put together a little wrapper shell script to do this for me.

The script provides a function named svncommit (which I alias to just ‘ci’ for supreme shortness :) ).

When used, after the “–This line, and those below, will be ignored–” marker line, the list of files and then diffs will be inserted, as shown in the screenshot below (click for full size):

Subversion commit message being edited

The script itself is relatively simple (it was knocked up quickly; I’ll probably improve on it sometime):

# Do an svn commit, with diffs included in the commit message
svncommit() {
 
    # Start preparing the commit message which we'll then edit
    COMMITMSG=/tmp/$USER-commitmsg
    echo > $COMMITMSG
    echo "--This line, and those below, will be ignored--" >> $COMMITMSG
    svn status "$@" >> $COMMITMSG
    echo >> $COMMITMSG
 
    # Now do a diff; work out stats on lines added/removed by looking at
    # the diff, add that info, then the diff itself
    svn diff "$@"   > /tmp/$USER-svndiff
    LINESADDED=$(  grep '^+[^+]' /tmp/$USER-svndiff | wc -l)
    LINESREMOVED=$(grep '^-[^-]' /tmp/$USER-svndiff | wc -l)
    echo "Added $LINESADDED lines, removed $LINESREMOVED lines" >> $COMMITMSG
    echo >> $COMMITMSG
    cat /tmp/$USER-svndiff >> $COMMITMSG
    echo >> $COMMITMSG
 
    ORIGMD5=$(md5sum $COMMITMSG)
    $VISUAL $COMMITMSG
 
    if [[ "$(md5sum $COMMITMSG)" == "$ORIGMD5" ]]; then
        echo "Commit message unchanged, commit aborted";
    else
        svn commit "$@" -F $COMMITMSG
    fi
 
    rm $COMMITMSG
    rm /tmp/$USER-svndiff
}
5 Comments more...

Facebook vs Twitter is a flawed comparison

by on Apr.27, 2009, under Uncategorized

Marshall Fitzpatrick writes on ReadWriteWeb that "despite new openness, Facebook remains fundamentally closed".

What are people saying on Facebook about the swine flu? Facebook knows, but they won’t tell you. The company made a major move today to open up some of the data on the site in some interesting ways – but the conversation on Facebook remains fundamentally closed due to extensive privacy limitations and the company’s disinterest in overcoming those limitations in an appropriate way.

Ask Twitter what people are saying on that site about the swine flu and you can get the full story to parse until you’re blue in the face.

Um, I can’t help thinking he’s comparing apples with polar bears here.

Twitter and Facebook are two very different beasts. On Twitter, it’s expected that whatever you say is public, and can be seen both by your followers and the general public on the public timeline (unless of course you’ve protected your updates, but I don’t think many Twitter users do that (I’d be interested to know the percentage that do, actually)).

On the other hand, you have different fingers Facebook is built from the ground up to facilitate sharing information with your friends, and only your friends – there isn’t much public access to the data.

The fact that you can’t readily find out what people are talking about via Facebook APIs in the way that you can with Twitter is not a surprise to me.

Leave a Comment more...


Easy CLI option parsing with Getopt::Lucid

by on Jan.31, 2009, under Perl, Programming, reviews, Uncategorized

I often write Perl scripts which need to read options given on the command line. Normally I turn to the venerable old Getopt::Long which does the job.

However, I was writing a script which needed to be able to accept only certain parameters, which were mostly optional, and also take a list of filenames. I wanted this to be possible in any order, e.g.:

myscript --foo=foo --bar=bar file1 file2
myscript file1 file --foo foo

Getopt::Lucid makes this all pretty easy, and also makes the code pretty self-documenting, too. Straight from the documentation, showing the various types of parameters it can parse:

@specs = (
    Switch("version|V"),
    Counter("verbose|v"),
    Param("config|C"),
    List("lib|l|I"),
    Keypair("define"),
    Switch("help|h"),
);
 
$opt = Getopt::Lucid->getopt( \@specs );
 
$verbosity = $opt->get_verbose;
@libs = $opt->get_lib;
%defs = $opt->get_define;

A real-world example,from one of my scripts which handles ID3-tagging:

# The options we can take - these correspond to the name of the tag that
# they'll set:
my @options = qw(track title artist album comment);
 
my @option_specs = (
    Getopt::Lucid::Switch('verbose|v'),
    map { Getopt::Lucid::Param($_) } @options,
);
my $opt = Getopt::Lucid->getopt(\@option_specs);
 
my @tags_to_set = grep { $opt->{seen}{$_} } @options;
my @files = @{ $opt->{target} };
 
if (!@tags_to_set) {
    say "Nothing to do.  Use one or more of the options:\n" .
        join ', ', map {'--'.$_} @options;
    exit;
}

(The script then goes on to loop over all files, and use Music::Tag to set the ID3 tags requested).

Leave a Comment more...

Favourite new Perl features

by on Jan.29, 2009, under Perl, Programming, reviews, Uncategorized

I’ve been starting to make use of the new features introduced in perl 5.10 recently (after being constrained by my main dev environments still running perl 5.8.8, and not having the time to upgrade).

My favourite features so far are:

The smart match operator

The new smart-match operator, ~~, is a great example of DWIM.

A few examples:

if (@a ~~ 'foo')  # list contains at least one item equalling 'foo'
if (@a ~~ /foo/) # list contains at least one item matching /fo+/
if (@a ~~ @b)   # lists contain same values

That’s just a brief overview; there’s plenty more documentation

say

Not a big change, but the new say keyword acts just like print, but adds an implicit newline to the end – so say 'Hello'; is just the same as print "Hello\n";

It’s more useful in cases where you would have had to add parenthesis to get correct precedence – something like: print join(';', @foo) . "\n"; can now be written more concisely as just say join ';', @foo;.

Switch (given) statement

given ($foo) {
    when (/^abc/) { abc(); }
    when (/^def/) { def(); }
    when (/^xyz/) { xyz(); }
    default { die "Unrecognised foo"; }
}

Defined-or

// is now the defined-or operator.

It’s pretty common to use conditional assignments like: $a ||= $b to assign to $a unless $a already has a value. Now you can use $a //= $b to test for definedness rather than truthiness.

Likewise, if ($hash{foo} // $hash{bar}) will be true if either of them is defined (even if they’re defined but have a false value).

Named regex captures

Parenthesised sub-expressions in regular expressions can now be given a name, and accessed via the special %+ hash:

if ($foo =~ m{ (?<year> \d{4} ) - (?<month> \d{2}) - (?<day> \d{2}) }xms) {
    say "Year: $+{year}";
}

The features above are my own personal favourites, in no particular order. The full (large) set of changes can be found in the perldelta for 5.10.0.

1 Comment more...

Practicing image manipulation with GIMP

by on Jan.14, 2009, under Uncategorized

It’s been a while since I’ve done any image manipulation, so last night I randomly decided to play with GIMP (the GNU Image Manipulation Program, basically an open-source alternative to Photoshop, although admittedly not as powerful).
(continue reading…)

1 Comment more...

Monitoring Twitter via RSS search result feeds

by on Jan.12, 2009, under Uncategorized

Want to make better use of Twitter, getting a better signal to noise ratio, spotting tweets about things you’re interested in without having to wade through things you’re not?

Use the Twitter search, and enter terms you’re interested in, seperated by OR (e.g. badgers OR mushrooms OR snakes), then hit search – as you’d expect, you’ll find any tweets mentioning any of the terms you mentioned.

Now, in the top right of the results page, is a “Feed for this query” link – this gives you an RSS feed for this search which you can subscribe to in your RSS reader of choice. Now, you have a feed you can monitor for anything that’s of interest for you, whether that be your personal interests, or your company’s brand and terms related to your target market (e.g. hosting OR domains OR ecommerce etc).

Of course, you could just hand-craft the feed URL, if you’d prefer – it will look like:

http://search.twitter.com/search.atom?lang=en&q=badgers+OR+mushrooms+OR+snakes

It’s easy enough to change that to whatever you want :)

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!