czwartek, 10 października 2013

No diacritics in epub ebook on Sony PRS-900

If you see question marks instead of diacritics or any other non-latin characters on Sony PRS-900 a simple solution is to embed a font that contains them, eg. there: http://ebook.online-convert.com/convert-to-epub

How come that default font on an ebook reader does not contain many eg. polish letters, this I don't know. Eg. Arial Unicode MS containing 38 917 characters is just 22MB in size (ref.).

niedziela, 15 września 2013

Dell's e6430 discrete graphics card on Debian

Some new laptops have two graphics cards. One power-efficient integrated with CPU and one powerful discrete (separate board).

Bumblebee project provides support for NVIDIA Optimus laptops. Installing and usage is straightforward and described here. In short (if you want proprietary drivers):
  1. make sure you have contrib and non-free repositories enabled 
  2. Install packages:
    # apt-get install nvidia-glx nvidia-kernel-dkms bumblebee-nvidia primus
  3. Installing nvidia driver package will automatically set it as a default rendering engine but it's not desired. Normally 3D would be rendered by integrated Intel card, so do:
    # update-alternatives --set glx /usr/lib/mesa-diverted
Normally this should be it, but unfortunately in current debian testing there is a bug causing an output:

$ optirun glxgears
[   42.214557] [ERROR]Cannot access secondary GPU - error: Could not load GPU driver
[   42.214599] [ERROR]Aborting because fallback start is disabled.


To fix this in file /etc/bumblebee/bumblebee.conf in section [driver-nvidia] change line:
KernelDriver=nvidia

to:
KernelDriver=nvidia-current

piątek, 13 września 2013

Debian - slow brightness responce on Dell laptop fix

On some Dell laptops with gnome3 brightness change takes veeeery long (seconds) and system is choppy in the meantime.

A workaround has been posted: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/828296/comments/5

The workaround is:
  1. add acpi_backlight=vendor to GRUB_CMDLINE_LINUX_DEFAULT option in /etc/default/grub file
    (eg. GRUB_CMDLINE_LINUX_DEFAULT="quiet acpi_backlight=vendor")
  2. run
    $ sudo update-grub
Bug for ubuntu is filed: https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/847001

Worked on my Dell e6430.

czwartek, 30 maja 2013

OpenStreetMap tile server on Debian

There are many reasons why one might want to run own OpenStreetMap tile server. It is somehow explained here, here and here. but, in my opinion, not thoroughly enough.

I'll explain in detail how I did it on a Debian Jessie server. Note that in this method tiles are generated manually. To generate tiles automatically a solution like apache mod_tile must be used.
  1. Download OpenStreetMap data.
    This file contains a map itself but in an abstract format. It's best to start with a small dataset (available at download.geofabrik.de), the whole planet is 28GB.
  2. Install and configure PostgreSQL database (description at debian wiki). That's where OpenStreetMap data will be kept for easy access.
    $ sudo aptitude install postgresql postgresql-client
    Add a user (preferably the name of user that will be accessing the database, say bob):
    $ sudo -u postgres createuser bob
    Add a database named gis owned by bob:
    $ sudo -u postgres createdb --encoding=UTF8 --owner=bob gis
  3. Install postGIS. This is a PostgreSQL extension for keeping there geographic data.
    $ sudo aptitude install postgis
    Configure created database for postgis:
    $ sudo -u postgres psql -d gis -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
    $ sudo -u postgres psql -d gis -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
    sudo -u postgres psql -d gis -c "ALTER TABLE geometry_columns OWNER TO bob"
    $ sudo -u postgres psql -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO bob"
  4. Install osm2pgsql - a script to load data from .osm file into PostgreSQL database.
    $ sudo aptitude install osm2pgsql
    Perform import:
    $ osm2pgsql --slim -C 1500 poland-latest.osm.pbf
  5. Install Mapnik - library to generate tiles (images) based on data in PostgreSQL database.
    $ sudo aptitude install python-mapnik2 mapnik-utils
  6. Download and extract Mapnik stylesheet fileshttps://github.com/openstreetmap/mapnik-stylesheets/archive/master.zip (it has a nice README file).
  7. Download coastline shapes with script included in archive above:
    $ ./get-coastlines.sh
  8. Modify xml files with script provided:
    $ python generate_xml.py --dbname gis --user bob --accept-none
  9. I had problems with fonts (they are mentioned here), but I had to comment out lines in inc/fontset-settings.xml.inc that contained "unifont Medium".
  10. To test if everything works change bounds in generate_image.py to whichever fit your needs (they should be covered by OSM data you downloaded though) and launch the script:
    $ python generate_image.py
    If everything went fine there will be an output:
    output image to image.png!
    And of course an image will be created.
  11. To generate all tiles modify file to choose what tiles you want to be created (at the bottom of the file). There are some examples provided. To create tiles for Poland for zooms ranging from 1 to 12 I used:
    bbox = (14.28,48.92, 24.21,54.95)
    render_tiles(bbox, mapfile, tile_dir, 1, 12 , "Polska")
    To than generate tiles create a directory, say tiles and do (in bash):
    $ MAPNIK_MAP_FILE="osm.xml" MAPNIK_TILE_DIR="tiles/" ./generate_tiles_multiprocess.py
    (it's a trick with setting environment variables for command execution).
To display your tiles using OpenLayers (as described here):
  1. Make your tiles available via web server.
  2. Install packaged version of openlayers:
    $ sudo aptitude install libjs-openlayers
  3. Create an index.html file and paste the following:

niedziela, 19 maja 2013

Portable radiation mapper

In January this year I've come up with idea to combine a radiation detector with GPS. Data collected by such a device would allow me to make a map correlating received radiation dose with geographic location.

Such a map would be very interesting. It's a common knowledge (I hope) that there are many natural radiation sources around, and their density surely varies. Cosmic radiation intensity increases with height above sea level (thinner atmosphere layer to absorb it), ground radiation is not the same everywhere. Also higher radiation is expected where there's more "stuff from underground" exposed - mining areas or rocky terrains. Buildings are build from materials dug from earth, so cities might be more radioactive than, say, forests.

It was my first time working with electronics on my own so I decided to make it as simple as possible. It turns out that parts are commonly available. This is what I got:
This is how these parts look combined:
I am really pleased to see how community centered around Arduino-like projects tries to make electronics as accessible as possible. Plus there are tons of shops with "hacker hardware" designed exclusively to be used in this kind of projects. It's kind of amazing how easy is to build an electronic device such as this one.

I wanted enclosure to be transparent, so I ordered a laser-cut acrylic panels. To combine everything I used a plastic that can be formed with your hands after being heated to 60°C.

 




It was very hard to make it look good since the plastic hardened rather quickly. But then I used a heat gun to soften it wherever I needed and formed it nicely.


Data analysis is done by fairly simple python script. Most crucial parts I've already described: downloading maps and scaling hexes in matplotlib's hexbin function. Scaling is used to visualize statistical uncertainties - small hexes represent points with relatively large uncertainty.

The device has been taking data for two months now with help of my colleagues from scientific club. These are maps: city scale (Kraków, Poland) and country scale (Poland).



It's too soon to draw any conclusions from this data, but new data is being collected even right now.