atomicules

Push propelled program tinkerer and picture maker.

LINK: Save Photoghost

I have only used them once, but that is because I have had a difficult time with film over the past few years and so haven't shot much at all. Film isn't really commercially viable (And everyone knows that) but that sure as hell doesn't mean it should die.

10k

I tweeted it, but then I sprained my knee a bit and so went back to 5k and wanted to wait until I'd done it again before writing about it in case the first time was a fluke. So today I managed to do it again! Yay! I mean, I suppose I should have been able to do this anyway because of the fitness from cycling, but I'm still pretty happy about this: Up and down hills again, faster than last time (not fast) and my joints felt better about it afterwards. I have no intention of turning into a crazy person, I think 10k is as far as I want to go - Faster though might be fun.

I still don't really enjoy running (cycling, at the right time, could be a pure thrill), but I am happy I can do the mind over matter thing and keep going. Cycling though I didn't really have to concentrate on, but running I really do have to watch my feet so as to not knacker my ankles or knees. I still can't decide whether running more often or less often would be better for me.

On a related note: I have been bicycle "window shopping", but I think the price of a pair of trainers (first pair still look barely worn) will outweigh a completely unnecessary bicycle purchase; Even if I can afford one now I don't need one.

Things have been very busy of late. I have things I want to write about, just struggling to find the time.

Gurr - Moby Dick.


[EDIT: 2016-09-17] I pretty much posted and ran because things have been crazily busy recently, but I needed to come back and just state HOW GOOD THIS IS. I hope the rest of the album is like this. If it is then this will be this year's Wolf Alice for me; It isn't like Wolf Alice, just AS GOOD AS Wolf Alice; It's actually got quite a 90s indie feel to it, but NEW.

cabal-install notes for NetBSD

Just a quick little post so in another three years time I'll be able to figure out how to do this again a bit more quickly.

If you are trying to use cabal with headers and things on none standard paths (e.g. pkgsrc) then you need to do:

cabal install curl --extra-include-dirs=/usr/pkg/include/ --extra-lib-dirs=/usr/pkg/lib --configure-option=CPPFLAGS=-I/usr/pkg/include/ --configure-option=LDFLAGS=-L/usr/pkg/lib

The important bit being the --configure-option flags as the --extra ones are documented and thus a bit more obvious.

Note: After doing no exercise at all last week and struggling to run for even 20 mins in Gozo, went out and did 10K today in cool Scottish mist

Note: Watching all this Olympic track cycling has given me the first twinge of wanting to get on a back on the bike.

c25k

I tweeted about it, but I guess I should write something about it properly as last time we were at five weeks through, the half way point. In the end, the nine week programme took us eleven weeks as we had to repeat a couple of weeks due just to general life interfering with plans.

It really is a good plan though. It worked great from my point of view of someone who was very fit, but liable to break and injure easily running and it worked great from my wife's point of view of someone who last ran when they were at school. We did the time based version so I don't know for sure how far we are running (I could measure it on a map); Time based seems most fair with a discrepancy in leg length - I have to double back in bits as it is so I don't get too far ahead.

I have had some discomfort (probably the right word to use instead of pain), but all that cycling has given me the ability to just get on with it; Weirdly I never really had much leg pain whilst cycling, just lots of it off the bike.

Fifteen hours minimum a week of cycling was probably a bit excessive, but at the same time I don't think one and a half hours of running is really going to cut it as far as staying fit and healthy goes. Ok, it has been nice to have a break, but I'd like to get to three and a half hours of running a week. I'm not sure exactly how to work this in, though. I really like the idea of running every other day and I think it would be best for me to carry on like that; I've not got injured myself yet so why jinx things? Perhaps I could do a thirty minute run with my wife in the morning per current routine and then thirty minutes later the same day? If I make one of those an hour that's three and a half hours a week. That'll do. I don't want to be an athlete, but it would be a shame to lose everything I've gained from cycling.

Writing crap Elixir code from the point of view of someone who writes crap Erlang code

Woo, quite a long title, but I think that effectively explains what this is going to be about. There are already lots of good posts on Elixir from proper Erlang programmers. This isn't meant to be another one of them. It's just a collection of things I've noticed.

It is pretty much the same

Superficially there is no real difference (or benefit to be gained) between Erlang and Elixir code. Here's some Erlang code:

pad_to(Length, Binary_string) when length(Binary_string) < Length ->
    Padded_binary_string = "0"++Binary_string,
    pad_to(Length, Padded_binary_string);
pad_to(Length, Binary_string) when length(Binary_string) == Length ->
    Binary_string.

And the equivalent in Elixir:

