Archive for the ‘Linux’ Category

PHP Help

Sunday, December 6th, 2009

Dear lazy web:

How do I make PHP not run out of memory when doing thumbnails of large images? I’ve got this code:

                        $href = $path . "/" . $file;
			$tn_file = "thumbnail-" . $file;
			$orig_file = $full_path . "/" . $file;

			/* generate thumbnail if it does not exist */
			if (file_exists ($tn_file) == false) {
				$im = @imagecreatefromjpeg ($orig_file);
				if (!$im) {
				        $im = @imagecreatefrompng ($orig_file);
					if (!$im)
						continue;
					$is_png = 1;
				} else
					$is_png = 0;

				if (imagesx ($im) < imagesy ($im)) {
					$new_width = round (imagesx ($im) / (imagesy ($im) / 240));
					$new_height = 240;
				} else {
					$new_width = 240;
					$new_height = round (imagesy ($im) / (imagesx ($im) / 240));
				}
				
				$copy_im = imagecreatetruecolor ($new_width, $new_height);
				imagecopyresampled ($copy_im, $im, 0, 0, 0, 0,
					$new_width, $new_height, imagesx ($im), imagesy ($im));
				if (is_png == 1)
				        imagepng ($copy_im, $tn_file);
				else
				        imagejpeg ($copy_im, $tn_file);

				imagedestroy ($copy_im);
				imagedestroy ($im);
			}

			//$get_url = "/images/thumbnail-" . $file;
			$get_url = $tn_file;

It works great for most of my images (as you can see here), but it doesn't for big images (2592x1944 pixels, like this one).

I've been trying all the solutions mentioned in this page, but none seems to work for me :-( I am assuming it's an out-of-memory problem, but could it be something else?

Syncing Evolution contacts to Ubuntu One

Friday, October 30th, 2009

The other day was about Tomboy notes, today, Evolution contacts syncing to Ubuntu One!

For the basic setup, see this tutorial. So, once you have contacts in the Evolution CouchDB Ubuntu One addressbook, syncing to Ubuntu One happens automatically:

The same contacts show up automatically in the Ubuntu One web UI:

Now, we just need to get mobile devices (N900, Android, etc) to sync contacts there also, and your contacts would be everywhere you need them!

Enjoy it!

Syncing Tomboy notes with Ubuntu One

Wednesday, October 28th, 2009

Lots of people keep asking the same question (how do I sync Tomboy notes with Ubuntu One?), so, since there is a nice tutorial already, posting it here to get to a wider audience: the tutorial.

Since this is also my first post about it (didn’t want to make it too public until it worked great), I wish to give special thanks to Sandy Armstrong, Tomboy’s super hacker, whose help in making this work has been very valuable. Not only he helped us in all the problems we found, but he was very receptive on our suggestions for changes in the syncing protocol. So, every time you sync your notes (to Ubuntu One or a Snowy server), please save some money to pay him (and me, if possible) some beers :-D

GCDS expectations

Thursday, July 2nd, 2009

With just a few hours before I leave to Gran Canaria, here’s a list of things I personally would like to get from the conference:

  • I’ve been to all GUADEC’s except for 2 (Stuttgart and Istanbul), and every time I’ve missed one GUADEC, I was doubly excited to go to the next one, so this year, having missed last year’s, this is the case again.
  • Since for the first time we are having a joint KDE/GNOME, I am expecting to have a big push on collaboration and cooperation between the 2 projects. I am not sure what would come out of this, but we should all really be looking for this, since it would just help both projects a lot. So, keep the rivalry only for the sport activities, please (maybe a KDE vs GNOME football game? :-) )
  • As I’ve already blogged about recently, we (at Canonical) are trying to push CouchDB use to the desktop. I’ve got all the code I’ve been working on ready to be shown (karmic packages here, but broken for jaunty right now, sorry), so if someone wants to see it in action (a technology preview, of course, not everything is done yet), just find me around and I’ll do a personal demo (a better demo if you buy me a beer :-D ). Other Canonical staff will be around also showing these (and other) technologies, so if interested, just ask.
  • GNOME 3.0 plans and technologies like mutter, gnome-shell.
  • I only played the FreeFA tournament in Vilanova (yeah, was part of the cool champion team), so looking forward to revalidate the title :-D
  • Mojo Picón, a spicy hot sauce typical from the Canary Islands. Make sure you try the Papas Arrugadas with that sauce.
  • Have a lot of fun!

