Tuesday, 26 August 2014

I wonder

I wonder



I wonder where I'm going
andI wonder where I've gone,

I wonder what I'm doing here
andwhen I'm moving on



I wonder when I'm going
asI think on where I've been

I wonder what I'm going for

whatever can it mean:



This coming and this going

from there and place to place

whatever do I do it for;

I know it's not a race


I wonder what I'm doing

what I'm here for anyhow

And does it really matter

If I don't do it now?



I know it has a reason

but what that is I don't know

I've tried to find out all my life

I have to find out so —



I'll remember where I'm going
andI'll know just where I've been

I'll know quite what I'm going for
andremember what I've seen


 (c) 1991 Sam Liddicott
I found this a bit sickly at the time and my view hasn't changed much in the last 23 years. verse 2 and 3 were scribbled through but I've included them here.

Inspired by mission transfers; and the first couple of minutes of this video:


The next wonder poem

The next wonder poem


Sometimes I'll wonder
&sometimes I'll won't,
&sometimes I'll wonder
why sometimes I don't

And when I sometimes wonder
Why I'm sometimes won't
I'm sometimesing wonder
how I still am.
wondering
about
nothing at all.



(c) 199x - 2014 Sam Liddicott

Poem: On wondering too much

On wondering too much

or

I also wonder


I wonder why I wonder,
What I do it for, and how,
I wonder as I wonder why I'm wondering right now

And as I wonder wonder wonder wondering today
I wonder if I should have really
stayed in bed today

(C) 1992 - 2014 Sam Liddicott

Friday, 18 July 2014

Windows can have UTC hardware clock

Thanks to reddit's Sceptically for this:

There's a registry setting you can use in windows to make it work with UTC on the hardware clock.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001

I don't know why they don't press that for you before it leaves the factory...

Dilbert.com

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?

Sunday, 20 April 2014

MAKEDEV and double virtualization

MAKEDEV can run in a couple of seconds - even on a virtual machine.

But if your virtual machine is hosting a qemu guest, then in that guest a fork/exec can take 0.2 of a second, and MAKEDEV generic-i386 can take a couple of hours. (This is because the kqemu kernel module is not available, http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/qemu-running-on-ubuntu-vmware-guest-cannot-find-dev-kvm-936253/).

The first hacky-hack to cut down on the number of fork/exec is to stop calling sed quite so often, cue this patch (requires MAKEDEV to run under bash).

--- /sbin/MAKEDEV 2009-07-30 08:39:09.000000000 -0700
+++ /MAKEDEV 2014-02-21 06:31:43.000000000 -0800
@@ -1,4 +1,4 @@
-#! /bin/sh -
+#! /bin/bash -
 # $Id$
 
 #---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#
@@ -116,7 +116,9 @@
 
 devicename () { # translate device names to something safe
  # A-Z is not full alphabet in all locales (e.g. in et_EE)
- echo "$*" | LC_ALL=C sed -e 's/[^A-Za-z0-9_]/_/g' 
+ #echo "$*" | LC_ALL=C sed -e 's/[^A-Za-z0-9_]/_/g' 
+ echo "${*//[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]/_}"
+  
 }
 
 makedev () { # usage: makedev name [bcu] major minor owner group mode
@@ -231,12 +233,14 @@
  exec 3<$procfs/devices
  while read major device extra <&3
  do
-  device=`echo $device | sed 's#/.*##'`
+  #device=`echo $device | sed 's#/.*##'`
+  device="${device%%/*}"
   case "$major" in
    Character|Block|'')
     ;;
    *)
-    safedevname=`devicename $device`
+    safedevname="${device//[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234566
+789]/_}"
     eval "major_$safedevname=$major"
     devices="$devices $device"
     ;;
@@ -247,7 +251,8 @@
 
 Major () {
  device=$2
- devname=`devicename $1`
+ devname="${1//[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234566
+789]/_}"
  if [ "$opt_d" ]
  then
   echo -1 # don't care
@@ -2149,7 +2154,8 @@
    exec 3<$procfs/devices
    while read major device extra <&3
    do
-    device=`echo $device | sed 's#/.*##'`
+    # device=`echo $device | sed 's#/.*##'`
+    device="${device%%/*}"
     case "$major" in
      Character|Block|'')
       ;;


The next hack is to stop the 5 or 6 fork/exec when MAKEDEV deletes a device node, creates a (temporary device node), chmods it, chowns it, and renames it.

How do we do that? We run MAKEDEV -n so that it does none of these and then feed the output to a perl script which will do them.

Sadly perl has no native mknod call and there are no libraries in this environment, and so I use perl's blessed syscall function with a hard-wired syscall 133 for mknod (as it is, on my kernel):

time /MAKEDEV -n generic-i386 | perl -ne '
print; 
umask(0);
($c, $f, $node, $major, $minor, $own, $perm) = split; 
if ($node eq "->") { 
  symlink($major, $f) || die "sym: $!";
} else {
  # system("mknod",$f,$node,$major,$minor) && die "mknod($f,$node,$major,$minor): $? $!"; 
  # chmod(oct($perm), $f) || die "chmod: $!"; 
  $n=0;
  $n=0010000 if ($node eq "f");
  $n=0020000 if ($node eq "c");
  $n=0060000 if ($node eq "b");
  $n=0140000 if ($node eq "s");
  if (syscall(133, $f, oct($perm) | $n, (($minor & 0xff) | (($major & 0xfff) << 8)
          | (( ($minor & ~0xff)) << 12)
          | (( ($major & ~0xfff)) << 32))) == -1) { die "syscall: $!"; }
  ($user,$group)=split(/:/,$own);
  $user=getpwnam($user);
  $group=getgrnam($group);
  chown($user,$group,$f) || die "chown: $own $!"; 
}
'

Leaving in the system("mknod,...) took around 24 minutes, but moving straight to syscall(mknod,...) takes1 minute 8 seconds.

I did toy with having bash use printf or something to pack a binary tar archive (or even getting perl to pack a tar archive) to pipe to tar -x, but... this will have to do for now.

I suspect this depends on a bug in MAKEDEV which seems to still create sub-directories needed even in -n mode.

It would have been better to pipe the output to a c program which would parse it, I will do that, another day...