Time to Stop Floating Around

PreCourse Week 1

Welcome to my blog about learning to code at Makers Academy. If you missed the last post, you can find it here. If you’re hungry for more, here’s the next.

If you’re curious to see what someone who’s just finished what I’m just starting is writing, go pay Dan Pelensky a visit.

I very nearly called this post ‘Octoplumbs’.


So it begins.

The lack of work-related intensity in my life for the past couple of years has made me super-eager to get on with this. It’s still 4-weeks till I actually have to show up for anything, but the work starts now.

The point of the pre-course is to get up to speed on the basic developer tools (command line and version-control) and to become confident with the basics of Ruby (see links to Codecademy courses if you’re interested in playing around).

Makers recommend we spend 20–30 hours per week pre-coursing. Currently I’m spending a dozen hours a week writing reports for $$$, but I’m so bored of the things I’ll put anything before them. Weirdly, the reports have turned out to be kind of useful in stimulating productive procrastination: I now code to avoid writing reports.

Leading up to this week, I skimmed through Zed Shaw’s ‘Learn Ruby the Hard Way’ to revise some core Ruby concepts. Skipped to the end to see what words of wisdom he had. It really articulated some of what‘s been floating around my head when I’ve been clumsily arguing that coding is creative, and reminded me that I’m doing something worthwhile:

Programming as an intellectual activity is the only art form that allows you to create interactive art. You can create projects that other people can play with, and you can talk to them indirectly. No other art form is quite this interactive. Movies flow to the audience in one direction. Paintings do not move. Code goes both ways.
Programming as a profession is only moderately interesting. It can be a good job, but you could make about the same money and be happier running a fast food joint. You’re much better off using code as your secret weapon in another profession.
People who can code in the world of technology companies are a dime a dozen and get no respect. People who can code in biology, medicine, government, sociology, physics, history, and mathematics are respected and can do amazing things to advance those disciplines.

Thanks Zed.

This week’s work

On Monday I received a link to a big file setting out all the work for the next 4-weeks, and introduced to a Slack group with the ~20 others on my cohort at Makers. Everyone seems super-friendly and keen to help out. There are many emojis.

First week is all about the developer tools.

Command line

Out of the blocks, I razzed through the Makers guide to the command line, amazed at how smoothly it went, only to realise 2 days later that I’d skipped half of it. I eventually completed the thing, learning a bunch of new commands and playing around with them.

Amongst other bits and bobs, I learnt how to navigate around my files and folders, copy, move and rename things, search for specific words within files, and edit permissions. Big shout-out to my new favourite command whoami, which tells you who you are. Keeps me grounded.

This week’s ‘Command Line Murder Mystery’ challenge really helped to consolidate what I’d learnt.

Git

Version-control is all about tracking changes in computer files, and coordinating work on files by multiple people.

Git is the choice software for tracking changes in code, and practically all self-respecting developers use it. Changes are made via the command line and are pushed-to/pulled-from GitHub, where everything is stored in an online profile. There, you can collaborate with other developers, manage version-control online, and browse other users’ code.

GitHub also serves as a developer’s resumé, and every tech employer will make it their first point-of-call when examining an applicant. From now onwards, Makers advise that I push every piece of code I write to my GitHub profile (here I am).

GitHub really take the cake for creepiest mascot with the terrifying ‘Octocat’. Some people think its cute. But those eyes. And the drip. Nah.

there’s a demon in him

After watching countless octopus videos, I then went through the pre-course guide to Git and things started to make sense. Before all this, the concept of Git totally baffled me, so it feels good to be making headway. Again, the ‘Murder Mystery’ challenge was a great way to practice what I’d learnt.

So far, pretty impressed with how smoothly Makers have coordinated everything and the quality of the learning resources.

My typing addiction