Only bad thing is that I’m going to miss the first few days of San Fermín festival in Pamplona, but well, since I’ll be back home on the 10th, I’ll have the chance to enjoy the last few days of it. As I said other times, please use other dates than July 6th to 14th next year!

See you all in Gran Canaria!

couchdb-glib 0.1

Thursday, June 11th, 2009

As the first step on CouchDB desktop integration, here’s version 0.1 of couchdb-glib, a GLib-based API to talk to CouchDB.

This initial version only allows reading and does all operations synchronously (not a problem in most cases, since the communication is done to the local CouchDB instance, which is quite quick, at least from what my tests show so far). Next releases will have all the missing functionality.

And, well, no screenshots to show, so here’s some example code for you to enjoy.

Source code is in GNOME GIT, under couchdb-glib module.

Desktop data/settings replication

Wednesday, June 3rd, 2009

In the last UDS, there were some talks about UbuntuOne, the technologies it uses, and how it could be well integrated into the Desktop. Also, there were discussions about how it could be integrated painlessly into upstream projects. So, here’s an idea on how this could be done.

First, it must be said that the easiest (and quickest) way of achieving UbuntuOne integration in Ubuntu would be to just patch/extend applications so that they supported accessing the UbuntuOne server, and have Ubuntu packages use that as default for users with UbuntuOne accounts. That would make most Ubuntu users happy, but it would not benefit at all users of other distributions, and worst, the upstream projects.

Now, if we look at the technologies being used in UbuntuOne, there is one awesome thing, called CouchDB, a project supported by the Apache Foundation, which provides databases (of JSON documents) that can be replicated (and 2-way synchonized) to other hosts. So, what if we had Linux Desktop applications use this for storage of files and settings?

couchdb-in-the-desktop

Well, what would happen is that we’d gain data / settings replication and synchronization for free. And also, if we could come up with standard formats / locations for common information (accounts, notes, mails, calendars, etc, etc), we’d also gain a shared storage for all applications to use, solving the problem of incompatible formats / locations used by similar free software applications.

And other advantages:

  • CouchDB knows already how to deal with conflicts, as this is included in the automatic replication / syncing features it provides.
  • While normal documents in CouchDB are JSON, you can attach any kind of file to any JSON document (even to empty JSON documents), so any kind of files can be stored. Also, it allows users to create as many databases as needed, so storage for different needs can be easily separated.
  • CouchDB provides a sort of revision history, so it could be used for nice stuff like Zeitgeist.
  • This, not being an Ubuntu-only solution, could benefit every Linux Desktop user.
  • UbuntuOne would be a service built on top of this that users can subscribe to. But others could just setup a CouchDB server on their home / company network and use that by just pointing their local CouchDB to their remote CouchDB replication server.

To continue my investigations/playing on this, I’m going to try writing a gvfs backend to manage files in the CouchDB instances. Once that’s done, applications could start just writing their files to couchdb://… URIs instead of file://… ones and enter the replication/synchronization world with just a single change. Next, a GConf/d-conf backend could be added for replicating/sync’ing settings, and so on.

GNOME Packaging Day

Monday, January 26th, 2009

In the last few openSUSE-GNOME team meetings, it was decided to do regular packaging days whenever GNOME point versions are released, with the goal of providing bleeding edge updates as quickly as possible. So, next week is that time: along with the GNOME 2.25.90 release on Feb 4th, Thursday Feb 5th we’ll be helding a packaging day to get the latest unstable GNOME release packaged into our GNOME:Factory project (to be used for openSUSE 11.2 but also available for 11.1). It is a great opportunity to find out how to contribute to the packaging of GNOME for openSUSE.

The packaging day will last the whole day long, so just come around #opensuse-gnome IRC channel on FreeNode at any time you want and ask how to help.

AdminKit 0.0.1

Wednesday, October 22nd, 2008

Last week it was hacking week for the openSUSE-GNOME team, so I continued working on a little project I started a few weeks ago, which is, in the good old Richard Hughes tradition, a thing called AdminKit, which is a PolicyKit-based framework for allowing user applications to run administration tasks.

