Skip to content

Instantly share code, notes, and snippets.

View pjf's full-sized avatar

Paul Fenwick pjf

View GitHub Profile
=head2 autodie and string eval
Due to the current implementation of C<autodie>, unexpected results
may be seen when used near or with the string version of eval.
I<None of these bugs exist when using block eval>.
Under Perl 5.8 only, C<autodie> I<does not> propagate into string C<eval>
statements, although it can be explicitly enabled inside a string
C<eval>.
@pjf
pjf / Example TZ conversion in Perl
Created July 31, 2009 03:08
Changing the timezone is as easy as ->set_time_zone()
#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie;
use DateTime;
my $dt = DateTime->now;
foreach my $timezone ( qw( Australia/Sydney GMT America/Los_Angeles ) ) {
Selecting all friends who are interested in a particular hobby should be easy, right?
Well, it is, provided you're happy to do subselects, and realise the hobbies come back as a giant string.
Luckily, all that hard work can be pushed off to the FQL server...
---
SELECT name
FROM user
WHERE uid IN (
SELECT uid2
@pjf
pjf / SillyFunction.pm
Created August 8, 2012 04:35
Code for Fuzzi
#
# Instructions
#
# 1. Figure out what this function does
# 2. Write a unit test for it
# 3. Refactor for readability and efficiency
#
# NOTE: Do regular commits that show agile style iterations through the problem.
# If you prefer a different language, you can provide your solution in PHP,
# Python or Javascript too.
@pjf
pjf / bmndr.pl
Created August 15, 2012 05:53
bmndr code
#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie qw( :all );
use POSIX qw( strftime );
use Config::Tiny;
use WWW::Mechanize;
use JSON::Any;
@pjf
pjf / gist:4087296
Created November 16, 2012 13:18
Housemate advertisement.
Have you dreamed of living walking distance from the University of Melbourne,
the fabulous restaurants of Lygon, the boutique coffee-shops of Rathdowne, the
bustling variety of Brunswick Street? I'm looking for housemates to join me in
Drummond Street, Carlton North, near the corner of Lee Street.
The location here is fantastic; there's a supermarket at the end of the street,
cafés and bakeries around the corner, libraries, parks, pharmacies,
post-office, University of Melbourne, and many, many restaurants all within
walking distance.
@pjf
pjf / event-tree.pl
Created November 26, 2012 00:49
Turns event invite information into graphviz files
#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie;
local $/ = q{<li class="fbProfileBrowserListItem uiListItem">};
<>; # Discard leader
@pjf
pjf / depression.txt
Created November 29, 2012 00:57
Depression
Dear Everyone,
I have depression.
This isn't the sort of sadness that sticks around for a week and then
goes away. It's not the sort of thing that even has a good reason, although
there might have been one originally. It's the sort of thing that can
stick with you for months or even years, is a recognised illness, and
is one of the worst possible states a human can experience.
@pjf
pjf / exifpic.pl
Last active December 10, 2015 09:58 — forked from anonymous/exifpic
# /usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use threads;
use Thread::Queue;
use autodie qw(:all);
use Image::ExifTool qw(ImageInfo);
use Data::Dumper;
use Imager;