Computers


Interesting Applications under Windows & Linux

see also Windows apps. [CZ] and Linux apps.

Last change: March 2 2006 AD

Content


--- APPLICATION NOTES ---


MEDIA Applications

1.Audacity 1.2.1 for Windows (home)

Recording:

2.Gimp 2.0

Draw a straight line: select the pencil tool, click where you want the start point, press Shift and click to the end point.

Layers & text: every part of the image may be in a separate layer => you can move them independently. In the image window: Layer->New Layer. To switch between layers and select which to show use Dialogue->Layers (or Ctrl+L).

Paths: to draw a path (e.g. borders of some part of the image) click in the image window Tools->Path (or B). The path consists of vertices and edges, you set the vertices by clicking in the picture. You can choose various types of line (dashed etc.).

Gimp plugins extend its capabilities and can be obtained from the plugin registry.

3. Mplayer (home)

Mplayer is a great media command-line player with a GUI gmplayer. Currently (2004/11) the gui only works under Linux.

I use "[g]mplayer" to refer both to gmplayer and mplayer.

Real fullscrean

Sometimes when you toggle the fullscreen mode (via 'f' or a gmplayer menu) only a large black area is added around the movie but it is not resized. There are two solutions as far as I know:

Subtitles

Display subtitles in a black area below the movie

Mplayer loads a subtitle file but default. If not you can use the option -sub <subtitle filename>.

By default, subtitles can only be positioned within the display area. To position them outside the movie you need to add a space to it:

[g]mplayer -vf expand=0:-100:0:0

- adds 100px black border below the movie

To set the subtitles' position within the whole area (the movie area + the border) use the menu Preferences->Subtitle & OSD->Position (0 = bottom, 100 = top) or the keys r and t.

Warning: there could be a problem if the movie height/width is 3/4, i.e. if it is in the TV format as opposed to the cinema format - perhpas a part of it could be out of the screen.

Czech subtitles & the encoding cp1250

To watch a movie with Czech subtitles in the Microsoft's encoding cp1250 you need an appropriate truetype font that contains the Czech accented characters, e.g. the "unicode" font Luxi Serif - mine is in /usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirr.ttf. It seems that the following requirements must be satisfied: your system must have the program iconv installed and in the path and freetype2 (version >= 2.1) must be installed too and mplayer must be compiled with the support for ttf. Then you can run mplayer as follows, specifying the encoding of the subtitle file with the -subcp option:

mplayer -subcp cp1250 -font /usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirr.ttf xampleMovie.avi [-sub a_subtitle_file]

WARNING: if you specify a wrong encoding (e.g. cp1250 while the subtitle file is in latin2 or utf8) no subtitles will be displayed.

Subtitles & true type font size

To change the size of a true type (.ttf) font used for subtitle use:

-subfont-text-scale N

where N = 1..100 is a percentage of the screen height; by default it's 5, 10 is large enough.

Problems

"Your system is too SLOW to play this!"
Try -nocache - may be you're using a cache to play a non-interleaved AVI file.

MPlayer under Linux

Mplayer - recording a stream (stream not seekable)

You can record a stream by giving the option -dumpstream. But it may happen that you're able to play a stream without problems (such as mplayer -playlist http://example.com:8000/listenradio.pls) but if you add the option -dumpstream you hear no sound and mplayer blocks right after saying "Stream not seekable!". It may help to find out what is the url of the stream itself (not the playlist) and use that url instead. You can get the url from the playlist or by running mplayer with -v and looking for something like "Filename for url is now http://example.com:8000/".

In my case, running mplayer -dumpstream http://example.com:8000/ still has not produced any sound and seemed to block after "Stream not seekable!", but a file stream.dump was created and was growing, i.e. mplayer was recording (verified with mplayer stream.dump).

PS: You may be also interested in the ption -dumpfile <name of file to save into>.

Mencoder - encode a video

Encoding a raw stream video with:

