Friday 30 May 2014

MessageFormat {0} for bash

Here is an sample string formatter written in bash, that works along the lines of the java string format class, see http://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html.


#! /bin/bash
# Sam Liddicott sam@liddicott.com
# e.g. formatecho "Hello {1}, date of {0} is {0,datetime}, using '{0,datetime}'\n" 1401444493 "$USER"

cutstr() {
  printf -v "$1" "%s" "${4%%$3*}"
  printf -v "$2" "%s" "${4#"${!1}"}"
}

formatstr() {
  local target="$1"
  shift
  local format="$1"
  shift

  local result
  local start
  local arg
  local func

  # slice up to ' or { and process
  while test -n "$format"
  do cutstr start format "['{]" "$format"
     result="$result$start"
     case "$format" in
          {*) cutstr start format "}" "$format"
              format="${format:1}"
              cutstr arg start , "${start:1}"
              arg=$(( arg + 1 ))
              if test "${start:0:1}" = ","
              then result="$result"$(${start:1} "${!arg}")
              else result="$result${!arg}"
              fi
            ;;
        "'"*) format="${format:1}"
              cutstr start format "'" "$format"
              # empty string means ' but bash 4.2 errors stop me defaulting 
              # to ' or $'\x29' so I copy the ' from format
              result="$result${start:-${format:0:1}}"
              format="${format:1}"
            ;;
     esac
  done

  printf -v "$target" "$result"
}

formatecho() {
  local _message
  formatstr _message "$@"
  printf "%s" "$_message"
}

datetime() {
  date -d @"$@"
}

formatecho "$@"


Wednesday 7 May 2014

Passive Aggression

This essay so far only covers passive-aggressive as a defence against the narcissistic psychopath, and not as a method of attack used by the narcissistic psychopath, or as a substitute means of communication.

Arguably, this is not true passive aggression but rather a refusal to engage. For a fuller look at passive aggression, see http://www.theguardian.com/science/brain-flapping/2015/feb/19/ok-dont-read-this-article-about-passive-aggressive-behaviour-honestly-its-fine
Passive Aggression
Passive-aggressive: Term for practitioners of non-violent inaction, employed by those who have not yet discovered the futility of ridicule against the practice.
Introduction
Much so-called passive aggression is not so much aggression, as dis-interest.
The accusation of passive aggressive is the last attempt of the psychopath to manipulate and dominate those who have made the ultimate withdrawal from a hostile environment, by refusing to participate.
It's older equivalent from the age of physical violence, which may still be familiar to some, is: "Come back and fight me you snivelling little coward!" or as it was understood by the hearer: “Come back so that I can beat you into submission!”
Those whose eloquence or tired persistence have crumbled before the illogical, unreasonable and unremitting demands of the exploitative bully have concluded that the only way to win is not to play the game; that validation from the psychopath is unsatisfying, that the promise of validation is unbelievable, that while yielding may defer immediate pain into future pain, playing the game only promises pain.
And what's wrong with passive-aggression, if we can call it that? How about calling it non-violent inaction? Does one really prefer passionate aggression, or violence? And does one leave place for those who don’t?

Victim-blaming

The accusation of passive-aggressive is an attempt to blame failure to engage, or to kindle even the smallest spark of trust, on the one whose engagement is to be exploited.
Having spent every cent of political capital, the passive-aggressive-accuser will attempt to bully-up some more, revealing themselves as a psychopathic snake-head demanding the privilege to present, ad-infinitum, scenario after scenario until they can find one that will cause the other to willingly do their bidding.

Preferred Environment

Those who prefer passionate aggression may thrive in an environment of passionate aggression. It may be that they think that they are the most aggressive and persistent and that they can dominate that environment and “do things right” (because, “Hey! If I was wrong, I would have changed my mind”)
Likewise one might expect that those in favour of actual aggression also suppose themselves to be among the biggest and the strongest.
One might suppose that PA accusers are attempting to perpetuate an environment in which (actual violence being outlawed) they can win by force of personality, while simultaneously preventing their victims from carving out a sanctuary of their own.

What does the passive-aggressive see?

The passive-aggressive’s behaviour silently says: “Why should I be interested in your little scheme? I’m not a resource to be exploited to your ends!”, but has somehow found it no longer worthwhile to say this out loud. It is not worthwhile to provide the psychopath with feedback how to constructing a more effective message/weapon.
The passive-aggressive sees no union, no meeting of the minds, except perhaps superficially.
The psychopath will offer scenarios that ostensibly are desirable to both parties based on the superficial union, but the passive aggressive is aware of an additional cost that is too expensive to explain.

How to deal with a passive aggressive

Take some actual real unselfish interest in the welfare and independence of the passive aggressive.
If you find that this doesn’t work then it wasn’t really unselfish, just more latent psychopathy.
Clue: it’s not supposed to work, what were you actually trying to do? Try granting the other person a little self-sovereignty.

Not passive, just hidden?

It isn’t all non-violent inaction though. Here are some classic petty revenges.

The revenge must be perfectly balanced, the punishment must fit the crime.

So is passive-aggressive nature or strategy? How are latent psychopathic in all of us manifest when we are not in a position to get caught by those who matter?