Mounir Lamouri's Blog

To content | To menu | To search

256 colors terminal with tmux and urxvt

A few days ago, I was trying to change my vim theme for a 256-color one and I realized urxvt was not supporting 256 colors out of the box. Hopefully, there is a patch to get a 256 colors terminal with urxvt. It is available in the the Gentoo package, you just have to enable the xterm-color USE flag for rxvt-unicode like this:

echo "x11-terms/rxvt-unicode xterm-color >> /etc/portage/package.use

If you recompile rxvt-unicode, you should now get more colors. You can test it by using a 256-color vim theme like desert256 [1]. You can also run:

tput colors

I got 88 instead of 256. I don't know why but it's still a lot better than 16 colors.

Now, you have to make sure tmux is using 256 colors otherwise you will get a weird behavior. According to the tmux FAQ, it is really easy and you have to add a this line in ~/.tmux.conf:

set -g default-terminal "screen-256color"

In my system it was not working so I have to tell tmux my terminal supports 256 colors by using '-2' argument. You can add this line to your ~/.bashrc to always call tmux with '-2':

 alias tmux="tmux -2"

Now, if you run `tput colors` in a tmux session, you should get 256.

If you are using vim, you should add this line to you ~/.vimrc:

set t_Co=256

Hope this is helping !

Notes

[1] To compare themes, you can try http://code.google.com/p/vimcolorsc...

Placeholder attribute in Firefox 3.7 alphas

The placeholder attribute for input and textarea elements is available on Firefox 3.7 since developer preview 3.7a2.

The placeholder attribute is a new attribute from HTML5 Forms specifications. The placeholder text is showed as a hint on input and textarea elements when the element is empty and not focused. This kind of behavior is already used by a lot of websites and even by Firefox user interface [1].
If you are a web developer and you want to use the placeholder attribute, you should know you can easily identify if the UA knows about the placeholder attribute with this simple code:

if(!"placeholder" in document.createElement("input")) {
  // your fallback
}

This way, you can have a sane fallback until you consider the placeholder attribute is supported enough to remove the fallback.

At the moment, there are still some minor issues about the placeholder like the style for Aero (Windows Vista and 7) [2] and some optimizations [3]. However, there is a bigger issue related to the ability to style the placeholder [4]. Indeed, at the moment, there is no specification about the placeholder style customization. Webkit have decided to use a CSS pseudo-element "-web-input-placeholder" but unfortunately, no consensus has been reached.

To know if your browser supports the placeholder attribute, just look at the input field below. If you see "tulip orchid" that means your browser support the placeholder attribute correctly. If you see only "tulip" that means you browser has an issue with new lines in placeholder text (WebKit has this issue [5]). If you see nothing that means your browser doesn't support placeholder at all.


This is my first contribution for the HTML5 Forms implementation in Gecko/Firefox. Next steps may be the constraint validation API, autofocus and other small stuff.

Notes

[1] Actually, Firefox is using the XUL 'emptytext' attribute for stuff like the search box which is going to be replaced by the placeholder attribute.

[2] https://bugzilla.mozilla.org/show_b...

[3] https://bugzilla.mozilla.org/show_b...

[4] https://bugzilla.mozilla.org/show_b...

[5] I have opened a bug, https://bugs.webkit.org/show_bug.cg...

Why I don't blog so much

Actually, there are two main reasons : I have not so much free time to blog and I have probably not so much interesting things to say. That's a bit contradictory but more you blog less you do things and more you do things, more you want to blog about them but less time you have to. Unfortunately, I am not in one of those situations : I have not so much time and not so much interesting stuff to say.

But the real reason why I can't blog is because every time I think about this blog I think about the things I would like to improve.

First of all, I would like to improve the SQLite backend of Dotclear. Dotclear has a database abstractor but it is not completely finished for SQLite. Indeed, SQLite doesn't let you add or delete columns in a table [1], you have to create a temporary table and Dotclear doesn't create a temporary table, it justs throw an exception. So, to update the blog, I mostly have to create a new one and import my SQLite database.

Then, still related to SQLite, I would like to use a web analytics. I think Piwik may be fine but it doesn't support SQLite. I don't get why and I should ask the dev team. In a more general concern, I do not understand why the PHP developers do not use database abstractors. It is like there is no database abstractor in PHP. Though, the one in Ruby on Rails framework is really powerful. Why have they not been inspired ?

Finally, I am looking for a Dotclear plugin which allows me to set in which planet a blog post has to be. I am subscribed only in the Gentoo Planet/Universe at the moment and having a gentoo tag is quite easy and it should correspond to what I want to be shown in the planet. However, I want to add my blog to a french free software association planet which has strict rules like "has to be written in french" and "must talk about free software" I don't think having a tag with the name of the association would be the right solution. Indeed, the tag means I've spoken about the association in the article, it doesn't mean the article has to go to a specific planet.
The category is not a solution too because a category is often too restrictive and I can only set one category for an article. That means if I am writing an article, it can't be published to more than one planet ? I don't think that's what I want.

