Software Development

A 46-post collection

Wellington Spearfishing

By Matt Button |  Aug 1, 2017  | diving, spearfishing, wellington, new-zealand, featured

A collection of links, with a Wellington focus, which I frequently use to work out if it’s worth going for a dive or not.

Feel free to get in touch if you have any links worth adding.

Webcams

Beacon Hill Webcam

Cornish - Lyall Bay webcam

Victoria University Coastal Ecology Lab - South coast time-lapse camera

Forecasts

MetService - 5 day forecast for Wellington

MetService - 10 day forecast for Wellington

Swellmap - Surf Forecast Conditions and Marine Weather

White Cloud Kiteboarding - Wind report

Windy - Interactive wind forecast maps

Maps

Cawthron Eye - Satellite view

LINZ - Hydrographic raster chart

Water Quality

Shellfish Biotoxin Alerts

Wellington Water Quality

Continue Reading...

dotnet new causing segmentation fault on Debian Linux

By Matt Button |  Jul 10, 2017  | .net-core, telemetry, openssl, dpkg, debian

Earlier this evening I installed .NET core preview 2 on Debian Sid, and tried to create a new project via the dotnet new command, only to get a segmention fault error message:

matt@IDSiG:~/git/testproject$ dotnet new console
Segmentation fault

In this instance, the segmentation fault on creation of a new project was is due to .NET Core telemetry being incompatible with version 1.1 of OpenSSL.

Continue Reading...

Writing a method that takes an integer, and returns it's factorial

Sometimes, when being interviewed for a job as a software developer, you’ll be asked a question such as “write a method that takes an integer as a parameter, and returns it’s factorial.”

For example, the factorial of 3 is represented as “3!”, which is calculated via 321, which equals 6. 4! is 432*1, which is 24, etc.

Putting aside whether these kinds of questions should be asked in an interview, if they’re asking you this, there’s a fairly high likelihood they’re asking for you to show that you understand recursion. If that’s the case, no problem, something like this will calculate the factorial:

let rec factorial n =
    match n with
    | 0 | 1 -> 1
    | n when n > 0 && n <= 12 -> n * factorial (n - 1)
    | _ -> failwith "Parameter n is out of the supported range. Must be between 0 and 12."

This can be run in the F# interactive shell via:

> factorial 3;;
val it : int = 6

But what if they want to find out whether you:

  1. Understand recursion, and…
  2. Know when you can avoid recursion, and just write simple methods instead.
Continue Reading...

CloudFlare S3 Website Error: 502 - Bad Gateway

By Matt Button |  Apr 29, 2017  | aws, s3, cloudflare, https, hugo, cloudfront, hostgator, amazon, 502, bad-gateway

I recently migrated my mattbutton.com blog away from Wordpress hosting in favor of a static site generated by Hugo, hosted on Amazon S3.

Initially, I hosted the static site via Aerobatic.io, who recently removed their free tier, and started charging $15 per month for hosting with a custom domain.. 50% more than the $10 per month I was previously paying for Hostgator Wordpress hosting. Unless I have certain specific requirements, I can’t justfy that kind of cost to host a static site.

Aerobatic.io are using Amazon S3 and Amazon CloudFront behind the scenes, so I decided to cut out the middle-man, set it up myself, and save nearly $15 per month.

Setting up the S3 bucket to host my site was fine. For the CDN/SSL side of things I initially tried using CloudFront because most of the AWS Hugo Hosting, HowTo guides were using it.

When trying to set up CloudFront via my personal AWS account, I got an error saying a distribution already exists for mattbutton.com. The reason for this error is because Aerobatic.io had already created a CloudFront distribution pointing to their own S3 bucket. CloudFront isn’t an option for me until Aerobatic.io delete their mattbutton.com CloudFront distribution.

I still wanted to use SSL, and had decided on setting up mattbutton.com with it mainly out of interest, partly because Google uses HTTPS as a ranking signal, and partly because Chrome will eventually show a Not Secure warning for all pages served over HTTP.

Since AWS CloudFront wasn’t an option, I decided on using the CloudFlare free plan for SSL and CDN. Everything went well, until I encountered a CloudFlare 502 Bad Gateway error page:

Cloudflare 502 Bad Gateway

I wasn’t having any luck searching for a solution to this error for this particular error. Fortunately, there’s a simple fix, if you know what you’re looking for, and you’re happy with the trade-offs involved.

Continue Reading...

Toastmasters Role Templates

By Matt Button |  Feb 25, 2017  | toastmasters

I joined a Toastmasters public speaking club back in November 2016. There are lots of resources out there, I found they were fragemented, and none really resonated my personal style of speaking, especially for the club I’m in, which adheres to the Toastmasters structure and rules, yet has a much more natural speaking than other clubs I’ve visited.

