Thursday, May 22, 2014

Photobook by LaTeX as PDF preparation for Blurb.com

DIY photo book by LaTeX is hard (!) but possible.

Why LaTeX [http://latex-project.org/]?
- It’s open and free;
- It’s powerful and beautiful;
- It’s scientific;
etc.

How I did it?
- Mainly using LaTeX minipage environment.
- And some LaTeX packages.

What's inside the archives?
- Take a look at the included README.txt file.

OK, where can I get them?
- Archives will be named photobook-ddmmyy.zip, current version is photobook-21052014.zip (have been done as May 21st 2014), located in [this Google Drive folder] (click to open).
- See pdf files layouts-ddmmyy.pdf in the Google Drive folder for overview of available templates.

Happy Children’s Day!

P.S. How to edit photos?
- Use your favorite editor, mine is GIMP.
- For batch (size, rotate,..) converting, convert in the ImageMagick suite is recommended. Again, use your favorite tool!

Friday, April 29, 2011

My article about FreeNAS is now online

The article is avaiable at PCWorld Vietnam's website [1] since May 2010 and has been voted as almost 10/10. Thank you all readers.

[1] http://www.pcworld.com.vn/articles/cong-nghe/ung-dung/2010/05/1219106/tu-tao-nas-tu-may-tinh-cu/

Saturday, September 18, 2010

Some crontab usages

1. Run a command at boot time
In /etc/crontab add:

@reboot root command

Replace root with username to run as regular user:


@reboot phan vnc4server :1 -geometry 1200x800 &


2. Run GUI programs
To run a GUI program by cron, we have to tell what display should be used by:

DISPLAY=:0 or export DISPLAY=:0

For example, to change fluxbox background automatically twice per hour, at 0 and 30 minute, run crontab -e, then add the following line:

0,30 * * * * DISPLAY=:0 fbsetbg -f -r $HOME/.fluxbox/backgrounds/

Change display number if needed, :0 will be right for most cases.

3. Daily backup to Dropbox at midnight
Run crontab -e, then add:

# run five minutes before midnight, every day
55 23 * * * $HOME/Dropbox/bin/b2d.daily && $HOME/out 2&>1

b2d.daily is a shell script:

$ cat $HOME/Dropbox/bin/b2d.daily


#!/bin/bash
tar czvf $HOME/Dropbox/My-Dir-`date +%F`.tar.gz \
$HOME/My-Dir && DISPLAY=:0 dropbox start

Here we see another way to run GUI programs by cron. Of course, you can use 2 continuous cron jobs, first — run tar, second — dropbox, instead of using b2d.daily script.

P.S. share your cron usages, if there're no top secrets.

Sunday, September 12, 2010

2-Cent Tip: Russian Keyboard Layout in Fluxbox

Russian Keyboard Layout in Fluxbox:

$ cat $HOME/.fluxbox/startup | grep kb
fbxkb &
setxkbmap -layout "us,ru(winkeys)" -option "grp:caps_toggle" -option "grp_led:scroll"

By using winkeys variant we have all keyboard shorcuts (Ctrl+C, Ctrl+V, etc) work.

Saturday, September 11, 2010

Combination of XDrawChem and Inkscape as an open-source molecular editor

There are dozen molecular editor for chemistry and biology [1], but very few of them are open source (or even free for education), and the lasts are feature-limited. Thus, XDrawChem [2] can draw quiet complicated molecules, but draws them not very beautifully. In the other side, this open source program can export images in SVG format, used as default in Inkscape [3], a famous vector editor, which is used to produce very beautiful drawings.

Our action is:
First, draw the molecule (or parts of it) in XDrawChem, then export the image in SVG format:
Draw part of the future molecule (Tinuvin 320) in XDrawChem

Open and edit the SVG file in Inkscape, and don't forget to convert text to path, if you want to edit the file in other system:
Tinuvin 320 (antioxidant)

Finally, save as pdf to use in a LaTeX document, or export to PNG to use in OpenOffice.org.

  1. http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style_(chemistry)/Structure_drawing
  2. http://xdrawchem.sourceforge.net/
  3. http://www.inkscape.org/

Friday, September 10, 2010

A workaround for OpenOffice.org Draw selection export to PDF

In the current version of OpenOffice.org 3.2, there is still a problem with selection export to PDF in Draw program — the result pdfs always have page dimension of the drawing (A4 or letter) as its paper size (fig. 1). For printing, this is fine, but annoying if you want, for example, include the graphic in a LaTeX document.
Fig. 1. Selection export to PDF bug.
To workaround this problem, change the drawing's page paper to the selection's size in menu Format / Page... then export. The selection's size can be found in the status bar (fig. 2).

Fig. 2. Selection's size in status bar (red stroke).
The result is fig. 3.
Fig. 3. PDF file by workaround.

P.S. Just one more tip: to export OpenOffice.org Calc chart to PDF, copy it to Draw, then...

Thursday, September 02, 2010

Setup a FreeNAS virtual machine in Linux by VirtualBox

We will consider two VirtualBox features — raw hard disk access and VBoxHeadless, to create and run a FreeNAS server "in background" (as a Linux service). It takes us 3 steps.

Step 1. Create and setup (install) a FreeNAS virtual machine with a small hard disk in VirtualBox, network interface is "bridged". The easiest way is using VirtualBox graphical interface. We are not going into details. Just be aware to use so-called "embedded" FreeNAS if you have much of RAM (FreeNAS 0.7.1 requires minimum 192MB). Otherwise install "full version" of FreeNAS and use swap, because the host (Linux) system needs RAM, too.

Step 2. Add raw disk to virtual machine [1].

Step 3. Use VBoxHeadless to run FreeNAS virtual machine without GUI:

$ VBoxHeadless --startvm FreeNAS --vrdp=off >> $HOME/VBoxHeadless.out 2>&1

Read more about VBoxHeadless in VirtualBox documentation [2]. In the command above FreeNAS is the name of created virtual machine, we turn vrdp server off, as FreeNAS has a very powerful Web interface at http://192.168.1.250 by default [3].
You may want to run the virtual machine automatically during boot process. Be aware to run it after vboxdrv service. For this purpose the most convenient solution is /etc/init.d/rc.local. This script run last, but run as root, thus sudo command is used:


$ cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.


sudo -H -u phan VBoxHeadless --startvm FreeNAS --vrdp=off >> $HOME/VBoxHeadless.out 2>&1


exit 0

Change phan to your username. The -H option is important, it tell sudo to set HOME environment variable to the home directory of the target user, where VBoxHeadless will find the virtual machine with "FreeNAS" name.

P.S. don't forget to turn off FreeNAS virtual machine before shutdown Linux.