“python.exe has stopped working” suddenly appeared under Windows 10

When attempting to start python tonight, Windows 10 suddenly produced the “python.exe has stopped working” error. Examining the event in the Event Viewer didn’t provide any more useful information, but surprisingly everything worked if I launched python.exe directly from Explorer – or through bash (cygwin), but not if I launched it through the regular command line (cmd.exe).

What solved it? Removing the old directory again (even after trying a fresh install) and then explicitly finding the 64-bit version from the python download page (it gives you the 32-bit version by default, it seems). Reinstalling with the new archive fixed everything, and now it works again (and I checked “pre-compile the standard library, but that shouldn’t change anything)! Woho! Now to just reinstall quite a few virtualenvs..

Making Multi-Level Anchors Work With globalindex.py for Sphinx

One of the issues I’ve come across when using Sphinx (awesome application) for writing documentation is that the table of contents disappear when using the singlefile format (which generates the documentation as one large page instead of having to click through to other files).

Luckily Matteo Franchin had the same issue, and created a small extension for Sphinx that allows you to add a TOC to SingleHTML builders as well! The problem I discovered after a while is that it ends up adding redundante HTML anchors for each level when resolving the TOC, where it ends up generating #html#anchors like that. Which doesn’t work.

I solved the issue (.. for my simple case, this is still a hack) by adding regular expression that removes any HTML anchors that are followed by another HTML-anchor (and could very possibly eat a lot more in edge cases, but hey, it works for me!).

rendered_toctree = re.sub(r'(#[^ "]+)#', '#', rendered_toctree);

The lines around line 59 should then look like:

            rendered_toctree = builder._get_local_toctree(docname, **kwargs)
            rendered_toctree = re.sub(r'(#[^ "]+)#', '#', rendered_toctree);
            node['content'] = rendered_toctree

Merging Weird, Splitted Email Attachments as .DAT-files With [x/x] in Subject

A client received a large collection of emails today, where the sender’s software had split the mail into several parts. Outlook / Exchange at our end did however not understand the scheme the user had used to split the files, so the mails arrived as separate entities in the mailbox.

Each mail was named in the same manner:

filename [1_3].dat
filename [2_3].dat
filename [3_3].dat

After saving the files by themselves, it became clear that the files contained a set of mime encoded files (separated by –-=_NextPart_) (I first attempted to decode one of the files by itself as base64, which failed).

To decode these files, I saved all the different parts of the .dat to a directory, then appended the files together with cat *.dat > merged.dat. At least we have a complete version of the attachment.

To extract the files from the attachment, use munpack – available in the mpack package under Ubuntu.

munpack merged.dat extracts all the files from the .dat to the current directory.

slice2php and Ubuntu: /usr/share/slice/Murmur.ice:9: error: Can’t open include file “Ice/SliceChecksumDict.ice”

Trying to generate Murmur.php for the server component of Mumble (named Murmur (which is the only place I’ve ever encountered Ice)), slice2php gave the error:

/usr/share/slice/Murmur.ice:9: error: Can't open include file "Ice/SliceChecksumDict.ice"
    #include 
1 error in preprocessor.

To fix this I had to run slice2php with a -I statement, to tell it where to find the SliceChecksumDict file (which you can locate using locate or find or the packages search):

slice2php -I/usr/share/Ice-3.4.2/slice /usr/share/slice/Murmur.ice

alt+<number key> stops working in irssi and putty under Windows

I have no idea why this happens. I have not been able to fix the underlying issue, but .. do you have photoshop open?

It turns out photoshop interrupts the alt+number keys globally, so even if you have putty open, changing windows with alt+<number key> won’t work. Closing photoshop makes everything work again.

Weird.

Sorting Strings as Numeric Values in Python3

A small hack to do natural, numeric sort of string values in Python is to use the int function when calling sorted (here, applied to a dictionary get it sorted by its keys):

    for position in sorted(positions.keys(), key=int):

This will call int() for each value in the list to sorted, and use the numeric value instead of the asciivalue (if the keys / elements are strings instead of numbers).

