Blog

Array handling in JS with functional purity

A convention has sprung up recently to make pure functions in Javascript. To get purity when dealing with arrays or objects cloning has been encouraged. But the nuance of Javascript and references is tricky. To get it right we need to understand references, mutations, shallow clones and deep clones. Which is quite a mouthful and is easy to trip over when coding.

TLDR

Know when we’re mutating to use shallow clones and avoid deep clones for internal functions.

Read more →

Running Dokku Locally

Dokku is a great PaaS (platform as a service) tool to deploy applications. It’s very easy to deploy to a Linux box with a simple wget command you can run a script that sets up all the necessary tooling. All that’s left is to enable a SSH key login. It sets up a remote git server which you can push to give you a Heroku like experience. Once the SSH key access is configured you can set a new remote from a git project. Upon push, Dokku will kick off a build process, wait for a health check and seamlessly swap out the previous instance (zero downtime deploys). You get so much for free from this open-source tool. The only downside is it operates on a single box so you can only scale up. But you can deploy multiple applications to a single box, and scale up running instances on that box. And given the size of machines these days scaling up can take my startup green field application quite far before having to consider horizontal scaling. A Linode box can be rented for $5 a month that’s capable of running a Rails app, and if you need scale Linode can upgrade your system resources up to 192GB, 32 Cores, 3840GB SSD easily supporting multiple instances of your app. If you need to scale beyond this Kubernetes with K8s or K3s is probably your next container orchestration tool.

Read more →
Cloudinary DAM

Cloudinary DAM

I was lucky enough recently to implement Cloudinary as a DAM solution on a project. A DAM being short for a digital asset manager. This is a type of cloud service typically used in the media and entertainment sectors. They’ve been around for decades but SaaS solutions have opened up, offering these services to the wider website consumer market. This enables sites running on Wordpress or Mageneto (or any CMS) to pick up an off the shelf solution. There are real SEO and User Engagement benefits to integrating one into your asset pipeline. Lets dig in to what Cloudinary has to offer and why this can help a website.

Read more →

Toxic bias in the Javascript community

Having been in the Javascript community for a while I’ve witnessed the building momentum towards a Functional Programming (FP) style. I think Javascript and FP are great but there is perhaps a miss-guided favor or emphasis put on FP as something superior. The React community help perpetuate this with the introduction of hooks, moving away from class based components (favoring functions) and libraries like Redux all employing bits of FP.

Read more →

Why I am using Go more

#Go

I’ve been subscribed to the Go mailing list for over 10 years. But I never really dived into the language. Work requirements never pushed me in that direction. In hindsight I regret not embracing it more. There are some qualities to it that really appeal to me. Particularly after developing a passion for Typescript and Nim.

Typescript made my Javascript world pleasurable to work in. And Nim really captured my interest. Being statically typed, compiled, optionally garbage collected with a really approachable syntax :heart:. Below I’ll try to illustrate why Im choosing Go for some tasks.

Read more →
A New Reality: Human Values and World Population

A New Reality: Human Values and World Population

A New Reality

A Kickstarter project finally arrived, it's a book called A New Reality: Human Values and World Population. It is a republication of a book originally by Jonas Salk. His son Jonathan Salk created this project to release an updated edition. It talks about modern-day issues primarily caused by over population creating this 'new reality'.

It's premise revolves around the sigmoid curve and how human population growth is out the point of inflection (the middle point of the curve where it transistions). All living organisms population growth follow this sigmoid curve. It can be seen with bacteria in petri dishes, fruit flies in glass containers and sheep introduced on the secluded Tasmania island. Even outside of laboratories at some point limits (food sources or waste removal) are reached causing populations to eventually plateau. Analysing human population growth we have been experiencing a period massive accaleration; And appear to be in the phase on inflection. Through this the book offers hope and warnings for the future. Many indicators suggest we have reached the turning point in human population growth (primarily that our population growth has actually started to decalerate).

Read more →
Chart Cheat Sheet

Chart Cheat Sheet



Terms

Graph - when a line is drawn, a diagram of a mathematical function/formula.

Chart - when other shapes and symbols are used for graphical representation of data (Pie/Bar).

Plot - points are marked on a coordinate system both axes must be continuous.

Diagram - a figure made to accompany and illustrate a geometrical theorem, mathematical demonstration.

Axis - designator for a Cartesian-coordinate dimension.

Axis

Axis

Ledgend

Ledgend

Bar Chart

Bar Chart

Read more →
Spartan Trifecta in Bright

