Sunday, 5 April 2020

Data Structures in JS: Linked Lists

I'm terrible for buying books and courses and never reading or watching them, so I decided to revisit one I bought not so long ago called Learning Data Structures in JavaScript from Scratch. The chap teaching it (Eric Traub) uses repl.it, but I decided to use JSFiddle. Here is the code from the first section, on Linked Lists:

On the whole, Eric Traub is an engaging tutor, and I learnt a load - well worth a watch. He sometimes speaks a little slowly, but I think that's deliberate, so I watched at 1.25 speed.

Sunday, 29 March 2020

A Third Alternative: Distributism

Last night, as so often happens at all times of the day, I got to arguing about politics and economics with my mate. I've mentioned to her that we seem to be two people suffering from Bi-polar; when she's feeling positive, I'm cynical and vice versa. We talked about possible solutions to what's bound to happen to the UK economy as a result of the double blow of Brexshit and CORVID-19. Last night I must've been on the upwards part of our cycle as I was proposing something along the lines of Labour Party before their defeat in the election last year. She was expecting more taxation and austerity, and the resulting loss of life was just far too miserable to envisage.

The beer I'd had must've made me poor game though, as I wasn't arguing enough or wasn't arguing with enough vigour. We're both Sci-Fi aficionados, and I had just finished the last episode of Picard so was more hopeful that a solution could be found which wouldn't leave us all in the shite. Eventually, I threw in the towel and went to a drunken bed. In the meantime, the star that she is, decided to find an alternative between Capitalism and Socialism and sent me this article, which I read this morning: Neither Capitalism Nor Socialism: A Third Alternative.

I've read it, and I recommend you do too. We did, along with some others, sort of kick around something a few years back, which was sort of like a worker co-operative - but it never got past the planning stage. Distributism seems very similar and kind of looks a little like an extreme form Balkanisation (is it just me or does Adam Robert's New Model Army look more and more likely?). It's tempting, but I'm not sure how it would work in terms of other requirements such as refuse collection, provision of healthcare and all those sorts of things. It would also mean people would need to shift allegiances from larger organisations to smaller ones. I've been in enough pubs and clubs when the football is on to know that that might be problematic.

Technologically there are movements to this sort of thing with things like the increased adoption of domestic Solar Power and Tesla's Powerwall. It's all very tantalising, and one can imagine plans for 3D printers being available rather than having to shift things via the roads. Or drone delivery, that might work? As you can doubtless tell, I like Sci-Fi, and I've found that having children and grandchildren means I'm more inclined to be positive; I'd like them to be able to grow up!

Just don't get us discussing UBI, as we'll be arguing until the cows come home! Despite both of us reading Guy Standing and Rutger Bregman.

Tuesday, 24 March 2020

Fretting?

I was listening to Radio 1 on Sunday evening (not sure what was on Radio 4, but it was boring, and I needed something to lift my spirits), and someone came out with this quote from the watchmaker and writer Corrie ten Boom :

"Worry does not empty tomorrow of its sorrow, it empties today of its strength."

The intention was excellent, as I know a fair few people are fretting at the moment with the chaos surrounding CORVID-19, but it left me somewhat disheartened as I really can't stop worrying. It's not something I can control, and it's also something that I've always been afflicted with. But rather than worrying about my inability to stop worrying I've learned to embrace it. Not only is the glass not half empty, nor is it half full; it's half full of deadly poison.

I've come to terms with it though, and I let it have full reign. I lie in bed fretting and lost in the Vortex of Hysteria until I've walked through all the possible negative implications of any given situation. Consequences up to, and including, the destruction of all human life on earth. And this can be over forgetting to put the empty milk-bottles out!

I do know that it's not classed as a healthy way of carrying on, and I dare say my cortisol levels are through the roof, but I do avoid watching the news! And worrying about the amount I'm worrying only makes things far worse. So, instead of worrying about the worrying I've come to an accommodation with the whole process - I dare say age has helped with that, as I know that I'll work through all the possible scenarios and then eventually drop off (or get up and have a wee dram).

Whatever though, I'll be prepared for the next day and will have girded my loins in preparation for the absolute shower of shite on its way. And, more often than not, I'll be pleasantly surprised that the conclusion was far better than anything I'd expected.

Why am I telling you all this? I guess it's to try and alleviate a small measure of any worry you might have about your inability to stop worrying. While it might not be healthy, it's possible to get through it. It might take some time, and it's worth bearing in mind that anything which goes on too long needs to addressing (After all, it's normal for people to feel sad, but to feel sad all the time is Depression, worrying all the time is Anxiety, and that's no fun at all!). What your time limit is is something you'll have to judge for yourself but do be cautious of following my method of pushing on through and embracing anxiety - it's worked and will continue to work for me, but might do you some harm. It's all very well spending time in the Vortex, but living there will only make you dizzy!

