Thursday, October 11, 2012

Coding fonts

I consider myself a programmer, and to perform this task I rely on a set of tools. I need a text editor, compilers and/or run-times, build-systems, code repositories, documentation, and sometimes even an IDE. Since the late 80s my text editor of choice has been Emacs (and Aquamacs on OS X), but I am also comfortable with vi (including Vim) and ed. Currently, I am investigating time in newer text editors, like Sublime Text (writing editor plugins in Python should be fun) and Chocolat, but we are not close friends yet (but I will spend more time with subl to see how our relationship evolves). More on these tools later.

When programming, the code is viewed in a text editor (or IDE) in a font (the size and style of a particular typeface). The default fonts for most code editors are OK, but we can do better than OK. On OS X I have tried and used a lot of different fonts for coding. Since yesterday my preferred font for coding Python was Menlo Regular 13 (also used by Xcode):

Menlo Regular 13

I believe Apple's Menlo has evolved from DejaVu Sans Serif Mono (common on Linux) and Bitstream Vera Sans Mono. Previously, I used Monaco Regular 12, but I switched to Menlo since I find it less noisy. Yesterday I came over this announcement of the open source font Source Code Pro from Adobe (via Daring Fireball):

Source Code Pro Regular 13

Now I have used Source Code Pro Regular 13 for one day programming in Python, and it is too early to conclude that the font is a good coding font option for me. My first impression is good. The font has a lightness to it that I like, and it is readable and clean. I will use it for a few more hours and then conclude if it should replace Menlo Regular 13 as my preferred coding font. I might even end up using different fonts depending on programming language and text editor. However, I recommend that you download and try this new open source font from Adobe.

Adobe also have other open source fonts available, including Source Sans Pro (revise and hosted on GitHub) and Kenten Generic.

Update 20140721: Other interesting coding fonts are Inconsolata and Fira Mono (from Mozilla's typeface Fira). This is Inconsolata:

Screen Shot 2014 07 21 at 09 36 39

And this is Fira Mono (Regular):

Screen Shot 2014 07 21 at 09 38 33

Update 20140805: You could also consider Input:

Input is a flexible system of fonts designed specifically for code by David Jonathan Ross. It offers both monospaced and proportional fonts, all with a large range of widths, weights, and styles for richer code formatting.

Monday, October 8, 2012

Generating a BibTeX file from Cristin data

Based on the previous script generating HTML from Cristin data, I created another script generating a BibTeX file from the same JSON data. The script has the same limitations as the previous one, but it should be easy to modify for your needs. Have fun!

Saturday, October 6, 2012

Fetch and process information from Cristin

Yesterday I wrote a small Python script to fetch and generate a publication list for web-pages. I use a web-services (ws) provided by Cristin (Current research information system in Norway). Cristin is a research information system for hospitals, research institutes, and universities and university colleges. From the provided ws I use the method hentVarbeiderPerson (see Brukerdokumentasjon Cristin Web Service for details). The argument lopenr is set to the unique id of the researcher (who's publications I want to fetch). The argument format is set to json and the argument sortering is set to to AAR_PERSON_TITTEL (meaning sort the results by year, name and title). The query string then becomes (replace <ID> with the unique id of the user):<ID>&format=json&sortering=AAR_PERSON_TITTEL

This query will return the publications in the JSON format. You can try this URL (with a real value for the id) in a browser or with command line programs like curl. The Python script processes it and generate HTML. The script is tailored towards publications registered in my name. However, it should be easy to modify the script to match your type of publications.  It reads the fetched JSON file from stdin and write the generated HTML to stdout. Errors and warnings are written to stderr. You should check the warnings. They might give you a hint of type of publications my script doesn't support.

In the returned data from Cristin each publication has two data sets. The "fellesdata" (common data, see commonmap in the script) part includes title, authors, year and some information on what type of publication it is. The "kategoridata" (category data, see catmap in the script) includes information about how the publication was published.  Based on these two sets of information I group the publications in different sections (like Web pages, Conference papers, Journal papers, and Reports, see tmap for details).  The order attribute specifies the order of the information inside each entry, and the porder attribute specifies the order of the sections (different type of publications). Have fun with it. The Python script is written for Python 3, but it should work with Python 2.

Friday, October 5, 2012

Almost two years in silence

I restart my blog today.  November 16th 2010 was my last post (on Beatles available in iTunes). Since many of my old post were dated, I've deleted them all.  The main reason for the silence is that other tools have replaced the purpose of the blog for me. I used the blog to remind myself on interesting software, web-pages, music and articles/text that I wanted to dig into later. Kippt and Instapaper has replaced the blog for these purposes.