Most of the time hacking on this has been dedicated to the PolicyKit stuff, but now everything should be in place, and, apart from the 2 methods I added (RunAsRoot to replace gnomesu/gksu/kdesu, and AddUser as an example of how to use YaST’s command line interface for the operations), more methods (users management, firewall, samba shares, etc) can be easily added. With this and the GUI from gnome-system-tools, I think we can start providing a distro-independent (and acceptable to all of them) set of administration tools for GNOME (and KDE, if they adopt AdminKit), or just add the needed admin functionality to already existing applications. From now on, here are my ideas:

  • Move PolicyKit mechanisms already existing in some GNOME modules (gnome-panel’s SetTime and SetTimezone, for instance) to AdminKit, provided people agree on adopting it
  • See system-tools-backends and reuse as much knowledge/code as possible
  • See at changing gnome-system-tools’ GUI to use AdminKit (once the functionality needed is moved to AdminKit)
  • Add more admin operations, as needed. For openSUSE, we have quite a lot of functionality via yast’s command line interface, and other distros have similar stuff, so anything we need can be added AFAIK.

Get the code with:

git clone http://www.gnome.org/~rodrigo/git/osc-plugins.git

(cd AdminKit, the other top-level dirs contain unrelated projects)

And, soon, packages at my home build service repository.

openSUSE build service collaboration

Friday, July 18th, 2008

One of the shortcomings of the openSUSE build service was, until recently, that it didn’t help outsiders (non-Novell employees) in contributing to the distribution’s packages. The build service team worked hard in the last few months, and now it is very easy for external people to send patches directly to be included in the main distribution.

First, you need to create a branch from the package you want to change:

osc branch GNOME:Factory gnome-utils

This creates a branch in your home project (home:$user:branches:GNOME:Factory), so just check it out:

osc co home:$user:branches:GNOME:Factory gnome-utils

Then, just work on changes, and when everything is ok and the package builds, just commit and submit a request

osc commit -m “Changed foo and bar”

osc submitreq create -m “Changed foo and bar”

Before submitting though, it might be wise to re-check your changes:

osc rdiff home:$user:branches:GNOME:Factory gnome-utils

which shows a diff of the changes in your branch.

osc commit/submitreq create will submit the changes to your branch and to the project you branched from (GNOME:Factory in this example), so that maintainers can review and accept (or reject) the submission. Maintainers just need to:

$ osc submitreq list GNOME:Factory

359 new home:rodrigomoya:branches:GNOME:Factory/gtk2-engines -> GNOME:Factory/gtk2-engines ‘——————————————————————-\nFri Jul 18 17:16:38 CEST 2008 – rodrigo@suse.de\n\n- Tag and upstream patches’

360 new home:vuntz:branches:GNOME:Factory/pango -> GNOME:Factory/pango ‘Tag pango64.patch’

363 new home:jproseve:branches:GNOME:Factory/glib2-branding-openSUSE -> GNOME:Factory/glib2-branding-openSUSE ‘Fix bnc#406741′

364 new home:rodrigomoya:branches:GNOME:Factory/fast-user-switch-applet -> GNOME:Factory/fast-user-switch-applet ‘Tag patch correctly’

365 new home:rodrigomoya:branches:GNOME:Factory/gnome-utils -> GNOME:Factory/gnome-utils ‘Tag some patches’

366 new home:jproseve:branches:GNOME:Factory/scrollkeeper -> GNOME:Factory/scrollkeeper ‘Tag patches’

367 new home:jproseve:branches:GNOME:Factory/icu -> GNOME:Factory/icu ‘Tag patches’

368 new home:jproseve:branches:GNOME:Factory/scrollkeeper -> GNOME:Factory/scrollkeeper ‘Tag patches’

which lists all the submissions waiting in the queue, and then just needs to review it:

$ osc submitreq show -d $id

which shows the patch for the submission identified by $id. And then, just accept or reject:

osc submitreq accept $id

osc submitreq decline -m “Your patch is wrong, don’t send me more” $id

Neat, isn’t it? This should help us a lot in getting users’ contributions quicker into the distro, as well as in a better patch reviewing system.

openSUSE 11.1 ideas

Thursday, July 3rd, 2008

Just recovered from the success of the openSUSE 11.0 launch, the openSUSE-GNOME team is already working on the future 11.1 (expected in December), so we are starting to get feedback for new ideas from users. Anyone can add their own ideas to this page, so if you want something new in either GNOME or openSUSE, add your ideas to the wiki.