Tuesday, February 10, 2009
Disabling mailto links in Firefox
Set network.protocol-handler.external.mailto to false in about:config to disable mailto links. Works in Firefox 2 and 3.
Saturday, January 24, 2009
Tearing while playing video with mplayer on Ubuntu
I had a slight tearing problem while playing video with mplayer on my Ubuntu 8.10 machine. My machine has a Intel i945 graphics card with the i915 driver. This is how I solved it.
In my case the problem was that mplayer used wrong xvideo adaptor.
So it's using port 97.
Running xvinfo displays information about the xv xorg extension. Two adaptors in my case; one bad and one good. Mplayer is unfortunately using the bad one because it always picking number #0.
Relevant parts from xvinfo:
Port 97 is Textured Video and port 113 is Video Overlay. The -vo parameter can be used to tell mplayer which adaptor to use.
And bam! That's it.
In my case the problem was that mplayer used wrong xvideo adaptor.
$ mplayer -v file.avi
...
using Xvideo port 97 for hw scaling
So it's using port 97.
Running xvinfo displays information about the xv xorg extension. Two adaptors in my case; one bad and one good. Mplayer is unfortunately using the bad one because it always picking number #0.
Relevant parts from xvinfo:
Adaptor #0: "Intel(R) Textured Video"
port base: 97
Adaptor #1: "Intel(R) Video Overlay"
port base: 113
Port 97 is Textured Video and port 113 is Video Overlay. The -vo parameter can be used to tell mplayer which adaptor to use.
mplayer -vo xv:port=113 file.avi
And bam! That's it.
Friday, August 29, 2008
Parse HTML using CSS selectors
lxml is a nice library for parsing XML and HTML with python. It can use CSS selectors to find nodes.
Here's an example that shows how smooth it is to use.
This one fetches all the anchor texts (truncated to not break the page.)
This one fetches all the link destinations (also truncated.)
Here's an example that shows how smooth it is to use.
>>> from lxml.html import parse
>>> google = file("google_se.html") # saved google result page for "example"
>>> root = parse(google).getroot()
This one fetches all the anchor texts (truncated to not break the page.)
>>> [link.text_content()[:20] for link in root.cssselect(".g h3.r a")]
['Image results for ex', 'Example (rapper) - W', 'Example - Wikipedia,', 'MySpace.com - EXAMPL', 'Dynamic Programming ', 'example - definition', 'example - Definition', "Example - I don't wa", 'XML by Example - Goo', 'Example', 'example']
This one fetches all the link destinations (also truncated.)
>>> [link.get("href")[:20] for link in root.cssselect(".g h3.r a")]
['http://images.google', 'http://en.wikipedia.', 'http://en.wikipedia.', 'http://www.myspace.c', 'http://www.avatar.se', 'http://www.thefreedi', 'http://www.merriam-w', 'http://www.youtube.c', 'http://books.google.', 'http://www.example.o', 'http://www.docbook.o']
Subscribe to:
Posts (Atom)