sonia hamilton – life on the digital bikepath – sonia@snowfrog.net

2 July 2009

Firefox – default paper size A4

Filed under: Firefox — Sonia @ 09:39

A bug that has been dragging on for years – Firefox under Ubuntu (and other distros) doesn’t respect the locale setting, and defaults to printing in US Letter size – grrrr…

Firefox: Guide for the Perplexed seems to suggest:

  • about:config
  • print.postscript.paper_size set to “A4″

Now to see if it holds, and work out a way to script this (I have a set of bash scripts that keeps all my Ubuntu desktops the same).

29 June 2009

Oracle RMAN backups

Filed under: Oracle — Sonia @ 11:59

More notes on Oracle RMAN backups, see also Oracle – how to purge old RMAN backups. Thanks Raoul for your email…

Are the backups being deleted using RMAN or simply 'rm'?

Oracle's RMAN can be set up to manage this for you based on RETENTION POLICY.  Eg, set retention policy to recovery window of 14 days and
it will regard any backups older than 14 days to be OBSOLETE. Obsolete backups can be removed regularly using this:
 DELETE NOPROMPT OBSOLETE;
in a script that RMAN runs, for example, the daily backup script.

Here's a quick rundown of the rman commands you might find useful:

-- list all configuration parameters
SHOW ALL;

-- check for spurious files in FRA (backup location)
-- typically, these can be safely deleted
-- but check messages/output first.
CATALOG RECOVERY AREA NOPROMPT;

-- check to see what backups are available in the backup
-- destination area (refresh with what's available)
-- missing ones are marked as EXPIRED
CROSSCHECK BACKUPSET;
CROSSCHECK COPY;

-- delete all obsolete backups
-- this physically removes the backup pieces from the backup
-- destination and removes knowledge of them from the control
-- file this is performed based on the RETENTION policy
DELETE NOPROMPT OBSOLETE;

-- delete all expired backups, etc
-- this is clearing the knowledge of such EXPIRED (missing)
-- backups from the control file
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED COPY;

Once you've set the retention policy, then the following backup script (or one like it) will remove old backups automatically.

-- full back, deleting archive logs after backing them up
backup device type disk tag '%TAG' database;
backup device type disk tag '%TAG' archivelog all not backed up delete all input;
allocate channel for maintenance type disk;
delete noprompt obsolete device type disk;
release channel;

Example of what to do if system runs out of disk space due to archive logs:

crosscheck archivelog all;
delete expired archivelog all;
backup archivelog all delete input;
backup database;

17 June 2009

Another year, another Sydney Film Festival

Filed under: Uncategorized — Sonia @ 15:25

Another year, another Sydney Film Festival. Two films I saw really stood out – The Cove (about the continued Japanese dolphin slaughter) and Che Part I and Part II (covering the Cuban and Bolivian years of Ernesto ‘Che’ Guevara). Also memorable was Big River Man, about a middle aged  Slovenian man who swims the entire length of the Amazon river.

Like always (this is my approx 15th festival), I start the festival with feelings of both anticipation and trepidation – anticipation that I’ll see some great films, and trepidation at the long nights and weekends in the dark, followed by getting up in the morning for work :-) But there’s nothing like seeing a great movie with several thousand other cineastes in the splendour of the State Theatre to renew my love of good cinema.

The Cove works at multiple levels. Firstly we’re made to enjoy the almost James Bond nature of the film makers’ mission, as the team try to infiltrate the area where the slaughter takes place in Taiji, Japan – think spies and decoys, cameras disguised as rocks, and run-ins with guards. Then we’re made to feel revulsion at the killing of these animals that are so like us – they love their freedom, get happy, sad, even commit suicide, and most of all are sentient (as in “having self awareness”). The scenes of the actual slaughter are gut-wrenching – thousands of dolphins are herded into a 100m wide cove and killed by hand with harpoons. Dolphins in their death throws spin around in circles screaming, thrashing their tails, and even jumping onto land. The blood filled seawater turns opaque and divers feel their way along the seabed by hand, searching for carcasses.

But then the film starts to ask some deeper questions. First of all, dolphin meat contains high levels of mercury due to pollution and is basically poisonousness and unsaleable. Eating meat with these levels of mercury leads to large numbers of horrendous birth defects – which the Japanese unfortunately became aware of in the 70’s – a whole generation of birth defects forcing the closure of  many polluting industries in Japan. So why keep up with the “harvest”, even if the meat has to be foisted onto the Japanese public via illegal meat substitution and Yakuza links? The answers seem to involve dirty international politics and ugly right wing Japanese nationalism.