mencoder film.stream -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq -vf scale=768:576 -oac copy -o encoded_film.avi

I got the following problem: when I tried to play the result there was only the audio and mplayer said "Cannot find codec matching selected -vo and video format 0x34504D46". According to an advice I've deleted all my codecs.conf (namely /etc/mplayer/codecs.conf), as mplayer has it built-in, tried to encode again - and it worked!

Note: I think that the command encodes video with mpeg4 implemented by lavc, the audio is only copied, and bitrate is set to 1000 (could be higher for better quality).

Merging videos with mencoder

Source: Julian Coccia's blog

cat *avi | mencoder -oac copy -ovc copy -o myvideo.avi -

This would simply concatenate all avi files in the current directory into a new video called myvideo.avi, maintaining the original audio and video codecs.

If you want this video to be viewable in a windoze machine (this part is not easy), then use the following codecs:

cat *avi | mencoder -oac pcm -ovc lavc -lavcopts vcodec=msmpeg4 -o myvideo.avi -

4. VLC media player (home)

Display subtitles by default (no need to set subtitle track manually): Preferences->Input->Choose subtitle track: replace '-1' by '0'. According to the (French) tooltip it only sets subtitle track for DVD but in fact it works for CD/files as well.

Position subtitles below the movie: as of today, 2004/12/4, this is not possible except for some DVD subtitles - VLC can only display the subtitles in the movie area. The feature is on the to do list but most probably it is not considered to be important. So hope & wait.


NET Applications

1.Apache, PHP, SQL server

The Czech language

See

1.1 Install Apache2 + PHP under Windows

- the Apache and php documentation is sufficient.

Notes:

httpd.conf

In the Apache configuration file httpd.conf do (in addition to those needed  by the php install):

1.
# Allow only local access. Was:
#Order allow,deny
#Allow from all
Order deny,allow
Deny from all
Allow from localhost, 127.0.0.1
Allow from mycomputer.example.com

2. Other examples
# Set parameters for www directory
<Directory "C:/*/my-www-dir"> ... </Directory >
<Directory "C:/Program Files/_net/Apache Group/Apache2/cgi-bin"> ... </Directory >
DirectoryIndex index.html index.php #added index.php
Alias /my-www/ "C:/me/net/my-www-dir/"  # will require the last '/'
#AddDefaultCharset ISO-8859-1  #If not commented-out, will override the page's charset

1.2 Install Apache2 + PHP under Cygwin

Problems

1.3 Personal Apache 1 under Linux

To start Apache if you're not the root you need to:

  1. Create a directory you've write access to to serve as the server root, e.g. /home/example/apache
  2. $ cp /etc/apache/httpd.conf /home/example/apache
  3. Modify /home/example/apache/httpd.conf:
  4. Start Apache: /usr/sbin/apache -f /home/example/apache/httpd.conf # use -F to run in the foreground
  5. I'd suggest to copy /usr/sbin/apachectl to a directory on your $PATH and modify it as follows:

    Now you can use 'apachectl start' and 'apachectl stop'.

1.4 Non-root install of MySQL under Linux

See this discussion.

Summary (if MySQL installed already):

PHP Note:

If you specify 'localhost' as the server name, the connection will die with "Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' ". Use '127.0.0.1' instead.

1.4 PostgreSQL run by a non-root under Linux

  1. Create the "database cluster" (root for databases and various psql files):
    mkdir /home/example/postgresql/data; chmod 0700 /home/example/postgresql/data
    /usr/lib/postgresql/bin/initdb -D /home/example/postgresql/data
  2. Set the directory where to place a socket (.lock file) - add unix_socket_directory = '/home/example/postgresql' to the file /home/example/postgresql/data/postgresql.conf (created in the data directory by the previous command).
  3. Run the database (instead of the -D <data directory> option you can put the directory name into the variable PGDATA):
    /usr/lib/postgresql/bin/postmaster -D /home/example/postgresql/data
    Useful options: -p <portNumber>, -k <directory for a lock file>
    You can use he program pg_ctl to start/stop/restart/... your server (give it the -D option).
  4. Create a new database - you have to give the absolute path to the socket directory:
    /usr/lib/postgresql/bin/createdb -h /home/example/postgresql testdb
  5. Connect to the database as the current user (e.g. username):
    /usr/lib/postgresql/bin/psql -h /home/example/postgresql testdb #connect via the socket
    /usr/lib/postgresql/bin/psql -h localhost [-p 5432] testdb username #connect via tcp/ip

Note: The location of PostgreSQL binaries may be different under other distributions than Debian.

2. TightVNC - remote desktop server & client

TightVNC is an open source (as opposed to VNC) software package that let's you see the desktop of a remote machine and control it. It's available for Windows, Linux and others. You can even work on you remote Linux machine while sitting at a Windows computer.

TightVNC is not very secure by itself so it's highly recommanded to use SSH tunnelling (howto) to connect the VNC client and the server. With a windows client you need a SSH client that supports port forwarding, e.g. the most used one: PuTTY (see windows howto).

Preparation

Tell to the vncserver what window manager and applications it should start at startup - edit $HOME/.vnc/xstartup

VNC: HOWTO Linux to Linux over SSH

Situation: you are on your local linux box called home.example.net that runs sshd and you've ssh access to a linux box work.example.net. You want to test that you can connect from that box via vncviewer to your vncserver running at home.

1. Setup ssh port forwarding at work
CONSOLE 1:
homeuser@home$ ssh workuser@work.example.net # log into work
workuser@work$ ssh -v -L 5977:127.0.0.1:5907 homeuser@home.example.net # port forwarding; change 'home.example.net' to your machine's name/IP ## SSH should, among others, print a line telling the forwarding is set similar to the following: # debug1: channel_free: channel 2: direct-tcpip: listening port 5907 for 127.0.0.1 port 5907, ... ## Now you are logged from home to work back to home; 127.0.0.1 is loopback device of home

Notes: notice you must type capital -L . If you type -l instead of it it won't work and ssh won't let you know you've made an arror.

2. Start the server and the client on the other side
homeuser@home$ vncserver :7 -localhost  # allow only connections from 127.0.0.1; the order of options mattters

CONSOLE 2:
homeuser@home$ ssh -X workuser@work.example.net # log into work from another console; -X = allow execution of X applications (GUI)
workuser@work$ vncviewer 127.0.0.1:77 # or 127.0.0.1::5977; vnc shall promt you for your vnc password
Notes

Starting vncserver on the display 7 means it will listen on the port 5907 and telling vncviewer to connect to display 77 means it will connect to the port 5977.

It's very important to set the port forwarding correctly otherwise I'll get an error like "vncviewer: VNC server closed connection". I believe it's because the vnc server accepts by default only local connections, i.e. from 127.0.0.1 and forwarding (work) 5977 to home.example.net:5907 will not use the loopback device (127.0.0.1) but the ethernet card you to use at home to connect to the net whose IP is determined by your provider. Thus, though you formally connect from the localhost (via ssh forwarding) from the localhost, practicaly it's not percieved as a local connection.

Security: Setting a Firewall

Assumption: your VNC server runs on the display 3.

To make your system more secure you should forbid any connection to the port 6003 (X server of the vnc) and you should stealth the port 5903 to hide it from all but the ip 127.0.0.1.

VNC: HOWTO Windows to Linux over SSH

1. Setup PuTTY

Session: set "Host Name" to home.example.com, "Protocol" to SSH

Connection: set "Auto-user name" to homeuser

Connection->SSH->Tunnels: setup Port forwarding - in the section "Add new forwarded port" set "Source port" to 5977 and "Destination" to 127.0.0.1:5907, click the button <Add>

Session: save the session - type any name into "Saved sessions" and click <Save>

2. Connect via PuTTY & start the server

In PuTTY click <Open> or click twice to the session name. Type your password to log in home.example.com.

homeuser@home-over-ssh$ vncserver :7 -localhost # start the server

3. Start the viewer

Under Windows, start the vncviewer. Server is "127.0.0.1:77". It should prompt you for your vncserver password.

Possible problems

As far as I know you won't be able to use an iso8859-2 (e.g. Czech) keyboard/characters because Windows uses its CP1250 encoding while Linux expects iso8859-2 input, so only rectangles, ? etc. will be displayed instead of non is8859-1 characters. Perhaps there is a way to correct it, I'd be glad to learn it.

Firefox - the best web browser ever

My favourite extensions:

Other useful extensions:

The Plugin "Plugger" (v. 5.1.3)

It wasn't able to handle ppt presentations in the full-screen mode (The menu in OpenOffice "Start presentation F9"). So I bypassed the plugger's oocontroler and run it in an external instance of the OpenOffice, which works fine. For that you need to modify your $HOME/.plugger/pluggerrc-5.1.3 - replace OO(impres) by a direct call to soffice:

## Presentations
##
...
nokill exits fill: soffice "$file"
#OO(impress)

Various

Open an URL in FireFox

$ mozilla-xremote-client -a firefox openURL\("http://www.centrum.cz/",new-tab\);


PROGRAMMING + Text editors

1. JEdit  - a great programmer's editor written in Java

More on jEdit: see my jEdit Developer documentation Another page page

1.1 Macros & BeanShell

Info about jEdit:

Other

BeanShell Troubleshooting & Limitations

So far BeanShell is unable to evaluate a class containing inner classes used by it:

class Impossible2EvaluateByBeanshell {
//eval causes "internal Error: Attempting to load class in the process of being defined"
   public static void iWillFail( java.io.File dir )
      throws MyInnerClassException {}
   static class MyInnerClassException extends Exception {}
}

jEdit's menu bar

1.2 Plugins

CODE BROWSER

Show 'class::method' instead of 'method': locate your ctags config file (e.g. ~/.ctags) and add the line '--extra=+q'. Note: #aComment is not allowed in the file.

1.3 LaTeX utilities

2. Software for XML (Oct 2004)

SAX
Simple API for XML - suggested API to be used by parsers => it's possible to change the parser you use.

3. ArgoUML - UML editor in Java

CANNOT CREATE BUT CLASSES/USE CASES:

State and activity diagrams can only be created when a class or actor is selected => create a class/actor first, click on it and voila!

4. Eclipse Tips

Version: 3.1.0, Linux GTK

Plugins

I'd recommend to separate your plugins from your eclipse instalation. That will make upgrades easier.

  1. Create a folder for the plugins such as /home/me/eclipse-plugins with the subfolders:
    /home/me/eclipse-plugins/eclipse
    /home/me/eclipse-plugins/eclipse/plugins
    /home/me/eclipse-plugins/eclipse/features
  2. Create the file /home/me/eclipse-plugins/eclipse/.eclipseextension that holds the minimal version of Eclipse required. Its content should be something like:

    id=org.eclipse.platform name=Eclipse Platform
    version=3.1.1

  3. Notify Eclipse of the plugin directory - in your eclipse instalation directory create the subdirectory links/ that will hold text files ending with .links and containing paths to the extension locations (path=...) - our example my-eclipse-plugins.links will contain:

    path=/home/me/eclipse-plugins

Some useful plugins:

Languages

Tips & Tricks

See Help->Tips & Tricks - they're great!!!

Change the value of the template variable {$user}
It's obtained from the java system property 'user.name' => edit eclipse.ini and add e.g.:

-Duser.name=Jakub Holy

Size of the recently opened files list
Change it in Preferences/General/Editors/"Size of recently opened files"

Useful hotkeys

A = Alt, C = Control, S = Shift

C-S-R
Find a resource (any file) in the project

Java editing (JDT - Java Devel. Tools)

Java debugging

Find out the return value of a method: select the whole line return ...; and inspect it (Ctrl+Shift+I, or through the context menu).

