Friday, September 29, 2017

Holyland USA

Picture taken at Brass Mill Center in Waterbury. 30 second exposure at f/22 ISO 400 from (cheap) tripod with remote release. Canon EOS 5D Mk III through an EF 24-105mm IS lens.

Holyland by Mark Becwar on 500px.com



The spikes around the lights in the image are called diffraction spikes, and are caused by the camera's aperture. Different shaped apertures create different patterns in the light. In this case the aperture is an 8 bladed construction, which causes the 8 radial spikes. (If you look at the flare in the top right corner you can see the shape of the aperture projected onto the image.)

Wednesday, September 27, 2017

A brief study in optimization (Part 1)

For this series we're going to look at writing, then optimizing an algorithm for generating triangle square numbers.

Wait, what is a triangle square number?

To understand what a triangle square number is, we first need to look at what a triangle number and square number are. Triangle numbers are numbers of the form 1 + 2 + 3 + ... + n. They have a neat property in that if you have a triangle number of things you can arrange them into an equilateral triangle. As in -



A square number is just a perfect square, like you learned about all those years ago in math class. A square number can be represented mathematically as n * n (or n2). Similar to the triangle number, if you have a square number of objects, you can arrange them into a square.


A triangle square number is a number that's both. Like 36, which is 6 * 6 so it's a square number, and 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 so it's also a triangle number.



Ok, so what does that mean to me?

Nothing. It's just a basic example we can use to look at algorithm design, and an iterative process for improving it. Also, stop being so judgemental, you're a figment of my imagination.

Point taken. Where do we start?

Next time we're going to start with the naive implementation, then work forward towards a better solution. Hopefully you learn something along the way.

* I stole the whole "arguing with an imaginary foil" thing from Ken over at Popehat. He's better at it than I am. No, I have no shame.

Tuesday, September 26, 2017

Be a coder! Not really.

Recently saw this on the Twitters:

She really should have hired a better programmer to write that crap. Here's a couple problems:
  • Variable names. What the hell is PM? Why are your variable names in all caps? Variable names should be descriptive.
  • Declaring PM is unnecessary. It serves no purpose.
  • CODING is declared using the 'let' keyword, which in JavaScript means that the variable is declared using block scoping. For you non-programmers out there, that means that as soon as execution leaves the curly braces, the variable CODING is undefined.
  • The code does literally nothing. There are no side-effects. Again for the non programmers: the computer is the same before running this as it is after running it, and it produces no effects visible to the user.
Here's code that actually, you know, does something:

if (getQueryVariable("PM") === "signed") {
    alert("Coding 4 All");
} 

It uses a function defined elsewhere, but there are actual side effects of running this code, namely a popup message box.

Why am I being pedantic?


Does she genuinely care about getting more people involved in the industry? No idea. Does the ham-fisted approach come across as genuine? Nope. Pandering to kids who are excited about programming does nothing to actually engage them. You just end up looking like the old guy with his hat sideways.

Friday, September 22, 2017

It's a blog! Kinda. Not really.

This is a blog. There are many like it, but this one is mine.

Realistically, this is just a placeholder site for the domain, so that when people go to it, they actually see something. There may be things from time-to-time that interest me, but no promises, and no apologies.

In the mean time, here are some links:

Programmer vs Software Engineer: The Interview

A common question presented in interviews for developer positions goes something like this: Given an array of numbers, write a function th...