Chromium opens downloaded files using xdg-open. Problem is, xdg-open
doesn’t work correctly with awesome (and also doesn’t support a number of
other, non-mainstream wms.)
The piece of code responsible for detecting the desktop environment:
(this comes from Gentoo’s xdg-open, ebuild
While we could easily monkey-patch this, or we could just set some environment
variables, but there’s a cleaner solution. Create the script
/usr/local/bin/xdg-open, so it will take precedence over the real xdg-open,
and have it set the environment variable only for the process you’re about to
I found some helpful information on this forum , though my idea is different as I want Chromium to use KDE
software when opening files (okular, gwenview, etc.)
As of xdg-utils version 1.1.0_rc1_p20120916, detectDE is now somewhat
smarter and a lot more complex (~70 LOC).
A broken Sapphire Radeon HD 4850 somehow ended up in my possession. I
didn’t know what was the problem, so I tried to plug it in in a mobo I just had
lying around, running the nightly oneiric.
The card showed up fine in lspci. I didn’t try using it with the open-source
drivers, as I’m not interested in putting a display on it. Instead I wanted to
play around a little with OpenCL, so I went for the closed-source Catalyst
driver. (This was a few days ago, when 11.6 was the newest version around - I
haven’t tried it with the latest 11.7 or with the 11.8 preview versions.)
The driver didn’t start, X choked on this error:
(EE) PPLIB: PP_Initialize() failed.
Since the driver is not open-sourced, googling around didn’t reveal any usable
source code on PP_Initialize. So I turned to objdump.
This revealed a few things about PP_Initialize. (I don’t think I should post
any dumps here, as I believe that would violate copyright laws.) I assumed it
returns a status code, so I tried overloading it and returning a different
status code instead:
This will start the X server but with our library preloaded. With a status code
of zero, the server now continued the loading of the driver, but of course
other errors have emerged. So I ended up overriding a couple more functions.
I was wondering if maybe PPLIB is part of the code that manages
PowerPlay functions, and if maybe just disabling it all and setting the
fan speed manually to 100% would give me a result.
Well, I was wrong. The only thing I gained was some experience with objdump,
reverse-engineering, some C and assembly. After disassembling the card itself,
I noticed that one of the conductors on the GPU seemed to be burned out -
probably causing card initialization to fail.
I also learned that when pre-loading with LD_PRELOAD, the overriding function
should accept the same number of arguments as the overriding function,
otherwise crap will be left on the stack, messing up the rest of the code. To
figure out how many parameters a function takes, it is usually enough to fund
it in the objdump output, look at the assembly, and count how many things are
popped off the stack before returning.
The pops usually occur around the top of the function body, just before the
ret statement, so no need to follow any jumps. Note to discard stack pointer
registers, %ebp and/or %esp.
Another thing I’ve learned playing around with GPUs is the fact that X has to
be running in order for OpenCL to work on a card. No displays are necessary,
but the Device sections in xorg.conf need to reference the proprietary
drivers (as the open-source ones don’t provide OpenCL support at the moment).
Exponentiation of large numbers can easily be implemented using exponentiation
by squaring, which greatly reduces the number of steps it is needed for a
given imput. Computing large exponents modulo a number is even faster and
requires less memory, as it reduces the size of the resulting integer.
The following implementation works for both Python 3 and python 2 (although in
Python 3 it will run faster):
Due to the modulo, the resulting function will be very fast: for example, it
calculates mesq(3**5**7, 11**17**3, 69) in a matter of milliseconds.
To get the idea behind, set the debug keyword argument to True. This will
show you how it actually calculates the result:
And finally, if you’re wondering where would you need madular exponentiation,
well, it comes in handy for example when generating Pratt certificates.
Do not actually use this code. This is just an example. A way faster
implementation is the built-inpow(), which also accepts a third argument
We had some great time, visited some Buschenschänke, and, of course,
wrote a lot of code. I mostly worked on code that was related to the project
I’m working on. Nevertheless, during the sprint we’ve implemented a new
library, a YAML connector for the YAFOWIL form/widget library, called
yafowil.yaml. I also contributed a patch to rod.recipe.appengine,
which is already publisted on PyPI.
Inspired by Ivan Vanderbyl’s implementation, I also put together a
progress bar, in pure CSS. The transition of the blue bar is also done
percentage text. It is also possible to animate it with pure CSS though.
Today I had some free time, so I played around with the
OpenStreetMap API. It turns out it’s quite
easy to draw 3D-looking buildings on a canvas. After an hour or two of coding,
I was able to render actual buildings from the OSM database:
Buildings rendered on a canvas
On the above picture, red buildings are “primary” ones (i.e. ones with an
address or a house number), while the grey ones are “secondary”. A demo
version of the canvas map can be seen
here (but only by people with decent
As a comparison, here’s how Mapnik renders the same data:
Even nicer is the result when it is drawn over Mapnik’s tiles:
The two images merged together
The above result could be improved by not rendering any of the buildings by
Mapnik, only the ground, & the roads. Then the canvas renderer could just place
everything else on top of the Mapnik layer (including amenities and other
While maps rendered on the server side are more compatible with old browsers,
canvas-based maps can be made more interactive (e.g. hovering or clicking on a
building could highlight it and pop up a message with the complete address or
relevant information). Other projects, such as
Cartagen, are capable of rendering a high variety of
objects, not just buildings, but they still require a lot of improvements, for
example the display of road names is note very optimal.
Hopefully, as more browsers support HTML5
and canvas by the day, people will implement great interactive applications
using this technology.