>> Single Point of Failure >>


Recent Entries



Popular Tags

Art Blog Blogging Book Books C++ C/C++ Calvin Cartoon Complaints Daughter Definition Development Event Experiment Family Favorites Firefox Focus Fun Google Humor Introspection Life Linux Movie Movies Music Organization Photo Photography Programming Python Reading Software Tips Tools Travel TV Ubuntu Vacations Video Water White Work

So little time for so many projects…

Ξ January 1st, 2013 | → 0 Comments |
Development |, , , , , |


I really love my Raspberry Pi. As expected, the first “projects” were simple and easy to setup: 

  1. the raspbmc-based media center (instructions here)
  2. the samba server for home backups (instructions here)
  3. setting up the wireless dong (no so easy as expected)

 

Now, the world awaits… 

  • To do some programming on the damn thing, I’ll have to setup a decent development/build environment. Considering the shortage of resources on the board, and how easy it is to copy an executable using the samba share, I’ll explore a cross-compilation approach.
  • There are also some home automation that I have in mind. I bet half of them are simply crazy, but maybe a few a them are actually feasible and practical.
  • And finally, how about building a small robot capable of cruising the living room on its own? That would be fantastic.

 

It’s really nice getting into the metal and all the rust, and it’s totally amazing how much fun one can get from a couple of flashing LEDs.

 


CPU load average in /proc

Ξ November 8th, 2009 | → 0 Comments |
Development |, , |


One of my C/C++ applications needed to provide information about CPU usage for debug and monitoring purposes. I never had to do anything like this, but quickly found what something interesting. The getloadavg is a standard library function that provides simplified information on CPU load average.

Because the function seems to point to /proc as source of information, I got to “take a look under the hood” and search for more information about /proc. I already knew that this so called filesystem (which in fact is only virtual) provides an easily accessible interface to kernel information.

Inside, it contains a folder called pid for each process running in the machine and several other folders/files that contain information on available memory, devices (e.g. disks) or kernel version.

If you take the usual look at the man page for proc, I’m sure you’ll find it interesting. it contains much more information than the one I was expecting.

 


Getting help…

Ξ November 3rd, 2009 | → 0 Comments |
Development |, , , |



There is nothing that provides more help to a Linux SW developer than the manual pages. Here’s how to install them in a Debian based system (i.e. my desktop ubuntu system):

sudo aptitude install manpages manpages-dev manpages-posix-dev

 


Use of LD_LIBRARY_PATH

Ξ May 10th, 2009 | → 0 Comments |
Development |, |


The use of Linux environment variables is not new for me, but for special reasons I learned something new about one specific environment variable. You’ve guessed it, although the variable itself was not new to me, I’m now more certain about the uses of LD_LIBRARY_PATH.

The motivation for this post is, at least to some degree, a linkage problem that I had to solve this week.
The only difference between two development ‘sandboxes’ was the definition of LD_LIBRARY_PATH.  I was certain that the variable was only used during execution time (to configure the search path for installed shared libraries). I was wrong!

After almost two hours banging my head against the wall, I found a very interesting paragraph in ld’s manual page.


[...]

The linker uses the following search paths to locate required shared libraries:

[...]

5. For a native linker, the search the contents of the environment variable "LD_LIBRARY_PATH".

[...]

So, the LD_LIBRARY_PATH is used to by the linker!

This solved my very specific problem, but I agree with the opinion of those [1][2][3] who defend that LD_LIBRARY_PATH should not be used to configure the linking process. In a development environment, the libraries to be used by the linker should be configured using the -l and -L flags. In this case, and only in this case, should the LD_LIBRARY_PATH be used to add development libraries to loading path.

 


More photos…

Ξ February 23rd, 2009 | → 0 Comments |
Development |, , |


You might have already noticed that the number of photos in my own Experiment photoblog. This increase in the number of photos is due to my vacations (sort of!), but also and specially due to the new Python upload “tool”* I’ve developed during the last week!


The all process was quite simple…

1. Design the interface using Glade-3. This step includes creating the window and placing some controls. My “tool” uses labels, text boxes, buttons, menus and even a status bar (which I didn’t get to use for any status display). Also, the required controls should be connected with event listener which will be customized by the developer. The only listeners the “tool” interface defines is the window_kill for the File -> Quit menu option and on_button1_clicked for the ‘Upload’ button.

2. The previous results in the generation of a window.glade file. In order to use this interface definition, the .glade file needs to be converted to a GTK definition file (e.g. window.xml). This conversion is performed using the gtk-builder-convert (simply execute gtk-builder-convert window.glade window.xml).

3. In order to use the Window.xml definition just create a Python class and build the interface in the constructor. Don’t forget to instantiate the handlers you defined for your interface. Here is an example of my gui.py (before customizing the button listener).

Again, I really find easy to make stuff work using Python.

* – The expression tool appears several times between quotes and in italic because the actual application took no more that a couple of hours to build, so calling it a tool is a bit too much. Moreover, it’s highly hardcoded so it’s not much of a tool… it’s more like a “tool”!

 


Some APIs…

Ξ February 14th, 2009 | → 0 Comments |
Development |, , |


Yes, this is YAPP (yet another python post) on my blog… Three in a row! Not that I’m counting…

This time is related to describe some interesting APIs available for python developers. A while ago I was making some experiments in order to develop a simple tool to upload my photos to my Picasa Web Album, and automatically also into my Experiment photoblog. Trying to use Java proved to be a pain in the ass! Now that I discovered Python, I again ready to give it a try.

After a first glance, here’s my findings:

So, I guess all I have to do is develop the GUI. The next move is try to use Glade-3 to do just that!

[UPDATE @ February 15th, 2009]

More interesting APIs available at any python installation near you:

  • urllib and urllib2 enable the developer to download almost anything from the web
  • urlparse easily decomposes any url
  • and, even csv files are easily parsed to be accessed as tables

 


How to: Join MPEG or AVI videos (now using Python)

Ξ February 8th, 2009 | → 0 Comments |
Development, Tools |, , |


Did I already told you that I really enjoy to develop scripts in Python? It’s simply great!

Last month I did some research on how to join video files and the result was this. Now, having discovered Python I took another dive into the problem. The previous solution worked nice, but I was making it work double. Let’s see, the script began by concatenating the video files in /tmp folder, and then encoding it into the final video file.

A much more efficient was to do it is to simply execute menconder providing all the files to concatenate (in order!) as parameters. This solutions directly creates the output file, avoiding the creation of any temporary file.

Using Python to create the new script and trying to improving the first script, the new joinvids.py is now able to join .mpg and .avi files (according to the extension of the files to join).

 


The Latest Experiment

Ξ February 8th, 2009 | → 0 Comments |
Computer, Development |, , , |


The last post was so long ago that it’s hard to remember. Usually, the lack of posts comes associated with some huge amount of work. I could say that this is another example how my work takes to much of my own time, but that would not be completely true. In fact, I have been working long hours but the main reason for not having time to write is another…

I don’t see myself has a sysadmin, but I like to do my own experiments… like building a file sharing server (one that no one will hever use), having a wireless network in place (to be used once every month by a computer that could easily be connected using a wired connection) or mounting a home theater PC (an placing the old computer box in the living room and understanding that it really looks ugly and out-of-place).

No, this time it wasn’t one of “my crazy” projects. I just decided to learn a new language… I didn’t actually decided it! Let’s just say that Python started to grow on me. And front my point of view, Python is far better that bash script or perl or any other scripting language out there. With it you can do the simplest things, like inspecting some file’s content or you can do the most complex procedure (including, for example, DB access).

Book Cover
A friend talked about Python with me, and for someone with background in C/C++ and some bash script, Python turned out to be really (REALLY!) simple. I’ve been using it for a couple of months and I already converted all my ‘~/bin’ scripts to Python.

My real interest began after finding “Python for Unix and Linux System Administration” and reading this really hands-on and example based ‘introduction’.

More on my Python experiments, soon… (I hope!)

 


Man Pages

Ξ September 14th, 2008 | → 0 Comments |
Development |, |


Did you ever tried to do man something… and the manual pages are simply not installed in the machine?

Now there’s a quick solution. Just use the online manpages, available from the Ubuntu Documentation.

 


Handling SIGSEGV Signal

Ξ May 9th, 2008 | → 0 Comments |
Development |, , , , |


Soon or later, your Linux developed C/C++ code will generate a SISEGV signal and your application will miserably crash. This signal is generated when a program tries to read or write outside the memory that is allocated for it, or to write memory that can only be read. (Actually, the signals only occur when the program goes far enough outside to be detected by the system’s memory protection mechanism.) The name is an abbreviation for “segmentation violation”.

In order to improve your program, and terminate in a controlled way, you can register a custom function to handle such signal. The following example shows the leave function that is called whenever a SIGSEGV signal is launched.

    #include

    #include

    void leave( int s ) {
        std::cout << "FATAL: Leaving due to SIGSEGV." << std::endl;
        exit( s );
    }

    int main() {
        // Register SIGSEGV handler!
        signal( SIGSEGV, leave );

        // originate a SIGSEGV
        double array[20];
        std::cout << array[10000] << std::endl;

        return 0;

    }

 


On the nightstand...