Why I am not working on all that stuff ? Because I have more important stuff to work on and the last time I wrote a line of PHP was ten years ago.

Being a geek is sometimes despairing...

OpenID: provide your own identity

OpenID is really interesting. I will not explain in details what it is about because openid.net or wikipedia will probably do that better than me. Basically, it's a try to get an unique way to log on various websites. For example, with OpenID, you can get authenticated on Facebook with your Google account[1]. Actually, OpenID is much more than a standard way to log on, it lets you externalizing the authentication server. That means you can use the OpenID account linked to your Yahoo! account[2] or even the one linked to your wordpress blog or any any one you may already have[3]. That also means you can use your own !

Why should you use your own server to provide your own identity on Internet ? Actually, this question should be "Why should I trust someone else to provide my identity on Internet ?". Indeed, with OpenID, you can externalize the authentication but that also means centralizing it. Having a lot of identities on Internet is annoying : you must file the same information, you have a lot of passwords, you don't always remember your username... But having the same account to log everywhere makes you very dependent on this account. If your OpenID provider closes its service, ask you to pay for it, doesn't respect your privacy, or anything else, you will be in a bad situation.

To prevent this situation, the best solution is to run and use your own OpenID server. If you already have one for anything else, adding OpenID is going to be easy. There is even a page with some solutions. phpMyID is really appreciated because it's lean but it's designed to provide only one account. That means you will not be able to offer an OpenID server to your friends. That's why I prefer SimpleID. How to setup the server will be maybe for another entry but I suppose anyone interested to do that will know how to found the information[4].

The simplest way is to delegate your authentication. That means you can use an OpenID account from myOpenID or any OpenID provider and, in your blog or any web page you control, you can add these lines in the HTML HEAD section:

<link rel="openid.server" href="http://www.myopenid.com/server" />
<link rel="openid.delegate" href="http://username.myopenid.com/" />

The example is using myOpenID but it could be wordpress, Yahoo! or anything else. openid.server is the server you want to use. openid.delegate is the OpenID account your provider told you to use (like username.wordpress.com for wordpress).
This solution lets you use your blog URL (or any webpage you want) as an OpenID account and it will transparently use the specified server. That means you will be able to change the server when you want without breaking your OpenID account. So, you are not as much dependent from the provider as you were. Unfortunately, there will always be a third party which you have to trust while you are using someone else as a provider.

Maybe you should now ask one of your geeky friend if she/he didn't setup an OpenID server or do it yourself ?

Why some Firefox plugins need to be compiled, example with Weave

Gentoo let the user installing a few Firefox and Thunderbird plugins via the package manager and people often consider it is useless. Actually, there are at least two reasons why it can be useful.
The first one is obvious : when installing a plugin with the package manager, you are sure it will be available for every users (except if it is manually disabled by the user). For example, you can install noscript for security reasons directly by enabling restrict-javascript USE flag.
The other reason is the compilation. Indeed, most plugins are platform-independent but some of them are not and those ones are not guarantee to work on your computer. For example, you can install Firefox on a lot of different platforms. If you stay with GNU/Linux, you can install Firefox 3.5 on alpha, amd64 (x86-64), arm, hppa, ia64, ppc, ppc64, x86[1] . This is true at least with Gentoo. It goes without saying if a plugin has a platform-dependent part, it will not provide a binary for all these platforms.

Concretely, I tried to install Weave 1.0 beta 1 and 2 from addons.mozilla.org. When launching Firefox, I got this output in the Weave Activity Log view:

2009-11-25 12:34:02	Service.Main         INFO	Loading Weave 1.0b2 in 5 sec.
2009-11-25 12:34:08	Engine.Bookmarks     DEBUG	Engine initialized
2009-11-25 12:34:09	Engine.Forms         DEBUG	Engine initialized
2009-11-25 12:34:10	Engine.History       DEBUG	Engine initialized
2009-11-25 12:34:10	Engine.Passwords     DEBUG	Engine initialized
2009-11-25 12:34:10	Engine.Prefs         DEBUG	Engine initialized
2009-11-25 12:34:10	TabTracker           DEBUG	Failed to load json: this.changedIDs is undefined JS Stack trace: ([object Object])@trackers.js:125 < Utils_jsonLoad("weave/changes/tab_tracker.json",[object Object],(function (json) {for (let id in json) {this.changedIDs[id] = 1;}}))@util.js:559 < T_loadChangedIDs()@trackers.js:123 < T__init()@trackers.js:76 < TabTracker__init()@tabs.js:356 < TabTracker()@tabs.js:345 < ()@engines.js:161 < Engine__init()@engines.js:179 < _init()@engines.js:303 < TabEngine()@tabs.js:56 < EngMgr_register(TabEngine,5,[object Array])@engines.js:113 < EngMgr_register([object Array])@engines.js:106 < WeaveSvc__registerEngines()@service.js:379 < _onStartup([object Object])@service.js:278 < notify([object XPCWrappedNative_NoHelper])@util.js:624
2009-11-25 12:34:11	Engine.Tabs          DEBUG	Engine initialized
2009-11-25 12:34:11	Service.Main         INFO	Resetting client syncID from _onStartup.
2009-11-25 12:34:11	Service.Main         INFO	Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:1.9.1.4) Gecko/20091109 Gentoo Firefox/3.5.4
2009-11-25 12:34:11	Service.Util         WARN	Component @labs.mozilla.com/Weave/Crypto;1 requested, but doesn't exist on this platform.
2009-11-25 12:34:11	Service.Main         DEBUG	Crypto check failed: TypeError: Svc.Crypto is null
2009-11-25 12:34:11	Service.Main         ERROR	Could not load the Weave crypto component. Disabling Weave, since it will not work correctly.
2009-11-25 12:34:11	Service.Main         INFO	Weave Sync disabled

