Executing an external program in Python…

November 19th, 2008

There are several ways of executing an external program from Python, but I had
the problem to catch the standard output.

After a while I came to the following solution:

import os

# Executing a shell command
mycmd = "python mycode.py"
child_stdin, child_stdout, child_stderr = os.popen3(mycmd)

# Reading the output streams
my_output = child_stdout.read()
my_error = child_stderr.read()

print "my_output:", my_output
print "my_error:", my_error

Enjoy,
Rob.

Hardened PHP

October 10th, 2008

In a (SUSE) server I’ve got this error message.

ALERT - configured request variable limit exceeded - dropped variable 'XXXX' (attacker 'XX.XX.XX.XX', file 'XXX'), referer: XXX

It looks like it has the “Suhosin Extension” of the Hardened-PHP Project.

So I configured the following variables in my .htaccess file:

php_value suhosin.get.max_vars 500
php_value suhosin.request.max_vars 500
php_value suhosin.post.max_vars 500

and everything worked fine again.

Enjoy,
Rob.

ObjectiveC on Ubuntu Linux

August 7th, 2008

Hi,
as I’m about to become an iPhone programmer (another one?), I’ve decided to set up an objective-c environment on my Ubuntu too.

First, I’ve downloaded all the packages for ObjectiveC and GNUstep I’ve found on Synaptic.

Second, I’ve tried to compile a classical Hello World file with gcc. Here’s the code (’Ciao mondo’ stands for ‘Hello world’ in Italian):

#import 

int main(int argc, char* argv[]) {
        NSLog(@”Ciao mondo”);
        return 0;
}

and i saved the source in a file called main.m

After that I’ve tried: gcc main.c -o hello and I soon got the following error message:

main.m:2:34: error: Foundation/Foundation.h: No such file or directory
main.m: In function ‘main’:
main.m:5: error: cannot find interface declaration for ‘NXConstantString’

Read the rest of this entry »

Converting SVG -> PNG with transparent backgrounds

July 29th, 2008

I’ve tried to convert an SVG image with transparent background to a PNG using the Image Magick’s convert command line tool. The result was an image with a white filled background.

After struggling with Yahoo search for about half an hour, I came across to this simple and useful tip:

convert -background none folder.svg folder.png

That’s it! No more white background ;)

Enjoy

Web Development

July 3rd, 2008

Enjoy,
Rob.

PyQt4 Tutorial

June 26th, 2008

PyQt4 is the wrapper for Trolltech’s Qt4 libraries. On the riverbank site you can find the sources and the windows binary; ubuntu seems to ship the binary on the official release, simply look for pyqt in synaptic.

Here is a good PyQt4 tutorial: zetcode

And here another good in Italian: un tutorial facile facile

Anybody knows about the binary on mac? I’ve found something on finkproject: anybody tested it?

Regards,
Rob.

Scripting Second Messenger

June 13th, 2008

I’m extending the Second Messenger by adding scripting capabilities.

I already have embedded a python engine in it and I’m working on a wrapper of the client object (I can’t give you all the power, sorry ;-).

I’m currently struggling with architectural issues and I hope to have a public version soon…

…maybe so soon that will have at first the ability to automatically answer to ScriptDialog messages. What for? Many camping chairs prompts the user with questions and possible answers: why not letting an automatic script to respond instead? ;-)

The next step could be to monitor group messages and automatically ban spamming people from your group.

Nice, huh?

Xmlrpclib with cookie aware transport

June 13th, 2008

Using Python made me fall in love with XmlRPC. The python xmlrpclib is great and I’m using this protocol with C# and PHP too.

The problem
Any call to an xmlrpc server is stateless, so that you are forced to send state information back and forth through additional parameters.

The solution
So that i dediced to write a transport object that keeps track of the session id cookies sent by the server.

Here’s the code:

Read the rest of this entry »

PHP and DL()

May 21st, 2008

The problem
I’ve tryied to execute a php script containing a dl() call to a .so from the command line and I’ve got the message:

Warning: dl(): Dynamically loaded extensions aren't enabled in /home/roberto/tmp/helloworld.php on line 6

The cause

The web host has not enabled dynamically loaded extensions.

The solution
I asked to the php interpreter where to find the configuration:

php --ini

Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
...

So with a simple sudo vi /etc/php5/cli/php.ini I changed the parameter enable_dl=Off to enable_dl=On.

Enjoy,
Rob.

Open source can change your life

May 15th, 2008

This post is really enlightning of how open source can really change/improve your life.


 
Roberto Rocco Angeloni is proudly powered by WordPress
Entries (RSS) and Comments (RSS).