Skip to content

Export graficos de R a otra maquina

Para cambiar el display en R a otra maquina

X11( display = “maquina:0″ )

Es una alternativa a salir de R y hacer

export DISPLAY=”maquina:0″

pero no hace falta reiniciar R

Share

Categories: Linux.

cd to real directory, not to the symlink

cd -P dir

Share

Categories: Linux.

Partitioned loopback devices

$ modprobe dm_multipath
$ losetup -f -v disk.img
Loop device is /dev/loop0
$ kpartx -a -v /dev/loop0
add map loop0p1 (254:0): 0 20971457 linear /dev/loop0 63
$ ls /dev/mapper/loop0*

Share

Categories: Linux.

Format floats in Ruby

“%.2f” % 2.3123123123
=> 2.31

Share

Categories: Linux.

Change a white background to transparent

Ingredients:

  • ImageMagick

Solution:

convert -transparent white file destination_file

You may want to add a fuzz if the border looks too sharp:

convert -fuzz 25% -transparent white file destination_file
Share

Categories: Linux.

How to enable & disable CPU cores online

Sometimes useful with licensing issues:

Here you will see the cpu cores available.

/sys/devices/system/cpu/

Now you can select the core and trigger to enable or disable with 1 and 0

echo 0 >> /sys/devices/system/cpu/cpu1/online

echo 1 >> /sys/devices/system/cpu/cpu1/online

now you can check on /proc/cpuinfo, top, or any utility to see the active cores on the system.

For disabling cores on boot permanently, try maxcpus=N  as grub parameter.

 

Share

Categories: Linux.

Common fiberchannel tasks on Linux using sysfs

Scan for new Luns:

for HBA_SCAN in `ls /sys/class/scsi_host/`
do
echo “- – -” > /sys/class/scsi_host/${HBA_SCAN}/scan
done
print port WWN:

for PORT_SCAN in `ls /sys/class/fc_host/`
do
cat /sys/class/fc_host/${PORT_SCAN}/port_name
done

Print  driver fields:

QLOGIC=`lsmod | grep qla | awk ‘{print $1}’| head -1`
EMULEX=`lsmod | grep lpfc |  awk ‘{print $1}’| head -1`
if [ -n "$QLOGIC" ]
then
modinfo $QLOGIC 2>&1|egrep “version|author|description”
fi
if [ -n "$EMULEX" ]
then
modinfo $EMULEX 2>&1|egrep “version|author|description”
fi

Share

Categories: Linux.

Autorotate images

jhead -autorot *.jpg
Share

Categories: Linux.

Improve history logging

By default, bash will only log 500 lines of history without a timestamp. To correct this behaviour, you may want to increase the number of lines logged by bash and include a timestamp to it:

export HISTTIMEFORMAT='%F %T '
export HISTFILESIZE=80000
export HISTSIZE=80000
Share

Categories: Linux.

Remove lines with duplicated fields using backreferences

The \1 can refer to a previously captured group even in the pattern:

grep -v “^\([[:alnum:]]\+\) \1$”

Note: This is not a general solution, just an ilustration.

Share

Categories: Linux.

Tags: