Caius Theory

Now with even more cowbell…

Cheshire Triathlon 2014

Successfully completed my second Sprint Triathlon of the season in Nantwich.

500m Swim - 00:10:49

Felt good swimming this. Mixed up my usual breaststroke with some front crawl to overtake and use my legs less towards the end. Think I need to put a shorter time down on paper next time though, was in with people who were swimming much slower than me. (Including one chap who was doing doggy paddle in the deep end and walking as soon as his feet touched bottom. Oh well!) Need to continue with front crawl practice, and aim to do next sprint tri entirely crawl.

Transition 1 - 00:02:43

Went well. Ran from pool to bike and felt OK. Kit on without any fuckups. Didn't fall off getting on bike. Winning. Need to practice getting on my bike in shoes at a run though.

20km Bike - 00:42:31

10 minutes quicker than same length course last year. (Although a slightly new route this year.) Lost a minute when my water bottle fell out about 12km in though. Barely saw a soul, got stuck at one pedestrian crossing on red. Felt very good on the bike (and finally beat Liam on the same route & day ). Need to fit a tighter bottle carrier to stop the bottle falling out on bumpy roads.

Transition 2 - 00:01:21

Came off bike well and ran to shoes. Couldn't find where I'd left them, was trying to find Liam's bike as my marker for it, only someone else earlier in the same row had the same bike as him! Wasted 10 seconds looking probably. Need to remember where my stuff is more accurately in future.

5km Run - 00:39:03

Boiling hot by the point I started running; didn't feel great in the first few hundred meters and never really got comfortable after that. Walked about 800m of it in total at a guess, really didn't have much left in my legs. Not convinced pushing less on the bike would've helped my run though. On the plus side, only 7 minutes slower than a training run a couple of weeks ago in similar heat, and this was on grass. Need to continue running at 5km distance, and train on grass as well as tarmac I think.

Total time - 01:36:27

8 minutes slower than York a couple of months ago, and felt much worse on the run. Very happy with my bike & swim though. More run training required!

Compile & run swift files directly

Turns out you can run a swift file without having to compile it into a binary somewhere and then run that binary. Makes swift behave a bit more like a scripting language like ruby or python when you need it to.

Using the xcrun binary, we can reach into the current Xcode /bin folder and run binaries within there. So xcrun swift lets you run the swift binary to compile files for instance. If you view the help with -h, there's a useful flag -i listed there:

-i    Immediate mode

Turns out immediate mode means "compile & run" in the same command, which is what we're after.

$ cat hello.swift
println("Hello World")

$ xcrun swift -i hello.swift
Hello World

Bingo. But what if we want to make hello.swift executable and call it directly without having to know it needs the swift binary to call it. Unix lets files define their shebang to say how the file needs to be executed, so lets go for that here too!

$ cat hello2.swift
#!/usr/bin/env xcrun swift -i
println("Hello World 2")

$ chmod +x hello2.swift
$ ./hello2.swift
Hello World 2

No more having to fire up Xcode for quick CLI tools, especially ones using the system frameworks!