C++ editing (CDT)

Code formatting for C++

Get the GNU indent plugin (it requires GNU indent to be installed). As the gnu indent assumes tab width to be 8 while Eclipse uses 4 by default you either have to change it for indent (the option --tab-size4) or for Eclipse (Window -> Preferences -> Editors -> Text Editors - "Displayed tab width").

GNU indent uses the GNU Coding Style by default.You can change the formatting by specifing some options in a .indent.pro file that is either in the same directory as the one indent is run from or in your $HOME. My .indent.pro contains:

--blank-lines-after-declarations
--blank-lines-after-procedures
--brace-indent0                 // '{' in the same column as 'if'
--tab-size4                     // the default in Eclipse

Eclipse & CVS

Eclipse & CVS over SSH

Eclipse 3.1.1, Jan 19 2006

If you use CVS over ssh (the ext method) and you authenticate yourself using a private+public key pair protected by a password:

  1. Preferences > Team > CVS > Ext Connection Method: select "Use another connection type method..." and set the connection type to extssh. (Using an external program with CVS_RSH set to ssh and CVS_SERVER = ssh results in "Unknown response received from cvs server:" with no details when you attemp a cvs operation).
  2. Preferences > Team > CVS > SSH2 Connection Method, tab General: click Add Private Key... to add the private key you use to authenticate with the server.

This should be all. When you attemp a cvs operation you should be prompted for your password.

CVS tips

Replace by a previous version: context menu: Replace with > Revision > click on the revision with right mouse button and select "Get Contents"; open & save & commit the file.


OFFICE

1. OpenOffice.org (OOo)

OOoLatexEquation
A macro that let you use LaTeX to create equations & whatever else and include it in OOo. Looks very cool. Homepage.
Writer2LaTeX/xhtml/BibTeX & Calc2xhtml
A Java converter from OOo to the given formats. See its homepage.

OpenOffice 1.0.2 - poznámky [CZ]

Problémy a Resení:

PYestane fungovat (automatická) kontrola pravopisu
Pøíèina: není urèen jazyk textu, resp. toto urèení se vypaøilo. Øe¹ení: 1. Vybrat v¹echen text (Ctrl+A), 2. Formát->Znak: nastavit jazyk na èeský ( i jiný).
Nefunguje dokonèování slov (hlavnì po spu¹tìní)
Mo¾ná pøíèina: seznam slov je prázdný a nedoplòuje se (i kdy¾ "Shroma¾ïovat návrhy" je zatrhnuto). Øe¹ení: Nástroje->Automatické opravy/Formát->Dokonèování slov: zru¹it volbu "Shroma¾ïovat návrhy" a zmáèknout OK, pak ji znovu povolit a OK.
Písmo UI
Zmìna písma UI: Tools -> Options -> OpenOffice.org -> Font Replacement, za¹krtnout "Apply Replacement Table", napsat "Andale Sans UI" - musím to napsat, proto¾e v dropdown menu to není.
LINUX: OpenOffice blocks at startup, perhaps after being killed / a crash
Use 'strace soffice' to find out where exactly it gets stucked. Perhaps it's when it tries to connect to a socket left by the previous version (something like "connect(9, {sa_family=AF_FILE, path="/tmp/OSL_PIPE_1000_SingleOfficeIPC_...") => killall soffice.bin, remove the socket from /tmp, try to start soffice and it should be ok.

OpenOffice 1.1.2 - poznámky

Vkládání nezalomitelné mezery za jednopísmenné pøedlo¾ky
Viz makro vlnka.

2. (La)TeX

Czech TeX/LaTeX under Debian

Support for Czech is included in the basic tetex-* (base, bin, doc, extra, lib, non-free) packages since Woody (see). You only need to enable it. If you've Sarge, use run texconfig and click "FORMATS", which will open a file in vim, uncomment whatever you want (e.g. the section "Czech") and type ':wq' to finish. Texconfig will automatically apply the changes and generate the uncomented formats.

