Archive for February, 2010

Ever want to immediatly serve content from a specific directory over HTTP, but didn’t want to bother messing with
httpd.conf or other webserver configiurations?

If you’ve got Python installed, this is a snap. Execute python with the SimpleHTTPServer module, using port 8080 so
there isn’t a need to elevate privs to root.

 python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 …

or python3 -m http.server 8080

Sure enough, pointing a browser to the IP address :8080 of the box hits my home directory listing. Super easy, super
fast, super simple!

I use this to serve content to my PS3. The PS3 doesn’t support NFS or CIFS, so to download content to the hard drive,
the best method is by pulling it over HTTP with the embedded web brower. On my MacBook, I change into the directory
containing whatever media I want to transfer, fire up HTTP, and suck it down to the hard drive on the PS3. Nice!

source: http://prefetch.net/blog/index.php/2009/10/31/serve-out-content-over-http-from-your-cwd-immediatly/

C:\Program Files\PS3 Media Server\win32>mencoder d:\77\DSC_0215.AVI -ovc x264 -x
264encopts bitrate=3200 -oac mp3lame -o d:\77\plc.mkv

You may check first what is the path of sendmail:
whereis sendmail or php -i | grep sendmail
move /usr/sbin/sendmail to something like /usr/sbin/sendmail.or
vi /usr/sbin/sendmail
put the code below:

#!/usr/bin/perl
# use strict;
use Env;
my $date = `date`;
chomp $date;
open (INFO, ">>/var/log/formmail.log") || die "Failed to open file ::$!";
my $uid = $>;
my @info = getpwuid($uid);
if($REMOTE_ADDR) {
print INFO "$date - $REMOTE_ADDR ran $SCRIPT_NAME at $SERVER_NAME \n";
}
else {
print INFO "$date - $PWD - @info\n";
}
my $mailprog = '/usr/sbin/sendmail.or';
foreach (@ARGV) {
$arg="$arg" . " $_";
}
open (MAIL,"|$mailprog $arg") || die "cannot open $mailprog: $!\n";
while (<STDIN> ) {
print MAIL;
}
close (INFO);
close (MAIL);


chmod a+x /usr/sbin/sendmail
touch /var/log/formmail.log
and chmod 777 /var/log/formmail.log

that should be all.

Full list of available commands    Ctrl-a Ctrl-?
Open a new screen in existing session    Ctrl-a Ctrl-c
Switch to last accessed screen    Ctrl-a Ctrl-a
Switch to next screen    Ctrl-a Ctrl-n
Switch to previous screens    Ctrl-a Ctrl-p
Disconnect, leaving the session running in background    Ctrl-a Ctrl-d
Split screen vertically    Ctrl-a Ctrl-S
Unsplit screen    Ctrl-a Ctrl-Q
Move focus between splits    Ctrl-a Ctrl-Tab
List currently opened screens    Ctrl-a Ctrl-S
Rename current screen    Ctrl-a Ctrl-A
Monitor a screen for silence    Ctrl-a Ctrl-_
To disconnect (but leave the session running)
Hit Ctrl + A and then Ctrl + D in immediate succession. You will see the message [detached]
To reconnect to an already running session
screen -r
To reconnect to an existing session, or create a new one if none exists
screen -D -r
To create a new window inside of a running screen session
Hit Ctrl + A and then C in immediate succession. You will see a new prompt.
To switch from one screen window to another
Hit Ctrl + A and then Ctrl + A in immediate succession.
To list open screen windows
Hit Ctrl + A and then W in immediate succession

wget --user-agent Firefox --save-headers --referer "http://www.google.com/search?q=duuude" "example.com"

<?php
$password = crypt(‘mypassword’ , ‘d4’);
print $password . ” is the CRYPT_STD_DES version of mypassword<br>”;
$password = crypt(‘mypassword’ , ‘k783d.y1g’);
print $password . ” is the CRYPT_EXT_DES version of mypassword<br>”;
$password = crypt(‘mypassword’ , ‘$1$d4juhy6d$’);
print $password . ” is the CRYPT_MD5 version of mypassword<br>”;
$password = crypt(‘mypassword’ , ‘$2a$07$kiuhgfslerd………..$’);
print $password . ” is the CRYPT_BLOWFISH version of mypassword<br>”;
?>

This will output something like this:

d4/qPbCcJ5tD. is the CRYPT_STD_DES version of mypassword
k7xEagYCDPPSc is the CRYPT_EXT_DES version of mypassword
$1$d4juhy6d$a.jIPYnvne1FWF2V6mGQR0 is the CRYPT_MD5 version of mypassword
$2a$07$kiuhgfslerd………..6k0kSI76CqJ/RWGnSp9MWRDF91gJZfW is the CRYPT_BLOWFISH version of mypassword

<?
$data = array(0, 1, 2, 'three', 4, 5, 'six', 7, 8, 'nine', 10);
$mod1 = preg_grep("/4|5|6/", $data);
$mod2 = preg_grep("/[0-9]/", $data, PREG_GREP_INVERT);
print_r($mod1);
echo "<br>";
print_r($mod2);
?> 

http://php.about.com/od/advancedphp/ss/php_preg.htm

The way to execute PHP on a .html page is to modify your .htaccess file. This file may be hidden, so depending upon your FTP program you may have to modify some settings to see it. Then you just need to add this line for .html:

AddType application/x-httpd-php .html

Or for .htm

AddType application/x-httpd-php .htm

If you only plan on including the PHP on one page, it is better to setup this way:

AddType application/x-httpd-php .html

This code will only make the PHP executable on the yourpage.html file, and not on all of your html pages.

http://lerdorf.com/veracruz.pdf

cat /etc/passwd | awk -F: '{print $1}' | while read line; do echo $line; crontab -l -u $line; done