Skip to main content

Posts

Showing posts with the label ugly hacks

How to fix Emacs 23 Huge ungly font on Lucid

Since I've upgraded to Ubuntu 10.04 (Lucid) Emacs 23 now has beautiful antialiased fonts, but I like the old bitmaped X11 "fixed" font. I do use a .Xresources file to setup emacs default font. This is my emacs section at .Xresources !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! emacs, xemacs !emacs*Background: DarkSlateGray emacs*Background: Black !!!emacs*Foreground: Wheat emacs*Foreground: White emacs*pointerColor: Red emacs*cursorColor: Red emacs*bitmapIcon: on emacs*font: fixed !!!emacs*font: 9x15bold !!emacs*geometry: 100x40+20+20 But for my surprise using this setup emacs launches with a ugly huge serif font. I tried to launch emacs with -fn fixed but the ugly font did still there. So I checked at my /etc/X11/fonts/misc/xfonts-base.alias, which is the file where fixed font is declared. And it was there: fixed -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1 And which had called my attention, was that 6x13 font alias had the same properties as the fixed:...

Convert Scanned PDF Documents to Text without having to wait for google bots

Working supporting old scientific hardware sometimes brings me some challenges. Usually, the manuals are only on paper and when there is a digital version it was digitized (scanned) . Googling a little, came to me an article which relies on waiting for the google to index your files and OCR them. But there is an open source alternative. Looking a little further, I did find another two articles at linuxquestions.org and at linux.com , on which I've found the tesseract-ocr . So to solve my issue, I had to first convert my PDF file to a bunch of TIF images, and so OCR them with tesseract. This way: gs -dNOPAUSE -sDEVICE=tiffgray -r300x300 -sOutputFile=page%03d.tif -- 1850_operators_manual.pdf ls -1 *.tif | cut -d e -f 2 | while read line ; do tesseract "page"$line "page"$line -l eng; done Hope this helps somebody...

Recursively Adding files to CVS

I'm still running a couple of projects which rely on CVS for version control. But adding more folders recursively is very painful. So I use this line as many times as there still being files/folders to be added. cvs update -R -P -d | grep "?" | cut -d " " -f 2 | while read line ; do cvs add $line ; done

Cross-compiling windows applications under linux with wine and DevC++

This post has the same title as this , from Violin Iliev because it is almost a "repost". I had an old post on compiling win32 binaries on linux , but the technique I had shown lack the windows resource file compiling. Violin had written his wrapper to the windres resource compiler, but one good "emergency option" if one couldn't, or don't want, or hasn't time to, write a wrapper or compile Violin'd wrapper, is to follow what was commented on Violin's blog by someone who signed as Andy. Andy said: "I had the same problems with windres and mingw32-make under wine 1.0.1 I solved the problems by putting an original copy of msvcrt.dll in the bin subfolder of mingw32 and telling wine to load it first instead of its own msvcrt emulation. hope it can be useful Andy"

Converting a video file to lots of images

Still for that grad school work on stereo video, I want to convert the videos I made to a bunch of bitmap images. With linux and ffmpeg it is easy. It is just type: ffmpeg -i video.dv image%03d.bmp There are more ffmpeg cheats at: http://webupd8.blogspot.com/2009/08/ffmpeg-cheat-sheet-19-best-practices.html Here is a couple of links very useful: Video convertion cheat sheat (http://www.m3fe.com/31765/) Video editing software (http://www.tech-faq.com/Video-Editing-Software.shtml) Specifically, the command line I was looking for is: ffmpeg -i esquerda.dv -f image2 foo_%02d.bmp

Some tricks with gnuplot

I've been using gnuplot to embed graphics on my scripts for quite some time. And I liked it much. Last month I was asked to maintain a legacy application which generates some live graphics using the JFreeChart class. It has some transparent animated 3D pie charts. So, I was wondering if I could do the same with a couple of scripts and gnuplot, generating an animated gif. After googling a little, I've found these links: Simple pie chart with Gnuplot Another simple 3D pie chart with gnuplot (script included) And, with these new gnuplot features, I will try to do some cool scripts ;-)

Compiling win32 binaries on linux

Old habits are hard to be dropped. As a long term linux user I fell much more comfortable using my old emacs text editor with a good old "green on black" Xterm terminal console window. So we have some legacy code here on my current job, those which must run also on windows. I was making some improvements on it, porting to use wx-widgets, compiling and using it on linux. But some windows users started to want those improvements on their widows versions. As the only WX programmer around, I was the only person able to compile the windows version. As I think future improvements would also be wanted by the windows users, I decided to deploy a windows wxDevCPP installation on wine on my linux workstation. Well the first steps are simple: First get a wx-DevCPP installation executable on Install it using wine Open your .dev files on wxDev Build it Now you have a Makefile.win, which can be used to directly compile win32 binaries. A batch file could also be written to make things easy:...

Converting charset enconding of a bunch o .tex files

A friend of mine came to me asking for a simple way to convert the charset encoding of a bunch o LaTeX files. He had all his files in the UFT-8 encoding and he wanted to convert all of them to "latin-1" (ISO-8859-1). So, I saved all the files he sent me in the same folder, opened a terminal shell window and typed the following command line: ls -1 *.tex | while read line ; do iconv -f utf-8 -t iso-8859-1 $line -o "latin1_"$line; done And voilà , they were now encoded with ISO-8859-1.

Pettry rendered LaTeX equations using PHP

When I was writing a simple scientific webapp, during my undergrads studies, I needed to generate some equations to be shown by the app. I was already familiar with LaTeX equation formatting syntax, so I decided to use this nice peace of software. So, after "googling" a little, I found the imgtex , written by Koji Nakamaru , which is a fast CGI script, written in perl. What I did, was port it to PHP. To run it, you must have a LaTeX distribution and the dvipng software both installed on the same machine which you will run the PHP script. Here is the PHP code: To use this code, you just have to pass the LaTeX commands through GET to the PHP. For example, adding the following string to your URL: http://localhost/imgtex.php?res=300&cmd=x=\frac{-b\pm\sqrt{-4ac}}{2a} The res variable sets the resolution for the generated image and the cmd specifies the LaTeX command. This way, the above URL will produce the following image:

PHP + GNU Octave to build a web based pump dimensioning system

During my undergrad studies, when I was doing the fluid dynamics class, we had to dimension pumping systems. The work involved in doing that used to be laborious, many coefficients, constants, etc, and we had to use only our scientific calculators. To check our answers when in home, everybody used to wrote their own spreadsheet. As a FLOSS enthusiast and long time PHP programmer, I decided to write a web based pump dimensioning system. As we calculated the fluid density depending on watter temperature, and we had used small numbers (E-5) which lead to underflow errors when the calculations were did using only PHP statements. In other hand, when using GNU Octave, the precision was great and things were much easy, because I didn't really needed to care about precision, was just type the calculations, press enter and get the right answer. So I wrote a PHP function that calls the exec command to run GNU Octave and get back the Octave output into one PHP variable. That way I got all cal...