Suranyami

Polyglot developer, geometric tessellation fan, ambient DJ. Edit profile

Since I've been playing around with using Obsidian to organise myself, I tried out some of the MathJax support. These are some examples I've tinkered with.

MathJax

Quick guide

Examples

An example of inline MathJax $\alpha, \beta, …, \omega$

$$\begin{matrix} 1 & x & x^2 \ 1 & y & y^2 \ 1 & z & z^2 \ \end{matrix}$$

$$ \begin{vmatrix} a & b \ c & d \ \end{vmatrix}=ad-bc $$

$$ \sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6} $$

$$ 10^{10} $$

$$ {x^y}^z $$

$$ x^{y^z} $$

$$ x_i^2 $$

$$ x_{i^2} $$

$$ \Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr) $$

$$ \left(\frac{\sqrt x}{y^3}\right) $$

$$ \frac ab $$

$$ \frac{a+1}{b+1} $$

$$ x \approx y $$

$$ \sqrt[3]{4} $$

$$ \infty $$

$$ \aleph_0 $$

$$ \nabla $$

$$ \partial $$

$$ \Im $$

$$ \Re $$

The new improved Ozzie term for “Abbreviation” shall henceforth be known as a “brev”.

As in:

“I brevved it” “it's a brev” “I'm brevving it”

Let's make it happen, people!

Our reputation as the dimunitive-superpower of the world is at stake.

October 18th, 2015 8:54pm

August 22 2012, 9:57 PM

Quite a few people have been asking me where “suranyami” comes from lately, which caused me to remember that I hadn’t transferred over the Suranyami Bullet story when I moved over to Posterous.

So here it is. This was a 2-part dream with a sequel that occurred over New Year’s Eve / Day and then 6 months later. I wrote it all down as soon as I woke up, because it was unusually vivid.

Suranyami Bullet

19981231

Suranyami Bullet

The war between Iraq and the USA had reached a point of extreme ridiculousness and was now taking criticism from all of the Islamic states, and many other nations also. Hundreds of cruise missiles were poised, and then fired from US carriers. Suddenly, one by one, they all disappeared. There was an ominous and eerie silence which was followed by a brief public broadcast from an obscure, fundamentalist (yet, pacifist) Islamic sect. They said that the time had come for the use of the Suranyami Bullet, a sacred object that they had been secrretly guarding for over 10,000 years. This was why all the missiles had failed. They said that when the Suranyami Bullet was fired it could shoot every individual human on the Earth straight through their heart, and that this was no idle threat.

At the very same time, I got an urgent email from an old friend, Julie Chan, asking me if I was available to work immediately on the most significant nanotech project ever devised: “the Suranyami Bullet”. I said “yes”. When I got there (in the Middle East) I found the most amazing laboratory… sophisticated beyond your wildest dreams. It had been built in one day by the simple insertion of a small metal key into a slot in this small bronzey-coloured bullet with little red spheres studded around one end of its casing. The ensuing nanotech lab was a “setup station” for the full release of its capabilities. Yesterday’s missile deactivation had been almost a trivial exercise once it had been activated. Now came the fascinating task of working out what it could really do, how it did it, and why had it been held in safe keeping for thousands of years by a group of devout Muslim priests.

Here were programmers, mathematicians, philosophers, physicists, chemsists etc… all coming to grips with this tiny device that was more powerful than anything else in the universe so far.

My initial doodlings at disassebling its products started with requesting a pencil to be produced and then using the equipment available to analyse it. The pencil had the unusual property that if you twisted it, it grew and shrank in girth and pencil-stroke darkness. I ran a scan for any structurse that had a structural similarity to a computer language statement such as:

ON EVENT(type) DO
  Statement
END

…etcetera and soon discovered many, many types of these structures, mostly idle, scattered throughout the entire makeup of the pencil. There seemed to be a pretty predictable one-to-one correspondence between the machine-micro-circuits and typical computer instructions, so I modified a cross-compiled hack of Fractal Painter and soon had a pencil that had the full functionality of Painter… touch this for this brush, press the ? and out unfolded an interactive instruction page, bend here to activate the image hose, etc… geeks emailed copies of the compilation code to each other with much delight.

19990101 Part 2

It turned out that the knowledge of when to activate the Suranyami Bullet had been passed down as an oral tradition from teacher to student for as long as anyone could speak. The time to activate it would come as a definite feeling by those who were physically near it. This was one of the major “tricks” that it was apparently capable of… that it had some form of psychic influence, but was obviously based on sound scientific principles.

Good progress had been made towards understanding it and how to take it to the next level. Upon activating Level 2, the thing burst up, down, in and out all at once, simultaneously consuming and producing at a massive rate.

Analysis had shown that, what looked like a large section of the bullet that was dedicated to “construction plans”, was in fact nothing but a big decompression algorithm. The data that it was decompressing turned out to be only 1 bit in length. It was anticipated that the output of the compression was a set of instructions, the size of which was in the googleplex range (10^(10^100)).^^

Somehow, the compression algorithm was always uniquely design to decode the same number, but using different techniques and pseudo-random number seeds would come up with wildly varying output. In fact, it was theorised that if we could understand the algorithm that designed the compression algorithm each time, we could compress any amount of data into 1 bit.

The bullet was now expanding at an enormous rate, consuming the ground, trees, buildings, etc… and looking like a cross between video static, pin-cushioned inflatable leather, nuclear powerplant plumbing, circuitry, organic mould and you-name-it. It inflated around and through everything, and by-and-large, pushed people harmlessly away from it.

In what seemed irrelevant (at first), I was asked to attend a funeral or my Uncle Jimmy by my Sister, Mum and Nana. They were very upset and worried about the strange, evangelical, bargain-basement, charismatic church sect that Auntie Babs had proposed for the funeral. They wanted me to go and talk some sense into her, so, could I sit in with Babs at the dress rehearsal for the funeral, which required a male for half of the burial ceremony.

The funerals this church did were a bit like the Reverend Moon mass marriage ceremonies, where stadiums were filled with lots of couples. I joined Babs and sat on the sideways-backwards seats that were used. We were in a huge L-shaped church hall with hundreds of others that were also burying people.

We had to put hand puppets on at various times, while we were rocking back and forth and cutting up bits of salami and saying the Eulogies in high-pitched, sing-song, cartoon voices. All the seats were alternating pink and white chequers and they rocked back and forth like fake stage-waves. Ultimately, it all got more and more surreal, to the point where I thought that I must be hallucinating, but it turned out that it was actually part of the bullet’s influence.

It had been gradually assimilating and rearranging everyone’s personalities and consciousness in to itself and this was a combination of some moral lessons that it wanted to teach, and the fact that it fully hadn’t grasped the subtleties of our lives and communication styles yet. The transition had seemed to happen quite smoothly at first, since it had a significant knowledge of how our bodies processed sensory data, and it was a fairly simple matter for it to release nano-bots into our lungs and the bloodstream that would then travel to the various parts of the body and start feeding false information into synapses.

A group of others and myself soon found ourselves suspended in a spherical field surrounded by the bullet’s machinations as far as the eye could see, which must have been millions of miles—there was no horizon. It had already become so big, it told us, that communications between parts of itself was suffering week-long lag times just to send messages, so it had developed time-space folding techniques to hyperspace signals and structures throughout itself. The devices to do this looked like identical mirror-inverted CDs without holes in the middle… a bit like the stepping disks in Ringworld. One side of each disk was a field that caused a time-space discontinuity whereby you could put your arm through one disk and it would start protruding out of the other disk, no matter how far apart they were.

We were being accelerated to the speed of light, now, whereby henceforth we would be increasing our mass and energy towards infinity, reducing the rate of time passing to zero, and becoming identical to light. As time stopped, we became immortal and at one with God: the Suranyami Bullet.

A new God-King-Emperor! Hurrah!

19990610

Crest of the Yami-God-King-Emperor of Suran

Peter Pegg, the intrepid “Dr Livingstone” explorer with the pith hat, hurriedly ushered me away saying “David, we simply must be involved in this… it is a once-in-a-lifetime opportunity”. We were in the kingdom of Suran, where the Suranyami Bullet had come from. The current God-King-Emperor had just died… his status was similar to the Zion/Ethiopian Harley Selassi/Markus Garvey “incarnation of god that walks upon the earth”. Peter had done extensive and very respectful research into the ritual of choosing the next “Suranyami” and he had, in fact, been asked by the Suranese Royal Family to assist in their holiest of rituals… the passing down from father to son of the holy godhead.

