Mendeley CSL Locales

I don’t talk often of my day job at Mendeley here… but this time I can’t stop myself.

Finally, Mendeley Desktop supports CSL Locales! In Mendeley we use the Citation Style Language and citeproc-js to render the citations and the bibliographies. A year ago I talked here about the CSL project (what is the CSL project? and how Mendeley helps the CSL project).

Now, in Mendeley Desktop version 1.13.4, the user can choose easily (View -> Citation Styles -> More Styles… bottom of that dialog) which language should be used to render the citations and the bibliography. I opened the internal Mendeley Desktop ticket in 2010 but we always had something more urgent to implement. We even decided to implement journal abbreviations before CSL Locales.

But I added gettext support to Pydance (in 2008 or 2009) and I implemented gettext support in Grub (back in 2009 and 2010). I talk about Mendeley with non-English users (especially when I travel back to Barcelona…) and I really wanted to implement the CSL Locales properly (we had a work around, not user friendly at all, for people who contacted support).

Anyway, I’m very happy that I got the time to implement it and finally release it! Even though this is just a step towards a better multilingual support: we’ve found a few problems with the Chinese locale and some styles might need a bit of improvement for some languages, etc. We need to collect feedback for a while. But here I am, happier than without CSL Locales.

My tenth Fosdem: 2015

A few weekends ago I went to Fosdem… again! It was my tenth Fosdem, I’ve been every year since 2006! I’ve mentioned it here on the blog almost every year.

And, like always: full of interesting talks, some devrooms were full which affected me for the automation and testing room and almost for the Mozilla room. But with about 25 talks at the same time it’s easy to find something else interesting and not full.

Also, I could meet or greet many friends from Catalonia and also other friends from the UK (Mendeley ex-colleagues, London Python Code Dojo guys… not to mention a few work colleagues).

One interesting moment of Fosdem 2015 was to see Larry Wall, the creator of Perl. I used Perl for a few years, more than 10 years ago. Nowadays I prefer Python but even though nowadays I prefer Python my first scripting language was Perl. And finally there will be Perl 6 before Christmas 2015! (Larry Wall said).

A very entertaining talk was the closing keynote about Mars One – a project where they want to send 4 people, in 2015, to live on Mars. It’s one-way ticket and they plan to keep sending 4 people every year to have a stable population on Mars. I find it unbelievable!

Then I also attended many talks in the LibreOffice room, Mozilla room, desktop, etc.

And because I’ve been to Fosdem before I usually know which speakers I like the most, and which ones I don’t like much (some of then repeat). One of them that I try to go regardless of the topic is Michal Meeks: his talks about LibreOffice (usually opimization, technical debt, etc.) are always interesting.

And now is the countdown for the next Fosdem!

Raspberry Pi: from none to two

I know that 2015 is a bit late to have the first Raspberry Pi “in production”… but until now I didn’t really need one and I try to not have things that I don’t need. Note that the meaning of the word “need” here is very flexible, as I actually don’t really need the Raspberry Pi that I have to survive or anything critical.

Anyway, I had two Raspberry Pi computers in the drawer (I got both of them for free, one 6 months ago and the other one a few years ago). I did play with Raspberry Pi on a Mendeley hackday and even at home for fun but that was just a day project instead of something more permanent like I have now.

Raspberry Pi to support a CCTV camera

One Raspberry Pi is supporting a Foscam CCTV camera. It’s the FI9851P and it’s a quite cool camera, nice looking, WiFi, movement detection, night vision, it has a video streaming so one can see live what’s happening with a phone app, a browser (it seems that only on Windows because it needs a specific plugin) or even using VLC!

When the camera detects movement (one can setup which zone of the image, and “how much change” should happen) the camera can do 3 things:

  • Send emails with the photos
  • Upload videos to an FTP server
  • Upload photos to an FTP server

I could have used my VPS FTP server, but the space there is a bit limited and I thought that something closer to the camera would make more sense (so it doesn’t depend on the Internet connection).

So at the moment I have the camera uploading photos and videos to the Raspberry Pi. Finally one of the Raspberry Pi is used! And because the power consumption of the Raspberry Pi is very low it’s quite convenient for this case: it doesn’t need to do many things but should not use much power.

