Blog

  • Getting The Maximum Of A Set Of Numbers

    damascus-unix-prompt

    You have a a column of numbers that you have produced in some manner such as :-

    $ awk '/clean message/ {print $(NF-1)}' mail.info.log
    ...
    100935
    12197
    3606
    84653
    4498
    99110
    4762
    3001
    10889
    12611
    12249
    12245
    136599
    49097
    6668
    

    And you want a quick and dirty way of finding the largest number. Well there is a way but it is perhaps the least efficient way to do it, and that is to sort the numbers into numerical order and use “head” to display the first one :-

    $ awk '/clean message/ {print $(NF-1)}' mail.info.log | sort -rn | head -1
    5476168
    

    But frankly there must be a better method. And yes there is if you happen to be using zsh (or possibly others, but this has been tested with zsh). Simply iterate over the values assigning the current value to the “max” variable if the current variable is larger :-

    $ max=0; for x in $(awk '/clean message/ {print $(NF-1)}' mail.info.log); [[ $x -gt $max ]] && max=$x; echo $max
    5476168

    You may be wondering why I don’t simply use the ability of awk to perform calculations. Well that is certainly possible, but I may not always be using awk to produce the numbers in the first place, and this is supposed to be a generic recipe.

  • Donald Trump Wants To Ban Muslims. Idiot.

    So Donald Trump wants to ban muslims from entering the US does he?

    Perhaps he really is not only a vicious racist but also as gormless as he looks in the photo (apologies for those of a sensitive disposition). There are others who have covered why banning muslims from entering the US is morally wrong, and if you do not understand why that is so, then explaining here is not going to make things any clearer.

    But in addition to being morally wrong, it is also dumb in the extreme. There are two important question to ask when looking at a policy …

    Is It A Practicable Policy?

    No.

    Islam is a religion and is not apparent from someone’s appearance. There is no label on their forehead!

    So a policy of restricting muslims would be limited to either asking them. Which would lead to a situation where you were excluding muslims who do not lie about their religion, or in other words you are letting in the kind of muslims that you should perhaps be excluding, and excluding the muslims there is no reason for excluding.

    Or you could do some sort of racial profiling, which amounts to not excluding muslims, but excluding light-brown skinned people. Again this will exclude the kind of muslims you do not want to exclude, whilst allowing through ones up to no good.

    Will It Accomplish The Mission?

    It really depends on what is intended by excluding muslims. If it is intended to portray the US as an intolerant country blundering around with incompetent measures that do more to annoy than to protect, them yes it can be said to accomplish the mission.

    If however it is intended to make the US safer from terrorists, then no. Terrorists are more interested in accomplishing their own mission than telling the truth, and will go out of their way to avoid being identified is muslims if they think that this will help in their mission.

    There is one small category of terrorists that this may protect against – those who are initially ordinary muslims but who later become radicalised whilst in the US. However having said that, the likelihood that this measure will protect against those vulnerable to becoming radicalised is pretty low.

     

     

  • The US Terrorist Incident That Wasn’t

    Waking up this morning, I find news of a terrorist incident in the US; except that it was not called a terrorist incident. It was announced as a mass shooting at a Planned Parenthood clinic. For those who are not aware, in the US, Planned Parenthood clinics sometimes perform abortions.

    There are those who protest about the abortions using methods up to and including murder. And whilst leaping to conclusions is not something to be encouraged, this incident has all the hallmarks of being a "pro-life" terrorist killing.

    (Image from the Casper Star Tribune)

    Given that the media is quite happy to label as terrorist incidents other killings, what is special about this incident?

    Perhaps it has something to do with who the perpetrators are – they are not wild-eyed revolutionaries, nor are they islamic fanatics; they are christian fanatics. And it seems that christian terrorists get the benefit of the media not labelling their outrages as terrorism. Why?

    And look at some of the twitter spew :-

    3nhP9mX

    PkqDdJC

    QxK1psbTqTI21T

     

  • Bomb Daesh/ISIS/ISIL?

    To bomb or not to bomb. That is the overly simplistic question.

    Daesh or ISIS or ISIL, or just that gang of murderous thugs are an odious bunch who deserve to be bombed into oblivion, but will bombing them actually accomplish anything? If I were convinced that bombing would either destroy ISIS (I'll stick with that name) without causing an unacceptable level of innocent victims, or it was part of a well planned and coherant set of policies to defeat ISIS then I would support bombing.

    But I'm not convinced. And I don't support bombing.

    Bombing has rarely if ever managed to defeat an enemy – bombs didn't stop Britain fighting in WWII, bombs didn't stop Germany fighting in WWII, etc. The example bombing fans always point to is the dropping of the atom bomb on Japan at the end of WWII; I would argue that those bombs didn't by themselves stop Japan from fighting on. 

    Bombing has been tried against ISIS before – just look above – does it look like a place that hasn't been bombed? And does ISIS seem like an organisation teetering on the edge of collapse? I'm inclined to agree with those who argue that ISIS is made stronger by bombs because of the propoganda they can make of it. They certainly make a better case than those who just shout "Bomb 'em".

    Come up with a reasonable strategy to defeat ISIS with a beginning, middle, and an end, and I'll support it – whether it includes bombing or not. 

    We have seen before that the West does not always plan these things very carefully – the second Iraq war was militarily well organised (as far as I'm qualifed to judge), but the aftermath wasn't planned for at all. We need a proper strategy.

  • What’s So Bad About Politican U-Turns?

    There's a lot that can be said about today's spending review, and I dare say people are saying some things about it.

    But my chosen topic is that "U-turn" that the media keep banging on about. What's so bad about listening and changing a bad policy?

    At the moment, we have a political environment where changing your mind is seen as somehow irresponsible and indecisive; yet what we have hear is a chancellor who has decided that the opposition to his tax credit cuts (which will disproportionally hit the poor) were opposed for genuinely good reasons.

    Is re-assessing a bad policy in the light of heavy opposition really a bad thing?

    Of course Osborne has sneakily got the cuts in anyway; all his welfare savings that he planned to get by punishing the poor for their feckless ways are still going to come about because he has still cut "Universal Credit" which new claiments get. It's existing claiments of "tax credits" who get their reprieve.