Thursday, March 10, 2005

PHP error...

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /dirname/filename.php(000) : eval()'d code on line 3

put {} around the $_SERVER['VARIABLE'] like this: ${_SERVER['VARIABLE']}

Wednesday, March 09, 2005

awk bits...

# List of logins


who | awk '{name[n++]=$1};END{for(i=1;i<=n;i++){printf name[i]" "}; print ""}'


# List of unique logged in users


who|awk '{w[$1]=$1};END{for(n in w)printf" "n}'

Tuesday, March 08, 2005

10 years and still counting...

Crazy... 10 years at this now, and I'm still learning the basics...

Take a break ... command :o) ...


DATE=$(date +'%y%m%d')
for VER in $(seq -f %02g 99)
do
    if [ -f file_${DATE}-${VER}.tar -o -f file_${DATE}-${VER}.tar.gz ]
    then
        echo "file_${DATE}-${VER}.tar already exists..."
    else
        tar cvf file_${DATE}-${VER}.tar clean
        gzip -9 file_${DATE}-${VER}.tar
        break
    fi
done


Never needed it till now... but I was thinking... .o0(I need to break out... what would the command be?)

Or driving sed... instead of:


    sed 's/^ *//g' | grep .


how about:


    sed -n 's/^ *//g;/./p'


:o)

Monday, March 07, 2005

Very cute...

I was wondering last night .oO(has anyone written a text editor in Perl?) - not an x app like ptked, but a console app... and yes of course they have...

http://ped.sourceforge.net/

- one of the monks has even done vi :o)
https://sourceforge.net/projects/vip
http://perlmonks.thepen.com/41736.html

Oh, and... http://ppt.perl.org/commands/ed/index.html

Sunday, March 06, 2005

Babygimp Homepage

Babygimp Homepage

Yeah! - Just what I needed... the tool that's under Gimp...

I used to use Windows paintbrush, but more often than not I needed to save it to xpm and take it back to Linux and tweak it... now I can save it as xpm native :o) perfect... it's the tool for pixel tweaking.

Friday, March 04, 2005

De Morgan's Theorem...

Does logic do your head in?


if(!condition1 | !condition2) equals if(!(condition1 & condition2))

And

if(!condition1 & !condition2) equals if(!(condition1 | condition2))

Perl multi-line match...

davis gave me the answer nicely...


#!/usr/bin/perl

use warnings;
use strict;

local $/;
$_ = <DATA>;

$_ =~ s/<table>\n<tr>/<!-- TABLE START -->/i;

print;

__DATA__

<TABLE>
<TR>
<TD>



And also added:

you can ignore leading spaces with:


$_ =~ s/\s*]*>\n\s*/\n/ig

Wednesday, March 02, 2005

Missing header files...


$ make hello
cc hello.c -o hello
hello.c:1:19: stdio.h: No such file or directory
hello.c:2:20: unistd.h: No such file or directory
hello.c: In function `main':
hello.c:89: error: `stdout' undeclared (first use in this function)
hello.c:89: error: (Each undeclared identifier is reported only once
hello.c:89: error: for each function it appears in.)
make: *** [hello] Error 1

# apt-get install libc6-dev

Hello, world!

:o)
(humming "the stripper"):

#!/bin/bash
/usr/bin/strip --remove-section=.comment --remove-section=.note --strip-all $@

Thursday, February 17, 2005

Need to update all of the CPAN modules on a server?

If you are using the CPAN module within Perl, you can update all of the installed modules on your system using the command:


perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)'


This forces CPAN to produce a list of all of the outdated modules on the machine and install them in one hit...

Not recommended for your average joe. you'll have to go over all of your module dependecies and check to see if updates break any of your live code.. still though there are instances where this can be useful.

Something else to think about... have a look here:


lrwxrwxrwx 1 root root 5 Feb 5 21:36 /usr/lib/perl/5.8 -> 5.8.4
drwxr-xr-x 5 root root 4096 Jan 30 2004 /usr/lib/perl/5.8.2
drwxr-xr-x 4 root root 4096 May 4 2004 /usr/lib/perl/5.8.3
drwxr-xr-x 30 root root 4096 Feb 17 18:05 /usr/lib/perl/5.8.4
drwxrwsr-x 9 root staff 4096 Mar 7 2002 /usr/local/lib/perl/5.6.1
drwxrwsr-x 21 root staff 4096 Dec 5 2003 /usr/local/lib/perl/5.8.0
drwxrwsr-x 4 root staff 4096 Oct 30 2003 /usr/local/lib/perl/5.8.1
drwxrwsr-x 11 root staff 4096 Mar 25 2004 /usr/local/lib/perl/5.8.2
drwxrwsr-x 12 root staff 4096 Jan 23 10:59 /usr/local/lib/perl/5.8.3
drwxrwsr-x 27 root staff 4096 Feb 17 18:08 /usr/local/lib/perl/5.8.4


On a box where Perl has been upgraded a few times there will be lots of old dirs with modules in...