So the photos and videos are uploaded by FTP. Then I can access them using Samba (from the local network -if using Android then one can set up ES File Explorer). From outside the local network I didn’t want to open the Samba port to the Internet (Android doesn’t allow to connect to Samba using a non-standard port) nor setup a VPN for this small case. So at the end I set up, first time too, WebDAV, on the Raspberry Pi using Apache, on Android using ES File Explorer. Now I can browse the files easily from outside the LAN or see the live stream.

Raspberry Pi for NAS

The other Raspberry Pi is being used to convert a hard disk into a NAS (standalone Network-Attached Storage). Basically I bought a USB hub, a hard disk case for the USB case and I put all together inside a small box. The outputs of the box are just the power connector and a network connection: I can connect form my machine to the hard disk of my old laptop in a very convenient way! Now I’m thinking of connecting my very simple USB printer into this Raspberry Pi to convert my USB printer into a network printer (so I didn’t need to plug the USB cable when I want to print).

Find Mendeley users

I haven’t written anything here for 3 weeks and a bit… but not because I didn’t do anything – quite the opposite, I finished or almost finished some projects.

First small project: a simple Web page so Mendeley users can add themselves on a map: find Mendeley users (we haven’t publicized it from Mendeley so there are almost no users, but if you have a Mendeley account it’s easy to add yourself: sign in and move the marker).

I started it “just for fun” at home, then See Wah and I kept working on it during a hackday at Mendeley. See Wah then kept working on it on another hackday for the UI/UX (User Interface and User Experience) (I’m not good designing UI and UX). And on the last hackday and a few more changes after that the map is live!

This is the first time that I’ve released something that uses MongoDB (it fits the data model that I needed really well). And for hosting I use Heroku… I really liked to used Heroku for the first time, and it was really easy to implement.

So: find Mendeley users pinux.info

Happy 2015!

I hope everyone have a good 2015!

And for the IT colleagues, and as I said when I started my holidays: I wish a bug free and feature rich year! 🙂

Recent change in the blog theme

A few weeks ago I changed this blog’s theme. Since 2006 it had had the same theme, which was getting a bit old, it had fixed width, and it wasn’t using the latest WordPress improvements like it didn’t have support for widgets.

I had a few requirements for the new theme: I wanted a 2 or 3 columns (I think that I need a sidebar for some links and information), I wanted to be able to have the header image since it has a long story behind it (it’s a painting of one of the original authors of the blog), I didn’t want to waste too much space with the heading, I wanted the same colour scheme, I wanted to be responsive. I also wanted a clear typography.

I’m surprised about how good WordPress themes work: there are many to choose from, they all work in all versions of WordPress. I found a few that look “almost like I wanted” but they had some problem, usually they had only one column or the header wasn’t as I wanted (I wanted to re-use the heading that I had, and responsive themes like to have the heading and then the text underneath instead of on it).

Anyway, I finally decided to use Atahualpa. It’s very customizable. I made the heading smaller and instead of the way that used to be I moved the text next to the image… it was the only way that I could make it all fit. It seems that Atahualpa even if it’s a modern theme I changed a bit to a retro looking, in the good way of retro. After a few weeks I can say that I like it, even though it was hard to decide the theme.

For historical purposes find a screenshot of the old theme:
Pintant - old - theme

Bye bye Thinkpad T60

A message for my old IBM Thinkpad T60 laptop: thank you for all your good service! I probably can say that it’s the best laptop that I have ever had and the one that lasted longest (8 years is quite a lot for a laptop!)

In August 2006 I got my previous laptop: an IBM Thinkpad T60. Even though I got it after IBM sold the laptop division to Lenovo it still says IBM Thinkpad. I didn’t know at that time but the laptop became a classic in the laptop world, and many people are building Frankenpads: the case of a T60 or T61 and they change almost all the components (even the screen) to revamp to the current standards. At the moment I don’t plan to have a Frankenpad but who knows in the future (and to be honest, I think that the T60 case is a bit too bulky).

In that 2006 laptop I installed a Debian Sarge that I updated quickly to the Debian Testing that would become Debian Etch. Then I updated it to a Debian Lenny, Squeeze and finally Wheezy (and then since then I kept the system running Debian testing).