def pad_to(length, binary_string) when length(binary_string) < length do
  padded_binary_string = '0'++binary_string
  pad_to(length, padded_binary_string)
end
def pad_to(length, binary_string) when length(binary_string) == length do
  binary_string
end

Apart from the wrapping of the code in def and end it looks pretty much the same.

You have to still use Erlang

Quite a bit. I was surprised how quick I came across the need to do this, but not all Erlang things have Elixir equivalents so you have to use Erlang code; However, at least this is seamless and painless.

Original Erlang:

Binary_string = hd(io_lib:format("~.2B", [Binary_number])),

Elixir port:

binary_string = hd(:io_lib.format("~.2B", [binary_number]))

defp is really neat

In Erlang you export only the functions you want:

-module(polyline).
-export([six_bit_chunks/1]).

six_bit_chunks(Encoded_polyline) ->
    six_bit_chunks_(Encoded_polyline, []).
six_bit_chunks_([Head | Rest], Chunks_list) ->
    Six_bit_chunk = six_bit_chunk(Head),
    %Add to Reversed_chunks
    six_bit_chunks_(Rest, [Six_bit_chunk]++Chunks_list);
six_bit_chunks_([], Chunks_list) ->
    lists:reverse(Chunks_list).

In Elixir everything that uses def is exported automatically. If you don't want something exported you use defp. This is really neat.

def six_bit_chunks(encoded_polyline) do
  six_bit_chunks_(encoded_polyline, [])
end
defp six_bit_chunks_([head | rest], chunks_list) do
  six_bit_chunk = six_bit_chunk(head)
  #Add to Reversed_chunks
  six_bit_chunks_(rest, [six_bit_chunk]++chunks_list)
end
defp six_bit_chunks_([], chunks_list) do
  Enum.reverse(chunks_list)
end

Indices are different

I don't know why, but indices are different. I don't think there is a clever reason. It just is.

In Erlang lists:sublist("words", 2, 3) returns "ord". And in Elixir Enum.slice('words', 2, 3) returns 'rds'; That is something else to be aware off the differences in single and double quotes; single quotes are charlists as per Erlang, whereas double quotes are for Elixir strings (something different).

Flipping order of args... and pipes.

In Elixir some functions have the order of the arguments flipped from how they are in Erlang. This threw me to start with and I thought it was to make Ruby programmers happy, but actually it's because of pipes.

In Erlang:

Eight_bit_chunks = lists:map(
    fun(Group_of_chunks) ->
        eight_bit_chunks(Group_of_chunks)
    end,
Five_bit_chunks).

In Elixir the list, etc is always first:

eight_bit_chunks = Enum.map(
  five_bit_chunks,
  fn(group_of_chunks) ->
    eight_bit_chunks(group_of_chunks)
  end)

This means you can then do things like this:

five_bit_chunks
|>  Enum.map(
      fn(group_of_chunks) ->
        eight_bit_chunks(group_of_chunks)
      end)

I.e. pull out and pipe five_bit_chunks into the Enum.map. Which doesn't look that impressive on its own but it means you can chain things together. Pipes are neat. My only quibble is that it is a step towards Haskell's esoteric symbols (I liked Erlang over Haskell just because it was a little easier to understand).

Phoenix

I am mid-way through porting my Erlang command line application to Elixir. My plan is to then use Phoenix to turn this into a web application so other people (ha!) can use it. I also have plans to improve it. Slow, long term plans. I mention this only to say that you can write Ruby without going near Rails and the same is true of Elixir and Phoenix; and both are something you should do.

Note: C25k done! We had to repeat the 'last' week due to missing a run.

Note: I have 12 rolls of film to use. Been so long since I've had that much to hand. It's all going in the Yashica Mat as well.

It Was Precisely Twelve O Clock

"It was precisely twelve o'clock; twelve by Big Ben; whose smoke was wafted over the northern part of London; blent with that of other clocks, mixed in a thin ethereal way with the clouds and wisps of smoke and died up there amongst the seagulls."

Mrs Dalloway by Virginia Woolf

If I'd been on the ball I'd have posted this at twelve o'clock. That's the last of them, anyway.

And The Leaves Being Connected

"And the leaves being connected by millions of fibres with his own body, there on the seat, fanned it up and down; when the branch stretched he, too, made that statement."

Mrs Dalloway by Virginia Woolf

Beautiful.

She Would Have Been Like Lady Bexborough

"She would have been, like Lady Bexborough, slow and stately; rather large; interested in politics like a man; with a country house; very dignified, very sincere."

Mrs Dalloway by Virginia Woolf

These are the ten most recent posts (not counting the note drivel), for older posts see the Archive.