Saving power with Linux
by Mostafa on Dec.03, 2007, under Linux
An interesting site with numerous tips and tricks on power efficient computing using Linux:
It is also home to the rather useful “PowerTOP” tool. If the testimonials are anything to go by, everyone running a recent release of Linux should give this a try.
Embedded multimedia in LateX/Prosper
by Mostafa on Dec.01, 2007, under How To ..., LaTeX
The movie15 package by Alexander Grahn is useful for this purpose. The movies embedded, however, cannot be viewed with any PDF reader on Linux.
Extracting Audio/Video
by Mostafa on Dec.01, 2007, under How To ..., Linux, Software
It’s really easy to extract either audio or video from a multimedia file using ‘ffmpeg‘. To extract audio only:
$ ffmpeg -i inputfile -vn -acodec copy outputfile
And for video only, replace ‘-vn‘ with ‘-an‘ and ‘-acodec‘ with ‘-vcodec‘.
ffmpeg is also commonly used as a transcoding tool.
SSH Blacklisting
by Mostafa on Nov.29, 2007, under How To ..., Linux, Software
After getting around 1500 failed ssh login attempts a day for a while on a server I manage, I decided to look into tools that automatically blacklist offending IPs.
Sshblack fits the bill perfectly. A HOWTO (including an init-script) for REDHAT-like systems is available from the OSS Watch Wiki.
Logo in a LaTeX document header/footer
by Mostafa on Oct.22, 2007, under How To ..., LaTeX
Easily accomplished using the ‘fancyhdr‘ package:
\usepackage{fancyhdr} \renewcommand{\headheight}{0.6in} \setlength{\headwidth}{\textwidth} \fancyhead[L]{}% empty left \fancyhead[R]{ % right \includegraphics[height=0.53in]{img-file} } \pagestyle{fancy}
All of that goes into the preamble of the document.
Duplicate identifiers with hyperref in pdflatex
by Mostafa on Oct.01, 2007, under LaTeX
The following warning is fairly common when hyperref is used with PDFLaTeX:
! pdfTeX warning (ext4): destination with the same identifier (name{page.1}) ha s been already used, duplicate ignored
The solution is to use the ‘plainpages=false‘ option with hyperref.
However, this appears to be insufficient for the article class with the ‘titlepage‘ option. To remedy the warning the following is additionally needed around the \maketitle in the body of the document:
\renewcommand{\thepage}{\roman{page}}
\maketitle
\renewcommand{\thepage}{\arabic{page}}
By switching the style of page counter before and after the title page, any ambiguity regarding page numbers is resolved (title page is logically page 1 but LaTex re-initiates the counter on the actual page 1 – leading to 2 successive page 1s).
User installation of additional TeX/LaTeX classes and styles
by Mostafa on Aug.09, 2007, under How To ..., LaTeX, Linux
When you are the sysadmin, you can simply drop the new class/style files under the system TeX path (e.g. /usr/share/texmf/tex/) and run ‘texhash’ to have them automatically picked up. But what do you do when you are just a regular user?
TeX/LaTeX looks at the TEXINPUTS environment variable to look for additional locations to search for included/referenced files. Therefore, new classes/styles can be easily added as follows:
- Create a directory for the files:
$ mkdir -p $HOME/tex/latex
- Place the new class files into that folder (each class can be in its own directory and contain subdirectories):
$ cp -a fancy-class $HOME/tex/latex/
- Export the TEXINPUTS variable and also add it to your $HOME/.bash_profile:
$ export TEXINPUTS=.:$HOME/tex/latex//:$TEXINPUTS
The ‘.’ ensures that the working directory is included in the search path. The double-‘//’ tells bash to also include files in subdirectories of ‘$HOME/tex’ recursively.
New BibTeX files can also be added locally in a similar fashion. The variables to set are then BSTINPUTS and BIBINPUTS.
The environment variable to set for MakeIndex styles is: INDEXSTYLE.
Source: AstroNat – Installation at The Smithsonian/NASA Astrophysics Data System
UPDATE [16 July 2009] The Kpathsea manual provides a wealth of information about usable environment variables.
Network Security
by Mostafa on Aug.09, 2007, under How To ..., Linux, Software
A list of very interesting articles:
http://backtrack.offensive-security.com/index.php?title=ExternalHowto
Joining PDF Documents
by Mostafa on Aug.03, 2007, under How To ..., Linux, Software
A quick search on the web reveals that the simplest (and most available) command to do so is:
$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf
Source: Putting together PDF files by Scott Nesbitt on NewsForge
[Update: Feb 1, 2011] jpdftweak is probably a better option with many useful features.
Named Pipes (FIFOs)
by Mostafa on May.22, 2007, under How To ..., Linux
A named pipe is a special kind of file on *nix systems that can be used for inter-process communication. They behave like FIFOs and are created using the command “mkfifo“:
$ mkfifo mypipe
$ ls -l mypipe
prw-rw-r-- 1 xxx xxx 0 May 22 10:18 mypipe
The “p” in the attributes list indicates that this is indeed a pipe.
A trivial example of its use may be to redirect the output of a command on a remote server to a pipe and then reading from that pipe from another host via ssh.