After performing each of the roles several times (Chair, Grammarian, Table Topics Master, etc) I found it useful to build up, and revise templates as my skill and personal style evolved. Below are my current templates, which I will update over time:

Continue Reading...

Searching for Whale Sharks in Koh Tao, Thailand

By Matt Button |  Nov 2, 2016  | thailand, travel, scuba, whale-shark, rocktopus-divers, toastmasters

I spent two weeks in late August on the island of Koh Tao, which is located in the eastern Gulf of Thailand.

The weather was perfect. Every day, I’d head out on the boat to go scuba diving at various dive sites around the island. I’d been a qualified diver for several months prior, so no training was needed, and I signed up for the fun dives, where we would be taken on underwater tours by a guide called a dive master.

I was planning on diving virtually every day around the beautiful island of Koh Tao. In particular, I was hoping to see some big sea creatures such as the Whale Shark.

Now I should give some context. Some of you might hear the word “shark” and think of danger, or perhaps a film such as Jaws

A whale shark, while being huge at up to 14m long and 21 tonne, is nothing like the kinds of sharks that you might see on the Discovery Channel’s Shark Week. Instead, a whale shark has no teeth, and is a gentle, slow-moving, filter-feeding carpet shark, feeding only on plankton (not on humans!!)

What does a whale shark look like?
Continue Reading...

Where I say goodbye to New Zealand, hello to Japan, and hello to Pocari Sweat

By Matt Button |  Oct 15, 2016  | japan, travel

I flew out of Wellington on 20th of July, 2016, in the middle of a bitter winter, for a two week adventure around Japan (Tokyo -> Takayama -> Kanazawa -> Hiroshima -> Kyoto), followed by four weeks in Thailand (Bangkok -> Chiang Mai -> Koh Phangan -> Koh Tao).

This was the longest trip I’ve been on as an adult, and was also my first time solo traveling outside of New Zealand.

I departed from Wellington, New Zealand, destined for Tokyo, Japan, on the plane you see below. In Wellington, it was on a freezing cold, dark, overcast winter day. In Tokyo, it was a hot summer day. There’s something awesome, and wonderful, about boarding a plane in winter, and 10 hours later, departing the same plane, to arrive in summer.

Goodbye Wellington
Continue Reading...

Traveling light on a six week trip around Japan and Thailand, in 2016

By Matt Button |  Oct 1, 2016  | japan, thailand, travel

Whenever I travel, I keep my luggage as light as possible, traveling with carry-on only; everything fits inside a 38 litre backpack, usually with room to spare, and this trip was no exception.

My entire set of luggage, for my 2016, six week trip around Japan and Thailand, weighed about 6kg (14lb). During my trip, I picked up a few more things, which pushed the total weight up to about 7kg, which was still within the carry-on weight allowance.

I travel light because I think it’s by far, the easiest, simplest way to travel; no checked-in luggage, means no lost luggage, no awkwardness with connecting flights (just grab my bag out of the overhad locker, and I’m ready to walk to the connecting flight), no need to wait for the baggage carousel, no dragging around multiple suitcases, easy to get on the bus or train.

Below is a photo all of my luggage, in the “capsule” room, where I slept in Asakusa, Tokyo.

Enaka Asakusa hostel capsule room - and all my stuff!
Continue Reading...

Creating comparison charts for stocks with FSharp Charting, Deedle and Yahoo Finance

By Matt |  Jun 29, 2014  | fsharp, deedle, yahoo-finance

When you want to visualize how a stock or portfolio has performed historically relative to the market as a whole, it is useful to create a comparison chart.

This blog shows how to create a line chart to compare two stocks with Deedle, FSharp Charting and F# Data.

In this example, the chart will show the perfomance of ANZ.AX relative to the ASX ALL ORDINARIES index (^AORD) over a three year period from 2011-1-1 to 2014-1-1.

Continue Reading...

A Basic Stock Trading Backtesting System for F# using Ta-Lib and FSharp.Data

By Matt |  Mar 8, 2014  | backtesting, fsharp, fsharp.data, ninjatrader, ta-lib, featured

This article is written for the intermediate F# audience who has a basic familiarity of stock trading and technical analysis, and is intended to show the basics of implementing a backtesting system in F#.

If you’re an F# beginner it may not take too long for you to get up to speed on the concepts if you check out a few resources. In particular:

The backtesting strategy which you will implement is a simple SMA crossover where the fast line is 10 bars and the slow one 25. When the fast line crosses above the slow line, a buy signal will be triggered, and when the fast line cross below the slow line, a sell signal will be triggered. Only one long position will exist at any time, so the system will not trigger another buy order until after the long position is sold.

Continue Reading...