Del.icio.us
I started using del.icio.us and I'm loving it!
Beelerspace has a pretty nice delicious HOWTO going.
I want to write more about his phenom, but I need some time to really dit into it.
Link to story
Technorati tags for this post: Tech programming python
# ssh -M -S ~/.ssh/remote-mux user@remotehostSsh will start a session as usual and also open up a Unix domain socket using the filename you provide in the ControlPath argument (-S option). To start another ssh session to the same host, you can do:
# ssh -S ControlPath=~/.ssh/remote-mux user@remotehostSsh will skip authentication (as you've already auth'd to remotehost) and will use the existing TCP connection for the second connection. The upshot of this is that logging in a second (or third!) time is instantaneous. Adding the -S and -M options on the command line is tedious. You can setup your .ssh/config file like this:
For your first connection, do:Host remotehost HostName remotehost User user ControlMaster yes ControlPath ~/.ssh/remote-mux Host remotehostfast HostName remotehost User user ControlMaster no ControlPath ~/.ssh/remote-mux
# ssh remotehostFor your subsequent connections, do:
# ssh remotehostfastLink to story
./extract_ics.pl -m ~/Mail/meetings -d ~/calendar -v
#!/usr/bin/perl -w
use strict;
use Email::Folder;
use Email::MIME;
use Time::Local;
use Date::Parse;
use Getopt::Std;
######################################################################
# #
# Find text/calendar MIME attachments in mailboxes and save them #
# into a local folder for import into Sunbird #
# #
######################################################################
# parse cmd line options
my $verbose = 0;
my %opts = ();
getopts('vm:d:', \%opts);
if ( ! $opts{'d'} or ! $opts{'m'} ) { usage(); }
if ( $opts{'v'} ) { $verbose = 1; }
my $maildir = $opts{'m'};
my $savedir = $opts{'d'};
# is -m a single mailbox or a maildir ?
if ( -f $maildir ) { parse_box($maildir); }
else {
# find all the mailboxes in our maildir
opendir(DIR, "$maildir") or die "Couldn't open directory $maildir";
my @boxes = grep { -f "$maildir/$_" && ! m/\.msf$/ && ! m/^\./ } sort readdir(DIR);
closedir(DIR);
foreach my $b ( @boxes ) { parse_box("$maildir/$b"); }
}
exit 0;
sub usage {
print qq(Usage: $0 -m -d [-v]\n);
exit 1;
}
# find all text/calendar MIME attachments in a mailbox
sub parse_box {
my $box = shift;
print "Reading mailbox $box\n" if $verbose;
my $folder = Email::Folder->new($box);
# foreach my $m ( $folder->messages ) {
while ( my $m = $folder->next_message ) {
# $m is an Email::Simple class, Email::MIME requires a string
my $parsed = Email::MIME->new($m->as_string);
my @parts = $parsed->parts;
foreach my $p ( @parts ) {
if ( $p->content_type =~ m|text/calendar| ) {
write_ics($p, $m->header("Subject"), $m->header("Date"));
}
}
}
}
# write attachments to a local folder
sub write_ics {
my ($p, $subject, $date) = @_;
# sanitize the subject line so I can use it as a filename
$subject =~ s/\s+/_/g; # no spaces
$subject =~ s|/|_|g; # no slashes
$subject =~ s|_+|_|g; # remove duplicate underscores
my $filename = "${savedir}/${subject}.ics";
if ( -f $filename ) {
print "WARNING: overwriting $filename\n" if $verbose;
}
if ( ! open(ICS, ">$filename") ) {
print qq(WARNING: failed to open $filename for writing\n);
return;
}
print "Writing $filename\n" if $verbose;
print ICS $p->body, "\n";
close ICS;
# set date of the file to date of email Date header
my ($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($date);
my $newtime = timelocal(0, $mm, $hh, $day, $month, $year);
utime $newtime, $newtime, $filename;
}
Update: Make sure you "compact" your Mozilla folder before you run the script. There are likely to be "deleted" messages in it.
Technorati tags for this post: Tech email thunderbird perl
rel="nofollow" attribute. So blog software authors
are encouraged to add that attribute to any links in comments or trackbacks.
Cool! Maybe I'll enable html in comments now.
Link to story
-i switch of lsof. The argument to -i can be either a protocol (TCP|UDP), a hostname or ip address or a port number. Or any combination of the above. The result: a nice listing of the processes with connections that match your criteria.
screen -r to get your whole screen session back.
Here's my personal ~/.screenrc
# no startup msg
startup_message off
# new windows go to home dir
chdir
# keep some status lines on bottom of screen
caption always "%{= bb}%{+b w}%n %h %=%t %c"
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
activity "Activity in %t(%n)"
# Create 3 more screens. They will exit once the designated
# program quits.
screen -t misc 0
screen -t mutt 1 mutt
screen -t www 2 lynx -book
# move to the main shell
number 0
Technorati tags for this post: Tech email thunderbird perl
Technorati tags for this post: Tech email thunderbird perl linux