Lightroom 6 freezing on splash screen on macOS

Today Lightroom 6 was freezing on the splash screen every time I would try to start it on macOS. I tried every hint I could find online without any luck. In the end, I realized with “Instruments” from XCode that Lightroom is storing some data in “~/Library/Application Support/Adobe/Lightroom” in addition to the catalog and the preferences. I restored this directory from a TimeMachine backup, and Lightroom started again immediately.


Posted in Photo | Leave a comment

Deleting outdated Teamcity builds using the REST interface

The cleanup rules of Teamcity are pretty limited. For instance, if you keep the N last builds on the default branch, it will also keep so many builds on all other branches, which is a problem in case there is a branch for every change (workflow based on code reviews or merge requests).

Until TW-8717 is finally implemented, I wrote a Powershell script that will just delete all the pins older than a specific date, if they are not pinned.

param (
       [String]$OlderThan = "20190501",
       [String]$TeamcitySessionId = "...",
       [String]$TeamcityHost = "teamcity.mydomain"

Function Get-Teamcity-Session()
  $cookie = New-Object System.Net.Cookie
  $cookie.Name = "TCSESSIONID"
  $cookie.Value = $TeamcitySessionId
  $cookie.Domain = $TeamcityHost
  $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
  return $session
Function Get-Builds-To-Delete()
  # defaultFilter:false is required, otherwise Teamcity will return only builds on default branch
  $uri = "https://$TeamcityHost/httpAuth/app/rest/builds/?count=100000&locator=defaultFilter:false,pinned:false,state:finished,finishDate:(date:" + $olderThan + "T000000%2B0100,condition:before)"
  return (Invoke-RestMethod -WebSession (Get-Teamcity-Session) -Method Get -Uri $uri);

Function Delete-Build($id)
  $uri = "https://$TeamcityHost/httpAuth/app/rest/builds/?count=100000&locator=pinned:false,state:finished,id:$id"
  return (Invoke-RestMethod -WebSession (Get-Teamcity-Session) -Method Delete -Uri $uri);

$CsvFile = "Builds-To-Delete-$(get-date -f yyyy-MM-dd_HH_mm_ss).csv"
(Get-Builds-To-Delete) | Export-Csv -Delimiter ";" -Path $CsvFile

# Start $CsvFile

$builds = (Get-Builds-To-Delete)
$count = $builds.Count
$current = 0
foreach ($build in $builds) {
    Write-Host "$current / $count"
    # $build
    $id = $ -as [int]
    if($build.state -ne "finished" ) {
        # Safety net:
        throw "Build $id did not finish";
    if($build.pinned) {
        # Safety net:
        throw "Build $id is pinned";

    if($build.branchName -and $build.branchName.StartsWith("release")) {
        Write-Host "Skipping release build $id"

Posted in Uncategorized | Leave a comment

Accept Outlook invitations automatically with custom response

I often need to accept invitations and set the corresponding event as private. This is very cumbersome in Outlook, therefore I wrote the following macro to do it for me:

Sub AcceptAndSetPrivate()
    Set CurrentItem = Application.ActiveExplorer.Selection.Item(1)
    Dim metAppt As AppointmentItem
    Set metAppt = CurrentItem.GetAssociatedAppointment(True)
    metAppt.Sensitivity = olPrivate
    metAppt.BusyStatus = olFree
    Dim metResponse
    Set metResponse = metAppt.Respond(olMeetingAccepted, True)
End Sub

To call it easily, put it in the Quick Access bar. Once you press the ALT key, Outlook will show which key to press next, “3” in the screenshot below:


I tried to also set the “BusyStatus” to “Free” automatically, like you can see in the code, but for an unknown reason, it has not effect.

Posted in Uncategorized | Leave a comment

Posting HTML to

Posting HTML in a post on is still a nightmare, here is the recipe that will hopefully help me next time I need it:

  • Switch to HTML mode
  • Add [code language="html"]
  • Encode your HTML code to replace HTML special characters by the corresponding HTML entities (there are many online converter, just search for HTML encoder)
  • Copy the encoded text in the post
  • Add [/code]

Note that you will have to copy the encoded HTML again if you edit the post, because the HTML entities will be interpreted and replaced by their clear test equivalent.

What a mess. I wish there was an easier method.


Posted in Uncategorized | Leave a comment

Converting RSS to HTML

Firefox unfortunately removed the support for RSS in the version 64. I am relying on RSS for multiple web pages I visit regularly, so I looked for alternatives. I was not convinced by the available Firefox plugins, they were either overkill for my use, not opensource, or both. So I though I could write a static local HTML page that would get the RSS, parse it, and generate a DOM. It turns out this is not that easy, because I couldn’t find any RSS parser in Javascript. All Javascripts libraries for RSS I found are relying on external services from Google or other providers for that. This was not an option for me either. I finally recalled SimplePie, an RSS parser in and for PHP that I used in the past for web development. It turns out it is very easy to write an RSS to HTML converter with SimplePie:

require_once 'autoloader.php'; 

// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

$url = "";
if(isset($_GET["url"])) {
    $url = $_GET["url"];
$sp = null;
if( ! empty($url) ) {
    $sp = new SimplePie();


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo ( $sp != null ? $sp->get_title() : "RSS to HTML" ) ?></title>


    <form action="rss2html.php" method="GET">
         <p>RSS feed URL: <input type="text" name="url" size="100" value="<?php echo htmlentities($url); ?>" /></p>

        if ($sp != null) {
        <div class="header">
            <h1><a href="<?php echo $sp->get_permalink(); ?>"><?php echo $sp->get_title(); ?></a></h1>
            <p><?php echo $sp->get_description(); ?></p>
        foreach ($sp->get_items() as $item):
        <div class="item">
            <h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
            <p><?php echo $item->get_description(); ?></p>
            <p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>



Just download SimplePie, add this PHP script to it, and you’re good to go. The URL is passed as GET parameter, so you can easily bookmark the whole address.

Posted in Uncategorized | Leave a comment

Compiling QT 5.2 with MinGW 7.x

As usual, building QT brought its load of challenges, here is what you need to know when building QT 5.2 with MinGW 7.x.

1. make sure you extract the source code and build it in relatively short path, for instance C:\Qt, otherwise the build might fail with random “file not found” issues

2. make sure you have “python” available in your PATH. “configure” will not check this and if you don’t have it, it will lead to the following error:

python C:/.../qt/src/qtdeclarative/src/3rdparty/masm/create_regex_tables > RegExpJitTables.h
python C:/.../qt/src/qtdeclarative/src/3rdparty/masm/create_regex_tables > RegExpJitTables.h
mingw32-make[4]: *** [Makefile.Debug:568: RegExpJitTables.h] Error 1

3. in “qtbase/mkspecs/win32-g++/qmake.conf”, set QMAKE_CXXFLAGS as following:

QMAKE_CXXFLAGS          = $$QMAKE_CFLAGS  -std=gnu++98

This will fix build error in javascriptcore which are due to the fact that the code base doesn’t build with a C++ 11 compiler, which is the default standard used in MinGW 7.

4. in “qtwinextras/src/winextras/”, add -lgdi32 to LIBS_PRIVATE:

LIBS_PRIVATE += -lole32  -lgdi32 -lshlwapi -lshell32

This fixes the link errors like:

undefined reference to "__imp_CreateRectRgn"
Posted in C/C++ | Leave a comment

MinGW/GCC: error: stdlib.h: No such file or directory in include_next

A common error with MinGW or GCC is the following:

C:\...\lib\gcc\x86_64-w64-mingw32\7.2.0\include\c++\cstdlib:75: error: stdlib.h: No such file or directory
at #include_next 

This is typically due to the fact that something messed up the system include path with -isystem. Specifying again some paths changes the search order, so that #include_next doesn’t find what it is supposed to.

If you use CMake, a workaround is to set CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES and CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES to the list of default system paths. CMake will then not pass it the the compiler anymore. It will still use them, in the correct, hard-coded order.

Instead of hard-coding these paths in you CMakeList file, you can retrieve them automatically from the C preprocessor:

    # Run the preprocessor in verbose mode on an empty input
        INPUT_FILE "NUL" # Special Windows file, equivalent to /dev/null
        OUTPUT_VARIABLE _mingw_cpp_out # Capture stdout
        ERROR_VARIABLE _mingw_cpp_error # Capture stderr
    # Create list of lines from stderr output:
    string(REGEX REPLACE ";" "\\\\;" _mingw_cpp_error "${_mingw_cpp_error}")
    string(REGEX REPLACE "\n" ";" _mingw_cpp_error "${_mingw_cpp_error}")
    # Look for this text block and gather the paths:
    #   #include  search starts here:
    #   C:/..../bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/include
    #   C:/..../bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/include-fixed
    #   C:/..../bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/include
    #   End of search list.
    foreach(_mingw_cpp_line ${_mingw_cpp_error})
        if("${_mingw_cpp_line}" MATCHES "#include  search starts here:")
            # Block starts
            set(_mingw_cpp_state "ON")
        elseif("${_mingw_cpp_line}" MATCHES "End of search list.")
            # Block ends
            set(_mingw_cpp_state "OFF")
            # Within block
            # Clean up and beautify the path
            string(STRIP "${_mingw_cpp_line}" _mingw_cpp_line)
            get_filename_component(_mingw_cpp_line ${_mingw_cpp_line} REALPATH)
            list(APPEND _mingw_cpp_list ${_mingw_cpp_line})

    # Set the list in the cache, so that we don't have to run the external process again

    set(CMAKE_MINGW_IMPLICIT_INCLUDE_DIRECTORIES ${_mingw_cpp_list} CACHE INTERNAL "List of MinGW system include paths")


Posted in C/C++, Uncategorized | Leave a comment

Building 32bit applications with mingw-w64 and CMake

The mingw-w64 provides ready-to-use packages with GCC for Windows. The toolchain is by default targeting the 64bit Windows architecture. It is possible to build 32bit binaries by using the -m32 option on the command line.

The toolchain can be easily integrated with CMake, however it gets more complicated when trying to build a 32bit application from CMake. After some trial and error, reading the documentation and debugging the CMake modules, I found out a simple solution that works for me:

    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")

    project(MyProject ...)


    find_library(gcc_lib libgcc_s_sjlj-1.dll)
    find_library(cpp_lib libstdc++-6.dll)
    find_library(pthread_lib libwinpthread-1.dll)

Some notes:

    • According to the CMake documentation, CMake should set “FIND_LIBRARY_USE_LIB32_PATHS” automatically because MinGW requires it, but as of now (mingw-7.2.0 and CMake 3.12), it is not the case. So set it explicitly. Without this, find_library() will happily find the 64bit version of the libraries in the MinGW installation, causing linker errors.
    • I set CMAKE_C_FLAGS and CMAKE_CXX_FLAGS before the project() statement, because in project(), CMake will look for the compiler and retrieve the library locations by introspection. If the -m32 flag is not used by then, CMake may find and use the location of the 64bit libraries, also causing linker errors later on
Posted in C/C++ | Leave a comment

Building protobuf with MinGW

Even if the documentation of the project doesn’t mention it, building protobuf with MinGW is easy when using CMake. The CMakeLists.txt is located in the “cmake” subdirectory.

I used following versions:

  • MinGW 7.2.0 (64 bit)
  • CMake 3.12.1
  • Protobuf 3.6.1

Two workarounds are however required with these versions:

Add “-DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON” to the CMake command line to avoid the error:

fatal error: stdlib.h: No such file or directory

See for more information

Also, you will need to apply this patch to cmake/tests.cmake:

# Patch from commit a69dfe63bc26c12fd2786aec9239076997110315
  set_source_files_properties(${tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing")

  # required for tests on MinGW Win64
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,16777216")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")

Posted in C/C++ | Leave a comment

Groovy: cloning nodes in an XML document

It’s pretty easy to clone nodes in a XML document using Groovy once XmlParser is used instead of XmlSlurper:

import groovy.xml.XmlUtil

def original = """
   <book id="sample">

def catalog = new XmlParser().parseText( original )

def sampleBook = { it.@id == "sample" }


3.times {
  def c = sampleBook.clone()
  c.@id = "$it"[0].value = "Author $it"
  c.title[0].value = "Title $it"


println XmlUtil.serialize(catalog)

The result is:

<?xml version="1.0" encoding="UTF-8"?><catalog>
  <book id="0">
    <author>Author 0</author>
    <title>Title 0</title>
  <book id="1">
    <author>Author 1</author>
    <title>Title 1</title>
  <book id="2">
    <author>Author 2</author>
    <title>Title 2</title>


Posted in Uncategorized | Leave a comment