Initially I used ReiserFS and then in 2009 I bought a new hard disk (greater capacity) and I moved the system and used XFS and also LUKS to cypher the data.

In 2014 the laptop was becoming quite slow. New webpages required more interaction, photos were bigger, mobiles took more photos, the screen during the last years got dimmer…

So, hello new laptop here!

PS: I haven’t written much here the last weeks… one of the reasons is that I spent time setting up the new laptop, moving the data, etc.

Llibre: Hackstory

Fa poc he llegit el llibre Hackstory de Mercè Molist. Quan el vaig començar no pensava que m’agradĂ©s tant com ha estat. Em va sorprendre molt.

És molt amè, informatiu, entretingut. Si recordo bĂ© comença cap a l’any 1980 amb temes de radioaficionats (que vaig fer els meus “pinitus”), desprĂ©s parla de BBS (en vaig ser usuari per força temps), les guerres amb Timofònica, ezines, IRC, estudiants entrant a universitats, Bulma, Badopi…

Alguna gent que surt a Hackstory els he conegut o conec. Molta altra gent els he llegit o em sonaven els noms, o el què havien fet. Recordo fa moltíssims anys llegir algunes revistes com ara SET.

M’ha agradat aprendre mĂ©s d’aquells temps, de tenir una visiĂł des de l’interior (havia vist el mĂłn des de fora però no des de dins). M’ha agradat re-viure algunes coses que havia llegit…

Si per aquí algú li sona el què he escrit més amunt: llegiu el llibre! I hi ha una feinada darrera el llibre que es veu que és immensa!