It’s getting worse. Here’s some fun facts:

  • The average person types at 40 wpm (words per minute) with an accuracy of 92%. Jobs in which typing is a key-skill require > 65 wpm.
  • “Key-pecking” limits you to ~25 wpm.
  • The fastest English language typist had a peak speed of 212 wpm.
  • Humans speak at 200 wpm, the average adult reading speed is 270 wpm, and the worlds fasted speaker speaks at a silly 637 wpm.

And here’s a tasty histogram of the typing-speeds of the kind of people who take typing-tests. As you can see, 212 wpm is ludicrous.

Is it a sign?

Give it a crack here. All in the little fingers.

Codewars

I’m gonna keep trying to break these down. It’s good for me.

Last week I was up against a 5-kyu which asked of me a programme that would find the (*deep breath*) prime-factorial-decomposition of any given number — meaning that my programme had to rewrite any number as a product of its prime factors.

For example:

  • 10 => (2)(5)
  • 56 =>(2³)(7)
  • 1 million => (2⁶)(5⁶)
  • 42,134,872,314 => (2)(3)(4931)(1,424,149)
Mum, listen:
Any text after a # is a comment, and should hopefully help you understand my thought process.
A ‘string’ is a finite sequence of characters. Strings are enclosed in speech marks.
An ‘array’ is an ordered collection of objects. Arrays are enclosed in square brackets.
A ‘hash’ is a a collection of key-value pairs. In Ruby, a hash looks like this: {‘UK’ => ‘London’, ‘Spain’ => ‘Madrid’, ‘Burkina Faso’ => ‘Ouagadougou’}
def primeFactors(n)
require 'prime'
primes = []
#get array of primes
(2..10000).to_a.each do |p|
if Prime.prime?(p)
primes << p
end
end
arr = []
#keep finding primes n is divisible by until n is itself a prime
#then, reassign n to the result we get after /. send divisor to arr
until Prime.prime?(n)
i = 0
until n % primes[i] == 0
i += 1
end

new = n / primes[i]
arr << primes[i]
n = new
end
arr << n
#now we have an array of the prime numbers whose product=original n 
#iterate over the array, counting duplicates

hash = Hash.new(0)
arr.each do |v|
hash[v] += 1
end
#put them into a string
str = ""
hash.each do |k, v|
if v > 1
str << "(#{k}**#{v})"
else
str << "(#{k})"
end
end
str
end

I found the solution by first creating an array of prime numbers, then iterating through the primes until n(the given number to be decomposed) could be divided by that number with no remainder. So, for any even number the first number returned would be 2, which was then added to an array to keep it for later (arr).

Next, I set n to the number left over by n/2 and repeated the process. Every time the new divisor was added to arr for later, and this was repeated until n itself was a prime number. Using the number 56 as an example, at this stage my programme would have returned [2, 2, 2, 7]. After I make the hash it’s all about converting that array into the string form (2**3)(7), which, in my code, is stored as str.

If this looks simple, don’t be fooled — it was bloody hard. It took me almost an hour, and what’s above is the result of a good wadge of refactoring (code speak for tidying-up). But those little green test-passed ticks were oh so sweet.

If this (or anything else here) looks completely indecipherable, pop me a message in the comments and I’ll try to explain it better. I really want people to be able to follow along with this, and it’s important I get more articulate in explaining my code.

Reading

I enjoyed this list of tips from Isaac Asimov about his views on inspiration and his attitude towards failure. Totally on-board with his point on producion being better than perfection.

Also been enjoying grappling with the code-y articles over at Hacker noon (despite not understanding half the stuff on there).


TODAY’S JAM

Today’s jam is a poem. It popped-up in the film Paterson, which you should watch, because it is superb.

This Is Just To Say by William Carlos Williams

I have eaten
the plums
that were in
the icebox

and which
you were probably
saving
for breakfast

Forgive me
they were delicious
so sweet
and so cold

If you read past the tapir, chances are you read the whole thing. If you enjoyed it, please click the little heart below. It’ll help others find this and enjoy it too.