Skip to content

Instantly share code, notes, and snippets.

@run4flat
run4flat / study-prima-mouse-interaction.pl
Created November 16, 2011 20:05
Basic Callbacks with Prima
use strict;
use warnings;
use Prima qw(Application);
my $wDisplay = Prima::MainWindow-> create(
text => 'Mouse Test',
onMouseDown => sub {
print "onMouseDown got args [", join('], [', @_), "]\n";
},
onMouseMove => sub {
@run4flat
run4flat / gist:1623396
Created January 16, 2012 22:34
PDL::Transform::Color - Convert between color systems
=head1 NAME
PDL::Transform::Color - Convert between color systems
=head1 SYNOPSIS
# load an image (in this case the cartographic demo)
use PDL::Transform::Cartography; $rgb = earth_image();
# convert the image to CMYK
@run4flat
run4flat / piddlebot.pl
Created January 22, 2012 04:47
piddlebot!
#!/usr/bin/perl
# This is a simple IRC bot that just rot13 encrypts public messages.
# It responds to "rot13 <text to encrypt>".
use warnings;
use strict;
use POE;
use POE::Component::IRC::State;
use constant CHANNEL => '#pdl';
# Load the current piddlebot functions:
@run4flat
run4flat / piddlebot.pl
Created January 22, 2012 23:34
Original Piddlebot.pl
#!/usr/bin/perl
use strict;
use warnings;
use POE;
use POE::Component::IRC::State;
use POE::Component::IRC::Plugin::AutoJoin;
#use POE::Component::IRC::Plugin::BotTraffic;
use POE::Component::IRC::Plugin::BotCommand;
use POE::Component::IRC::Plugin::CycleEmpty;
@run4flat
run4flat / example.pl
Created January 24, 2012 03:44
PDL+TCC
use strict;
use warnings;
use PDL;
use Inline Pdlpp => Config =>
INC => "-I$ENV{HOME}/include",
LIBS => "-L$ENV{HOME}/lib -ltcc",
;
use Inline 'Pdlpp';
@run4flat
run4flat / PDL_Checker.pm
Created January 24, 2012 14:21
Testing POD
use strict;
use warnings;
our @all_listings;
my %actions;
# Import the names of the main listings and run the command or print help
sub PDL_Checker::import {
shift;
@all_listings = @_;
@run4flat
run4flat / matrix-viewer.pl
Created January 31, 2012 20:23
save a matrix
use strict;
use warnings;
use PDL;
my $data;
BEGIN {
$data = rfits('20kV_1p45A_14deg_Fourier.fit');
}
use PDL::Graphics::Prima::Simple [$data->dims];
@run4flat
run4flat / fit-data.pl
Created February 2, 2012 20:24
Simple Perl script to generate and fit noisy linear data
use strict;
use warnings;
=pod
To run, say something like this:
perl fit-data.pl data.dat
where data.dat is the file created using make-data.pl
@run4flat
run4flat / lvalue-validation-class.pl
Created February 10, 2012 15:29
Using Want to validate lvalue methods (why is this not used everywhere, especially MooseX::Meta::Attribute::Lvalue?)
use strict;
use warnings;
# Create a new person, give him some cash:
my $david = Person->new(name => 'David', age => '29');
$david->wallet->cash = 30;
print $david->name, ' has $', $david->wallet->cash, "\n"; # $30
# This doesn't work, for reasons not clear to me:
$david->wallet->cash -= 10;
@run4flat
run4flat / comment-lines.pl
Created March 8, 2012 18:22
Quick line fixing with Perl
use strict;
use warnings;
open my $in_fh, '<', $file_name;
open my $out_fh, '>', "$file_name.new";
while(<$in_fh>) {
# Current line is stored in $_
# if current line contains the text 'zend-extensions'...
if ($_ =~ m/zend-extensions/) {