jueves, 29 de septiembre de 2011

Warning: date(): It is not safe to rely on the system's php.ini


Editar /etc/php.ini y añadir:
date.timezone = "Europe/Madrid"

domingo, 4 de septiembre de 2011

Comparar 2 ficheros de texto línea a línea

Siempre lo intento hacer con el comando "comm", pero nunca sale el resultado esperando si el fichero es demasiado grande.. en perl:

#!/usr/bin/perl

use Data::Dumper;


open(A,"$ARGV[0]");
@a1=;
close A;

open(B,"$ARGV[1]");
@a2=;
close B;

my @a  = array_differenz(\@a1, \@a2);
foreach (@a) { print; }


sub array_differenz ($$) {
my $a1   = shift; # array reference
my $a2   = shift; # array reference

my @a1m2 = @$a1;  # array 1 minus array 2;

for my $element (@$a2) {
for my $index (0..$#a1m2) {
if ($element eq $a1m2[$index]) {
splice @a1m2, $index, 1;
last;
}
}
}

my @a2m1 = @$a2;  # array 2 minus array 1;

for my $element (@$a1) {
for my $index (0..$#a2m1) {
if ($element eq $a2m1[$index]) {
splice @a2m1, $index, 1;
last;
}
}
}

return (@a1m2, @a2m1);

} # sub array_differenz


jueves, 1 de septiembre de 2011

Velocidad en discos USB en linux

De: http://www.linux-usb.org/FAQ.html#i5

A:For USB Mass Storage devices (that is, devices which use the usb-storage driver) max_sectors controls the maximum amount of data that will be transferred to or from the device in a single command. As the name implies this transfer length is measured in sectors, where a sector is 512 bytes (that's a logical sector size, not necessarily the same as the size of a physical sector on the device). Thus for example, max_sectors = 240 means that a single command will not transfer more than 120 KB of data.

Linux 2.6 gives you the ability to see and to change the max_sectors value for each USB storage device, independently. Assuming you have a sysfs filesystem mounted on /sys and assuming /dev/sdb is a USB drive, you can see the max_sectors value for /dev/sdb simply by running:

cat /sys/block/sdb/device/max_sectors
and you can set max_sectors to 64 by running (as root):

echo 64 >/sys/block/sdb/device/max_sectors
Values should be positive multiples of 8 (16 on the Alpha and other 64-bit platforms). There is no upper limit, but you probably shouldn't make max_sectors much bigger than 2048 (corresponding to 1 MB, which is quite a lot).

In general, increasing max_sectors will improve throughput since it means that larger amounts of data can be transferred in a single command with no need for being split up among multiple commands. Of course this is subject to diminishing returns when max_sectors is very big. More importantly, it's true only up to a point. Many devices have limits on the amount of data they can transfer, and if you try to exceed that limit you will most likely crash the device.