Archive

Archive for the ‘Software Development’ Category

How to create two wired virtual serial ports on Linux?

February 19th, 2010 fvicente No comments

To create two bridged virtual serial ports use the following command:

socat -d -d pty,raw,echo=0 pty,raw,echo=0

The output will show you which are the virtual ports (or pseudo terminals) created, e.g.:

2010/02/19 16:16:33 socat[9662] N PTY is /dev/pts/3
2010/02/19 16:16:33 socat[9662] N PTY is /dev/pts/4
2010/02/19 16:16:33 socat[9662] N starting data transfer loop with FDs [3,3] and [5,5]

Note: if you are using Ubuntu and you do not have this command, try:

sudo apt-get install socat

Image source

How do I compare two binary files on Linux?

February 19th, 2010 fvicente No comments

The easiest way I found is dumping the binaries into text files using hexdump and then comparing them with your favourite program (diff, Meld, etc.). E.g.:

hexdump -C a.bin >a.txt
hexdump -C b.bin >b.txt
diff a.txt b.txt

Image source

Extracting FLV meta tags with Python

February 5th, 2010 fvicente No comments

I’ve stolen this code from http://code.activestate.com/recipes/457406/ which in turn was stolen / ported from http://inlet-media.de/flvtool2 , made some small fixes in bugs related to the date conversion function, object and array unmarshaling, file name hardcoded, etc… If you want to learn more about the FLV format and metatags read Acrobat’s Video File Format Specification Version 10
Read more…

Categories: Programming FAQ Tags: , , , ,

(HTML) Table cell not inheriting style

June 4th, 2009 fvicente No comments

The goal of this new blog category called “Programming FAQ” is to publish short posts with day to day programming problems and their solutions, or at least provide a tip to find the proper solution to your problem. And today we start with this simple and stupid problem that can happen to anyone with poor HTML experience like me. “My HTML table does not seems to inherit the style from a parent element”, here is the example:

<html>
<body>
<div style="color: blue;">
	<table>
	<tbody>
		<tr>
			<td>BLUE TEXT</td>
		</tr>
	</tbody>
	</table>
<div>
</body>
</html>

In the below example I would expect to see the “BLUE TEXT” in blue, but is not (at least in FireFox). So what the hell is wrong with my code? probably many things but because I’m not interested in following/reading the W3C recommendations for my uncle’s home page, here is one possible solution: Add the transitional DOCTYPE to your document, or the DOCTYPE that adequate better to your page (read more here). E.g.:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

So, now you know. Never forget the DOCTYPE it is very important… Why? read this… It has to do with poor standards, browsers and all that crap.

Categories: Programming FAQ Tags:

Simplified DES (S-DES) file encryption implementation in C

May 8th, 2009 fvicente No comments
Simplified DES

Simplified DES

This encryption algorithm is not secure at all, in fact it was made for educational purposes. It uses a 10-bit key that can be quickly broken by a brute force attack. But, who knows, it may be good for someone interested in some quick encryption where security is not that important, or for embedded devices were resources are limited, or just for lazy students. :D

Read more…

Cool JavaScript Tool Window

March 30th, 2009 fvicente No comments
Tool Window

Tool Window

This JavaScript class wraps a given HTML element into a movable and resizable floating tool window.  Required libraries: scriptaculous and prototype.js

How to use the code:

Download full source (including scriptaculous and prototype). The pieces of code developed by me are released under BSD license, please verify third party libraries licenses before using them.

See the DEMO PAGE!

enjoy it!

File Upload Progress with mod_python

March 28th, 2009 fvicente 1 comment
Upload Progress with mod_python

Upload Progress with mod_python

Now that Gmail has added a progress bar for attachment uploads, everybody wants to do the same including myself :)
So, with the same method that everybody uses consisting in an upload form with a hidden <iframe> as target, and then a periodic Ajax request to update the progress, I made a simple implementation using mod_python on the server side… This is a veeery simple example, like everything that you do with Python.
Additionally I’ve added an upload size limit control based in examples that can be found in the mod_python forum site. Use the source Luke!

See LIVE DEMO!

Read more…

MacOS X 10.5.x (Intel) + mod_python + PIL + PyCAPTCHA notes

March 3rd, 2009 fvicente No comments

If you have a Mac OS X Leopard on an Intel platform, and you are interested in installing mod_python using your default apache setup and the python that comes with the Framework, even more if you want to give PyCAPTCHA a try together with mod_python, then check out this post! I’m covering also the installation of required libraries for PyCAPTCHA under Leopard (FreeType2, libjpeg, PIL)

Read more…

Slice and rotate images with CutNRot

June 4th, 2008 fvicente No comments

Cut and Rotate

Today I’m introducing another utility script written in python that uses wxPython to edit your scanned images (JPEG, BMP, TIFF, etc.) obtain sub-images, rotate and save them.

Read more…

Code optimization for RXTX parallel port implementation

May 26th, 2008 fvicente No comments

DB-25 Connector

RXTX is a native lib providing serial and parallel communication for the Java Development Toolkit (JDK). All deliverables are under the gnu LGPL license. The native part is developed in C.

If you are using the parallel port functions of this project for version rxtx-2.1-7r2 or older, you may be interested in this code optimization, it is a small change but it may improve the resource usage in certain cases.

Read more…