Secondly, inorganic pollutants are concentrated as we move up the predator-prey cycle, and dolphins (like wolves, lions, humans) are at the top of the food chain. Dolphin meat contains so much mercury that it’s inedible – what about us? How is that we can poison our environment so much that we’re poisoning ourselves?

9 June 2009

Source keychain credentials in Perl

Filed under: Perl, Ssh — Sonia @ 12:16

I use keychain for securely caching my ssh key credentials when running scripts from cron.

Here’s how to use keychain with Perl scripts:

Create a wrapper script:
source ~/.keychain/hostname-sh
run_perl_program.pl

To run a one-off command do:

system("source ~/.keychain/hostname-sh; cmd");

5 June 2009

ruby gem server

Filed under: Ruby on Rails — Sonia @ 12:41

I’m back to Rails development after a few months doing other things. Note to brain: the ruby gem server is now started using gem server & rather than gem_server &, like it used to be… </frustration>

Offline rdoc gem documentation in Ruby

2 June 2009

Perl – @INC

Filed under: Perl — Sonia @ 09:34

@INC – like $PATH for do, require, use

Display existing @INC:

  • perl -V | tail
  • perl -le ‘print for @INC’

Modify @INC:

  • in a script: unshift @INC, “/home/sonia/lib/perl”
  • better: use lib ‘/home/sonia/lib/perl/’;
  • for shell: export PERL5LIB=/home/sonia/lib/perl
  • onetime at command line: perl -I/home/sonia/lib/perl foo

Also:

22 May 2009

Perl – my, use vars, our, local, use strict

Filed under: Perl — Sonia @ 18:16

Some notes for me as I attempt to get a better understanding of Perl’s variable scoping rules. A work in progress…

  • Perl has 2 separate ‘namespaces’ for variables – package aka global (Perl 4) and my aka private aka lexical scoping (Perl 5)
  • the default package is main, this can be changed with the statement package foo; which then applies to all subsequent code until another package statement is encountered
  • lexical scoping is done with {} (either via subroutines/operators or ‘naked blocks’); the top level is the file itself (’file level’).
  • use strict; (specifically use strict ‘vars’;) requires that variables either use a package qualifier (eg $main::foo) if they’re package variables or be lexical variables declared with my. You can get around this extra typing for package variables with use vars (or no strict ‘vars’ for a block)
  • our($foo,$bar) is like use vars qw($foo $bar), however it’s lexical ie can be restricted by {}’s (an equivalent no use vars doesn’t exist). Looked at it another way, our ’spans’ package declarations (as it’s lexical) whereas use vars is ‘reset’ by package declarations.

Also:

  • dynamic scoping is done with local – see Wikipedia – Scope (programming). Lexical scoping is the norm in modern programming languages, dynamic scoping is a Lisp’y idea that uses a sort of stack for variable scope resolution, that can only be determined at runtime.  When to use local? Rarely… Seven Useful Uses of local
  • local only works with package variables not lexical/my variables; an example of where local can be useful is to temporarily change a Global Special Variable (eg $) $EFFECTIVE_GROUP_ID) before calling a subroutine: “local saves away the value of a package global and substitutes a new value for all code within and called from the block in which the local declaration is made” eg
{
    local $) = getgrnam(USER) if $< == 0;
    enable($host);
}
  • do C-style static variables in this manner:
        { my $seed = 1;
          sub my_rand {
            $seed = int(($seed * 1103515245 + 12345) / 65536) % 32768;
            return $seed;
          }
        }
  • xx

Some Links:

Firewalling on Solaris 10

Filed under: Iptables, Solaris — Sonia @ 12:31

Firewalling on Solaris 10:

  • config file: /etc/ipf/ipf.conf
  • flush all rules: ipf -Fa
  • reload: ipf -f /etc/ipf/ipf.conf

Email from Julian:

The native firewall that comes with Solaris is “ipf”.

Configuration files are in the directory /etc/ipf and the file is “ipf.conf”, NAT rules in “ipnat.conf”. Unlike iptables, where the configuration file is a series of “iptable” commands, “ipf.conf” is purely a configuration file. Traffiic must be enabled on each interface, so you have “pass in” to allow traffic in on interface A and a “pass out” to allow traffic out on interface B, if it is acting as a firewall, obviously this is not.

As of Solaris 10, processes are started via service manager. To check if ipf is running, you can:

# svcs -a |grep ipf
online May_05 svc:/network/ipfilter:default

