Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

marcel (3299)

marcel
  (email not shown publicly)

Journal of marcel (3299)

Friday July 26, 2002
09:28 AM

Karaoke Streaming Server

Converging Technologies idea: A karaoke streaming server. Just streams text in appropriate intervals.

Tuesday July 23, 2002
08:53 AM

Full-screen movies with Quicktime

The QuickTime Player Applescript Dictionary reveals that the player can indeed play movies at full-screen, so you don't have to get QuickTime Pro for just that. Here's a program that lets you do it from the command-line.

#!/usr/bin/perl

use warnings;
use strict;
use File::Spec;

my $movie = shift || die "usage: $0 movie\n";
my $path = File::Spec->rel2abs($movie);

my $script = EOAS;
set thefile to get POSIX file "$path"
tell application "QuickTime Player"
        activate
        open thefile
        present movie 1 scale screen
end tell
EOAS

exec '/usr/bin/osascript', '-e', $script;
die "can't exec osascript: $?";

08:02 AM

SSH authentication

I just got fed up with having to enter the password for ssh connections time and again. Of course, it's a simple matter of copying a few files and setting a few permissions, but I just can't remember the exact things to do. So here you go: just create a key with

        ssh-keygen -t dsa

and run this script:

#!/bin/sh
# rhive.sh - create remote hive (well, RSA authentication).
# $1 needs to be 'user@host'. Need to enter password two or three times.

echo 'Creating remote .ssh directory...'
ssh $1 'mkdir -p ~/.ssh && chmod 700 ~/.ssh'

if [ -f ~/.ssh/identity.pub ] ; then
        echo 'Transferring identity.pub -> known_hosts...'
        scp ~/.ssh/identity.pub $1:~/.ssh/known_hosts
fi

if [ -f ~/.ssh/id_dsa.pub ] ; then
        echo 'Transferring id_dsa.pub -> authorized_keys2...'
        scp ~/.ssh/id_dsa.pub $1:~/.ssh/authorized_keys2
fi

echo 'Setting permissions on public keys...'
ssh $1 'chmod 600 ~/.ssh/*'

07:43 AM

Personal Call Stack

I need a personal call stack. You want to do X. But to accomplish that, you need to do Y. To be able to do Y, you first need to do Z. When you've finished doing Z, you've probably forgotten about X, namely why you were doing Y and Z in the first place. That is, if you even remember Y. In short, I need a call stack. And I will not support continuations.

07:43 AM

OS X talk

Discussions about OS X in the last few days mainly seem to center around two topics: the case-insensitivity of HFS+ and a stoned girl named Ellen Feiss.

07:29 AM

spoken news

Hear your favourite RSS newsfeeds: Take some LWP, a little XML::RSS and season with command-line driven AppleScript.

#!/usr/bin/perl

use warnings;
use strict;
use XML::RSS;
use LWP::Simple;
$|++;

my %news = (
        slashdot => "http://slashdot.org/slashdot.rdf",
        useperl => "http://use.perl.org/useperl.rss",
);

my $key = shift || die "usage: $0 key\n";
die "unknown key\n" unless exists $news{$key};

my $rss = XML::RSS->new or die "can't create XML::RSS?";
eval { $rss->parse(get( $news{$key} )) } and not $@
        or die "cannot get or parse content: $@";

for my $item (@{$rss->{items}}) {
                my $title = $item->{title};
                my $spoken = prepare_spoken($title);;

                print "title: \n";
                print "spoken: \n\n";
                system('/usr/bin/osascript', '-e', sprintf q!say "%s"!, $spoken)
                        == 0 or die "can't speak '$spoken': $?";
                sleep(1);
}

sub prepare_spoken {
                local $_ = shift;
                $_ = lc;

                s/\.NET/ dot net /gi;
                s/U\.S\./ U S /gi;
                s/mozilla/ mo zilla /gi;
                s/AMD's/ AMDs /gi;
                s/yapc/ yapsee /gi;
                s/bsd/ BSD /gi;

                s/(\d+)-/ $1 /gi;
                s/(?=\S)\.(?=\S)/ dot /gi;
                s/(?=\.)/ /g;
                y/"()//d;
                $_
}

__END__

Note that prepare_spoken is rather primitive; some more general rules would be appreciated. Send suggestions to marcel@cpan.org.