Wednesday, May 25, 2011

Niced

Hi everybody,

I just wrote a small script to send a job (under LINUX-like systems) with priority 19 (like using the command renice after sending it).

The script is based on the true command nice, not on the one included in most of the shells which is almost not configurable.

This is the script:


#!/bin/bash
# send a job with priority 19
#
# niced
# Author: Roberto Lineros
# Date: May 25, 2011


if [ $# -eq 0 ]; then 
echo "niced: none argument has been passed"
exit 1
fi


prior="-n 19"


# IFIC's scientific linux
pa="/bin/nice"
if [ -a $pa ]; then
$pa $prior $@
exit 0
fi


# UBUNTU
pa="/usr/bin/nice"
if [ -a $pa ]; then
$pa $prior $@
exit 0
fi


# in principle more LINUX OS can be added :)


and it works on IFIC's scientific linux and Ubuntu-like systems.

(To install it: save the script in a textfile named niced, copy it on your executable path and change its properties with chmod +x niced to be executable)

:)

Sunday, February 27, 2011

Valencia.

In this blog, I have not written so much about what is going. Some months ago, I moved to Valencia. Looking in youtube for videos about the city I found this:


Monday, January 24, 2011

catPDF

Several times I have to join/merge PDF files into a single one. I read that it can be archieved using ghostscript in the following way (more details):

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf

Nevertheless, for people that do not want to deal with commands and terminals, I did the following GUI-script that uses zenity and ghostcript to produce same results like to use the command line.



I called it catPDF because I tried to keep the spirit of cat command in linux.


Check it out.

Sunday, September 26, 2010

Using new fonts is OpenOffice.

Hi guys!!!

I don't know which program you use for doing presentation. In the beginning, I used to do my slides with prosper (LaTeX), but with the time I started to change to Impress -- the "power point" of Oracle's Open Office -- because it was easier to do more nicer slides. One of the inconvenience of Impress (under Linux) is the low number of nicer fonts. 

I fixed this inconvenience  by adding new fonts. First of all, to create a folder .fonts in your $HOME; Then you just have to copy in it the font files. After that one needs to re-make the font library executing: sudo fc-cache -f -v

After these simple steps, you can enjoy a richer set of fonts in your system, specially in Impress.





Cheers

More info:


Saturday, September 4, 2010

Cleaning Google-Chrome's cache

Hi again (This is the last post of the day ;P)

Anyway, this trick is to improve the speed and to keep clean the cache of Google Chrome in Ubuntu.


So, first you have to convert your /tmp folder into a tmpfs system (check it out here).

Chrome store the cache in the folder .cache/google-chrome at $HOME. So the idea is to link cache's folder with the /tmp folder. First you have to delete (or move to another place) the folder google-chrome then make the link.


ln -s /tmp $HOME/.cache/google-chrome 


Now all cache is written in the /tmp folder which, thanks to tmpfs, is allocated in the RAM/swapp memory. After each reboot the cache is deleted.


See you.

Caveat: if you share the computer, your cache could be seen by someone else.

Credits/inspirations:

http://ubuntuforums.org/showthread.php?t=1277711
http://ubuntuforums.org/showthread.php?t=1451839

using DNS cache for faster internet.

At home, I have an ADSL connection to internet which is rather slow. So, reading how to improve it, I found that using a DNS cache you can reduce the time used for request an IP number to the DNS server.

In the guide, you can find all the details. Roughly speaking, it is just:

sudo apt-get dnsmasq

Edit /etc/dnsmasq.conf and look for the line: #listen-address= and replace it with listen-address=127.0.0.1

edit /etc/dhcp3/dhclient.conf and uncomment (remove the #) the line with #prepend domain-name-servers 127.0.0.1;

then, edit /etc/resolv.conf and put first on nameserver's list the line nameserver 127.0.0.1

finally, restart dnsmasq doing: sudo /etc/init.d/dnsmasq restart


How to know if it works; Run dig google.com look up the response time, usually some ms, and run the command again; You should see a huge reduction on the response time.

See you.


More info:

faster Ubuntu using tmpfs.

Hi everybody,

I read in some blog that tmpfs can help to improve a lot the performance of your Ubuntu linux. I tried this trick on a netbook and on a desktop with moderate resources (especially RAM). So, first is to modify your etc/fstab file by adding these lines:


# reduce the number of writes
tmpfs /tmp  tmpfs defaults,mode=1777 0 0
tmpfs /var/lock  tmpfs defaults,noexec,nosuid,nodev,size=10m,mode=1777 0 0
tmpfs /var/run  tmpfs defaults,nosuid,size=10m,mode=0755 0 0
tmpfs /lib/init/rw tmpfs defaults,nosuid,mode=0755 0 0
tmpfs /dev/shm  tmpfs defaults,nosuid,nodev 0 0

where we use tmpfs to replace Ubuntu's temporal directories. Tmpfs allocates, from now, the information among the RAM (very fast) and the swap (rather slow). Usually these special folders are just located in the hard disk.

Maybe, your Ubuntu does not like any of these changes. It is better to add them one by one, each time you would like to reboot the system.

At any time, you can check the status using the command df -h

See you.


More info/credits:


Tuesday, August 31, 2010

Sage: a free open-source mathematics



I got some comments about SAGE.

Today, I finally installed on my desktop (Ubuntu 10.04) and I tried it. It goes fast in every test that I did.

It is pretty easy to install and very easy to learn how to use it, of course, if you know any programation language and/or you are familiar with Mathematica and similar programs.

Seriously, I use from time to time Mathematica but I do not want to pay for it or pirate it, neither. I guess this is a good alternative to that.

See you.

Tuesday, July 20, 2010

Mollweide projection with gnuplot

Most of the people knows I am a fun of the plotting tool gnuplot.


Well, I needed to do some plots using the elliptical projection or Mollweide projection of some data. Unfortunately, gnuplot is not able (not out the box :) ) to do that. So, I create the proper function to perform that. This is the code to add:


mwhigh(x) = 1.0 + -0.919061*(abs(1.0-x))**0.674635
mwmed(x) = mwhigh(x) -0.0807765 + 0.161136*x -0.0796311*x**2
mwlow(x) = mwmed(x) -3.53551e-05 + 0.000645749*x

mwst(x) = x < 0.2 ? mwlow(x) : (x < 0.9 ? mwmed(x) : mwhigh(x) )

mwt(b) = b>0 ? asin(mwst(sin(abs(b)))) : -asin(mwst(sin(abs(b))))

mwx(b,l) = 2.0*sqrt(2.0) * l * cos(mwt(b))
mwy(b,l) = sqrt(2.0) * sin(mwt(b))



so, for a table b (-pi/2, pi/2) and l (-pi,pi) the functions mwx and mwy generate the map. :)



very nice, no?

Monday, July 19, 2010

:) even more tweaks

Sometimes it goes to a low--graphics mode.


I found some suggestions here:

http://ubuntuforums.org/showthread.php?t=1484137

it is something related to the intel 945GME graphics card.


see you.