If you unzip the xpi file, you will found a platform/ directory which is containing platform-dependent files. If we stay with GNU/Linux, we have Linux/, Linux_x86_64-gcc3/ and Linux_x86-gcc3/ directories. If we launch 'file platform/Linux/components/WeaveCrypto.so', we got:

platform/Linux/components/WeaveCrypto.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped

So, x86, x86-64 and arm are supported, not surprising. But my old Powerbook G4 (PowerPC) is not. Actually, it would be if I was using MacOS X instead of GNU/Linux.

I don't know if addons.mozilla.org should specify the supported platforms for platform-dependent plugins because arm, x86 and x86-64 are covering most of the target systems. Actually, as far as I know PowerPC is fully supported only by Gentoo and Debian. Anyway, if you are using an unconventional platform, you may want to compile your own weave plugin and probably a few others.

Luckily, weave has just been updated to 1.0b2 in the Gentoo tree :)

Notes

[1] mips is working with Firefox 2.0.0.19 and sparc with Firefox 3.0.11

Lecture about Mozilla at INSA Lyon

Last Friday (November 13 2009), I gave a lecture/conference titled Mozilla and its technologies in the context of the Mozilla Campus Reps program. Indeed, I am a Mozilla Campus Rep at INSA Lyon, my university.

The lecture had four parts. First of them was a classic presentation of Mozilla and Netscape history. Then, a presentation of some Mozilla projects like applications, libraries, tools and especially Mozilla Labs. The real technical part was about the Mozilla Platform (Gecko, XUL, ...). To complete, the Open Web and web standards.

Everything went well. I planned to give a 30-minute to 45-minute length lecture with 15 minutes of questions but it looks like I had a lot of things to say and I talked one hour long. Fortunately, there wasn't a lot of questions so I finished in time.
The most important is I had only good feedback which is pretty cool for a first experience !

The Mozilla campus Reps program wasn't able to send me a swag pack so I asked to Tristan Nitot (Mozilla Europe) who seemed delighted to help. Paul Rouget (Mozilla Europe too) also helped with some advices. A big thank you to both of them !

Finally, you can download my slides. You can also get the source files here. The slides have been made in latex with beamer. All this stuff is available in Creative Common Attribution 3.0 (CC-BY).
The slides aren't really verbose. They have been made only to get attention of the audience and let them follow me. I've spoke about a lot of subjects that are not even mentioned like JavaScript benchmarking, V8, FOSS work-flow... I find it more dynamic and -I hope- less boring for the audience.

It was a nice experience and I'm glad to have spread Firefox and Mozilla !

Introducing media-video/miro

Miro described itself as Open-source, non-profit video player and podcast client. It's actually somewhat a swiss-knife for videos if you are using video sharing services (like youtube or dailymotion), following podcasts and downloading videos via bittorrent.
Miro lets you do everything in one place. You can directly search for a video, download it and see it locally. Then you can organize your videos whatever it comes from and remove them when you want. To me, it's sound like the equivalent of songbird for videos.

Miro is also known for it's "Adopt a line" campaign which consist of paying 4$ per month to adopt a line of code and support the project. An innovative idea which seems to work.

So, bug 131527 is now fixed and Miro is known as media-video/miro in Gentoo's tree.
Try it and report bugs !

Gentoo/PPC needs you !

Gentoo/PPC team is here to make sure packages are marked stable and are keyworded as soon as possible and without breaking the tree. Unfortunately, we can't manage the flow of bugs coming and the list is growing too quickly.
Stabilizing and keywording is a big work. Fauli have explained it a few weeks ago in a blog entry.

So if you have a PowerPC and you want to help, you can and we will appreciate it !
First of all, look at the Gentoo/PPC testing doc. Some things may be outdated, consider essentially the procedures.

I've made some bug lists to make the life of everybody easier:
- stabilization requests
- keyword requests
- security bugs

Please, refer to the Gentoo/PPC testing doc if you want to help on one of these bugs.

Do not hesitate to come see us on #gentoo-powerpc on freenode.

Thème Time Flies par David Yim