“online” status tells you that it is running.

Commands to see what is happening.

“ipfstat”: show statistics, bytes in, bytes out etc.

“ipfstat -i” to display input running rule set

“ipfstat -o” to display output running rule set

“ipf -f /etc/ipf/ipf.conf” to load rules from config file.

“ipmon -s [file]” to have ipf log to “file”

To restart using service manager

“svcadm restart svc:/network/ipfilter:default”

See man page for “ipnat” for options to display NAT options.

Link from Rusty’s blog: http://ozlabs.org/~rusty/index.cgi/2006/08/15

Last word: Solaris’s version of tcpdump is “snoop”. So to monitor traffic: “snoop -d e1000g0 not port 22″ you can add “-v” etc.

9 May 2009

Perl – use, require, import, and do

Filed under: Perl — Sonia @ 21:43

Some notes on Perl’s use, require, import and do. Quick notes for me; not meant to be authoritative…

  • use is done at ‘compile-time’ and require is done at ‘run-time’ (ie can conditionally load modules)
  • require is the older method, but use uses require to do it’s work:

use Foo;   # equivalent to:
require Foo; Foo->import();
.
use Foo qw (foo bar);   # equivalent to:
require Foo; Foo->import(qw(foo bar));
.
use Foo();   # equivalent to:
require Foo;   # ie don't import anything, not even the default things

  • a Library is a just a file of code; a Module has package Foo in it (and usually other stuff)
  • use only works with modules, whereas require works with both modules and libraries. Corollary: use only works with module names (Foo), whereas require also works with paths (eg ~/lib/foo.pm)
  • require Foo will check if Foo has already been loaded, whereas do Foo will unconditionally reload Foo
  • better practice is to write modules rather than librarys, to prevent namespace pollution. A simple module:

package Foo;   # minimal. Usually add things like:
use base qw (Exporter);
our @EXPORT = qw(qux slarken);   # keep this list small - namespace pollution

  • to use this module:

use lib '~/lib'; # add this to %INC
use Foo;   # loads module, imports symbols in @EXPORT
Foo->bar();   # correct
Foo::bar();   # works, but not for inherited methods
qux();   # works, due to export
bar();   # carks

Some links:

4 May 2009

Syncing Palm Pilot with JPilot and visor on Ubuntu

Filed under: PalmPilot, Ubuntu — Sonia @ 17:24

(Updated May/09 for Ubuntu 8.10/Ibex): for a long time I couldn’t get JPilot syncing with my Palm Pilot on Ubuntu 8.04 and 8.10. Turns out I wasn’t reading my own instructions… here’s the cleaned up version:

  • load visor module sudo modprobe visor and check loaded lsmod | grep visor
  • add visor module to /etc/modules
  • click sync button on Palm Pilot and check USB devices are being created:
    • in one terminal, tail -f /var/log/messages
    • in a second terminal, check the ownership of links ls -al /dev/ttyUSB* and check you are a member of the appropriate group (usually dialout) grep dialout /etc/group
  • sudo aptitude install jpilot and start JPilot
  • read this step carefully: no need to change the Serial Port setting in Preferences – JPilot will pick up the correct one on the first sync (which is now unexpectedly Other rather than /dev/ttyUSBO or usb:)
  • read this step carefully: from jpilot File > Install User, click sync button on Palm Pilot, count to 5, then click Install User button in JPilot dialog box
  • click sync button on Palm Pilot, count to 5, then click Sync in JPilot
  • if syncing isn’t working (especially on a machine that’s been upgraded from an older version of Ubuntu), try closing JPilot, mv .jpilot .jpilot.bak, restarting JPilot, then doing the Install User steps again

See also:

http://www.linuxquestions.org/questions/showthread.php?t=79965

http://ask.slashdot.org/article.pl?sid=05/05/13/0234225

http://www.linuxmuse.com/articles.php?action=printerf&article=29

http://www.linuxquestions.org/questions/showthread.php?t=177780

http://www.linuxquestions.org/questions/showthread.php?t=221854

http://www.rockhopper.dk/linux/hardware/pda.html#chap5_sect1

http://archives.mandrivalinux.com/expert/2003-02/msg02508.php

http://www.faqs.org/docs/Linux-HOWTO/PalmOS-HOWTO.html#PC-CONNECT-USB

http://pilot-link.org/README.usb

Carsten Clasohm’s Blog : USB Palm and Fedora Core 3

Writing udev rules by Daniel Drake

Linux Magazine – The Linux Device Model

Older Posts »

Blog at WordPress.com.