Avoiding postfix error “status=deferred (unable to look up host”

My emails wouldn’t send when I was working from home, giving me this message in /var/log/mail.log:

Nov 11 12:38:16 machinename postfix/smtp[20672]: CF5D6D41CE2: to=, relay=none, delay=14416, delays=14416/0.01/0.07/0, dsn=4.3.5, status=deferred (Host or domain name not found. Name service error for name=relay.example.com type=AAAA: Host not found)

It turned out I was telling postfix not to use DNS to resolve the domain name of my mail relay server. There were several postfix config options I needed to remove to make this work:

# Make sure all of these are commented out or removed!
#default_transport = smtp
#relay_transport = smtp
#inet_protocols = ipv4
#smtp_host_lookup = native

The default values for these options are fine, but the ones shown above stop it working, so remove them or comment out with a # at the beginning of the line.

More at Postfix configuration parameters.

Finding the download count of GitHub releases

You can use the GitHub API to find out how many times the files in your releases have been downloaded.

For example, to find out how many downloads there have been of my Rabbit Escape project you can do:

curl -s https://api.github.com/repos/andybalaam/rabbit-escape/releases | egrep '"name"|"download_count"'

Or you can look through the information manually by visiting a URL like https://api.github.com/repos/andybalaam/rabbit-escape/releases in your browser.

To get the total I came up with this beautiful incantation:

curl -s https://api.github.com/repos/andybalaam/rabbit-escape/releases | egrep 'download_count'  | cut '-d:' -f 2 | sed 's/,/+/' | xargs echo | xargs -I N echo N 0  | bc

Android: using a TextView to show rich text in an AlertDialog

If you want to display a link or basic formatting in an AlertDialog on Android, you can do it by providing HTML.

The key parts you need are Html.fromHtml and TextView.setMovementMethod.

Make sure you pass the dialog’s context in to the constructor of the TextView, not the context of the current activity. Otherwise the colours in your TextView will be wrong and you may well end up with black text on a dark grey background.

AlertDialog dialog = new AlertDialog.Builder( activity )
    .setTitle( t( world.name ) )
    .setPositiveButton( "Yes!" )
    .setNeutralButton( "Maybe?" )

TextView view = new TextView( dialog.getContext() );
view.setText( Html.fromHtml( "<b>foo</b> <a href='#'>bar</a>" ) );
view.setMovementMethod( LinkMovementMethod.getInstance() );
view.setPadding( 10, 10, 10, 10 );

dialog.setView( view );

If you are on API level 11+, you can use AlertDialog.Builder’s getContext() method, so you don’t have to create the dialog until the end.

Assassination of individuals by the state

I wrote to my MP (via writetothem.com) about the British government assassinating people they suspected of planning terrorist attacks. He replied saying that the government believes the action was legal, proportional and necessary. Part of this justification was based on the fact that circumstances in Syria make it difficult to disrupt attacks in other ways. He stated the people killed were recruiting ISIL members and planning specific attacks in Britain. He also stated that this action was unconnected to general military action against ISIL in Syria.

My reply is below. Feel free to re-use and adapt it if you want to send a similar letter.

Dear Philip Hammond,

Thank you for your reply to my letter about the assassination of Junaid Hussain and Reyaad Khan.

I have 4 questions:

1. When did the British government start assassinating individuals suspected of planning terrorist attacks?

2. What standard of evidence is required to assassinate someone?

3. How imminent must a suspected attack be to warrant assassination?

4. What oversight is there of each decision to perform an assassination?

I continue to believe this practice is in conflict with British values and international law. You mention the UN Charter: I assume you are referring to Article 51 of the UN Charter, which refers to “armed attack” against a country. I do not accept that an individual suspected of planning a terrorist attack falls under the definition of an “armed attack” which was surely a reference to warfare by state-like entities, rather than plans being made by individuals to commit acts well-covered by UK criminal law.

We celebrated the 800th anniversary of Magna Carta in your constituency this year. Our reasons for celebration included the limitation of the state’s power over the individual. When the state executes individuals without trial or even publication of evidence, is there any practical limit to its power?

Yours sincerely,

Andy Balaam