Tuesday, February 17, 2009

Auto Repair

Just changed a wheel bearing on the Impala, thanks to this video:

http://www.youtube.com/watch?v=Y-TsTn-3ktk

Also came across this good blog:

http://free-auto-repair-advice.blogspot.com/

Thursday, January 8, 2009

perlboot

Beginner's Object-Oriented Tutorial

It's a pretty nice tutorial accessible via 'perldoc perlboot'

As usual, it's also available on the web, for example:
http://perl.active-venture.com/pod/perlboot.html

Friday, December 12, 2008

Picture Backups

Just wanted to mark down my backup command... I also throw SSH in there sometimes to backup to a remote machine:

(cd /cygdrive/c/my_backup ; tar czf - Pictures_Backup) | gpg -o - -c - | split -b 512M - backup_

I noticed the flavor of "split" varied between cygwin and RHEL.

UPDATE:

A couple of new notes:

tar cvzf - DirToBackup | gpg -o - -c - | ssh me@some-server 'cd /backups/backupdir ; cat | split -b 512m - date_tar_gz_'

Then, use the following to produce "differential" backups:
tar cvzf - --newer "YYYY-MM-DD" DirToBackup | blah blah blah


(note to self: one canine pound)

Wednesday, November 12, 2008

Linux Kernel Modules

Just some info about Linux kernel modules. This faq gives some small examples to write. I'm just jotting it down because it's something I'd like to know a little more about in the future:

http://www.faqs.org/docs/kernel/x571.html

Tuesday, November 4, 2008

Perl and Dates

Just a quick code snippet I through together to remember some of the date parsing modules that seem to come standard with Perl 5:

use Date::Parse;
use Date::Format;
use strict;

my $date = "2008-12-30 05:00:00";
my $machine_time = str2time($date);
my $week = time2str("%U", $machine_time);
my $month = time2str("%L", $machine_time);

print < < EOF;

Date is: $date
Machine Time is: $machine_time
Week is: $week
Month is: $month

EOF

Thursday, October 30, 2008

OO Perl

Just wanted to jot down a good OO Perl site I came across:

Wikipedia had a decent example that got to the point:

So, here's some poop I through together just to use as my own reference. It's a Poop class!

(NOTE: Some of the lines may have been screwed up during the copying and pasting... but I don't care right now)


package Poop;
use strict;

our $VERSION = "1.0";
my $DEBUG = 0;

=head1 NAME

Poop - A pooping package.

=head1 SYNOPSIS

use Poop;
my $boy = Poop->new();
$boy->eat("Candy Bar", "Ice Cream");
$boy->poop() if $boy->turd();

=head1 DESCRIPTION

Just an OO Perl template

=head1 METHODS

=head3 new

my $cat = Poop->new();
my $dog = Poop->new(eat => @food, debug => 1, size => $size);

Instantiates a new Pooping object.
If a list of C<@food> is given, the object eats right away.
If $size is given, the object's stomach is set to that size (default 10).
If "debug" is a true value, debugging will be turned on.

=cut

sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my %params = @_;
my $self = {};

bless ($self, $class);

$self->debug($params{debug}) if exists $params{debug};

$self->{TURD} = 0;
$self->{FOOD} = [];
$self->{SIZE} = exists $params{size} ? $params{size} : 10;

$self->eat(@{$params{eat}}) if exists $params{eat};

return $self;

}

=head3 eat

my $dog = Poop->new();
$dog->eat("Dog food", "Dog bone");

Causes the object to eat the items in the list. The object will quit eating when it has to poop.
Returns a list of food it couldn't eat if it can't eat it all.
Returns an empty list if it ate it all.

=cut

sub eat($) {
my $self = shift;

$self->_DEBUG_PRINT("Eating...");

while (@_ && ! $self->turd()) {
my $f = shift;
push @{$self->{FOOD}}, $f;
print "-- Mmmmm... $f\n";
}

return @_;

}

=head3 turd

my $dog = Poop->new();
$dog->poop() if $dog->turd();

Reports whether the object has a turd. And object with a turd cannot eat anything else.

=cut

sub turd() {
my $self = shift;

$self->_DEBUG_PRINT("Checking for turd...");

return 1 if @{$self->{FOOD}} >= $self->{SIZE};
return 0;
}

=head3 poop

my $dog = Poop->new();
$dog->poop() if $dog->turd();

Makes the object poop. If there is no turd, it will return 0 and not poop.

=cut

sub poop() {
my $self = shift;
my @sounds = ("Grunt","Plop","Spphhlll","Splash","Pfffft");

$self->_DEBUG_PRINT("Entering pooping phase...");

if (! $self->turd()) {
$self->_DEBUG_PRINT("No turd to poop with...");
return 0;
}

while (my $food = shift @{$self->{FOOD}}) {
my $sound= $sounds[int(rand() * @sounds)];

print "-- $sound... $food\n";
sleep 1;
}

$self->{TURD} = 0;
}

=head3 puke

my $dog->puke();

Expells the most recent item ate. Returns the item if it existed, otherwise returns undef.

=cut

sub puke() {
my $self = shift;

my $last = pop @{$self->{FOOD}};

if ($last) {
print "-- Blahhhhh..... $last\n";
return $last;
}

return undef;
}


=head3 debug

$dog->debug();
$dog->debug(0);
$dog->debug(1);

Returns the current debug setting, sets it to false, or sets it to true (respectively).

=cut

sub debug($) {

my $self = shift;

return $DEBUG unless @_;

if ($_[0]) { $DEBUG = 1 }
else { $DEBUG = 0 }

return $DEBUG;
}

sub _DEBUG_PRINT ($) {
my $self = shift;
return unless $DEBUG;

print "-- DEBUG: " . shift;
print "\n";
}

1; # Really only need this unless you make this a .pm and "use" it.


#
# Just putting it all in one file...
#

package main;
#use Poop;

sub feed(@) {
my $obj = shift;

print "Feeding it: " . join(", ", @_) . "\n";
my @full = $obj->eat(@_);

if (@full) {
print "Couldn't eat: " . join(", ", @_) . "\n";
} else {
print "Ate it all. Good boy!\n";
}
print "\n";
}

my $dog = Poop->new(size => 5);

feed($dog, qw/Bones Chocolate Cat Soap/);
feed($dog, "Saw Dust", "Dog Food");
print "Puked up " . $dog->puke() . "\n";
print "Puked up " . $dog->puke() . "\n";
feed($dog, "Pie", "Hot Dog");
print "Go potty, boy:\n";
$dog->poop();
print "Good boy, here's a treat!\n";
$dog->eat("Treat");
print "Nooo!!! Don't puke in here!!!\n";
print "Puked: " . $dog->puke() . "\n";



Wednesday, October 29, 2008

Firefox Memory

Just a useful setting I found for Firefox to reduce the memory usage:
http://www.litfuel.net/plush/?postid=118

Basically, do the "about:config" and change the browser.sessionhistory.max_total_viewers setting. By default, this caches 10 pages per tab.