Spartan Trifecta in Bright

We had an awesome weekend away in Bright, a small mountain town on the edge of Victoria Australia. Completing the Spartan race trifecta. The trifecta is where one completes all three of the Spartan race types (Sprint - 7km+, Super - 14km+ and Beast - 21km+). The sprint turned out to be around 9.5km and the beast was 24km which was a little more than we were expecting.

Some enthusiasts will attempt whats called an Ultra Beast where you run the Beast course twice. Effectively giving you a full marathon experience whilst completing obstacles and mountain climbs. Three crazy monkeys were attempting it on the Sunday. Two completed and one was disqualified for surpassing the time limit. I'm blown away and impressed by these individuals.

Read more →
Complexity of Dantes Inferno

Complexity of Dantes Inferno

Quick glance at The Divine Comedy and how difficult it is to read.

A while back I read Dante's Inferno, knowing next to nothing about the history or story. Only having fragments of knowledge which I'd gleaned from games. As I began to read I learnt that it is a poem, originally written in Italian. By Florence poet Dante Alighieri 1265 – 1321. His work known as Dante's Inferno or The Divine Comedy, is a masterpiece of world literature. He begun working on it c. 1308 and completed in 1320, a year before his death in 1321. Its release in Italian was contentious, as notable literature of the time was published in Latin, available only to the affluent that could read it. The Italian language was considered a 'common' language, and works published in this tongue (Italian) didn't receive the same esteem. Dante helped establish Italian as the national language.

Read more →
Analysis of Harry Potter in German

Analysis of Harry Potter in German

This is a minor analysis of German - Harry Potter & The Philosophers Stone, for language learners.

A common technique for language learners is mass exposure, where you immerse yourself in all mediums of a language. The most accessible and perhaps the most beneficial when beginning a language is reading. Ebook readers make books from all languages very accessible. And have the added benefit of onboard dictionaries, where translations are a finger gesture away. I've found it a helpful technique myself. And believe its popular amongst polyglots out there (at least the one or two I follow). And after breaking it down it starts to become clear why this is an effective learning technique.

Read more →

Netbeans & Silver Stripe

OK quick note, Netbeans is an awesome IDE. Love the debugging options an set to xdebug default options. So it just works when running Linux PHP Xdebug. Was a life changer when someone showed me how about six months ago.

Silver Stripe is also an awesome PHP framework/cms. But .ss files the ones used by the Silver Stripe templating system don’t get recognised by Netbeans. A quick Google resulted in a few incomplete forum results. I’m using Netbeans 7.2 and it took under a minute once I knew where to go, to enable syntax highlighting and code completion (apart for ss template tags).

Read more →

Cassandra CQL

So apart from needing to redesign/rebuild my site, I really need to start writing more about my experiments. More for my own record than a public one.

Recently started playing with the whole Nutch family (Hadoop, MapReduce, Hbase, Pig, Solr, Nutch,… etc). I finally got Nutch 2.1 set up with Cassandra 1.2 (that in itself should be another article) with the aim to run data extraction and post to Solr’s Lucene index. Initially I’ve just indexed my own site, but need to inspect the Cassandra data. Been playing with pycassa with some success (the library rocks I just suck at python), and looking at some gui’s. But now settling on CQL as a means to navigate the data. In this post I hope to record the queries I’m yet to use to inspect a Cassandra Nutch data store.

Read more →

Bitmap to ByteArray

Some notes about using sprites from Flash Professional in Flash Builder.

1 When adding Sprites or Movie Clips to a Flex application add them to a UIcomponent first or use rawChildren.addChild() to avoid run time errors.

fx:Script spritecanvas.addChild(new Sprite()); // OR this.rawChildren.addChild(new Sprite(); </fx:Script> <mx:UIComponent id=“spritecanvas” width=“100%” height=“100%"> 2. The information on labeled timelines and labeled movieclip instances remains intact