The sacred tree room which had grown from Moses’ burning bush grown over thousands of years and turned inside out: it had one secret branch that grew from the outside through the trunk, inside the special room-cavity-altar exposing the holy knot, then continued back out through the trunk to the outside world again.

It was considered auspicious that there were two total foreigners there (surprisingly!) because there had never been anyone from the outside world in the Kingdom of Suran… the coincidence was not taken as mere chance.

The three of us (the son, Peter and myself) entered the tree-room and Peter was asked to use the cylindrical saw to cut out the middle heart of the knot. When this happened, the new godhead flowed out of the tree in a sacred fire that would settle down (usually) on the head of the King’s son… but to everyone’s shock, it settled on mine. I wore the holy flame which engulfed my mind and skull.

There was nothing else to do but walk proudly out onto the branch-walkway and claim myself as the new God-King-Emperor of Suran.

Soon, we were whisked off in a convoy of pink cadillacs with 50s housewives wearing John Galleano-esque lemon-yellow, pistachio-green and pretty-pink shirts and flowing skirts, accessorised with long gloves. The celebrity cavalcade wandered along winding coastal roads to the theme of “A Summer Place” with all the ladies waving their hands like the Queen does, holding their parasols, and rejoicing “Oh, hooray! We have a new God-King!”

September 9th, 2013 3:00pm

I deactivated my Facebook account today. I’ve downloaded a dump of all my data (1GB), and after I’ve compressed and archived it, will be deleting my account. (Update: this has been done now).

The final straw for me was yet another anti-vaxxer in my group of people I know. I can’t take it any more… it’s either Trump fans, anti-vaxxers, climate denialists, racists, nazis, extremists of all sorts. I can't do much to stop those people, but I can disconnect from it. I get absolutely nothing but hate and anxiety from it, and unfortunately, the volume of that outweighs the good experiences from people I know and love. It's sad, but true.

I’ve basically decided that Social Media as a whole is corruptible with apparently minor effort by state-based malicious agencies, charlatans, anti-science idiots and general-purpose assholes.

I am reverting back to RSS for news, direct, invite-only groups like the one I have in Slack, but will probably start making more of a presence in Element and Matrix and any other similar systems that are decentralized, open-source and community-driven.

My Element address is: @suranyami:matrix.org

Tried out Jitsi Meet the other day. It’s based on Matrix, and is actually pretty good. Not quite as good as Zoom, but a lot better than Google Meet.

Had an unusual sort of query where we had a stream of sales data that was cumulative for the day but sent through in updates, so had to total them for a given store, for all users, but for the last entry on the day. And it was stored in Postgres in a JSON blob.

Here's how I ultimately solved it in postgres:

SELECT
  CAST(data ->> 'boxes' AS INTEGER) as boxes,
  data ->> 'storeid' AS storeid,
  data ->> 'username' AS username,
  CAST(inserted_at AS date) AS inserted_date
FROM
  external_records
WHERE
  api_id = 6
  AND data ->> 'transactiondate' IS NOT NULL
GROUP BY
  data ->> 'storeid',
  data ->> 'username',
  CAST(inserted_at AS date),
  inserted_at,
  data
ORDER BY
  inserted_at DESC;

I've been using Beekeeper Studio for running SQL queries. It's so much nicer than PGAdmin.

And here it is in ecto:

  def last_for_store_on_day(api_id, storeid, date_string) do
    date = Date.from_iso8601!(date_string)
    IO.puts(date)

    query =
      from(ex in ExternalRecord,
        where: ex.api_id == ^api_id,
        where: fragment("CAST(inserted_at AS DATE)") == ^date,
        where: fragment("data ->> 'storeid'") == ^storeid,
        group_by:
          fragment("""
          data ->> 'storeid',
          data ->> 'username',
          CAST(inserted_at AS date),
          inserted_at,
          data,
          id
          """),
        order_by: [desc: ex.inserted_at]
      )
    Repo.all(query)
  end

The fragment expressions are a little odd at first, but I like this a lot more than just doing the entire block as SQL, if only for security purposes.

Canonical XSP page

