2012/04/27

mount windows share

/etc/fstab:
//our_share/michael /mnt/my_share smbfs users,rw,noperm,credentials=/etc/samba/cred-file,forceuid=michael,forcegid=admin 0 0

/etc/rc.local:
mount //our_share/michael

2012/04/19

link button

[ a style="display:block; padding: 3px 20px; border: 1px solid #b2b2b2; background: #ccc; text-decoration: none; float: left; color: black; font-size: 14px;" href="" ]

2012/04/13

ENV

DOCUMENT_ROOT: /home/user/localhost
GATEWAY_INTERFACE: CGI/1.1
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.7
HTTP_ACCEPT_ENCODING: gzip, deflate
HTTP_ACCEPT_LANGUAGE: en-us,en;q=0.5
HTTP_CACHE_CONTROL: max-age=0
HTTP_CONNECTION: keep-alive
HTTP_HOST: localhost
HTTP_USER_AGENT: Mozilla/5.0 (X11; Linux i686; rv:2.0.1) Gecko/20100101 Firefox/2.0.1
PATH: /usr/local/bin:/usr/bin:/bin
QUERY_STRING: key=value
REMOTE_ADDR: 127.0.0.1
REMOTE_PORT: 49185
REQUEST_METHOD: GET
REQUEST_URI: /cgi-bin/env.pl?key=value
SCRIPT_FILENAME: /home/user/localhost/cgi-bin/env.pl
SCRIPT_NAME: /cgi-bin/env.pl
SERVER_ADDR: 127.0.0.1
SERVER_ADMIN: webmaster@localhost
SERVER_NAME: localhost
SERVER_PORT: 80
SERVER_PROTOCOL: HTTP/1.1
SERVER_SIGNATURE:
Apache/2.2.20 (Ubuntu) Server at localhost Port 80

SERVER_SOFTWARE: Apache/2.2.20 (Ubuntu)

2012/04/11

matcher

#!/usr/bin/perl

$string = 'abcdefg efgdabcz';

$matched = $string =~ /ab.{2}/g;
($match) = $string =~ /ab.{2}/g;
($match1, $match2) = $string =~ /ab.{2}/g;
@matches = $string =~ /ab.{2}/g;
$count = @matches = $string =~ /ab.{2}/g;

print "matched: [$matched]\n";
print "match: [$match]\n";
print "match1: [$match1], match2: [$match2]\n";
print "matches: [@matches]\n";
print "count: [$count]\n";

2012/04/02

Regex modifiers

/m    (^) ... ($)  \n  (^) ... ($)
/s    (^) ...  $  (\n)  ^  ... ($)
/ms   (^) ... ($) (\n) (^) ... ($)

         (\A) ... \n ... (\Z) \n
         (\A) ... \n ...     (\z)


###
havoc without [ms]:

#!/usr/bin/perl

$str = "abc\ndef\nghi";

print 'NO [m] [s]: ';
if ( $str =~ m/^(\w{1}).*(\w{1})$/ )
{
        print "$1::$2";
}
print "\n";


print '[m]: ';
if ( $str =~ m/^(\w{1}).*(\w{1})$/m )
{
        print "$1::$2";
}
print "\n";


print '[s]: ';
if ( $str =~ m/^(\w{1}).*(\w{1})$/s )
{
        print "$1::$2";
}
print "\n";

# s/// is ok (/s by default)
print "[change]: \n";
$str =~ s/def//;
print "$str\n";