So the quote from Corrie ten Boom might be correct, but stopping yourself from worrying might be nigh on impossible. There is a route through though, either using my slightly dodgy method, or one or more other means. Breathing-exercises and Yoga work a treat, as can medication (but you know what I'm like with meditation) and/or prayer (I use the term lightly, but giving over control to a higher power works for some people). I dare say there are any number of possible routes through the anxiety you're feeling at the minute (or at any time), so do some research!

Whatever method you choose to implement - don't fret over fretting too much; do something about it!

Friday, 13 March 2020

Band name?

That was fun, though adding the white background behind the text was a ball-ache!

I did another, more psychedelic, version:

Spinner 33

I saw this the day before yesterday so finished the above last night:

It's not quite right, but it's getting there - I'll revisit, once I've got some more time.

Wednesday, 26 February 2020

Pin Tweaks

A mate shared an article with me a little while back about Sci-Fi, one particular quote stood out:

Science fiction wasn’t about evading reality – it was a literary anthropology which made our own society into a foreign culture which we could stand back from, reflect on, and change.

I've always been a fan of this sort of thing, and you just need to take a squint at Star Trek to clock that the Klingons were thinly disguised Russians during the Cold War (a good read on this subject is here).

Along with the fun and critical thinking that is associated with the genre itself, the people who write about it are also clever wee buggers, not opposed to some critical thought on related subjects. This article on my RSS feed caught my eye this morning. If you've managed not to meet or love someone with Dementia or some other degenerative neurological condition which leaves the body there, but slowly erodes the brain, then count yourself blessed. Whether you have or not, this discussion of Twin Peaks is well worth a read.

Sunday, 23 February 2020

SVG Cube

My Dad and I share a love of op art and are forever sending across images we like. He recently sent me something from Pinterest, and I loved it, but what I loved more was a related image, and I got to thinking about how to replicate it using SVGs. Yesterday morning I took a stab at it and clocked it was quite a simple design made up of 3 skewed and rotated rectangles that were then arranged into a hexagon. The hexagons were then placed adjacent to each other and offset above and below.

What took some time this morning was figuring out how a hexagonal design could be placed within a rectangle - but after staring at the lino in our bathroom it came to me.

Anyway, I also took the time to refactor the image I created in Inkscape so that it is made up of a def and a couple of patterns. After all, the rectangular sides of the cubes have the same fill but are just rotated and skewed. So the fill could be a pattern, the cube could be a def, and then the arrangement of seven cubes (which are required to create a properly tessellating design, and all use the same cube, just arranged appropriately) could be another pattern. From many hundreds of lines of repeating XML I came up with this:

  <pattern id="side-fill"
    x="0"
    y="0"
    width="36"
    height="36"
    patternUnits="userSpaceOnUse">
    <path style="fill:#000000;stroke:none;"
      d="M 0,30 2,30 1,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 2,30 4,30 3,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 4,30 6,30 5,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 6,30 8,30 7,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 8,30 10,30 9,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 10,30 12,30 11,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 12,30 14,30 13,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 14,30 16,30 15,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 16,30 18,30 17,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 18,30 20,30 19,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 20,30 22,30 21,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 22,30 24,30 23,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 24,30 26,30 25,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 26,30 28,30 27,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 28,30 30,30 29,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 30,30 32,30 31,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 32,30 34,30 33,0 z" />
    <path style="fill:#000000;stroke:none;"
      d="M 34,30 36,30 35,0 z" />
  </pattern>
  <defs>
    <g id="cube">
      <rect x="0"
        y="0"
        width="36"
        height="36"
        transform="matrix(0.87,-0.5,1,0.58,0,0)"
        fill="url(#side-fill)" />
      <rect x="0"
        y="0"
        width="36"
        height="36"
        transform="matrix(-0.87,-0.5,0,-1.15,30,51.9)"
        fill="url(#side-fill)" />
      <rect x="0"
        y="0"
        width="36"
        height="36"
        transform="matrix(0,1,-1,0.58,60,0)"
        fill="url(#side-fill)" />
    </g>
  </defs>
  <pattern id="tile"
    x="0"
    y="0"
    width="125.28"
    height="108"
    patternUnits="userSpaceOnUse">
    <g transform="translate(-30,54.6)">
      <g transform="translate(93.96,-54)">
        <use xlink:href="#cube" />
      </g>
      <g transform="translate(31.32,-54)">
        <use xlink:href="#cube" />
      </g>
      <g>
        <use xlink:href="#cube" />
      </g>
      <g transform="translate(62.64)">
        <use xlink:href="#cube" />
      </g>
      <g transform="translate(125.28)">
        <use xlink:href="#cube" />
      </g>
      <g transform="translate(93.96,54)">
        <use xlink:href="#cube" />
      </g>
      <g transform="translate(31.32,54)">
        <use xlink:href="#cube" />
      </g>
    </g>
  </pattern>
Fun eh? You can see it in my playground here, and with it being an SVG you can scale to your heart's content.