Tema pràctic: el vaig llegir al meu llibre electrònic en format epub (es pot baixar de Hackstory.es (enllaç epub).
A la Web hackstory.net hi ha més informació i es pot llegir també online.

El projecte va ser fundat per crowdfunding. A hores d’ara es poden fer donacions mitjançant Paypal o bĂ© Bitcoins (veure Hackstory.net al menĂş de l’esquerre). Si us ho passeu bĂ© llegint-lo tambĂ© us ho passareu bĂ© col·laborant una mica.

Així que gràcies Mercé i tothom qui hi ha col·laborat!

Mapnik, osmosis, MongoDB bbox queries

Recently I’ve done a few tests querying data (POIs, Points of Interest) from Open Street Map. I imported the data from OSM into different databases and formats and I wanted to query it.

I’ll show 3 queries: from MongoDB, from PostgreSQL (tables using Osmosis format), from PostgreSQL (tables using osm2psql format).

POIs from MongoDB

I found this one the easiest query to write. I imported the data using the steps described on Derick Rethan’s blogpost (see his Github repository, I used the command:
php5 ./3angle/import-data.php localhost spain-latest.osm to import it.

To query all the POIs for a given bounding box I use:

query = {"l": {"$geoWithin": { "$box": [ [ southwest_lng, southwest_lat], [northeast_lng, northeast_lat] ] } } }
pois = list(pois.find(query))

(replace southwest_lng and the other variables by their positions such as -0.09546518325805664,51.50291256180409,-0.08447885513305664,51.5070930676199 for a small part of London).

This was easy and I liked MongoDB and their GIS (geographical queries) support. It also was my first contact with MongoDB.

POIs from PostgreSQL, Osmosis format

I used osmosis to import data from OSM into PostgreSQL.

The query to get all the POIs for a given bounding box, in my case, is:
SELECT id, tags -> 'amenity' AS amenity, ST_Y(geom) as latitude, ST_X(geom) AS longitude FROM nodes WHERE ST_Intersects(geom, ST_MakeEnvelope(%(southwest_lng)s,%(southwest_lat)s,%(northeast_lng)s,%(northeast_lat)s,4326))

(replace %(southwest_lng)s and the variables by their values, see MongoDB for an example)

Notice that a “\d nodes” (describe nodes) table returns:

tags | hstore |
geom | geometry(Point,4326) |

“tags” column type is hstore (it’s a key-value column). The “geom” type is geometry(Point,4326). 4326 is standard coordinate system for the Earth (see World Geodetic System Wikipedia’s entry).

In this case, the query returns all nodes which geometry (just the position, in this case they are always points) intersects with the given box created using 4326 standard. It’s important that the ST_Intersects projection (4326) matches the projection defined in the column. Forgetting the standard (4326) in the ST_Intersects causes the query to run but not to get the expected results (having some sort of visual validation is important: I thought that the query was working because it returned results… but it wasn’t the case).

POIs from PostgreSQL, osm2psql format

You could import OSM data into PostgreSQL using osm2psql. This format is usually used by Mapnik to render the maps.

In this case the query is:
SELECT osm_id AS id, amenity, ST_Y(ST_Transform(way,4326)) AS latitude, ST_X(ST_Transform(way,4326)) as longitude FROM planet_osm_point WHERE ST_Intersects(way, ST_Transform(ST_MakeEnvelope(%(southwest_lng)s,%(southwest_lat)s,%(northeast_lng)s,%(northeast_lat)s,4326), 900913))

The planet_osm_point_index table contains the position (way column) as:

way | geometry(Point,900913) |

It’s not using the projection 4326 but the projection 900913 (also known as Web Mercator. Wikipedia recognizes that it’s a confusing denomination, and I would like to add that the fact that in PostgreSQL the projections are just numbers instead of names is even more confusing.

In this case the query creates a ST_MakeEnvelope (a bounding box) using the location (using the projection 4326 because my client passes it using this format). After that the function ST_Transform transforms this into the projection 900913 because it’s the one saved in the database (otherwise we might not get the correct results). And, like I did before, the query checks that the POIs are in the bounding box (envelope).

To return the data: it gets the position (way) which converts to the desired projection (ST_Transform) and then returns the latitude or longitude (using ST_X, ST_Y).

I found the PostgreSQL quite confusing because the naming of the functions and a new concept for me was the different projections: if one is not careful they can be easily mixed.

I was surprised that I couldn’t find on the Internet any example queries like these ones: it seems that getting POIs from a bounding box should be the “Hello World!” for OSM and PostgreSQL. So, in this blog post, I hope to fix The Internet adding the missing information.

Foreign travel advice: Spain

A few months ago I was researching how safe it is to travel to a few countries. I used the Foreign Travel Advice webpage from the British government.

I thought to do a bit of “quality control” of their information. What do they say about countries that I know well?

So I went to read what they say for Spain. I could find that in Spain “There is a general threat from terrorism.” (this helps to understand what they mean by “general threat from terrorism” when they say this about other countries). I also learnt that a nurse in Spain tested positive for Ebola (they really update the information often).

But what it surprised me the most is the explicit warning that “balconing” is risky. It says:
“There have been several deaths as a result of falls from balconies. Don’t take any unnecessary risks, especially when under the influence of drink or drugs. See Balcony falls”. It’s so important that it links to a specific section balconing falls which adds more information:

“There have been a number of very serious accidents (some fatal) as a result of falls from balconies. Many of these incidents have been caused by British nationals being under the influence of drink or drugs and most should have been avoidable. Your travel insurance probably won’t cover you for incidents that take place while you’re under the influence of drink or drugs.

Some local councils have introduced laws banning the misuse of balconies with fines for those who are caught.

I’m sure that all the balconing accidents were avoidable!

I’m surprised that this needs to be written there but on the other hand every year a few people die because they jump from a balcony to the swimming pool (usually drunk people). I’m not sure how effective the warning will.

One more public announcement: if you don’t play the lottery and someone sends you an email to say that you won the lottery but that you have to pay some costs: very likely that it’s a scam! (and not only in Spain):

There have been reports of lottery scams in Spain. A person receives what appears to be official notification from the Spanish Inland Revenue office (Hacienda) that they’ve won the Spanish lottery and should deposit money in a bank account to receive their winnings. It’s likely to be a scam if you haven’t entered a lottery, you’re asked to pay anything up-front and the contact telephone number is for a mobile phone.”

Some time ago I did a similar exercise: I read what the Spanish Foreign Travel Advice says about the United Kingdom. Well, I have to say that after reading that text it seems that Oxford Street is one of the most dangerous places in the world!