Correct hyphenation
  1. Either use '\usepackage{czech]' and process with [pdf]cslatex and do not use babel
  2. Or use babel ('\usepackage[czech]{babel}' but not usepackage{czech}) and process with [pdf]latex.
tex2rtf & Czech

It was hard to create a RTF with correct Czech. Finally, I discovered a method that shall work (for a text in iso-8859-2(latin2)): 1. The source cannot contain neither '\usepackage{czech]' nor '\usepackage[czech]{babel}'; 2. The source must include '\usepackage{babel]' and '\usepackage[latin2]{inputenc}'; 3. process with:

latex2rtf -C latin2 -i czech my-latin2-file.tex

vlna: jednopismenne predlozky

Pred publikaci je treba pustit na zdrojak program vlna, ktery nahradi mezery za jednopismennymi predlozkami a spojkami nezlomitelnou mezerou (s tebou -> s~tebou). Program je napr. na ftp://math.feld.cvut.cz/pub/olsak/vlna/.

utf8 in LaTeX - package utf8

\usepackage[utf8]{inputenc}

- it cannot be used together with babel (including things like \usepackage[T1]{fontenc} and \usepackage{czech} - you have to remove them to get rid of errors).
- it requires the package latex-ucs (apt-get install latex-ucs) = utf support for latex
- make sure that your editor saves the file in utf8; I can only recommand jEdit.
- and that's all! you can start typing e.g. Czech characters.

Powerpoint-like presentation with LaTex

  1. Beamer - a recommanded way of creating presentation. (apt-get install latex-beamer) Clanek o Beameru na root [CZ].
  2. TeXPower - "a bundle of style and class files for creating dynamic online presentations with LaTeX", links to alternatives. Indeed cool!
  3. pdfscreen - the LaTeX pacakge. See Creating `Powerpoint-like' presentations with LaTeX.

LaTeX examples

Define a new command that displays a given text in italic and adds quotes around it

\newcommand{\inlcitace}[1]{,,\textit{#1}''}

Usage: here comes \inlcitace{quoted string in it} end.


SECURITY

GPG - GNU Privacy Guard (GnuPG)

GnuPG is an Open Source replacement for PGP (Pretty Good Privacy), which is a program and standard for cryptographic privacy and authentication. It's used to sign and encrypt messages and files. See GnuPG homepage for more information.

Key servers

Search Google for 'gpg "public keyserver"'.

Create your own key pair

  1. gpg --gen-key # answer the questions; your key info will be "your-name (a comment) <user@domain>"

    It will print something like "pub 1024D/93887B45" => your public key ID is 0x93887B45. The key may be identified either by it's id or by the user@domain you specified during the generation.

  2. Create a revocation certificate for the key:

    gpg --output gpgkey-revoke-certificate.asc --gen-revoke <key ID> # the certificate will be in gpgkey-revoke-certificate.asc

    Note: you created a "generic" revocation certificate; if you revoke the key for a special reason it's a good idea to create a new revoc. certificate and state the reason in it.

  3. Export the public key so that you can send it to somebody:
  4. Export the public key to a keyserver (e.g. pks.gpg.cz) - most of them share the keys so it's enough to choose one:

    gpg --keyserver www.keyserver.net --send-key <user@domain>

Verify a file's signature

  1. Find & import author's key: gpg --keyserver www.keyserver.net --recv-keys <key ID> [OR: --search-key <user@domain>]

    Note: instead of user@domain you can search for a part of the key info (e.g. "jakub holy" or "Jakub Holý") but it's slower.
    Some key servers have web interface for searching keys, e.g. wwwkeys.eu.pgp.net.
    If some key server doesn't respond it may be down, try another one.

  2. Check the signature: gpg --verify filename.asc

Notes


OFFICE

PROGRAMMING etc.

MEDIA

UTILITIES / VARIOUS

SECURITY

SYSTEM


Jakub Holý 2004 AD