Friday 13 November 2009

mysql and regular expressions

The first time I needed to have some kind of complex select statement, I started to pray about the ability to use regular expressions with mysql.

Easy as it may be: use REGEXP!

For example:

SELECT * FROM db.ip_addresses WHERE ip_address REGEXP '^192\.168\.0\.(133|135)$';

See the official documentation and details here.

Friday 6 November 2009

Now save and quit... doh!

If you like me are annoyed by the "recording" feature on vim (or better, by the way you can accidentally start it), then you may find at least useful to learn how it can be actually used.

This post explains it.

Monday 26 October 2009

Most used Perl editors

I've seen this poll too late, although it's interesting that the most used Perl editor is the vi family (where I'd belong) with 34%, followed not very closely by Emacs (13%).

Eclipse + EPIC got only 6%...

The full poll results here.

Tuesday 20 October 2009

Debianize a Perl module

What a good day.

Not only I've got a new laptop from the company, but I've found also an extremely useful tool to build a debian package from a perl module: dh-make-perl.

You just need to do 2 things:

- Run dh-make-perl on the untarred module directory (this creates the necessary debian dir and files).
- Inside the module directory, run debuild.

Very nice. Now I wonder why most of the CPAN and POE components don't come with a debian package...

Thursday 8 October 2009

When was that package installed?

On debian/Ubuntu you can check the installationdate from the output of:
ls /var/lib/dpkg/info/*.list -lh

Just | grep the name of the package you're interested to.

See this for important details.

Friday 17 July 2009

debian policy for init scripts

It could be useful to add your /etc/init.d/ script to debian/conffiles to avoid overwriting local changes.
Sometimes sysadmins change the init scripts and with this little tip you can help them in case of package upgrades.

From the Debian Policy Manual:
"The /etc/init.d scripts must be treated as configuration files, either (if they are present in the package, that is, in the .deb file) by marking them as conffiles, or, (if they do not exist in the .deb) by managing them correctly in the maintainer scripts (see Configuration files, Section 10.7). This is important since we want to give the local system administrator the chance to adapt the scripts to the local system, e.g., to disable a service without de-installing the package, or to specify some special command line options when starting a service, while making sure their changes aren't lost during the next package upgrade. "


Using externals with SVN

UPDATE: You need to specify the directory you want to create when setting the external property. No need to create the dir before propset: it'll be done automatically when you 'svn up'.


- Create somewhere in the SVN repo the directory you want to use as external (let's call it SVNEXTURL)
- Go in the working copy where you want to have an external reference and:

svn propset svn:externals 'newlocaldir SVNEXTYURL' .

where newlocaldir is the name of the directory being created by SVN during this operation.
Quotes are needed.
Note the '.'

- and then
svn up

Enjoy!

Problem: if you're using a version of svn-buildpackage older than 0.6.24 (debian), it won't work with external references. You can upgrade to >= 0.6.24 or apply locally the patch described here:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=363003

Monday 18 May 2009

Lessons learnt #1

Not a real surprise, but useful to write it down...

- If you have data that varies depending on the platform or environment you're using, be sure to have it in a separate file, marked as config file (for example using debian/conffiles if you build debian packages)

- Be sure to have a clear way to handle dependencies - Write them down and whenever possible use automated tools, as debian/control if applicable)

Friday 15 May 2009

I'm cellphone only

Now that I think about it, it's since 2000 that I don't have a fixed telephone line in the house where I live. Cell phone and ADSL or 3G data connection meant to replace it (with some limitations in terms of service availability and emergency calling).

It's probably a known trend: in the US 20% of people have made the same choice.

And look how many families are adopting wireless phone services only! I'll write on this topic and on interesting solutions.

VOIPBLOG.IT reported it in Italian.

Thursday 14 May 2009

2700 blogs available on the Kindle Store (and a digression)

Quite amazing to see how many blogs you can subscribe to from the Kindle Store.
Prices go from 0 to $1.99.

By the way, digging a little bit in the past (March 2008), I've found an interesting rumor from Apple about a tablet from Mac:
A little birdy tells me that Apple will announce a 12 or 13-inch tablet in the fall of this year. Most likely in the September or October time frame.


That was rumored one year earlier as well (January 2007).

I could go even further in the past, but the good news seems to be that this time, eventually, we'll get the mega tablet from Mac on the next Fall... maybe.

Wednesday 13 May 2009

curl for HTTPS (and Twitter)

curl is a powerful library available on different platforms - I use it on Linux debian.

You can use it just to get http pages, or to post data and get a response from a server.
HTTPS is available too.

An example:

curl -k --data @request.xml https://127.0.0.1/service

posts the XML data contained by request.xml using a HTTPS connection (and ignoring invalid certificates, option '-k' - just for testing purposes).

This is a more interesting usage: it's nice to get info from Twitter or even send messages ("update your status") with just a command line:

Get status:
curl http://twitter.com/users/show.xml?screen_name=giavac

Send a message:
curl -u user:password -d "status=describing how to use the Twitter API" http://twitter.com/statuses/update.xml

To install curl on debian:

apt-get install libcurl3

(install dependencies too, and I suggest to include libcurl3-gnutls-dev)

Tuesday 12 May 2009

How many different tea times do you have?

Just realized that in UK you can refer to the "last or almost last meal of the day" as "Tea".

This just makes sense, considering that while driving you have to keep the left, but on the escalator you have to keep the right if you're standing, and the left if you're walking.

Not mentioning that your weight can be measured in stones, but in the gym weights are in pounds OR kilos, while when you buy food they use ounces.

I'll have a twentieth of gallon of tea before going home for the tea...

41.5% of Italians don't use Internet

...even if Facebook looks very crowded!

Source IlSole24Ore.

Sunday 10 May 2009

Touching art with an iPod


Positively surprised to experience that the so-called audio guides have been replaced by iPod Touch at Tate Modern.

Advantages are:
- You can see movies and pictures together with the audio presentations
- Easier to use - no need to enter a number to select an argument
- Lighter

Disavantages:
- Even if you're a Tate member, and you're paying for the guide, you have to leave an ID...

e-readers and advertising on newspapers


Yesterday I wrote a quick note on Kindle DX, the new e-reader from Amazon, and today on The Independent I've found an article titled "Hold the front page: newspapers have a future" (see picture, taken this afternoon from Tate Modern).


Statistics say clearly that advertising in newspapers is going down rapidly (starting well before the 2008 internation crisis), so in this area, like on the web, there's more and more focus on context advertising. Less costs, higher conversion rates.

e-readers can be, more than just an interesting gadget, a tool to access "custom" advertising and ad-hoc contents. It would be nice to read your favorite magazine, select some additional content, find deals on what you're interested in and... buy it straigth away!

But I was also thinking: is an e-reader really needed? Or maybe manufacturer of mobile devices, already accessing Internet via WiFi and 3G, should just provide a big, plug&play screen, optimized for reading? Rather than spending 350P for the Kindle DX, I'd spend half of it for a portable screen to attach to an iPhone...

Friday 8 May 2009

Kindle DX - Cool but expensive, and won't replace books (I hope)

The title says almost everything I wanted to write about the new Amazon e-reader.

A detailed article from BBC News.

When the prices will start dropping, I'll take it into serious account.

VoIP banned from MS MarketPlace (MS style)

That's the way MS wants to compete on the Mobile applications against the AppStore: banning VoIP from the allowed applications.

It's the 4th point in their Prohibited Application Types document.

Topic followed through VOIPBLOG.it and thestandard.com.

Thursday 7 May 2009

Where cloud computing is going

Just finished reading an interesting article by Paul Bennet on Cloud Computing.
It really looks like we're going in that direction, with security and data privacy as key points.
Furthermore, in UK as well you can get notebooks for free with a monthly data contract!
The OS is not a problem, however the availability of VPN clients will be extremely important.

Wednesday 6 May 2009

MySQL - Last INSERT id

If you want to know which is the ID of the last INSERT been made from the current connection, when auto_increment is active, use this:

SELECT LAST_INSERT_ID();


A few lines in non-optimized perl:

my $sel_last = "SELECT LAST_INSERT_ID();";
my $sth = $dbh->prepare($sel_last)
or die "Couldn't prepare statement: " . $dbh->errstr;

$sth->execute()
or die "Couldn't execute statement: " . $sth->errstr;

my @data;
while (@data = $sth->fetchrow_array())
{
print "Last ID was.... $data[0]";
}

More details here for the MySQL statement and here for the perl DBI.

Friday 1 May 2009

MS and Verizon to fight the iPhone

'Pink' is the code name for a new mobile device aiming to compete with the iPhone.

Key points are:
- Touchscreen (surprise)
- More powerful OS (extending Windows Mobile)
- More applications (maybe with the same iPhone Apps approach?)
- An online store (Windows Marketplace for Mobile)
- WiFi (in collaboration with Verizon Wireless)

News from the Online Wall Street Journal, reported in Italian for IlSole24Ore.

Thursday 30 April 2009

base64 encoding/decoding

One of the biggest problems nowadays is to being able to encode or decode to/from base64.

Jokes apart, if you need to quickly check a base64 string, try this encoder or this decoder (mind the note before using them).

Wednesday 29 April 2009

Facebook Lexicon

Pretty nice application for Facebook - It enables you to see statistics on keywords on the public walls.

Give a look to it here: http://www.facebook.com/lexicon/ and try for example: "brawn, ferrari" or "iphone, ipod".

About ICE negotiation

Disclaimer: I wrote this article on March 2022 while working with Subspace, and the original link is here:  https://subspace.com/resources/i...