lunes, 20 de diciembre de 2010

RECUPERAR GRUB: UBUNTU 10.4

Inicia con un live-cd de Ubuntu.
En una consola (aplicaciones - Accesorios - Terminal)
Ejecuta:

sudo su
mount /dev/sdb5 /mnt
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt
update-grub
grub-install /dev/sda
grub-install --recheck /dev/sda
Ctrl+D para salir de chroot.
umount /mnt/sys
umount /mnt/proc
umount /mnt/dev
umount /mnt
reboot

domingo, 12 de diciembre de 2010

MULTIPROCESO PERL FORK

1) INTRODUCCIÓN.
Muchas veces realizamos acciones que pueden hacerse en paralelo,
por ejemplo generar 6 tomos de un libro en latex. Cada tomo puede generarse
de forma independiente.

El objetivo es que si se tienen 4 procesadores cada procesador genere
un libro, y cuando termine siga generando otro libros.

La conclusión es que tarda 1/3 parte menos de tiempo en realizar
las tareas.

Esta basado en el programa jigl, que genera albunes de fotos, a una
velocidad de vértigo) el cual consulte las fuentes
para poder hacer mi propio script.


2) SCRIPT EN PERL

#!/usr/bin/perl -w
# Por Paco Aldarias
# Fecha: 12/12/2010
# Pasado en: jigl
# Script que genera tomos en paralelo

use Cwd;

my $MP_MAX_JOBS = mp_detect_cpu();
print "Número procesadores: $MP_MAX_JOBS";
my $startDir = cwd;

&main();

###########################################################
sub mp_detect_cpu
{
my $r = `grep processor /proc/cpuinfo |wc -l`;
mp_debug("Detected $r cpu.\n");
return $r;
}
###########################################################
sub mp_debug($)
{
print "mp[$$]: ". $_[0];
}
###########################################################
sub mp_wait_jobs($)
{
my($n) = @_;

while(1){
my $running = scalar(keys %mp_jobs);
mp_debug("$running job(s) currently running.\n");

last if $running <= $n; mp_debug("Waiting...\n"); # Wait for a job to finish. my $c = wait(); my $rc = $?; mp_debug("-> $c ($rc)\n");

# Sanity checks.
if($c < 0){
print "mp: wait() returned $c. Strange!\n";
}

if(!exists $mp_jobs{$c}){
print "mp: wait() returned $c, but job is not"
." in mp_jobs. Strange!\n";
}

# Check the return code and die if non-zero.
die $mp_jobs{$c} if $rc;

# Forget job.
delete $mp_jobs{$c};
}
}
###########################################################
sub mp_wait_for_free_slot()
{
mp_wait_jobs($MP_MAX_JOBS - 1);
}
###########################################################
sub mp_wait_for_all_jobs()
{
mp_wait_jobs(0);
}
###########################################################
sub mp_launch($$)
{
my($cmd, $die_msg) = @_;

# Wait for a free slot first.
mp_wait_for_free_slot();

# Ok, fork.
my $r = fork();

if(!$r){
# We are in the child.
# Do the job.
mp_debug("Running $cmd \n");
exec($cmd);

} else {
# We are in the father.
# Remember the child as well as the die msg.
mp_debug("Launched $r.\n");
$mp_jobs{$r} = $die_msg;
}
}

######################################################3
sub main {

my @carpetas=`find . -type d -name \"tic1tomo?-*\" | cut -d "/" -f2`;

foreach $c (@carpetas) {

#Eliminamos saltos de linea.
$c =~ s/\n//g;
$c =~ s/ //g;

my @f = split("-",$c);

print "Carpeta: $c Fichero: $f[0]\n";

chdir $startDir;
chdir "./".$c;
$cmd = "pdflatex -interaction nonstopmode /home/paco/Dropbox/ceed1011/apuntes/".$c."/".$f[0].".tex -output-directory /home/paco/Dropbox/ceed1011/apuntes/".$c."/";
print "Comando: $c";
$dieMsg = "Mensaje Error\n";
mp_launch($cmd, $dieMsg);

}

mp_wait_for_all_jobs();

}
######################################3

domingo, 21 de noviembre de 2010

EXTRAER VIDEO EN UBUNTU DE UN DVD: DVDRIP

Instalar:
sudo aptitude install dvdrip rar mplayer

Este programa permite extraer vídeo rápida y facilmente de un dvd.
Dispone de formato de salida avi.

lunes, 25 de octubre de 2010

FUENTES DE LAS LETRAS EN QCAD.

Instalando Qcad en LLiurex no aparecen las fuentes, vamos a instalarlas.

1. Descargar el archivo qcad de la web oficial.
qcad-2.2.2.0-1-demo.linux.x86.tar.gz

2. Descomprimirlo.

3. Buscar donde se guardan las fuentes en Qcad.
Ir al menú - edit - aplication preferences - path - fonts
En mi caso es:
/usr/share/qcad/fonts

4. Crear la carpeta.
mkdir /usr/share/qcad
mkdir /usr/share/qcad/fonts

5. Copiar las fuentes
sudo cp /home/lliurex/Descargas/qcad-2.2.2.0-1-demo.linux.x86/fonts/* /usr/share/qcad/fonts/

lunes, 11 de octubre de 2010

METRONOMO: GTICK

Existe un metrónomo en linux que permite medir la duración
de las notas musicales, se llama gtick

instalarlo con:
sudo aptitude install gtick

martes, 28 de septiembre de 2010

TECLADO EN UBUNTU

1) PARA REINICIAR EL SERVIDOR GRAFICO:

IR AL MENU SISTEMA- PREFERENCIAS - TECLADO - DISTRIBUCIONES - OPCIONES.
SECUENCIA DE TECLAS PARA MATAR SERVIDOR X.
- ACTIVARLO.

2) ATAJOS DE TECLADO.
PULSANDO CTRL+C QUE MUESTRE LA CALCULADORA
PULSAMOS ALT+F2 Y ESCRIBIMOS: gconf-editor
2.1) DEFINIMOS EL COMANDO EN: apps - metacity - keybinding_commands
SOBRE COMMAND1 BOTON DERECHO. EDITAR CLAVE Y PONER: /usr/bin/gcalctool
2.2) ASICIAMOS COMMAND1 LAS TECLAS CON: apps - metacity - global_keybindings
SOBRE COMMAND1 BOTON DERECHO: ESCRIBIMOS c

domingo, 26 de septiembre de 2010

EDITAR PDF CON OPENOFFICE GRAPH

INSTALAREMOS:
sudo aptitude install openoffice.org-pdfimport

Y YA PODREMOS EDITAR LOS FICHEROS PDF.