“Klareringsforholdet mellom arbeidsstasjonen og primærdomenet ble ødelagt.” or “The trust relationship between this workstation and the primary domain failed.”

I added the Norwegian translation of the error message to the title as well to help any Norwegians trying to find a solution to this Windows AD issue. The root cause is that the kerberos secret on the client no longer (for some reason) matches the secret stored in the AD forest. The usual fix is to make the client rejoin the domain, however, there’s a better solution.

First you’ll need Administrator access to the client. If you’re unable to log in as an Administrator (because the computer was locked by a domain user account before the secret got borked), reboot the client without any network access. This will allow the user to log in with the cached credentials, as the client is unable to discover that its secret differs from the secret stored in the domain.

You’ll need to download the Remote Server Administration Tools for Windows 7, and install it on the client. After installing, go to Programs and features in the Control Panel, select enable / disable windows features on the left pane, and navigate through:

Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools

.. and find the choice that includes “console tools” (I don’t remember the exact name).

Start cmd as an administrator (right click, select run as administrator under Accessories), and use netdom.exe to sort the issue out properly.

netdom resetpwd /s:<server.domain.local> /ud:DOMAIN\user /pd:*

The user referenced by DOMAIN\user needs to have access to add / edit clients in the domain.

svn: OPTIONS of ‘‘: SSL handshake failed: SSL error: A TLS warning alert has been received. ()

If your svn client suddenly starts complaining about something similar to

svn: OPTIONS of '...': SSL handshake failed: SSL error: A TLS warning alert has been received. (...)

The reason might be that the host in the URL (https://example.com/ => example.com) doesn’t match the ServerName setting in the SSL host for your web server. You might not have configured this, so for Apache add:

ServerName example.com

.. and restart the server. It might just work again!

deck.ignite.js – Ignite / Pecha Kucha presentations in deck.js

After experimenting with deck.js yesterday for two presentations I had to give at a local networking meet, I decided to try to hack together a small extension for deck.js that makes any presentation an Ignite presentation. The concept is simply: 20 slides, 15 seconds for each slide – allowing you to only present the absolute minimum about a subject.

Using the extension is easy; simply download deck.ignite.js from my github repository and add a script tag that references the file after you’ve loaded the usual deck.js files (together with your other extensions):


You can also configure the delay used for each slide (Pecha Kucha presentations use 20 seconds) by setting the igniteDelay option when initializing deck:

$.deck(".slide", { igniteDelay: 20 });

You can read a more detailed description at the github project page.

Building Gearman under Red Hat Enterprise 4 (RHEL4) or older CentOS-versions

While building gearman on our older RHEL4 servers, there was two issues that surfaced:

  • The version of boost included in RHEL4 is too old (1.32) for gearman. I decided to download the new boost version (1.48.0 at the time of writing) and install it. Be sure to remove the old version with rpm -e boost-devel, so that you don’t get strange conflicts while attempting to build the benchmark tools:
    benchmark/blobslap_worker.cc:89: undefined reference to 
    `boost::program_options::options_description::m_default_line_length'
    benchmark/benchmark_blobslap_worker-blobslap_worker.o(.text+0x1d9):
    benchmark/blobslap_worker.cc:89: undefined reference to 
    `boost::program_options::options_description::m_default_line_length'
    
  • Issues while trying to build the tests/ directory:

    tests/stress_worker.cc: In function `test_return_t worker_ramp_TEST(void*)':
    tests/stress_worker.cc:113: error: `pthread_timedjoin_np' was not declared in this scope
    tests/stress_worker.cc:113: warning: unused variable 'pthread_timedjoin_np'
    make: *** [tests/stress_worker.o] Error 1
    

    This can be solved by removing the whole section enclosed in the #ifdef _GNU_SOURCE
    section. Let the content in the #else-part in place. Removing this will not affect the usual (and any important parts of it) gearman distribution in any way.

The configure / make process of gearman needs a way to exclude the benchmark/ and tests/ parts of the project from being built.