fx:Script [Embed(source=”../sprites/Demo.swf", symbol=“test”)] private var TimeLineTest:Class; var TestTimeLine:MovieClip = new TimeLineTest() as MovieClip; TestTimeLine.gotoAndPlay(’timelinelabel’); // accessing sub movie clips which have been given an instance name in Flash Professional // TestTimeLine.inception == MovieClip </fx:Script> 3. AS3 code however does not remain intact but stop() commands do (I’m wondering if I’m missing a flag here when embedding) A movie clip symbol in Flash Professional which is given a base class of the following

Read more →

Laravel Object Clone

Nice little laravel clone function. Extending the base elquent model for your self is generally best practice.

Then you can whack function little helper functions in there like this.

  public function __clone() {

        $clone = new self($this->to_array());

        unset( $clone->id );

        $clone->exists = false;

        return $clone;

    }

Read more →

Flash Professional & Flash Builder Compatibility with Sprites

Some notes about using sprites from Flash Professional in Flash Builder.

When adding Sprites or Movie Clips to a Flex application add them to a UIcomponent first or use rawChildren.addChild() to avoid run time errors.

<fx:Script>
 spritecanvas.addChild(new Sprite());
 // OR
 this.rawChildren.addChild(new Sprite();
</fx:Script>
<mx:UIComponent id="spritecanvas" width="100%" height="100%">

The information on labeled timelines and labeled movieclip instances remains intact

<fx:Script>
 [Embed(source="../sprites/Demo.swf", symbol="test")]
 private var TimeLineTest:Class;
 var TestTimeLine:MovieClip = new TimeLineTest() as MovieClip;
 TestTimeLine.gotoAndPlay('timelinelabel');
 // accessing sub movie clips which have been given an instance name in Flash Professional
 // TestTimeLine.inception == MovieClip
 </fx:Script>

AS3 code however does not remain intact but stop() commands do (I’m wondering if I’m missing a flag here when embedding) A movie clip symbol in Flash Professional which is given a base class of the following

Read more →

Joomla 1.5 Component with Jquery and Mootools

I’ve been building a component for Joomla 1.5 and I really wanted to use Jquery in the admin over Mootools. Unfortunately Googling for this answer is tricky as so many people are posting examples how to remove Joomla js from their frontend template. The following is very ‘hacky’ but if you’re feed up with the Joomla API and want to throw together a component, without mootools, it’s useful. It stops the need to export jQuery into a different name space, therefore breaking 3rd party jQuery plugins.

Read more →

Adobe AIR SQLite ORM

Quick update and interesting note. I’ve been blogging about AIR and SQLite databases, and recently I’ve had to put together an analytics tracking library for AIR (currently Google Analytics only supports Flex apps, it needs the DOM to function).

Wanting a better approaching to persistent data in AIR I started writing my own DataObject to handle saving and retrieving data. While writing it I thought surly someone had implemented something like this, and sure enough they have.

Read more →

Interger Primary Key as Rowid SQLite

Interesting quirk about SQLite table PRIMARY KEY’s. I’ve been using ID as my table KEY name, a habit adopted from MySQL. And in recent SQLite development I’ve been using

ID INTEGER PRIMARY KEY AUTO_INCREMENT; But it turns out SQLite column PRIMARY KEY’s are only created under specific conditions.

This is incredibly important to get right as primary keys return SELECT or SORT querys about twice as fast as a normal column search. SQLite actually makes a separate ROWID column by default for all tables that don’t have an Integer Primary Key. Only if another column name is explicitly stated as below, will SQLite not make a default ROWID column (take note of ASC). INTEGER PRIMARY KEY ASC

Read more →

Insert Or Update if row exists AIR SQLite

OK leading on from the previous post, here’s a solution for the INSERT or UPDATE if the row exists. Which is a fairly desirable behaviour for programmers. Saving an initial select if exists then update else insert routine.

This sounds like it would be an easy fix, but I must have been googling the wrong question because I couldn’t find one article relating to Adobe AIR/Flex insert or update. Reading the SQLite docs helped a whole bunch http://www.sqlite.org/lang_insert.html

Read more →

3115 Error with SQLite

With SQLite in Adobe AIR, I was running some initial tests to figure out a cleaver TRIGGER to UPDATE or INSERT appropriately.

So far I’ve been writing all my query’s in Flex, writing statements manually for instant feedback. I encountered the #3115 Error. Searching through google I see a lot of posts about this. The answer it seems is widely varied. Other possibilities include incorrect path to applicationStorageDirectory or invalid table names. My issue (to the best of my knowlodge) was a reserved word inside single quotes.

Read more →

Javascript Time Functions

A quick note on converting javascript time stamps to human-readable format. I had been working on a travel calculator with new Google Maps v3 which required this for UI.

The following function takes a javascript Date object as a parameter and converts it to a human-readable string.

The functions themselves are simplistic. But can be tedious to work out in a pinch. Also, the pluralise function is a good starting point for converting other values to human-friendly names. While it won’t cover all edge cases it services the majority.

Read more →