An XSP page is an XML page with the following requirements:

  • It must have a cocoon processing instruction that invokes the XSP processor <?cocoon-process type="xsp"?>

  • The document root element must be <xsp:page>

  • It must also have any language and Taglib declarations as attributes in the <xsp:page> tag (e.g. <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">

  • In order for the XSP page to be useful, it will also require usually at least an xsp:logic element and an xsp:expr element.

Usually you will also require further processing of the resulting page, with a stylesheet for instance, to transform the results of your code into a readable form for the viewer (typically to HTML).

You should remember that cocoon processing instructions act upon a whole document, then generate a result document, which will in turn be passed to the next cocoon processor, rather like a pipeline.

So, here is a minimal XSP page:

<?xml version="1.0"?>  
<?cocoon-process type="xsp"?>  
<?cocoon-process type="xslt"?>  
<?xml-stylesheet href="page-html.xsl" type="text/xsl"?>  

<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">  
<xsp:logic>  
  static private int counter = 0;  
  private synchronized int count() {  
    return counter++;  
  }  
</xsp:logic>  

<page>
  <p>I've been requested <xsp:expr>count()</xsp:expr> times.</p>  
</page>  
</xsp:page>

Let's look at each part of this, one at a time:

<?xml version="1.0"?>

required for every XML page

<?cocoon-process type="xsp"?>

first process this page with the Cocoon XSP Processor

<?cocoon-process type="xslt"?>

then run the results through the XSLT processor

<?xml-stylesheet href="page-html.xsl" type="text/xsl"?>

This is the stylesheet that the XSLT processor should use

<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">

This is required for an XSP page.

The document root must be xsp:page.

The language attribute is optional.

You can also specify optional Taglibs here by including their XML namespace references. You will definitely need at least the xmlns:xsp definition.

Other Taglib namespaces are available and should be added here as attributes... see Built-in Taglibs below.

<xsp:logic>
  static private int counter = 0;  
  private synchronized int count() {  
    return counter++;  
  }  
</xsp:logic>

<xsp:logic> tags specify definitions of things in the language that is used on this XSP page... usually functions and class-wide variables.
In this case, we are using Java.

<page>  
  <p>I've been requested <xsp:expr>count()</xsp:expr> times.</p>  
</page>  

Here is the bulk of the page content specified as general XML.

The first element that you place here (in this case <page>) will become the document root element of the xml document that will be generated after the XSP processor has finished.

The <xsp:expr>count()</xsp:expr> element here is saying “call the function 'count()' and convert the result into a text node”. <xsp:expr> is used wherever you need to insert live data into the output document.

The output of the XSP processor will produce the following page (obviously the value of count() will change over time:

<?xml version="1.0"?>  
<?cocoon-process type="xslt"?>  
<?xml-stylesheet href="page-html.xsl" type="text/xsl"?>  
<page>  
  <p>I've been requested 0 times.</p>  
</page>

3 types of XSP pages

Embedded Logic

In this situation, we place the code directly in the XML page. This is pretty bad style and only really useful for trivial examples, but it's useful to run through what happens when an XSP page “does stuff”.

So what happens?

First, the XSP processor parses the XML file and turns the whole page into an XSP servlet. Sounds strange, but true? All of the static XML gets turned into Java commands that insert XML elements, attributes and entities into a DOM tree. It can be very educational to take a look through your servlet engine's “repository” directory: there you will usually find a java file corresponding to each XSP page. You'll be surprised to see just how much a simple XSP page expands out to...

So, the static XML elements turn into function calls with constant parameters, whereas the dynamic logic bits (the whole point of this) get turned into... you guessed it... function calls with variables as parameters.

In this scenario, the XML page IS an XSP page... it has the canonical format for an XSP page. The root element of an XSP page must be xsp:page. The resulting XML page is then transformed using the relevant XSLT stylesheet, which (in this case) results in a HTML page.

Included logicsheet

This is a much more preferable way to be working, whereby parts of the original XML document that are matched by the stylesheet are replaced with sections of logic code.

In this scenario, an XSP page is generated from the original XML page, rather than the original XML page BEING an XSP page.

This is an example of a “logicsheet”. The original XML file's elements are replaced with pieces of logic (or plain ole XML, as needed). The transformation is done by an XSL stylesheet, the results of which are pieces of XSP logic or expressions.

In the diagram we see that the <item/> element will be substituted with the contents of the <template match="item></template> element. In this case, it's an <xsp:expr></xsp:expr> element which will presumably contain some kind of Java code, which, when executed will insert a text node into the XML result tree.

More importantly than the specific contents of the page, once again it is important that the root element of the resulting XSP page is an <xsp:page> element.

By this stage, the result of this transformation (produced by the logicsheet) is a canonical XSP page. This will then be “executed” and the result will be an XML page, with all the variable bits replaced with actual values. Once again, the XSL stylesheet transforms the final outcome into a HTML page.

XSP page with taglib logicsheet

In this instance we are could be dealing with either of the two previous scenarios, the only difference is where the logicsheet lies. The taglibs are central libraries that can be referred to from anywhere within an XSP page. The most important aspect of the taglib is that it has an XML namespace declaration, declared in the original logicsheet, and matched in the <xsp:page> xmlns attribute.

A namespace declaration is a URI (usually, something like: “http://www.suranyami.com/MyImportantLibrary"). Apparently, there doesn't actually have to be anything at that address... just that it's a uniquely identifiable name.

This namespace declaration then matches to the logicsheet referred to in the cocoon.properties file. Here is a typical situation:

XSP page

<xsp:page xmlns:**utilities**="_http://www.suranyami.com/myUtilities_">  
...  
</xsp:page>

#### Logicsheet file

```xml
<xsl:stylesheet version="1.0" xmlns:**utilities**="_http://www.suranyami.com/myUtilities_">  
...  
</xsl:stylesheet>

cocoon.properties

processor.xsp.logicsheet.**utilities**.java = file:///home/dayv/myUtilities.xsl

XSP core tags & meanings

<xsp:page>

The root level element of an XSP page.

<xsp:logic>

Defines a section of code such as functions and variable declarations.

<xsp:expr>

Inserts a text node into the output tree of the XML file.


2001-12-06 David Parry

Thanks to The Wayback Machine for having a copy of this. My blog stats were showing that people still referred to this. Sorry it was missing for so long!

I had a dream that Lady Gaga was judging an industrial design competition. My entry was a gigantic version of the iPod Shuffle with a turntable inside it for vinyl records.

It had a huge clip that you could use to clamp it to your arm (but it tended to cut off your circulation), or your head. She liked it so much she agreed to help me find a manufacturer for it “because it was just so ridiculous”.

Then we all went for rides down the water slides.

2011-07-02 18:02  by David Parry

Add this to ~/.zshrc:

    skip_global_compinit=1

2013-09-11 14:36

Whenever, as is the usual course of events during the day, I push to a remote git repo with git push origin master, I have this annoying habit of singing the words to this song that I heard in my collection ages ago:

“Original master: him dead!”

It’s from a collection of West African funk, a quite groovy song, of which they were virtually the only lyrics.

Eventually, my coworkers, er, noticed this habit of mine, responding with:

“What the hell is that? That thing you keep saying.”

To which I then immediately responded:

“it’s a song, let me play it for you, it’s called… ummm… hang on, I’ll look for it… ummm… I don’t know what it’s called. Or who it’s by. Or what album it’s from. I know it's from a compilation of West African funk…”

Cue rolling eyes, and mutterings of “of course it is…”.

And things stayed in that nebulous state of affairs, with the added surreallity of everyone else that works with git in my office singing the same thing each push, despite none of us having the slightest clue what it was.

Until yesterday, when pure luck and random-play caused it to pop up! Yay.

It’s called:

“Natural Points”, by Smahila & the SBs, on the album “The Danque!!!”

2011-10-22 18:47  by David Parry

I was chatting with Tony from work the other day about the Buddhist idea of Right Speech, which is one of the items in the Noble Eightfold Path. It turned out I could only remember 2 of the 4 requirements, so I had to look them up:

Right speech is the first principle of ethical conduct in the eightfold path. Ethical conduct is viewed as a guideline to moral discipline, which supports the other principles of the path. This aspect is not self-sufficient, however, essential, because mental purification can only be achieved through the cultivation of ethical conduct. The importance of speech in the context of Buddhist ethics is obvious: words can break or save lives, make enemies or friends, start war or create peace.

Buddha explained right speech as follows:

  1. to abstain from false speech, especially not to tell deliberate lies and not to speak deceitfully
  2. to abstain from slanderous speech and not to use words maliciously against others
  3. to abstain from harsh words that offend or hurt others, and
  4. to abstain from idle chatter that lacks purpose or depth.

Positively phrased, this means to tell the truth, to speak friendly, warm, and gently and to talk only when necessary.

So, in summary:

  1. speak the truth
  2. speak kindly
  3. speak gently
  4. speak only when necessary

October 14 2011, 9:40 PM  by David Parry

Enter your email to subscribe to updates.