Archive for category Programming

Second place at Paris Android Dev Camp 2012

Our team, called the Épicuriens, had a great time at the Paris Android Dev Camp 2012. And we were even happier because we finished 2nd out of 11 teams, and ended up winning Android tablets for each team member!

The Paris event was part of the Global Android Dev Camp, which took place in in 88 different cities on the same weekend. Every continent was represented except Antartica!

Each team had less than 48 hours to create a complete Android App, and in Paris we had an extra requirement that the App be based on an Open Data Set.

Our Épicuriens team was made up of 3 Android hackers/developers

And one interaction designer

Since all the team members like wine (in France who doesn’t), we decided to use the Appelation Origine Controlée data set published by the French government. Believe it or not, out of 36 000 towns in France 22 000 belong to AOCs! We did restrict our App to only the wine AOCs, which did bring the number down a bit.

At the end of the weekend using our “AOC France” App, users could easily find wine producers in the different wine French wine producing areas. proto map navigation, location based notifications, an augmented reality view, and even a good old drill down list navigation.

Here are some screenshots from our App.

The whole event was very well organized thanks to the Paris Android User Group. They even shot a few videos of us during the weekend.

Compiling log4cpp 1.0 with gcc 4.3 or 4.4

In gcc 4.3 some bugs were fixed, unfortunately they can cause compile errors with code that would compile with older versions.

In particular this is the case with log4cpp 1.0 which fails with the following message: BasicLayout.cpp:37:5: error: ‘auto_ptr’ in namespace ‘std’ does not name a type

Luckily the fix is very simple; all that is required to get a clean compile is add an #include <memory> in src/BasicLayout.cpp.

Create a PDF file for each Excel Worksheet

Sometimes it’s nececessary to generate a separate PDF file for each worksheet within an Excel workbook. This can be a big waste of time; especially if there are many sheets and/or you have to regenerate the PDFs every time the content changes!

If you are using Microsoft Office 2007 or later, the following VBA macro automates the process. The Fname variable can be used to customize the PDF file names that are generated.

Option Explicit

Sub createPDFfiles()
    Dim ws As Worksheet
    Dim Fname As String
    For Each ws In ActiveWorkbook.Worksheets
        On Error Resume Next 'Continue if an error occurs

        ' Name PDF files based on the worksheet Index (e.g Annex 1.1.1, Annex 1.1.2, etc.)
        Fname = "Annex 1.1." & ws.Index & "_result"

        ' If you want to name the PDF files differently just change the Fname variable above to
        ' whatever you like. For example if you changed Fname to:
        '  Fname =  “C:\myFolder\pdfs\” & ActiveWorkbook.Name & "-" & ws.Name
        '  The files would be stored in C:\myFolder\pdfs, and named using the
        ' spreadsheet file name and the worksheet name.
        ' WARNING: Using worksheet names may cause errors if the  names contain characters that Windows
        ' does not accept in file names. See below for a list of characters that you need to avoid.
        ws.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:=Fname, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
    Next ws
End Sub

The following characters are not allowed in Windows file names, they will cause the macro to fail if you use them:

< (less than)
> (greater than)
: (colon)
” (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)

Functional programming languages

In Can Your Programming Language Do This?, Joel Spolsky gives a nice simple explanation on how functional languages can make your code smaller, tighter, more reusable, and more scalable. Google has used this to their advantage in creating Map Reduce.