<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Matthew Jackson</title>
  <subtitle></subtitle>
  <link href="https://matthew-jackson.com/feed.xml" rel="self"/>
  <link href="http://matthew-jackson.com/"/>
  <updated>2024-07-10T00:00:00-00:00</updated>
  <id>https://matthew-jackson.com/</id>
  <author>
    <name>Matthew Jackson</name>
    <email>hello@matthew-jackson.com</email>
  </author>
  
  <entry>
    <title>This is a pathetic piece of shit</title>
    <link href="http://matthew-jackson.com/blog/a-pathetic-piece-of-shit/"/>
    <updated>2013-02-23T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/a-pathetic-piece-of-shit/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;Nothing like a deadline to focus the mind, eh? I&#39;m not trying to say &quot;I don&#39;t want my client work to be perfect. Please take all my clients&quot; but it is certainly easier to be pragmatic about things when you *need* to finish. &lt;/p&gt;
&lt;figure&gt;
  &lt;blockquote&gt;
    A blank piece of paper isn&#39;t at all frightening, when you have a deadline.
  &lt;/blockquote&gt;
  &lt;figcaption&gt;Dan Antopolski, Comedians Comedian Podcast, &lt;a href=&quot;http://soundcloud.com/stu-goldsmith/the-comedians-comedian-1/&quot;&gt;Episode 3&lt;/a&gt; &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;I heard the above during an episode of the excellent &lt;a href=&quot;http://www.comedianscomedian.com/&quot;&gt; Comedian&#39;s Comedian podcast&lt;/a&gt;[^1] during which, Dan Antopolski was discussing his writing process and said a couple of things which nailed how I&#39;ve been feeling of late.&lt;/p&gt;
&lt;p&gt;When I was young, I used to draw. A lot. I was alright at it. I won a Blue Peter badge (sort of)[^2]. I wanted each picture to be its own work of art, like I saw in my head. No practice. No iteration. Just straight into the final piece every time. I &lt;em&gt;had&lt;/em&gt; to have a crisp sheet of bright, white paper. I would &lt;em&gt;need&lt;/em&gt; a pointy sharp pencil and a sharp, black, felt-tipped pen.  Like, a &lt;a href=&quot;http://www.amazon.co.uk/Berol-Colour-Fibre-Tipped-wallet/dp/B000NJXUBO&quot;&gt;Berol fine&lt;/a&gt;. Box fresh, without a fuzzy tip (that&#39;s how I roll kids).&lt;/p&gt;
&lt;p&gt;When I made mistakes, the sheet was sacrificed. I hated the scratchy, corrective smudges of the rubber or the ghosts on the reverse if I (horror of horrors) used the back. I&#39;m sorry rain-forests.&lt;/p&gt;
&lt;p&gt;I&#39;ve wanted to have a blog for some time. It almost comes with the job description. But I don&#39;t like designing for myself. I&#39;m an awful client. I put it off for client work. I start. I get a new idea (almost as soon as I&#39;ve started). I get bored. I redesign. I move things around the page. I decorate. I throw it out. I get a new sheet...&lt;/p&gt;
&lt;p&gt;The fear of putting something terrible (or worse mediocre) on-line, something meant to represent me as a designer, developer and human, is crippling. The thing is, at some point you have to ship. You need to get on with it. If it never gets out of the door, it won&#39;t &lt;em&gt;even&lt;/em&gt; be shit. It&#39;ll be &amp;lt; shit.&lt;/p&gt;
&lt;p&gt;Mr Antopolski talks about a similar issue in the interview above and tells a story about &lt;q&gt;the mother of his children&lt;/q&gt;, who, whilst working in theatre was given a maxim by her director:&lt;/p&gt;
&lt;figure&gt;
  &lt;blockquote&gt;
    Let it be the pathetic piece of shit it was always meant to be.
  &lt;/blockquote&gt;
  &lt;figcaption&gt;Dan Antopolski&#39;s children&#39;s mother&#39;s director, via Comedians Comedian Podcast, &lt;a href=&quot;http://soundcloud.com/stu-goldsmith/the-comedians-comedian-1/&quot;&gt;Episode 3&lt;/a&gt; &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Thats it. My new mantra. Let go. Let it be awful, or mediocre, or fantastic. And iterate. And evolve. And improve.&lt;/p&gt;
&lt;p&gt;So now my blog exists. It is rough. There&#39;s no navigation, no link colours, one grid layout for all sizes. It is not finished. But its shipped [^3]. It will change (probably). It will get better (maybe). If it doesn&#39;t, so what? Its just some shit I made.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&quot;heading heading--sub&quot;&gt;Footnotes&lt;/h3&gt;
&lt;p&gt;[^1]: Which is amazing, by the way. Especially if you like geeking out on comedy. Even if you don&#39;t its great to hear people in a completely different field talk about there creative/collaborative processes.&lt;/p&gt;
&lt;p&gt;[^2]: I came 48th or 76th in my age group for a competition to design a character for energy saving light bulbs (It was a glow worm. See what I did there?). I won a &amp;quot;competition Winner&#39;s badge, which got me into Bristol Zoo for free.&lt;/p&gt;
&lt;p&gt;[^3]: Full disclosure I redesigned this halfway through setting the blog up&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>A tale of two porridges</title>
    <link href="http://matthew-jackson.com/blog/i-eat-ux-for-breakfast/"/>
    <updated>2013-04-03T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/i-eat-ux-for-breakfast/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;You know what really winds me up? Everything. I regularly veer from rage, rants and righteous indignation to abjectness, gloom and melancholia. &lt;/p&gt;
&lt;p&gt;Sometimes over important things (government omnishambles, the forthcoming apocalypse, the royal family[^1]) Sometimes over fucking ridiculous things like my toaster (either cook the bread or don&#39;t, you bastard!), vapid link-bate on Facebook (Can you name a [insert noun] without a [insert letter] in it?), something called a &amp;quot;One Direction&amp;quot; and most recently an advert trying to spark a debate on how the nation wipes its arse:&lt;/p&gt;
&lt;figure&gt;
	&lt;div class=&quot;video aspect aspect--16-9&quot;&gt;
		&lt;iframe width=&quot;&quot; height=&quot;&quot; src=&quot;https://www.youtube.com/embed/9dBYzgW7xjk&quot; frameborder=&quot;0&quot;&gt;&amp;nbsp;&lt;/iframe&gt;
	&lt;/div&gt;
&lt;/figure&gt; 
&lt;p&gt;I&#39;ve been working pretty hard at on not being grumpy about things all the time. Mainly, I don&#39;t want my daughter to have to deal with a grumpy dad, however its also quite tiring being annoyed all the time. But the world makes it bloody difficult sometimes. I usually manage to avoid getting wound up before I leave the house (a consequence of not listening to &lt;a href=&quot;http://www.bbc.co.uk/programmes/b006qj9z/episodes/player&quot;&gt;The Today Programme&lt;/a&gt; anymore). Then t&#39;other day, my other half bought some posh porridge...&lt;/p&gt;
&lt;p&gt;Once upon a time there were two porridge manufacturers. Both decided to put each serving of porridge in its own sachet to make it easier to make in the morning. One manufacturer (lets call them Quakers), put nice clear pictures on the back showing you how long to nuke it for and (&lt;em&gt;and&lt;/em&gt;), you can use the sachet to measure the milk. (G E N I U S). Their porridge was loved throughout the land, for the dwellers of Earlymornington were a simple people, with no use for fancy ideals like thinking or reading.&lt;/p&gt;
&lt;p&gt;The second manufacturer (we&#39;ll call them Dorset Cereals), decided that people should probably not be given that sort of assistance. They decided they would write their instructions in 8pt monospaced type (white on light blue since you ask). The people of Earlymornington, were forced turned back to the cupboard to retrieve the box to find out how to assemble their breakfast. And they were sad and embarrassed by their simpleness...&lt;/p&gt;
&lt;p&gt;Finally, as if to rub salt into my bleary eyes, you &lt;em&gt;could&lt;/em&gt; still use the packet to measure the milk. It just wasn&#39;t made obvious so I wasted my time going back to the cupboard &lt;em&gt;FOR NOTHING&lt;/em&gt;, people! Aaaaaaagggghhhh...[^2]&lt;/p&gt;
&lt;figure&gt;
&lt;blockquote&gt;
If we could change ourselves, the tendencies in the world would also change. 
&lt;/blockquote&gt;
&lt;figcaption&gt;
	Mahatma Gandhi, &lt;a href=&quot;http://www.nytimes.com/2011/08/30/opinion/falser-words-were-never-spoken.html&quot;&gt;Source&lt;/a&gt;
&lt;/figcaption&gt;
&lt;/figure&gt; 
&lt;p&gt;I think the reason I love my job so much (and the reason that I don&#39;t think I will ever tire of it), is that everyday I am given the opportunity to not let stupid details like this annoy other people. I might not be able to change the government (irony &lt;em&gt;and&lt;/em&gt; satire) and I won&#39;t be able to stop ecological Armageddon (I buy cereal in individual packets FFS) but I can (hopefully) make buying a T-Shirt or booking a holiday a smooth (maybe fun) experience.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&quot;heading heading--sub&quot;&gt;Footnotes&lt;/h3&gt;
&lt;p&gt;[^1]: Seriously, why the fuck are we paying for these people?&lt;/p&gt;
&lt;p&gt;[^2]: Actually, reading this back it sounds as though I&#39;m being pretty stupid&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Notes on customer service</title>
    <link href="http://matthew-jackson.com/blog/customer-service-for-designers/"/>
    <updated>2013-07-03T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/customer-service-for-designers/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;The following are some rules I&#39;ve learned during several years of customer service jobs in my previous life as a senior complaint handler for a large financial institution. I have written them down as a note-to-self as I could do with being reminded sometimes. Thought maybe others might find them useful too:&lt;/p&gt;
&lt;h2&gt;Everyone is a customer&lt;/h2&gt;
&lt;p&gt;The back-end dev who works in your studio? She&#39;s a customer. The junior designer who shadows you? He&#39;s a customer. Your boss? Customer. Printers? Customer. They are all relying on you to provide something. Even if they are not direct customers. All the following rules apply to all of them.&lt;/p&gt;
&lt;h2&gt;Be nice&lt;/h2&gt;
&lt;p&gt;Its not hard. Introduce yourself if you&#39;ve not met, shake hands, make small talk about the weather, ask how you can help. Be attentive when they talk and excited, passionate, polite and helpful when you talk.&lt;/p&gt;
&lt;h2&gt;Your shitty day does not matter&lt;/h2&gt;
&lt;p&gt;If you can&#39;t handle putting on a front and being nice as pie like you&#39;re having the best day of your fucking life, don&#39;t go to work. Whatever happens, follow rule number 2.&lt;/p&gt;
&lt;h2&gt;Talk&lt;/h2&gt;
&lt;p&gt;Talk all the time. Regular update emails. Daily/weekly calls. Face to face meetings. Keep the communication up. Show sketches.  Show the progress of the work. Show good ideas. Show bad ideas. Silence is the enemy.&lt;/p&gt;
&lt;h2&gt;Listen&lt;/h2&gt;
&lt;p&gt;When they&#39;re telling you stuff, make sure you listen hard. Make notes, clarify points and ask questions at the end if you still don&#39;t get something.&lt;/p&gt;
&lt;h2&gt;Manage expectations&lt;/h2&gt;
&lt;p&gt;Customers &lt;em&gt;can&lt;/em&gt; like surprises, but only good ones. Commit to stuff you will definitely do. Tell them what you won&#39;t do, if appropriate. Try and explain when you&#39;ll do all the stuff and keep them in the loop if the timescales or things change.&lt;/p&gt;
&lt;p&gt;If you commit to doing something, verbally or in writing, do it.  No ifs. No buts. If the reason you can&#39;t do it is outside of your control, tell them soon and suggest an alternative. If its a temporary hiatus on doing the thing, explain when you expect to be able to do the thing and feed back to them.&lt;/p&gt;
&lt;p&gt;Oh if you have to deliver bad news, it&#39;ll suck, but most people can take it and take it pretty well. Just be helpful and bring some potential solutions to the wake if you can.&lt;/p&gt;
&lt;h2&gt;Embrace complaints&lt;/h2&gt;
&lt;p&gt;Fuck ups and customer complaints are both the best feedback you&#39;ll ever get and the best opportunity to make a customer love you. If you fuck up, don&#39;t try and cover it. Admit and fix it. Don&#39;t believe me. I got &lt;a href=&quot;http://jmi.fsu.edu/Services/Resources/Jerry-s-Articles/Selling-Your-Product-or-Service/Customer-Service-Data&quot;&gt;statistics&lt;/a&gt;, fool. Further listening on this subject &lt;a href=&quot;http://www.amazon.co.uk/Rastamouse-Album-Makin-Ting-Good/dp/B0052T7J12&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Don&#39;t be a dick&lt;/h2&gt;
&lt;p&gt;Scenario A: If you turn a project around under time (it happens), you will be tempted to pocket the change and take a few days off in your pants. Don&#39;t. Instead, why not say “Hey. We&#39;re already done. You can have more internets for your moneys! Or maybe we&#39;ll renegotiate the moneys”. That customer will come back.&lt;/p&gt;
&lt;p&gt;Scenario B: If you can&#39;t do what they need; tell them. People prefer honesty. Tell them what you can do and how you&#39;ll help them. If its not right for them, try and point them in the direction of someone who can help. They&#39;ll appreciate it.&lt;/p&gt;
&lt;h2&gt;Let them shout&lt;/h2&gt;
&lt;p&gt;If a customer ever feels the need to shout at you, Let them. Whether they are in the right or completely out of order. Let them know your listening (nod or make “uhuh” noises). Make mental or actual notes. Then when they&#39;re done you have two options:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Say sorry. Discuss how you will put it right.
2. Don&#39;t say sorry. Discuss how you will help put it right. 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Might be your fault, might not. Fix it. Be a hero. (See Don&#39;t be a dick)&lt;/p&gt;
&lt;h2&gt;Be appropriate&lt;/h2&gt;
&lt;p&gt;An attractive member of your preferred sex approaching you demurely in a night club (should) precipitate a very different tone and body language from you than a police constable walking up to the side of your car, which he has just pulled over.&lt;/p&gt;
&lt;p&gt;Likewise, when you meet a customer, you can pretty much tell if you need to use your &lt;a href=&quot;http://www.overthinkingit.com/wp-content/uploads/2009/01/seriousface.jpg&quot;&gt;serious-face&lt;/a&gt; or not. You are a grown up.&lt;/p&gt;
&lt;p&gt;Whilst your voice should always be professional, the tone of your voice, the language you use can (and should) be altered for the customer in front of you. They aren&#39;t always in front of you though.&lt;/p&gt;
&lt;p&gt;Sometimes, answering the phone or sending an email starting “&#39;Sup”, will be totally fine. Other times, it will be wholly inappropriate. You may only deal with “cool” bro-grammer start-ups, but if your shit is hitting their fan, answering the phone like that will lead to them tearing you a new one.&lt;/p&gt;
&lt;p&gt;My advice, have a standard greeting, for any communication where you can&#39;t see their face. It should say hello, tell them who you are and ask what they want, nicely.&lt;/p&gt;
&lt;h2&gt;Its ok not to know something&lt;/h2&gt;
&lt;p&gt;If someone asks you something in a call or a meeting and you do not have a fucking clue what they&#39;re talking about, you may feel an overwhelming desire to make something up. Stop. Don&#39;t panic.&lt;/p&gt;
&lt;p&gt;Customers are humans and they know you are a human. They will understand, and in some cases be reassured, if you take a breath and say: “I&#39;m sorry I don&#39;t know the answer to that, I will get back to you on that later today” and move on. (See manage expectations)&lt;/p&gt;
&lt;h2&gt;Empathy&lt;/h2&gt;
&lt;p&gt;A company I used to work for had a corporate initiative which was &amp;quot;Walk a mile in the customer&#39;s shoes&amp;quot;. I wouldn&#39;t necessarily have put it as wanky as that, but the sentiment is good. Just have some consideration for their perspective.
This extends to not bitching on twitter when they want the logo bigger or the background green, or when they want to use the design their nephew made in Powerpoint. Empathise. Understand. Explain why their idea is balls and why your idea is &lt;em&gt;the&lt;/em&gt; balls.&lt;/p&gt;
&lt;h2&gt;Know when the customer is wrong&lt;/h2&gt;
&lt;p&gt;It definitely happens. If you know you&#39;re in the right about something tangible (eg. not a preference on colour based on a design hunch), you are allowed to be firm and stand your ground.&lt;/p&gt;
&lt;h2&gt;Letting go&lt;/h2&gt;
&lt;p&gt;Sometimes you will lose &amp;quot;battles&amp;quot; with the customer. Sometimes your idea will be the wrong one for their business or brand. Sometimes their idea will be better. Sometimes their idea will suck so hard… Ultimately, it is their call and they are paying you to fulfil &lt;em&gt;their&lt;/em&gt; brief. &lt;a href=&quot;http://www.youtube.com/watch?v=aPVLyB0Yc6I&quot;&gt;Sometimes you eat the bar sometimes the bar eats you&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Smile&lt;/h2&gt;
&lt;p&gt;The customer will smile with you. It will come across in correspondence, communication and your work. Smile when you answer the phone. Smile when you write the email. Smile at the meeting. Smile during daily stand ups. Smile while you&#39;re making stuff. Smile when you deliver the stuff. Smile writing the invoice. Smile writing the chasing letter. Smile when you get paid.&lt;/p&gt;
&lt;p&gt;Jesus. You get paid to do your fucking hobby.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Setting up Grunt from scratch</title>
    <link href="http://matthew-jackson.com/blog/setting-up-grunt-from-scratch/"/>
    <updated>2013-09-08T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/setting-up-grunt-from-scratch/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;Being a modern web designer involves a lot of tools. &lt;a href=&quot;http://gruntjs.com/&quot;&gt;Grunt&lt;/a&gt; is currently my new hotness. Its a tool I use to manage a bunch of other tools I use. In fact its consolidated about 5 different tools I had into one click (well command but more on that later).&lt;/p&gt; 
&lt;p class=&quot;drop-cap&quot;&gt;In this post I&#39;ll walk through getting set up with Grunt and in the next post, we&#39;ll set up Grunt to handle Sass with Compass, Jekyll, JS concatenation and minification, Live reloading changes to any of the HTML/CSS/JS and finally multi-device browsing and browser refresh. Boom.&lt;/p&gt;
&lt;h2&gt;Rule 1: Don&#39;t fear the Terminal&lt;/h2&gt;
&lt;p&gt;We&#39;re gonna get in the command line in a minute. I promise it isn&#39;t gonna get weird. I used to hate it too. Then I got to love it. Then I started using it for loads of stuff. Then I hated it, because all the tabs or windows I needed open drove me nuts. What&#39;s so beautiful about Grunt, is you can run loads of commands in one line. Stick with me on this, its awesome[^1].&lt;/p&gt;
&lt;p&gt;Just follow along with what I&#39;m doing by copying everything out of the code example &lt;em&gt;after&lt;/em&gt; the &lt;code&gt;$&lt;/code&gt; sign (that&#39;s just t omake it look more like OSX terminal and makes me feel cool). The commands examples are the same for Mac and Windows and if they aren&#39;t I&#39;ll write them both out cos I got your back.&lt;/p&gt;
&lt;p&gt;Windows note: You can&#39;t ctrl+v to paste in CMD in windows. You can right-click and paste though.&lt;/p&gt;
&lt;h2&gt;Install all the things&lt;/h2&gt;
&lt;p&gt;Ok So first we gonna need to get our Node on. This is a cinch. Go to the &lt;a href=&quot;http://nodejs.org/&quot;&gt;Node JS Website&lt;/a&gt;. Click install. Job done. You are one of the cool kids.&lt;/p&gt;
&lt;p&gt;When you install node, you also get &lt;a href=&quot;https://npmjs.org/&quot;&gt;NPM&lt;/a&gt;. NPM is a big library of Node modules (kinda like apps or plugins built with and for Node). Its also how we&#39;re gonna install Grunt. Its Terminal time.&lt;/p&gt;
&lt;p&gt;Open up the Terminal (Mac) or Cmd (Windows) and type in:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; -g grunt-cli&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Lets break that down:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&amp;quot;npm&amp;quot; tells terminal/cmd what program we&#39;re commanding&lt;/li&gt;
&lt;li&gt;&amp;quot;install&amp;quot; is the command&lt;/li&gt;
&lt;li&gt;&amp;quot;-g&amp;quot; is an argument (a kind of optional bit of info) for the command short way of saying &amp;quot;--global&amp;quot; This means we&#39;re installing Grunt globally on our system. This is a good thing. You want to be able to use it everywhere.&lt;/li&gt;
&lt;li&gt;&amp;quot;grunt-cli&amp;quot; Is another argument. This time telling NPM what you want to install. In this instance the Grunt Command Line Interface.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So basically you told your computer:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ Yo, Computer 
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ Get NPM to &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; Grunt globally, is it? 
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ I&#39;ll put the kettle on.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hit enter.&lt;/p&gt;
&lt;p&gt;The terminal or the cmd window is gonna go a bit Matrix for a bit. It&#39;s basically telling you what its doing. It can look a bit scary, but should all be fine.&lt;/p&gt;
&lt;p&gt;When I installed something from NPM for the first time on a mac, I got an EACCESS Error (which scared me). Didn&#39;t happen on Windows though.&lt;/p&gt;
&lt;p&gt;A lot of solutions online tell you to just install the package again like this, using SUDO.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; -g grunt-cli&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ummm. Don&#39;t do that. Although I trust Bocoup and the community around the grunt-cli, this is a bad habit to get into. The sudo command is basically the airport security for your mac waiving someone through an airport security check. Sometimes thats good. Sometimes we want people to be checked.&lt;/p&gt;
&lt;p&gt;The method I used is to type this in the terminal once:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;chown&lt;/span&gt; -R &lt;span class=&quot;token environment constant&quot;&gt;$USER&lt;/span&gt; /usr/local&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I got this code from &lt;a href=&quot;http://aralbalkan.com/scribbles/npm-install-g-please-try-running-this-command-again-as-root-administrator/&quot;&gt;Aral Balkan&lt;/a&gt; and he also points to this &lt;a href=&quot;http://foohack.com/2010/08/intro-to-npm/#what_no_sudo&quot;&gt;What, no sudo? article&lt;/a&gt; furthering the point above.&lt;/p&gt;
&lt;h2&gt;Getting ready to Grunt&lt;/h2&gt;
&lt;p&gt;First we&#39;re going to get the terminal/command prompt to the right folder. To do this we use the change directory command or &lt;code&gt;cd&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; path/to/my/project-folder&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and hit enter. The terminal should show you what folder you&#39;re now in. This means any commands you run now will be specific to that folder.&lt;/p&gt;
&lt;p&gt;Mac note: on a mac, you can do this&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/path/to/project&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;~&lt;/code&gt; puts you in your home directory.&lt;/p&gt;
&lt;p&gt;Windows note: on windows, I do this&lt;/p&gt;
&lt;pre class=&quot;language-powershell&quot;&gt;&lt;code class=&quot;language-powershell&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&gt;_ cd c:\path\to\project&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Setting up a Grunt on a new or existing project is easy. You just need to add 2 files to the folder where everything lives: Gruntfile.js and package.json. These files are pretty central to how Grunt works. The package.json file tells node all the things you need to include in your project and also some general information, which might be useful if your project is on github or something. Here&#39;s an example fo the package.json file for this site, with some dependecies removed so its not really long:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// package.json&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Matthew-Jackson.com&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;1.1.0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Personal Site&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;main&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;_site/index.html&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;repository&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://github.com/matthewbeta/matthewbeta.github.io&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@matthewbeta&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;devDependencies&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;// dependencies here... &lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can make a package.json file in the command line or you can copy the example into a new file, save it as package.json nd edit the bits you need.&lt;/p&gt;
&lt;p&gt;To create it in the command line hop over to the terminal. You should be in the right folder if you followed along earlier:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; init&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The command prompt will walk you through setting up the file automatically§ in this format:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;Question&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;NPM Suggested answer&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It&#39;ll look something like this:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;Press ^C at any &lt;span class=&quot;token function&quot;&gt;time&lt;/span&gt; to quit.
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;name: &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;awesome&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; 
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;version: &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0.0&lt;/span&gt;.0&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; 
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;description: Demo
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;entry point: &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Gruntfile.js&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; 
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;test&lt;/span&gt; command: /
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; repository: /
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;keywords: /
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;author: @matthewbeta
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;license: &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;BSD&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; /
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Question&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;NPM Suggested answer&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can either type in an answer, or if NPM guessed right in the suggestion, you can just hit enter.&lt;/p&gt;
&lt;p&gt;Next create a new file in your project and name it Gruntfile.js. Copy and paste in the following code (we&#39;ll go over it in the next post):&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;grunt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// Project configuration.&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;initConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    pkg&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;file&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;readJSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;package.json&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;   &lt;span class=&quot;token comment&quot;&gt;// Tasks&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// Load the plugin that provides the &quot;uglify&quot; task.&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadNpmTasks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// Default task(s).&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;registerTask&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;default&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;
&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Recap&lt;/h2&gt;
&lt;p&gt;Ok. That was more epic than I intended but the initial set up is the hardest/least fun bit. We installed Node.js and NPM. Got used to using the command line, installed Grunt globally and set up our project to use Grunt. You should feel like a fucking boss. Good job. Next time all the cool stuff.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&quot;heading heading--sub&quot;&gt;Further reading&lt;/h3&gt;
- [Introduction to NPM - How To Node](http://howtonode.org/introduction-to-npm)
- [Getting started guide - Grunt JS](http://gruntjs.com/getting-started)
&lt;h3 class=&quot;heading heading--sub&quot;&gt;Footnotes&lt;/h3&gt;
&lt;p&gt;[^1]: Check out this &lt;a href=&quot;http://wiseheartdesign.com/articles/2010/11/12/the-designers-guide-to-the-osx-command-prompt/&quot;&gt;guide to terminal for Mac&lt;/a&gt; or this &lt;a href=&quot;http://www.makeuseof.com/tag/a-beginners-guide-to-the-windows-command-line/&quot;&gt;Guide to command prompt for Windows&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Installing Sass and Compass on Mac or Windows</title>
    <link href="http://matthew-jackson.com/blog/installing-sass-and-compass-mac-windows/"/>
    <updated>2013-09-14T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/installing-sass-and-compass-mac-windows/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;Quick post. I&#39;m going to assume you&#39;ve heard of Sass and Compass before and I&#39;m not going to cover any of that. If you haven&#39;t heard about them or their preprocessor cousins I hope you get good broadband under your rock cos you need to do some serious google catch up. &lt;/p&gt;
&lt;p class=&quot;drop-cap&quot;&gt;If you want to Sass and Compass without a tool like &lt;a href=&quot;http://incident57.com/codekit/&quot;&gt;Codekit&lt;/a&gt; or &lt;a href=&quot;http://alphapixels.com/prepros&quot;&gt;Prepros&lt;/a&gt; (I did to use Grunt) then you might have to go and install Sass and Compass manually. Don&#39;t worry. Its super easy.&lt;/p&gt;
&lt;h2&gt;Don&#39;t fear the command line&lt;/h2&gt;
&lt;p&gt;First thing&#39;s first, we need to do this via the command line (CMD in Windows, Terminal on Mac). I used to fear not having a GUI. Then someone pointed out to me &amp;quot;The Command Line &lt;em&gt;is&lt;/em&gt; the GUI&amp;quot;. Once you get used to it and get over the inital fear of wiping out your hard drive or sending your browsing history to the NSA (lolz) its really awesome. I recommend reading these posts if you wanna bit of a primer or a walk through some basics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://wiseheartdesign.com/articles/2010/11/12/the-designers-guide-to-the-osx-command-prompt/&quot;&gt;guide to terminal for Mac&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.makeuseof.com/tag/a-beginners-guide-to-the-windows-command-line/&quot;&gt;Guide to command prompt for Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://matthew-jackson.com/notes/development/setting-up-grunt-from-scratch/&quot;&gt;Installing Grunt from scratch (by me)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Installing Compass&lt;/h2&gt;
&lt;p&gt;OK so if you want Compass you need Sass, and if you need Sass you need Ruby. If you&#39;re on a Mac, you already have it[^1]. If you&#39;re on Windows - too bad... Just kidding. Installing Ruby on a Windows is easy. Go get &lt;a href=&quot;http://railsinstaller.org/&quot;&gt;rails Installer&lt;/a&gt; and download the appropriate package for your OS. install it (it installs a bunch of useful stuff, including Ruby, Ruby-on-Rails and Git). Go do that and I&#39;ll wait here...&lt;/p&gt;
&lt;p&gt;Done? Cool. So now we want to make sure &lt;a href=&quot;http://rubygems.org/&quot;&gt;Ruby Gems&lt;/a&gt; is up to date. Ruby Gems is like &lt;a href=&quot;http://npmjs.org/&quot;&gt;NPM&lt;/a&gt; but for Ruby (maybe NPM is like Gems for Node, I dunno). If you don&#39;t know what I&#39;m talking about, go read the &lt;a href=&quot;http://matthew-jackson.com/notes/2013-09-08-setting-up-grunt-from-scratch/&quot;&gt;previous article&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So jump over to your command line&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ gem update --system&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That&#39;ll get everything up to date before we install Compass. Now enter&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ gem &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; compass&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Done. Thats Sass and Compass (and Ruby) installed and this is only the 5th(ish) paragraph.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Grunt workflow for compiling Sass &amp; Compass and minifying Javascript</title>
    <link href="http://matthew-jackson.com/blog/grunt-workflow-for-sass-compass-and-js/"/>
    <updated>2013-09-17T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/grunt-workflow-for-sass-compass-and-js/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;Previously, we installed Node, NPM and Grunt including setting up a package.json and a Gruntfile. In this exciting installment, we&#39;re gonna plug everything in so you can see how amazers Grunt is, experience its awesome power and bathe in a warm glow of lazy satisfaction.&lt;/p&gt;
&lt;p class=&quot;drop-cap&quot;&gt;If you haven&#39;t installed &lt;a href=&quot;http://matthew-jackson.com/notes/development/setting-up-grunt-from-scratch/&quot;&gt;Node, NPM and Grunt&lt;/a&gt;, you need to. So jump over to that post and install all the stuff (its really not hard or too scary) and then come back.&lt;/p&gt;
&lt;p&gt;Here&#39;s what we want Grunt to do for us:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Watch our project for changes to HTML, JS and Sass&lt;/li&gt;
&lt;li&gt;Compile our Sass and Compass&lt;/li&gt;
&lt;li&gt;Minify and concatenate our JS&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Lets crack on.&lt;/p&gt;
&lt;h2&gt;What is Grunt again?&lt;/h2&gt;
&lt;p&gt;Grunt is a javascript task runner, in that it is written in Javascript (using Node JS) and it runs tasks. Grunt uses 2 files - a package.json (which tells grunt what all the dependencies it needs are) and a Gruntfile. If you followed the previous article, you might have both of these in your project folder. If not go download or fork the &lt;a href=&quot;http://matthew-jackson.com/blog/grunt-workflow-for-sass-compass-and-js/&quot;&gt;Github repo&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Package JSON File&lt;/h2&gt;
&lt;p&gt;The package.json file is an NPM thing. My understandign (or lack of) is that it stores metadata for all your Node dependencies in your project. Here&#39;s a &lt;a href=&quot;http://docs.nodejitsu.com/articles/getting-started/npm/what-is-the-file-package-json&quot;&gt;nice overview of package.json&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Installing a Grunt plugin&lt;/h2&gt;
&lt;p&gt;Grunt makes use of plugins to do all its automating and task running. We need several plugins to achieve our 5 goals set at the top of the post. We need one to watch for changes, one to run compass, one to concat/minify our JS and one to do the live reload multi device thingy.&lt;/p&gt;
&lt;p&gt;Jump over to your command line. First we need to browse to our project in the command line:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; path/to/my/project/folder&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So, if you input &amp;quot;cd&amp;quot; followed by the path to your project, you can now install the first plugin; grunt-contrib-watch&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; grunt-contrib-watch --save-dev&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The command line will throw some robot-barf at you now but keep your cool. When thats done, go check your package.json file. It should have updated the dependenciy section to include grunt-contrib-watch:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt; &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token string&quot;&gt;&quot;devDependencies&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;grunt&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;~0.4.1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;grunt-contrib-watch&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;~0.5.0&quot;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now go back to the command line and repeat this process (ie. one by one) with the following plugins:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; grunt-contrib-compass --save-dev&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; grunt-contrib-uglify --save-dev&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So with a bit of luck, you now have all the plugins you need for your project. Your package.json should list all these in devDependencies (maybe a few more too).&lt;/p&gt;
&lt;h2&gt;Gruntfile&lt;/h2&gt;
&lt;p&gt;A grunt file looks a bit like this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;grunt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// Project configuration.&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;initConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    pkg&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;file&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;readJSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;package.json&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;   &lt;span class=&quot;token comment&quot;&gt;// CONFIG ===================================/&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// DEPENDENT PLUGINS =========================/&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadNpmTasks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// TASKS =====================================/&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;registerTask&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;default&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The Gruntfile is split into 3 main sections:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Dependencies&lt;/li&gt;
&lt;li&gt;Tasks&lt;/li&gt;
&lt;li&gt;Task configuration&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You set up the configuration and options in the first section of your Gruntfile, you then reference the plugin in the second section, then tell Grunt to run the plugin, as per the configuration. This is done by either typing &amp;quot;grunt&amp;quot; into the command line, or &amp;quot;grunt task-name&amp;quot; to run a specific or subset task.&lt;/p&gt;
&lt;p&gt;Lets first list our dependencies to include. Find the line &lt;code&gt;grunt.loadNpmTasks();&lt;/code&gt; and copy and paste it 3 times. It should now be this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token comment&quot;&gt;// DEPENDENT PLUGINS =========================/&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadNpmTasks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadNpmTasks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadNpmTasks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add the name of a plugin, wrapped in quotes, between each set of brackets so it looks like this:&lt;/p&gt;
 &lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token comment&quot;&gt;// DEPENDENT PLUGINS =========================/&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadNpmTasks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;grunt-contrib-watch&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadNpmTasks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;grunt-contrib-compass&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;loadNpmTasks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;grunt-contrib-uglify&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, lets configure our watch task. Underneath the comment about Configuration copy and paste this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// CONFIGURATION =============================/&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;watch&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt; 	compass&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    	files&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;**/*.{scss,sass}&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    	tasks&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;compass:dev&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    js&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		files&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;**/*.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		tasks&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;uglify&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What we&#39;ve done here is to create a watch task, sub tasks of that called compass (which we&#39;ll refer to now as watch:compass) and js (watch:js). We configured watch:compass task to watch files with .scss or .sass extensions. If they change the watch:compass task will call our &amp;quot;compass:dev&amp;quot; task. We configured the js task to watch for changes in js files and run the &amp;quot;uglify&amp;quot; task&lt;/p&gt;
&lt;p&gt;Lets set up the Compass task. After the last closing bracket and comma of the watch task (follow the indentation) add the following:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;compass&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	dev&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		options&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;              &lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;			sassDir&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;styles/sass&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;			cssDir&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;styles/css&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;			environment&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;development&#39;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we&#39;ve set up a compass task, with a sub task called dev (compass:dev), we&#39;ve topld it where our sass is and where to output the css. We&#39;ve also set the environment to production. This will use some defaults for our compilation which are useful for development (like keeping it expanded, adding line comments etc).&lt;/p&gt;
&lt;p&gt;Now we could have just set up a compass task (without the dev bit). The options chunk would have just been between the compass:{} brackets. However, we&#39;re going to be a bit smarter thn that. We&#39;re going to set up a seperate sub task for production. Edit your compass task to look like this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;compass&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	dev&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		&lt;span class=&quot;token comment&quot;&gt;//... dev options here&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	prod&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		options&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;              &lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;			sassDir&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;styles/sass&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;			cssDir&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;styles/css&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;			environment&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;production&#39;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt; 	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we could call compass:prod as a task and it would copile our sass into a compressed style, ready for deployment.&lt;/p&gt;
&lt;p&gt;Lets set up our ugilfy task to concat and minify our JS. After the compass task, add the following:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;uglify&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	all&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		files&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        	&lt;span class=&quot;token string&quot;&gt;&#39;js/min/main.min.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        	&lt;span class=&quot;token string&quot;&gt;&#39;js/libs/jquery.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        	&lt;span class=&quot;token string&quot;&gt;&#39;js/main.js&#39;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        	&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When we call this task, Uglify is going to get all the files listed between the square brackets, minify them and then squish them all together. If we had some sort of HTML build process (say using a static site generator) we could include the full scripts in development and run the above minification code as apart of our prod task - just like we did with the Compass task above.&lt;/p&gt;
&lt;p&gt;Its this kind of build procedure that really makes Grunt shine over things like Codekit (which is awesome and that isn&#39;t meant to sound like a diss). You can run a tailored dev and production build just by using a &lt;code&gt;grunt prod&lt;/code&gt; command. You could even use something like &lt;a href=&quot;https://github.com/zonak/grunt-ftp-deploy&quot;&gt;Grunt Git Deploy&lt;/a&gt; or &lt;a href=&quot;https://github.com/zonak/grunt-ftp-deploy&quot;&gt;Grunt FTP Deploy&lt;/a&gt; as part of the pro build and send your site up to the server. But I digress...&lt;/p&gt;
&lt;h2&gt;Default task&lt;/h2&gt;
&lt;p&gt;We need to compile our CSS and JS when we kick Grunt off. We also wanna run our watch task. To do this, we&#39;ll trigger it using our default task. Find the line in your Gruntfile that looks like this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;registerTask&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;default&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Any tasks we want to run when we enter Grunt need to go between the square brackets. so add &lt;code&gt;&#39;compass:dev&#39; , &#39;uglify&#39; , &#39;watch&#39;&lt;/code&gt; between the brackets (with quotes and comma seperated).&lt;/p&gt;
&lt;p&gt;Anyways, lets try out what we&#39;ve done so far. Jump over to your command line (making sure you&#39;re in your project folder), type &amp;quot;grunt&amp;quot; and &lt;del&gt;hit enter.&lt;/del&gt; &lt;ins&gt;We forgot something!&lt;/ins&gt;&lt;/p&gt;
&lt;p&gt;If you had have pressed enter, you would have seen this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;Running &lt;span class=&quot;token string&quot;&gt;&quot;watch&quot;&lt;/span&gt; task&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Waiting&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;Warning&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;EMFILE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; too many open files&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;over and over and over again... You can try doing it if you like, just be prepared to hit &lt;code&gt;ctrl + c&lt;/code&gt; (Mac and Windows) to cancel the process.&lt;/p&gt;
&lt;p&gt;The reason is we&#39;re watching all the JS files in our project. If you go take a peak in the node_modules folder (which was added when we installed all our node plugins, you&#39;ll see we have lots of folders wiht lots of javascript files in them. We need to be more specific about what js files to watch. Update your watch task:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;watch&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt; 	compass&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    	files&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;**/*.{scss,sass}&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    	tasks&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;compass:dev&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    js&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		files&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;js/**/*.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &amp;lt;== CHANGE HERE&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		tasks&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;uglify&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By adding the js folder, we can ensure Grunt isn&#39;t wasting time and energy watching millions of js files (unless you have millions of js files in your js folder - I don&#39;t recommend a million javascript files in your project)&lt;/p&gt;
&lt;p&gt;Try running grunt now by going to your command line and entering “grunt”.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;Running &lt;span class=&quot;token string&quot;&gt;&quot;compass:dev&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;compass&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; task&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;unchanged styles/sass/style.scss&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Compilation took &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;.001s&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Running &lt;span class=&quot;token string&quot;&gt;&quot;uglify:all&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;uglify&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; task&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;File &lt;span class=&quot;token string&quot;&gt;&quot;JS/min/main.min.js&quot;&lt;/span&gt; created.&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Running &lt;span class=&quot;token string&quot;&gt;&quot;watch&quot;&lt;/span&gt; task&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Waiting&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Boom! The feedback is pretty self explanatory. Whats it waiting for? Changes to compile. Go make a change to the style.scss file and hit save. Now check the command line. You should see something like:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;Running &lt;span class=&quot;token string&quot;&gt;&quot;watch&quot;&lt;/span&gt; task&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Waiting&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;.OK&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; File &lt;span class=&quot;token string&quot;&gt;&quot;styles/sass/style.scss&quot;&lt;/span&gt; changed.&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Running &lt;span class=&quot;token string&quot;&gt;&quot;compass:dev&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;compass&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; task&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;   remove .sass-cache/ &lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;   remove styles/css/style.css &lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;   create styles/css/style.css &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;.009s&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Compilation took &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;.01s&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Done, without errors.&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Completed &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;.305s at Mon Sep &lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2013&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;22&lt;/span&gt;:31:48 GMT+0100 &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;BST&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; - Waiting&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The change should now be visible in your css file too! Huzzah.&lt;/p&gt;
&lt;h2&gt;Seperate Grunt tasks&lt;/h2&gt;
&lt;p&gt;The last thing we&#39;ll set up is a non-default task.&lt;/p&gt;
&lt;p&gt;Now you can run any task in grunt by typing &amp;quot;grunt taskname:subtask&amp;quot; in the command line. For example to run our compass:prod task, we would enter:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ grunt compass:prod&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That would be fine, but if you had a JS build for prod, or the aforementioned ftp deploy you wanted to run at the same time, that would be moer cumbersome to type into terminal.&lt;/p&gt;
&lt;p&gt;Underneath the line of our default task, enter the following:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// PROD BUILD&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;grunt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;registerTask&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;prod&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;compass:dev&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we create a task called &amp;quot;prod&amp;quot; and add one task to be run when its called (our compass:prod task). Same rules apply as the default task, to add others, just add them in the order you want them performed (left to right), in quotes, comma seperated.&lt;/p&gt;
&lt;p&gt;Go make a change to the Sass file and then run this in terminal:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;$ grunt prod&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If everything worked, it should have recompiled, but compressed th eoutput CSS onto one line.&lt;/p&gt;
&lt;h2&gt;Automation work done = Cocktails&lt;/h2&gt;
&lt;p&gt;And we&#39;re done. Its a bit of work setting everything up, but now most of that is done and won&#39;t need so mch work next time. It&#39;ll be simple to take the Gruntfile and Package file and extend them to meet the needs of your next project.&lt;/p&gt;
&lt;p&gt;If I got anything wrong or you&#39;ve any questions, tweet me. I&#39;m generally not a dick.&lt;/p&gt;
&lt;p&gt;Happy grunting.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Update&lt;/em&gt; Thanks to &lt;a href=&quot;https://github.com/rightsaidjames&quot;&gt;@rightsaidjames&lt;/a&gt; for &lt;a href=&quot;https://github.com/matthewbeta/grunt-demo/pull/1&quot;&gt;this pull request&lt;/a&gt;. Corrections have been made!&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Do</title>
    <link href="http://matthew-jackson.com/blog/do/"/>
    <updated>2014-01-27T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/do/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;You can wait for your boss to tell you to do it, your client to ask you to do it or for someone else to blog about how to do it&lt;/p&gt;
&lt;p&gt;Sometimes you just have to do it.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Weeping coconuts</title>
    <link href="http://matthew-jackson.com/blog/weeping-coconuts/"/>
    <updated>2014-01-31T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/weeping-coconuts/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;Of course we all know Facebook is the fount of all evil, but this week I saw a post from a friend, which was sort of a chain letter that didn&#39;t make me want to pick out my eyes with rocks. It was a call to occupy Facebook with art&lt;/p&gt;
&lt;p class=&quot;drop-cap&quot;&gt;The post was a picture of &lt;a href=&quot;http://en.wikipedia.org/wiki/Jake_and_Dinos_Chapman&quot;&gt;Jake and Dinos Chapman&#39;s&lt;/a&gt; &lt;a href=&quot;http://jakeanddinoschapman.com/works/the-sum-of-all-evil/&quot;&gt;The Sum of alll Evil&lt;/a&gt;. The piece is as awesome as it is horrific, so I clicked like (as is the parlance) and commented my approval. However, my comment was then replied to, informing me I had been given Frida Kahlo. &lt;/p&gt;
&lt;h2&gt;Wat?&lt;/h2&gt;
&lt;p&gt;Re-reading the initial post explained that by liking it, I consented to taking part in a sort of cultural sit-in. Not being a huge fan of Kahlo, I&#39;m not very familiar with her work. She&#39;s the self-portrait lady, yeah?&lt;/p&gt;
&lt;p&gt;I did some google research and found out a bit about her style and why she painted what she did. Started reading a bit of bio and before I knew what was going on I was learning about something. Something that wasn&#39;t javascript or CSS level 4 selectors and it was interesting, damnit.&lt;/p&gt;
&lt;p&gt;I eventually settled on this:&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;http://matthew-jackson.com/assets/images/weeping-coconuts-1951.jpg&quot;&gt;
&lt;figcaption&gt;Weeping Coconuts (Cocos gimientes) by &lt;em&gt;Frida Kahlo&lt;/em&gt; (1951)&lt;/figcaption&gt;	
&lt;/figure&gt;
&lt;p&gt;I chose this because it&#39;s supposed to be very sad; As Kahlo got older she turned away from self-portraits and started painting still life. This was possibly due to the affect of prescription medication had on her ability to paint with the detail she&#39;d used to &lt;a href=&quot;http://matthew-jackson.com/blog/weeping-coconuts/%5Bsource%5D(http://www.fridakahlofans.com/c0612.html)&quot;&gt;^1&lt;/a&gt;. Kahlo thought they would sell quicker and she and her husband, Diego Rivera, needed money to pay her medical bills &lt;a href=&quot;http://matthew-jackson.com/blog/weeping-coconuts/%5Bsource%5D(http://www.fridakahlofans.com/c0610.html)&quot;&gt;^2&lt;/a&gt;. However, despite this tragic tale, nothing about the actual image seems sad to me. In fact, a crying coconut seems absurdly funny.&lt;/p&gt;
&lt;p&gt;It was painted as a gift to a friend, Elena Boder. Boder didn&#39;t like it and returned it, expecting Kahlo to offer her another one. She didn&#39;t. She just painted over the &amp;quot;For Elena Boder&amp;quot; bit and sold it &lt;a href=&quot;http://matthew-jackson.com/blog/weeping-coconuts/%5BSource%5D(http://www.fridakahlofans.com/c0612.html)&quot;&gt;^3&lt;/a&gt;. Hence the message on the finished piece saying &amp;quot;Painted with great affection. Frida Kahlo&amp;quot;&lt;/p&gt;
&lt;p&gt;Clearly an excellent sense of humour.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Header image attributed to &lt;a href=&quot;http://www.flickr.com/photos/velovotee/&quot;&gt;velovotee&lt;/a&gt; from &lt;a href=&quot;http://www.flickr.com/commons&quot;&gt;The Commons on Flickr&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&quot;heading heading--sub&quot;&gt;Footnotes&lt;/h3&gt;
</content>
  </entry>
  
  <entry>
    <title>How much does a website cost?</title>
    <link href="http://matthew-jackson.com/blog/how-much-does-a-website-cost/"/>
    <updated>2014-03-06T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/how-much-does-a-website-cost/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;If you ask me, I&#39;m gonna ask how much you got. I am aware that makes me sound like a jerk. Or a con artist. Let me explain why it makes sense for both of us.&lt;/p&gt;
&lt;p class=&quot;drop-cap&quot;&gt;My partner and I are currently trying to buy a house (I know. Pretty cool). Now there are &lt;a href=&quot;http://www.rightmove.co.uk/property-for-sale/property-42913942.html&quot;&gt;houses&lt;/a&gt; and there are &lt;a href=&quot;http://4.bp.blogspot.com/_vqBNElQIYfE/TFYH3TnutrI/AAAAAAAAAEI/gdBnjQmWmwA/s1600/twistershithouse.jpg&quot;&gt;houses&lt;/a&gt;. One of the first questions the Estate Agent will ask is always &quot;what&#39;s your budget?&quot; &lt;/p&gt;
&lt;p&gt;An estate agent needs to know how much I have so we don&#39;t waste each others time either looking at stuff I can&#39;t afford or places I don&#39;t wanna live.&lt;/p&gt;
&lt;p&gt;A website is a lot like a house. It can be big. Or small. Complicated or easy to build. Have lots of features or hardly any. It has running and upkeep costs… You get the idea.&lt;/p&gt;
&lt;p&gt;I have a figure in my head of £250 to £300 per day when I look at a project. How many days it takes me are dependent on a lot of things, as explained above. Is that amount negotiable? Everything is negotiable.&lt;/p&gt;
&lt;p&gt;Building a website or app is a 2 way thing. Both you and I are gonna dance. What you initally wanted might not be possible for your budget. But we can work out a solution to your problem that is within your budget (probably) and build the best website you can afford.&lt;/p&gt;
&lt;p&gt;So… what do you wanna make and how much you got?&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Inspired by &lt;a href=&quot;https://twitter.com/molovo/status/441506011799912448&quot;&gt;this tweet&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Purple</title>
    <link href="http://matthew-jackson.com/blog/purple/"/>
    <updated>2014-06-12T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/purple/</id>
    <content type="html">&lt;p&gt;I&#39;ve been following Eric Meyer&#39;s posts about the terrible tragedy thats unfolded for his family over the last year.&lt;/p&gt;
&lt;p&gt;Its made me think about my own young daughter and made me try not to think about how to deal with something terrible like this. Its made me think about the sister who I never knew and how my parents dealt with it. I pray I never have to.&lt;/p&gt;
&lt;p&gt;Today I made my site purple (it is my and my daughter&#39;s favourite colour too) for Rebecca, for my sister Laura, for all the families who go through the worst thing I can possibly imagine, and for me because however pithy it felt good to do something.&lt;/p&gt;
&lt;p&gt;&amp;lt;3&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Node.js Child Process ENOENT Error on Windows (title for make SEO Good)</title>
    <link href="http://matthew-jackson.com/blog/node-child_process-enoent-error-windows/"/>
    <updated>2014-09-10T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/node-child_process-enoent-error-windows/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;Node JS on Windows can be a &lt;a href=&quot;https://github.com/joyent/node/issues/6960&quot;&gt;challenge&lt;/a&gt;. TBQH Windows can be a challenge. I ran into a sticky problem the other day and thought I would share the solution.&lt;/p&gt;
&lt;p&gt;Lets say we&#39;re running a &lt;a href=&quot;http://gulpjs.com/&quot;&gt;Gulp&lt;/a&gt; task to build a &lt;a href=&quot;http://jekyllrb.com/&quot;&gt;Jekyll&lt;/a&gt; site. Part of &lt;a href=&quot;http://blog.overzealous.com/post/74121048393/why-you-shouldnt-create-a-gulp-plugin-or-how-to-stop&quot;&gt;Gulp&#39;s philosophyy&lt;/a&gt; is that plugins are a means of last resort, and you should just write straight Node/JS. We can use node&#39;s built in &lt;a href=&quot;http://nodejs.org/api/child_process.html&quot;&gt;child_process&lt;/a&gt; module to run commands just like we were typing them in to the terminal:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; cp &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;child_process&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// later&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;cp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;jekyll&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;build&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;stdio&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;inherit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// cool shit happens&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is pretty cool. I was pretty pleased with myself when I was building a Jekyll site (and my Sass) using Gulp. Like all of the cool kids, I wanted to show off my coolness to the folks at work (we use Jekyll for prototyping a lot). Unfortunately when I tried it on my Windows machine in the office, I got this bullshit:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;events.js:72&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    throw er&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; // Unhandled &lt;span class=&quot;token string&quot;&gt;&#39;error&#39;&lt;/span&gt; event&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;          ^&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;Error: spawn ENOENT&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    at errnoException &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;child_process.js:988:11&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    at Process.ChildProcess._handle.onexit &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;child_process.js:779:34&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;HAHAHAHAHA You suck at your job. Why don&#39;t you tell your girlfriend to call me when she wants to see a real programmer&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Yes. My PC is a dick. I hacked around the problem (by using child_process.exec seen as you ask), but why didn&#39;t it work? Well This week I found out the answer…&lt;/p&gt;
&lt;p&gt;Turns out this ENOENT error means that it can&#39;t execute the command. eg. Jekyll doesn&#39;t resolve to an executable file. When we run &lt;code&gt;jekyll&lt;/code&gt; from the Command Prompt, it looks for an actual executable and doesn&#39;t find one, but &lt;em&gt;does&lt;/em&gt; find a jekyll.bat file and helpfully resolves to that for you.&lt;/p&gt;
&lt;p&gt;Node&#39;s child_process doesn&#39;t do that, so you need to do something like this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;cp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;jekyll.bat&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;build&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;stdio&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;inherit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hooray! it worked. Oh noees but now it doesn&#39;t work on not-Windows. Sad face. I want portable code dammit! We need it to write &lt;code&gt;jekyll&lt;/code&gt; on non-windows systems, and &lt;code&gt;jekyll.bat&lt;/code&gt; in windows land. If only there was a way to conditionally set a variable value in Javascript with some kind of ternary operator…&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; cp &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;child_process&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// make a variable based ont he system&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; jekyll &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;platform &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;win32&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;jekyll.bat&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;jekyll&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Use that sukka&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;cp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;jekyll&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;build&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;stdio&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;inherit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// cool shit happens E V E R Y W H E R E&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://gist.github.com/matthewbeta/25a33958de7cf5a8145d&quot;&gt;The resulting Gulpfile as a Gist&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a href=&quot;http://stackoverflow.com/users/1877762/spikemeister&quot;&gt;SpikeMeister&lt;/a&gt; off of Stack Overflow (&lt;a href=&quot;https://twitter.com/bighuggies/&quot;&gt;@bighuggies on twitter?&lt;/a&gt;) for answering &lt;a href=&quot;http://stackoverflow.com/q/21856861&quot;&gt;this question&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Find and Store your IP Address with Node</title>
    <link href="http://matthew-jackson.com/blog/find-and-store-your-ip-with-node/"/>
    <updated>2014-10-15T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/find-and-store-your-ip-with-node/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;Say you are using Grunt or Gulp on a team. You need to have your Gulp or Gruntfile in version control so that any changes or improvements can be enjoyed (or endured) by everyone.&lt;/p&gt;
&lt;p&gt;Now let&#39;s say you all want to be running a cool task like &lt;a href=&quot;http://browsersync.io/&quot;&gt;Browser Sync&lt;/a&gt; and due to the network neck-beards and their crazy rules, you need to specify your host explicitly using your IP (eg. 192.168.X.XX). All your IP addresses are different though! Oh noes. Looks like you&#39;ll have to manually edit it every time.&lt;/p&gt;
&lt;p&gt;Or you could use the built in &lt;a href=&quot;http://nodejs.org/api/os.html&quot;&gt;Node OS&lt;/a&gt; API. Like so:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// REQUIRE THE OS MODULE&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; os          &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;os&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; ifaces      &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; os&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;networkInterfaces&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/*...*/&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// THIS FUNCTION GETS YOUR LOCAL IP SO WE CAN SERVE THE BUILT SITE FROM IT&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// No more having to keep swapping the IP&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; lookupIpAddress &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; dev &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; ifaces&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dev &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;en1&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; dev &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;en0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token keyword&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    ifaces&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;dev&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;details&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;details&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;family&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;IPv4&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;            lookupIpAddress &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; details&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;address&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; ipAddress   &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; lookupIpAddress&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/*...*/&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// EXAMPLE ONLY - NOT REAL&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;browsersync&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	options&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;		host&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ipAddress&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Use the variable we stored earlier!&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now whenever anyone runs the gulp or grunt (or any node thingy) it will get their IP and use that. Swag.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://gist.github.com/matthewbeta/25a33958de7cf5a8145d&quot;&gt;Full (Gulp) example as a gist&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Organising Javascript for beginners (like me)</title>
    <link href="http://matthew-jackson.com/blog/organising-javascript/"/>
    <updated>2014-10-18T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/organising-javascript/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;So you&#39;ve heard about this Java Script thing (I&#39;m tipping it to be big this year). You&#39;ve played with it and can write some jQuery soup. But eww. Everything gets messy and difficult and your head hurts  and it makes you want to go kick a tree.&lt;/p&gt;
&lt;p class=&quot;dropcap&quot;&gt;I&#39;ve felt like this. Many times. I&#39;m starting to wrap my tiny brain around some basic Javascript structuring and here&#39;s a brain fart containing some of what I understand:&lt;/p&gt;
&lt;h2&gt;Objects&lt;/h2&gt;
&lt;p&gt;The easiest way to structure your JS is to organise it into an object literal. An object literal is a means of storing data. The data takes the form of key value pairs (key = value) and the values can take the form of strings, arrays, functions or other objects.&lt;/p&gt;
&lt;p&gt;There are a few ways to create an object literal. My preferred (and I think the most straightforward) is by making a variable, who&#39;s value is an empty object.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; me &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sweet. We now have an object literal called &amp;quot;me&amp;quot;. But it&#39;s pretty boring... Let&#39;s fill it with some stuff:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;me&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;firstname &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Matthew&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;me&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// {firstname: &#39;Matthew&#39;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let&#39;s add my lastname in the same way, then print the lastname property to the console:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;me&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;lastname &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Jackson&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;me&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;lastname&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &#39;Jackson&#39;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can get the data or set the data via an intuitive dot syntax (&lt;code&gt;objectName.propertyName&lt;/code&gt;). Let&#39;s add a function to my object:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;me&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;greeting&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Hello, &#39;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39; + this.firstname + &#39;&lt;/span&gt; &#39; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;lastname&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can call that function like this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;me&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;greeting&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &#39;Hello, Matthew Jackson&#39;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So far so good. Our code is more organised, we can write some pretty expressive and easy to read code, and we get a bonus. We are namespacing our application. In this instance our namespace is &lt;code&gt;me&lt;/code&gt;, namespacing is important. It means we avoid accidentally overriding things.&lt;/p&gt;
&lt;h2&gt;Namespacing&lt;/h2&gt;
&lt;p&gt;When I were a lad, we didn&#39;t have &amp;quot;TV on demand&amp;quot;, the &amp;quot;internet&amp;quot; or &amp;quot;The Cloud&amp;quot;. If we wanted to watch something when we weren&#39;t in, we would record it on a video tape. The blank video tapes we had in the olden days, came with some stickers for you to label the video (eg. Mum&#39;s Tape - London&#39;s Burning). This stopped, other people just picking the video and recording over it with Predator, &lt;em&gt;without realising they were doing it&lt;/em&gt; (sorry, Mum).&lt;/p&gt;
&lt;p&gt;Namespacing applies the same principal to our Javascript. Its very easy to give 2 different things the same name when you&#39;re coding (especially on a team). This makes it very easy to override one thing with another without realising. By namespacing our code under &lt;code&gt;me&lt;/code&gt; we can have another object, &lt;code&gt;you&lt;/code&gt;, with the same properties, and neither overrides the other:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; you &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  firstname&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Gary&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  lastname&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Biscuits&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token function-variable function&quot;&gt;greeting&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;G&#39;day, &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;firstname&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;you&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;greeting&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &quot;G&#39;day, Gary&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thats a little contrived, but you can hopefully see how, in a larger application, namespacing makes it harder for us to override our values accidentally.&lt;/p&gt;
&lt;p&gt;But what if we name our namespace the same thing as another namespace?&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// later in our code&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; me &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;me&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;powers&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;grumpiness&#39;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;me&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;greeting&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;//undefined is not a function&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Well we can test to see if our name already exists, when we set the variable:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; me &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; me &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This checks to see if &amp;quot;me&amp;quot; already exists. If it does, we just use the existing &amp;quot;me&amp;quot;[^1]. Then we can continue adding properties to it using the dot syntax (&lt;code&gt;me.powers = &#39;grumpiness&#39;&lt;/code&gt;). If it doesn&#39;t already exist, we assign an empty object as the value, just like in the first example (&lt;code&gt; var me = {}&lt;/code&gt;).&lt;/p&gt;
&lt;h2&gt;Breaking it up&lt;/h2&gt;
&lt;p&gt;We can further organise our code by splitting it into smaller files. The object literal pattern can help here too:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// scripts/personal-details.js&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; me &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; me &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;me&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;details &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  firstname&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Matthew&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  lastname&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Jackson&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token function-variable function&quot;&gt;fullname&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;firstname&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; lastname&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; firstname &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39; &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; lastname&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  age&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  twitter&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;@matthewbeta&#39;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// scripts/head.js&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; me &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; me &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;me&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;head &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  facialHair&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  eyes&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You could then either link both of these seperately (eww... gross), or with a build step to concatenate them.&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;In larger more complex applications or sites, I could see the nesting getting crazy (&lt;code&gt;me.property.name.long.list.myfunction();&lt;/code&gt;). I think just being pragmatic and sensible would avoid anything too mad.&lt;/p&gt;
&lt;p&gt;I also found it took a but longer to write at first (not an issue now). The wins from breaking everything up and keeping it organised are definitely worth a few extra minutes up front. Having a simple pattern to follow has also encouraged me to write more reusable objects and functions.&lt;/p&gt;
&lt;p&gt;Code architecture is a spectrum and this is on the very-quick-easy-end. It does feel good taking steps into making more organised and maintanable code but I&#39;m also aware that there are many applications and this won&#39;t be the best pattern for all of them.&lt;/p&gt;
&lt;h2&gt;Enjoy better writers? Read these:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://rmurphey.com/blog/2009/10/15/using-objects-to-organize-your-code/&quot;&gt;Using Objects to Organize Your Code&lt;/a&gt; by &lt;a href=&quot;https://twitter.com/rmurphey&quot;&gt;Rebecca Murphey&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://css-tricks.com/can-you-over-organize-javascript/&quot;&gt;Can You “Over Organize” JavaScript?&lt;/a&gt; by &lt;a href=&quot;https://twitter.com/chriscoyier&quot;&gt;Chris Coyier&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://addyosmani.com/blog/essential-js-namespacing/&quot;&gt;Essential JavaScript Namespacing Patterns&lt;/a&gt; b &lt;a href=&quot;https://twitter.com/addyosmani&quot;&gt;Addy Osmani&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&quot;heading heading--sub&quot;&gt;Footnotes&lt;/h3&gt;
&lt;p&gt;[^1]: Its not doing that really. Its assigning the value of the existing &amp;quot;me&amp;quot; to the newly declared &amp;quot;me&amp;quot;. The above is easier to write though.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>🔗 Understand Javascript Array Reduce in 1 Minute</title>
    <link href="http://matthew-jackson.com/blog/Understand-Javascript-Array-Reduce-in-1-Minute/"/>
    <updated>2015-01-30T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/Understand-Javascript-Array-Reduce-in-1-Minute/</id>
    <content type="html">&lt;p&gt;This really helped me &amp;quot;get&amp;quot; array.reduce:&lt;/p&gt;
&lt;p&gt;&amp;quot;Everybody knows what looping over a collection is. But do you know what reducing a collection means? No? Are you sure?&amp;quot;
&amp;quot;It sounds scary. But it is in fact pretty simple. You do it all the time. Here. Let me show you an example:&amp;quot;&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; total &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; numbers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;   total &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;quot;That’s it. You just reduced the “numbers” collection into the “total” variable. Pretty simple huh?&amp;quot;&lt;/p&gt;
&lt;p&gt;It is now, yeah :)&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.airpair.com/javascript/javascript-array-reduce&quot;&gt;Understand Javascript Array Reduce in 1 Minute&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Javascript unit testing 101</title>
    <link href="http://matthew-jackson.com/blog/javascript-unit-testing-101/"/>
    <updated>2015-06-13T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/javascript-unit-testing-101/</id>
    <content type="html">&lt;p class=&quot;lede&quot;&gt;Unit testing seems like exercise: The consensus seems to be that we should do it, I&#39;m sure we&#39;d feel better if we did do it, but no one seems to do it as much as they should.&lt;/p&gt;
&lt;p class=&quot;drop-cap&quot;&gt;Part of the reason I haven&#39;t been unit testing my Javascript is because I didn&#39;t really know how (shame-face emoji). Recently, I sat down and got my head around the practical implications of writing, running and passing JS unit tests. The basics at least. In the interests of posterity and sharing for the greater good, I&#39;ll try and explain what I learned&lt;/p&gt;
&lt;p&gt;First off, I am not going to get into the ins and outs of why you should (or shouldn&#39;t) unit test. I&#39;ll assume that you&#39;re here because, like me, you knew enough to know it sounds like a good idea. My interest in testing has meant I have listened to many podcasts (highly recommend &lt;a href=&quot;http://ttlpodcsat.com/&quot;&gt;TTL&lt;/a&gt; with &lt;a href=&quot;http://rmurphey.com/&quot;&gt;Rebecca Murphy&lt;/a&gt; btw), conference talks and read many posts and documentation sites for various testing frameworks. In my previous job at Comtec, I was also fortunate to be sat behind some very talented JS and C# engineers and got to ask questions and see what their apporach was.&lt;/p&gt;
&lt;p&gt;Based on what I&#39;ve absorbed, I&#39;m setting up my workflow as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I&#39;ll be attempting Test Driven Development (TDD if you like accronyms). This is basically writing tests first, then writing code to make the tests pass. This makes the most sense to me&lt;/li&gt;
&lt;li&gt;I&#39;m going to use &lt;a href=&quot;http://mochajs.org/&quot;&gt;Mocha&lt;/a&gt; and &lt;a href=&quot;http://chaijs.com/&quot;&gt;Chai&lt;/a&gt; for no other reason than the docs are really good and there is also a cool Yeoman generator (more later)&lt;/li&gt;
&lt;li&gt;I am &lt;em&gt;only&lt;/em&gt; doing unit tests. This means I&#39;m not going to try and test DOM interactions. Integration tests seem fun, but I need to walk before I can get onto that bus.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Get setup&lt;/h2&gt;
&lt;p&gt;To get started, and follow along you will need to install &lt;a href=&quot;http://nodejs.org/&quot;&gt;Node&lt;/a&gt;. Just follow the link and click install. You&#39;ll also need to use the terminal or the command line (don&#39;t be afraid) to get set up with Yeoman and Bower. Bower requires git too. If you need to install that, go and  install the Github GUI for your system &lt;a href=&quot;https://windows.github.com/&quot;&gt;Windows&lt;/a&gt;, &lt;a href=&quot;https://mac.github.com/&quot;&gt;OSX&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;After Node has installed, open your terminal and&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; -g yo bower&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then install a Yeoman generator to quickly create our test stuff:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; -g generator-mocha&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then create a folder for your project and navigate there with your terminal/command line&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; testing &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; testing&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then run the generator to make all the folder structure&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;yo mocha&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, you could go and get the &lt;a href=&quot;https://github.com/matthewbeta/testing/tree/master/test&quot;&gt;files and folder structure from github&lt;/a&gt; (contains spoilers)&lt;/p&gt;
&lt;p&gt;Once thats finished, you can get Bower to install all the files:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;bower &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You&#39;ll be left with a folder structure something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;└── testing/
    └── test/
        ├── bower_components/
        ├── spec/
        └── index.html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create a folder called &lt;code&gt;scripts.js&lt;/code&gt; in the &lt;code&gt;test&lt;/code&gt; folder. This will be where we write the code we want to test. Add a link to it in &lt;code&gt;index.html&lt;/code&gt; where it tells you to include source files:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- ... --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- include source files here... --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;scripts.js&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token script&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All set &lt;code&gt;&amp;lt;/yak-shaving&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Aside: If you already had a project setup with scripts, styling, the whole deal, you could still have opened your command prompt at the route and run the &lt;code&gt;yo mocha&lt;/code&gt; and &lt;code&gt;bower install&lt;/code&gt; commands to add the test folder and required test suite, files and dependencies to your project. Thats why Yeoman is cool.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Testing time&lt;/h2&gt;
&lt;p&gt;If you open up &lt;code&gt;index.html&lt;/code&gt; in a browser, you should see a Mocha test results page with some zeroes in the top right, showing no passes or failures. Yay. We&#39;ll fix that in a mo, but first, heres a simple thing to build and test:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We&#39;ll build the functions for a basic calculator (add, subtract, divide and multiply)&lt;/li&gt;
&lt;li&gt;The calculator functions should only work on real JS numbers eg:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// good&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;//Bad&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; fakeNumber1 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; fakeNumber2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;two&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; wut &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Lets start with addition. We want a function which takes 2 parameters, a and b, then returns the result of adding those together. Therefore, if a is 1 and b is 2 we want it to return 3.&lt;/p&gt;
&lt;p&gt;If you look in &lt;code&gt;test.js&lt;/code&gt; you&#39;ll see the basics of a Mocha test. The first &lt;code&gt;describe&lt;/code&gt; function call is gonna group all our tests together, then the second is for a specific function or piece of functionality. Then the &lt;code&gt;it&lt;/code&gt; function explains some basic functionality. Lets update &lt;code&gt;test.js&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// The overall suite of tests are for our calculator&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Calculator&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// The function we want to test&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;add(a, b)&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;// describe a test&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token function&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;a + b should be add up to the right amount&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;// Write our assertion&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token function&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;to&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;equal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok so we wrote a test. The assertion we wrote was using the Chai assertion library. It lets write a test in quite a natural style. &lt;a href=&quot;http://chaijs.com/api/&quot;&gt;Check out the Chai docs&lt;/a&gt; for some examples of other assertions and styles that will suit your use case. Lets open &lt;code&gt;index.html&lt;/code&gt; in a browser. You should see your test and its all red and failing and gross. No probs, we expect it to fail because we haven&#39;t written any JS yet. Lets open &lt;code&gt;scripts.js&lt;/code&gt; and create an &lt;code&gt;add&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;a&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; b&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Save that and refresh index.html in your browser. Yay! passing test. But that really is the most basic portion of our test. Lets add some more tests to make sure we can only accept, real numbers. Back in &lt;code&gt;test.js&lt;/code&gt; add some tests like these:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// The overall suite of tests are for our calculator&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Calculator&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// The function we want test&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;add(a, b)&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;// describe a test&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token function&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;a + b should be add up to the right amount&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token function&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;to&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;equal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token function&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;should throw an error for non numbers&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; notNumber &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;num&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token function&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;three&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;four&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;to&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;throw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Error&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token function&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;four&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;to&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;throw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Error&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token function&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;3&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;to&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;throw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Error&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token function&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; notNumber&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;to&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;throw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Error&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We&#39;re using Chai assertions again, only this time its a bit more complicated because we want to expect our function to throw an error. We can&#39;t call the add function directly to get Chai/Mocha to run the test (like we did above). We need to (and sorry this gets technical skip over if you trust me and don&#39;t care) pass in the function and use bind to attach the context (what the function&#39;s &lt;code&gt;this&lt;/code&gt; would be. In this case &lt;code&gt;window&lt;/code&gt; as add is in the global namespace), and the arguments (the two things we want to add together). To test different scenarios, I&#39;m passing &lt;code&gt;add&lt;/code&gt; strings and an object. The text strings and object should be pretty easy to check. JS has a special function for checking if something is not a number: &lt;code&gt;isNaN(number)&lt;/code&gt;. Except this has some gotchas. The main one being that &#39;1&#39; will return false (&lt;em&gt;is&lt;/em&gt; a number).&lt;/p&gt;
&lt;p&gt;We need to check if its a string first. Something like:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;typeof&lt;/span&gt; arg &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;string&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; arg &lt;span class=&quot;token keyword&quot;&gt;instanceof&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Its not a number&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If its not a string, we need to test if it is not a number in any other way:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;isNaN&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// or this more robust one I found on StackOverflow&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;isNaN&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;parseFloat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isFinite&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Given we are going to need to test the arguments of all our basic calculator functions, we could write a function to reuse. Lets write a test first:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// ...other tests up here ^&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token function&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;isNumber(n)&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token function&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;should return false if n is not a number&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    assert&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isFalse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    assert&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isFalse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;string&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token function&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;should return true if n is a number&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    assert&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isTrue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Check index.html and all tests bar the first &lt;code&gt;add&lt;/code&gt; test should be failing. Lets make our &lt;code&gt;isNumber&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;typeof&lt;/span&gt; n &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;string&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; n &lt;span class=&quot;token keyword&quot;&gt;instanceof&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;//returns false if it isn&#39;t a number and true if it does&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isNaN&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;parseFloat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;n&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isFinite&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;n&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now the only test left to fix is the second &lt;code&gt;add&lt;/code&gt; test. Lets fix that by updating the &lt;code&gt;add&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;a&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; b&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// check our arguments are numbers&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// and if everything checks out&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;// Not numbers? Throw toys out of param (geddit?!)&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Not a number&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Tada! all passing. That feels nice. We can fill in all our other tests in the same way and write our subtract, multiply and divide functions to ake them all pass too. You can see what I did &lt;a href=&quot;https://github.com/matthewbeta/testing&quot;&gt;over in the Github repo&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;You could absolutely take this all further. I doubt my tests are very robust (for a pretend, hypothetical app). For instance what if we overload the functions (eg. &lt;code&gt;add(1,2,3)&lt;/code&gt;)?&lt;/p&gt;
&lt;p&gt;You could also take a look at the other assertion methods Chai provides. See if &lt;a href=&quot;http://chaijs.com/api/assert/#isNumber-section&quot;&gt;there&#39;s one&lt;/a&gt; that might have been useful here...&lt;/p&gt;
&lt;p&gt;You could add a UI and consider other types of testing, like integration or regression testing. &lt;a href=&quot;https://css-tricks.com/automatic-css-testing/&quot;&gt;You can even do this for CSS&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As I&#39;ve been learning about testing, I have been more considerate and deliberate writing code. For example I always make sure I plan my approach before I start, keep my functions simple, and make sure I understand what the functionality needs to be. If your job involves you building to user stories, I could see unit tests being really great to ensure the code meets all of the requirements. I will definitely be trying to get deeper down the testing rabbit hole.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Converting an SVG Polyline to a Path with this one weird trick</title>
    <link href="http://matthew-jackson.com/blog/converting-an-svg-polyline-to-a-path/"/>
    <updated>2015-07-27T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/converting-an-svg-polyline-to-a-path/</id>
    <content type="html">&lt;p&gt;Quick post: Today I was saving an SVG for a line graph out of Illustrator and found that the lines were rendered as &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polyline&quot;&gt;polylines&lt;/a&gt;. This is all well and good, except when you want to animate them, when it isn&#39;t.&lt;/p&gt;
&lt;p&gt;You&#39;ll probably get something that looks like this:&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;polyline&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#000000&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;stroke&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#000000&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;stroke-miterlimit&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;10&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;points&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;100,200,300,400&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You just need to make a couple of tweaks. Change the tag name, change the &amp;quot;points&amp;quot; attribute to &amp;quot;d&amp;quot;, and put an &amp;quot;M&amp;quot; in front of first point (which moves the start of the point to the right position):&lt;/p&gt;
&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;path&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#000000&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;stroke&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#000000&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;stroke-miterlimit&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;10&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;M100,200,300,400&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I had a hunt online and there was not a specific post on how to do this (just &lt;a href=&quot;https://gist.github.com/andytlr/9283541&quot;&gt;this Gist&lt;/a&gt;), so I&#39;ve made one. I&#39;m pretty confident this won&#39;t always work so go careful out there. If I&#39;m doing this wrong or just being a dumby, &lt;a href=&quot;http://twitter.com/matthewbeta&quot;&gt;tweet at me&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://twitter.com/matthewbeta&quot; class=&quot;signature&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Manifesto</title>
    <link href="http://matthew-jackson.com/blog/manifesto/"/>
    <updated>2016-10-07T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/manifesto/</id>
    <content type="html">&lt;p&gt;I thought I should have a bullet point manifesto. I have seen a few of these on sites lately so I guess I need one too?&lt;/p&gt;
&lt;p&gt;Here goes...&lt;/p&gt;
&lt;h2&gt;Matthew&#39;s Manifesto&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Bullet point manifestos are for wankers&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Perfect.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/matthewbeta&quot;&gt;@matthewbeta&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>The best meal I ever ate</title>
    <link href="http://matthew-jackson.com/blog/the-best-meal-i-ever-ate/"/>
    <updated>2018-04-02T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/the-best-meal-i-ever-ate/</id>
    <content type="html">&lt;p&gt;In 2006, I went to visit a friend in South Thailand. As part of the trip, we
decided to go on a bike ride width-ways across the country from Hat Yai to
Tammalang (basically coast to coast at the thin bit) with a stop overnight at a
waterfall-come-nature-reserve campsite called Ton Nga Chang.&lt;/p&gt;
&lt;p&gt;Thailand is hot, so we started cycling at 3am when the temperature was bareable.
We arrived at the waterfall at around 7am and spent the day dicking about in a
waterfall. Evening came and we set up our hammocks ready for a night under the
stars. As the tourists started clearing out, it became clear we were the only
people stopping over. The idea this was campsite, quickly disappated as we
realised we would effectively be sleeping in the jungle.&lt;/p&gt;
&lt;p&gt;A couple who ran a shop got chatting to us, and quickly told us we shouldn&#39;t
sleep where we had strung up our hammocks &amp;quot;because of the snakes&amp;quot; and offered us
the store room at the back of their shop. We tried to bed down in there, but the
continuous scuttling of animals (no idea), the giant insects (I saw a blue and
white beetle as big as my fist) made that pretty bleak and I made it pretty
clear that our accommodation wasn&#39;t gonna work out for me.&lt;/p&gt;
&lt;p&gt;Knowing we would need some sleep before another 3am start and a 75km cycle, my
friend called his girlfriend (who was Thai) and she had a look online and made
some calls. She found a &amp;quot;hotel&amp;quot;, about 15-20km back the way we had come. We (I)
decided that would be a good plan, and we set off in the wrong direction to find
a bed.&lt;/p&gt;
&lt;p&gt;We arrived at the hotel about 40 minutes later. The gentleman at reception were
surprised to see us, and even more surprised that we wanted a room for the
night, as it was customary to hire this place in hours. The hotel was made up of
a few small chalets, ours featured a large (hopefully one way) mirror across one
wall, a sink, toilet and a collection of small geckos. We slept like babies for
about 4 hours.&lt;/p&gt;
&lt;p&gt;At 3am we woke up to a nutritious breakfast of Lays Potato Chips. We shared a
300ml bottle of water and saddled up for what was now a 95km ride into darkness.
We had to stop a few times, as we were both lagging. When we got to about the
60km mark, in the middle of effing nowhere, we pulled over and our prospects looked...
not good. Neither of us sure we could actually carry on cycling without food or
water. We were also aware that the sun would be up in about an hour and the
temperature would probably go from being about 20-25ºc to 35-40ºc, which would
exacerbate our problems. We were in a bit of a pickle, with no choice but to
keep on cycling and pray.&lt;/p&gt;
&lt;p&gt;As we passed over a hill, in the distant dark was the glow of tube lighting. A
small building by the side of the road. A strange service
station.&lt;/p&gt;
&lt;p&gt;The building had a porch with a few plastic patio tables outside, occupied by a
group of men whose faces looked like they worked hard, worked long, and worked outside.
Inside the building was a collection of trays, all piled with different
breakfast foods. We grabbed bottles of water, plates, and handfulls
of food. I don&#39;t really remember what, but I do
remember a lot of banana leaf parcels, stuffed with a stodgy
rice/coconut/banana... thing. Here is what it looked like.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://matthew-jackson.com/assets/stickyrice.jpg&quot; alt=&quot;A lump of sticky rice with a piece of banana in it, sitting on a banana leaf&quot;&gt;&lt;/p&gt;
&lt;p&gt;Reader, I could &lt;em&gt;literally&lt;/em&gt; feel the energy going back into
my body. The best thing I&#39;ve ever eaten. It was ugly,
unspectacular, cheap, and utterly life affirming.&lt;/p&gt;
&lt;p&gt;Its all about context...&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Getting my (blog) shit together</title>
    <link href="http://matthew-jackson.com/blog/getting-my-blog-shit-together/"/>
    <updated>2018-04-13T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/getting-my-blog-shit-together/</id>
    <content type="html">&lt;p&gt;A change is as good as a rest so I&#39;ve cleaned up the site with a new colour scheme some minor tweaks and less minor under the hood improvements. I made a list of stuff I wanted to tackle. Some of it was technical, some of it was just to make publishing and maintenance easier. I am also on a drive to simplify everything, so I wanted the easiest way forward with every decision.&lt;/p&gt;
&lt;h2&gt;HTTPS &lt;s&gt;Everywhere&lt;/s&gt; anywhere&lt;/h2&gt;
&lt;p&gt;Firstly, I really wanted to get HTTPS working. This site was previously hosted on &lt;a href=&quot;https://pages.github.com/&quot;&gt;Github Pages&lt;/a&gt; (which I love) but with a custom domain, its pretty much impossible to get a real SSL. I thought about self hosting, but I know it&#39;ll be a pain to deploy. GH Pages makes that really easy by doing a build whenever you commit.&lt;/p&gt;
&lt;p&gt;I recently heard about &lt;a href=&quot;https://netlify.com/&quot;&gt;Netlify&lt;/a&gt; and how they do hosting of static sites so I went and had a read. The news is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Its basically free (for my purposes)&lt;/li&gt;
&lt;li&gt;It deploy/build on git push &lt;em&gt;and&lt;/em&gt; you can have build hooks (e.g. &lt;code&gt;curl&lt;/code&gt; a URL and trigger a build).&lt;/li&gt;
&lt;li&gt;SSL is a one click process (as is forcing HTTPS)&lt;/li&gt;
&lt;li&gt;They do DNS too - I didn&#39;t end up using this as it would have meant too much dicking around. If you do use it, you get their super cool CDN too for free.&lt;/li&gt;
&lt;li&gt;H2 out of the box&lt;/li&gt;
&lt;li&gt;They offer a simple way to configure headers info (e.g. a CSP) by including a &lt;code&gt;_headers&lt;/code&gt; file.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I encourage you to go take a look. The docs are great and my site was hosted and setup in 5 minutes (not an exageration).&lt;/p&gt;
&lt;h2&gt;Offline is the new online&lt;/h2&gt;
&lt;p&gt;Now I had SSL setup, I could finally the second thing on my shame list – setting up a Service Worker. I basically stole all my SW code from this &lt;a href=&quot;https://css-tricks.com/serviceworker-for-offline/&quot;&gt;CSS Tricks post&lt;/a&gt;. The setup caches pages as you view them, loads pages cache first then goes to the network.I added an &lt;a href=&quot;http://matthew-jackson.com/offline.html&quot;&gt;offline page&lt;/a&gt; to show if a page is not in the cache or available over the network. Worked like a charm.&lt;/p&gt;
&lt;h2&gt;Auditors&lt;/h2&gt;
&lt;p&gt;Next was some general tidying up around the site. I used Chrome Dev Tools Audits to run a bit of a scan of the site. After a few accessibility and SEO tweaks I got some pretty ok scores:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://matthew-jackson.com/assets/audit-scores.png&quot; alt=&quot;A screen shot showing 100% scores for all audits in Chrome&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;N.B. I know this isn&#39;t the be-all-and-end-all but it was a pretty good benchmark - Good enough for my levels of effort.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Syndication&lt;/h2&gt;
&lt;p&gt;Next I like the idea of owning my content, but also would be good to syndicate the content to &lt;a href=&quot;https://medium.com/@matthewbeta&quot;&gt;Medium&lt;/a&gt; (at first). I found a nice Jekyll plugin for &lt;a href=&quot;https://github.com/aarongustafson/jekyll-crosspost-to-medium&quot;&gt;cross posting to Medium&lt;/a&gt;. It took some fiddling to get it running, but was reasonably straight forward. I&#39;m struggling to get all the posts up at the mo due to the API upload limit. Once the old posts are up, it should just work™️ for new posts.&lt;/p&gt;
&lt;p&gt;Bonus: I also added an &lt;a href=&quot;https://ifttt.com/&quot;&gt;IFTTT&lt;/a&gt; task to tweet about it - as I&#39;m shit at publicising when I post).&lt;/p&gt;
&lt;h2&gt;Keep it regular&lt;/h2&gt;
&lt;p&gt;The last thing on my list is to actually write some stuff to post. So this is the first one of those ✅. I also want to get better at sharing links on my blog first and then pushing them to Twitter so I&#39;ve now tweaked som estuff to make that possible by just adding a variable to a post.&lt;/p&gt;
&lt;p&gt;Speak soon…&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>📐 CSS Angles with G.C.S.E Trigonometry</title>
    <link href="http://matthew-jackson.com/blog/css-angles-with-gcse-trigonometry/"/>
    <updated>2018-04-26T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/css-angles-with-gcse-trigonometry/</id>
    <content type="html">&lt;p&gt;At work last week, we started building a cool new project and part of the design revolves around angles. A particularly tricky part is angular-cropped images. The images need to have a 8 degree angle top and bottom to give a skewed look–however the image cannot be distorted.&lt;/p&gt;
&lt;p&gt;Here&#39;s an example of what we want:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://matthew-jackson.com/assets/angle-example.jpg&quot; alt=&quot;Bill Murray, but with the top and bottom of the photo with wedges sliced out&quot;&gt;&lt;/p&gt;
&lt;p&gt;Some other points worth mentioning are that the images can be any size and in any width container.&lt;/p&gt;
&lt;p&gt;After quickly abandoning my initial attempt with transform skew, I reached for the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path&quot;&gt;&lt;code&gt;clip-path&lt;/code&gt; property&lt;/a&gt;. Clip path accepts a polygon value, which you can create with some 4 lots of 2 percentage coordinates. I like to use a web app called &lt;a href=&quot;https://bennettfeely.com/clippy/&quot;&gt;Clippy&lt;/a&gt; to quickly test out polygons so I knocked up a quick example:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://matthew-jackson.com/assets/clippy-test.png&quot; alt=&quot;Screen grab of Clippy web app showign a rough angled masked image&quot;&gt;&lt;/p&gt;
&lt;p&gt;This uses the follwing CSS which kind of makes sense but it actually doesn&#39;t work.&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token property&quot;&gt;clip-path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;polygon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;0 8%&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 100% 0%&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 100% 92%&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0% 100%&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The issue is, if the image proprtions change, the angle is going to change. Basically we need to work out the sides of a triangle when we only know 2 angles. Like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://matthew-jackson.com/assets/angle-problem.jpg&quot; alt=&quot;Photo showing the unknown values and known 8° angle of the triangle slice we need to &#39;clip&#39; from our image&#39;&quot;&gt;&lt;/p&gt;
&lt;p&gt;One thing we can know though, is the aspect ratio of the image. For example the image we&#39;ve been using is &lt;em&gt;16:9&lt;/em&gt;. Therefore we could add those measurements in and see if it helps us. As the clip-path will be in percent, we can scale it all up after.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://matthew-jackson.com/assets/angle-closer.jpg&quot; alt=&quot;Photo showing the 16 x value, 9 y value and known 8° angle of the triangle slice we need to &#39;clip&#39; from our image&#39;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Now we have a triangle where we know 1 side (16 width) and one angle (8°). Digging out my old maths textbooks, I can confirm that we need to use some GCSE trigonometry. To be specific, the phrase &lt;a href=&quot;https://www.mathsisfun.com/algebra/sohcahtoa.html&quot;&gt;&lt;code&gt;SOH CAH TOA&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Effectively, this is mnemonic to remember the 3 ways of working out the sides of a triangle, based on the information you have. We have the &lt;em&gt;Opposite&lt;/em&gt; angle (8°) or &lt;em&gt;O&lt;/em&gt;, the &lt;em&gt;Adjacent&lt;/em&gt; side (16 wide) or &lt;em&gt;A&lt;/em&gt;. O and A means we need to use &lt;em&gt;T&lt;/em&gt; (Tan). Using the formula &lt;code&gt;Tangent = Opposite / Adjacent&lt;/code&gt; (TOA). Algebra time...&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://matthew-jackson.com/assets/algebra.png&quot; alt=&quot;Photo showing the formula Tangent = Opposite / Adjacent with values applied and then the equasion being simplified to its result revealing the 3rd missing side of the triangle as 2.248653355238256&quot;&gt;&lt;/p&gt;
&lt;p&gt;That shows the other unknown side of our triangle is 2.248653355238256 in length. This doesn&#39;t solve our clip-path issue by itself. First we need to get this as a percentage of the whole length of the vertical side (9).&lt;/p&gt;
&lt;p&gt;So, to work out the top angle, we need to divide this by 9 and multiply it by 100%:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;tan&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;8deg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; * &lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt; / &lt;span class=&quot;token number&quot;&gt;9&lt;/span&gt; * &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;%&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the bottom angle, we need to reverse it by taking it away from 100%:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;% - &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tan&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;8deg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; * &lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt; / &lt;span class=&quot;token number&quot;&gt;9&lt;/span&gt; * &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;%&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Unfortunately CSS (or any of it&#39;s preprocessors?) don&#39;t have native trigonometry functions. However, someone already made them! Take a look at the post &lt;a href=&quot;https://unindented.org/articles/trigonometry-in-sass/&quot;&gt;Trigonometry in Sass&lt;/a&gt;. By adding these functions into our code, we can then use the functions in our SCSS. Here&#39;s our final clip-path for our 16x9 image:&lt;/p&gt;
&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token property&quot;&gt;clip-path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;polygon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;0 #&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;tan&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;8deg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; 16 &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; 9 &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; 100%&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 100% 0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 100% #&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;100% &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;tan&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;8deg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; 16 &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; 9 &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; 100%&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0 100%&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here is a Codepen showing the same applied to 16:9, 4:3 and 3:4 aspect ratio images (I&#39;m using &lt;a href=&quot;https://daverupert.com/2012/04/uncle-daves-ol-padded-box/&quot;&gt;Intrinsic Ratios/Uncle Dave&#39;s Ole Padded Box&lt;/a&gt; to maintain the images&#39; aspect ratio):&lt;/p&gt;
&lt;div class=&quot;flex-media flex-media-16x9&quot;&gt;
	&lt;p data-height=&quot;600&quot; data-theme-id=&quot;light&quot; data-slug-hash=&quot;VxKNEV&quot; data-default-tab=&quot;result&quot; data-user=&quot;matthewbeta&quot; data-embed-version=&quot;2&quot; data-pen-title=&quot;Trigonometry Image Skew&quot; class=&quot;codepen&quot;&gt;See the Pen &lt;a href=&quot;https://codepen.io/matthewbeta/pen/VxKNEV/&quot;&gt;Trigonometry Image Skew&lt;/a&gt; by matthew jackson (&lt;a href=&quot;https://codepen.io/matthewbeta&quot;&gt;@matthewbeta&lt;/a&gt;) on &lt;a href=&quot;https://codepen.io/&quot;&gt;CodePen&lt;/a&gt;.&lt;/p&gt;
	&lt;script async=&quot;&quot; src=&quot;https://static.codepen.io/assets/embed/ei.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
&lt;p&gt;Hope that didn&#39;t fry your brain like it did mine.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Sauce + Food</title>
    <link href="http://matthew-jackson.com/blog/sauce-plus-food/"/>
    <updated>2018-05-03T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/sauce-plus-food/</id>
    <content type="html">&lt;p&gt;I recently tried Curry Würst (or tomato sauce with a side of frankfurter and chips). It was disgusting, but got me thinking about sauces.&lt;/p&gt;
&lt;p&gt;This is an unordered list of the best sauce-plus-food combinations. Don&#39;t @ me.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Salad Cream with Lasagne.&lt;/strong&gt; I promise. This is the &lt;em&gt;best&lt;/em&gt; sauce/food combination.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Barbecue Sauce with Fried or Scrambled Eggs.&lt;/strong&gt; This is the only sauce you should have with eggs. Except...&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Chilli Sauce with Eggs (any way).&lt;/strong&gt; Especially Encona Hot Pepper Sauce, Sriracha or Sweet Chilli. Also with Avocado. The chilli sauce should be hot.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Worcestershire Sauce with Cheese and Beans on toast&lt;/strong&gt; This is my comfort food.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;P.S. Also, Bacon should be eaten with Brown Sauce. Not tomato.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Twenty Nineteen A.D.</title>
    <link href="http://matthew-jackson.com/blog/twenty-ninteen-ad/"/>
    <updated>2019-01-01T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/twenty-ninteen-ad/</id>
    <content type="html">&lt;p&gt;I&#39;m not usually into the idea of New Year === fresh start. Its just an arbitrary date in the cosmic scheme of things. However, this year feels
necessarily different.&lt;/p&gt;
&lt;p&gt;2018 was a tough one for me. There are some particular reasons for that and some less easy to put my finger on. Regardless, I am pretty pleased 2018 ended when it did (and good riddance).&lt;/p&gt;
&lt;p&gt;I feel like 2019 will be a more positive year. I don&#39;t do resolutions as that’s an unnecessary pressure to put on yourself. That said, there are definitely things I want to do differently this year. I want to affect my year as much as I can by changing a few habits of my own. To help me I&#39;ve decided to publish an unordered lists of those things.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Be. More. Positive&lt;/li&gt;
&lt;li&gt;See more live art and comedy&lt;/li&gt;
&lt;li&gt;Go on more dates with SH&lt;/li&gt;
&lt;li&gt;Be more understanding of things that irritate me (that includes myself)&lt;/li&gt;
&lt;li&gt;Exercise more&lt;/li&gt;
&lt;li&gt;Eat better and drink better&lt;/li&gt;
&lt;li&gt;Wear shirts&lt;/li&gt;
&lt;li&gt;Read more&lt;/li&gt;
&lt;li&gt;Write more&lt;/li&gt;
&lt;li&gt;Draw&lt;/li&gt;
&lt;li&gt;Be interested&lt;/li&gt;
&lt;li&gt;Focus on things that are in my ability to change or affect&lt;/li&gt;
&lt;li&gt;Worry less about things that I have no control over&lt;/li&gt;
&lt;li&gt;Chew gum&lt;/li&gt;
&lt;li&gt;Meditate if/when I feel like&lt;/li&gt;
&lt;li&gt;Play more&lt;/li&gt;
&lt;li&gt;Get regular haircuts&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Hopefully next year’s list will be shorter.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>This is Going to Hurt - Adam Kay</title>
    <link href="http://matthew-jackson.com/blog/this-is-going-to-hurt-adam-kay/"/>
    <updated>2019-01-02T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/this-is-going-to-hurt-adam-kay/</id>
    <content type="html">&lt;p&gt;Certainly late to the party, but I highly recommend this book - &lt;a href=&quot;http://www.thisisgoingtohurt.co.uk/&quot;&gt;This is Going to Hurt by Adam Kay&lt;/a&gt;. Kay has turned his diary entries into a fantastic book, chronicling his 6(ish) years as a Junior Doctor.&lt;/p&gt;
&lt;p&gt;It made me laugh, cry, and wince. Beautiful, poignant, and important.&lt;/p&gt;
&lt;p&gt;It is &lt;a href=&quot;https://m.imdb.com/title/tt8681148/?ref_=m_nm_knf_t1&quot;&gt;being made into a comedy series for BBC&lt;/a&gt;. I hope they can do it some justice. If they can make it a quarter as affecting as the book, it will be powerful indeed.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Phone Blogging (Phlogging)</title>
    <link href="http://matthew-jackson.com/blog/phone-blogging/"/>
    <updated>2019-01-03T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/phone-blogging/</id>
    <content type="html">&lt;p&gt;So to help me with one of &lt;a href=&quot;https://matthew-jackson.com/notes/twenty-ninteen-ad&quot;&gt;my new year changes&lt;/a&gt; (to blog more frequently), I’ve set up my phone so I can blog without needing my laptop.&lt;/p&gt;
&lt;p&gt;For this setup I needed 2 apps:&lt;/p&gt;
&lt;h2&gt;Working Copy&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://itunes.apple.com/gb/app/working-copy/id896694807?mt=8&quot;&gt;Working Copy&lt;/a&gt; by Anders Borum, is a Git client for iOS. It’s pretty full featured. All I really need though is to edit text and commit/push/pull from my blog Git repo.&lt;/p&gt;
&lt;p&gt;Pushing new changes to the repo kicks off a build on Netlify and my blog is published.&lt;/p&gt;
&lt;p&gt;The editing experience isn’t ideal though. I’d rather use a purpose built text editor. So…&lt;/p&gt;
&lt;h2&gt;iA Writer&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://itunes.apple.com/gb/app/ia-writer/id775737172?mt=8&quot;&gt;iA Writer&lt;/a&gt; by Information Architects is a lovely text editor (and has great Markdown features). It’s available on iOS and MacOS and, importantly for my purposes, I can open/edit/create a document from Working Copy right in iA Writer.&lt;/p&gt;
&lt;h2&gt;Automation &amp;amp; Problems&lt;/h2&gt;
&lt;p&gt;So as I mentioned, my blog auto builds on commit. I also have it setup to cross-post to Medium automatically (if I want). I’ve also got an IFTTT action to tweet new posts when my RSS feed updates.&lt;/p&gt;
&lt;p&gt;So minimal friction. My issue is I want to have a text shortcut to format my YAML front matter at the start of the post MD file. This needs to be formatted like this:&lt;/p&gt;
&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;snippet&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;crosspost_to_medium&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;token boolean important&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;published&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;token boolean important&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I thought I could just setup a text-snippet shortcut in iOS settings, but that doesn’t allow multiple lines. You can set this up on MacOS and it gets shared to all devices by iCloud, but using it on iOS in Notes or Writer crashes the app. Yikes.&lt;/p&gt;
&lt;p&gt;My best solution for now is to have the YAML saved in a note which I can copy and paste in each time. This is kind of gross to me. What I need is to setup some kind of template for Writer that lets me start a post with the front matter already there. Not sure that’s possible though…&lt;/p&gt;
&lt;h2&gt;Phlogging workflow 1.0&lt;/h2&gt;
&lt;p&gt;So my workflow is now:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open Writer&lt;/li&gt;
&lt;li&gt;Create or open a doc in &lt;code&gt;_posts&lt;/code&gt; or &lt;code&gt;_drafts&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Copy and paste my YAML front-matter from a note 🤮&lt;/li&gt;
&lt;li&gt;Write post&lt;/li&gt;
&lt;li&gt;Open Working Copy&lt;/li&gt;
&lt;li&gt;Commit and push&lt;/li&gt;
&lt;li&gt;🍸&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So far it’s working. I’ve blogged every day so far in 2019. I won’t keep that up, but I don’t need to. Just need to get into a more regular rhythm of blogging what I would tweeted.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Matilda</title>
    <link href="http://matthew-jackson.com/blog/matilda/"/>
    <updated>2019-01-04T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/matilda/</id>
    <content type="html">&lt;p&gt;The family went to see Matilda (the musical) at the Wales Millennium Centre (WMC) yesterday afternoon.&lt;/p&gt;
&lt;p&gt;We bought tickets when they went on sale around 2 years ago so it’s been a long wait. TL;DR totally worth it. You should try and see this if you can.&lt;/p&gt;
&lt;p&gt;Firstly, the WMC is such a lovely theatre. I always feel like I’m seated in the inside of a grand piano or a giant ant colony. We also had great seats at the front row of the circle.&lt;/p&gt;
&lt;p&gt;I am not a fan of musicals (generally), but this was really good. A few things really hit me:&lt;/p&gt;
&lt;h2&gt;Theatre design is rad&lt;/h2&gt;
&lt;p&gt;The set design of theatre fascinates me. You have such a limited pallet to use to, not only provide locations for the story, but also to theme the production and tie it all together. Save for a few props, most things are left to The viewer’s imagination and when it’s done well, you don’t need more than that.&lt;/p&gt;
&lt;p&gt;The sets today were perfect, linking together the story, stage dressing and scenes. It was quirky and sometimes unsettling in a way that absolutely makes sense for the story. They also had a lot of small details woven in and even utilised the main theme (books/letters/lettering) to great effect in one of the songs/dances.&lt;/p&gt;
&lt;p&gt;The coming together of all the disparate parts of a show like this; actors, songs, sets, lighting etc is like magic.&lt;/p&gt;
&lt;h2&gt;Story telling&lt;/h2&gt;
&lt;p&gt;Story affects so much of our lives and how we view the world. This is both magical and crazy. Matilda touches on this, directly in one scene.&lt;/p&gt;
&lt;p&gt;Even when we know all the protagonists are made-up, we can’t help but empathise with them. This isn’t an original thought, I know. I was just particularly struck by it yesterday.&lt;/p&gt;
&lt;h2&gt;Child actors&lt;/h2&gt;
&lt;p&gt;The nature of the story dictates that child actors were going to make up a good chunk of the cast. They were all really good. Matilda was especially good (I cant tell you the actors name as I couldn’t find it on the &lt;a href=&quot;https://uk.matildathemusical.com/tour/cast/&quot;&gt;show site&lt;/a&gt;. I can’t imagine they were much older than my eldest daughter. They left me gobsmacked. Bravo 👏🏽.&lt;/p&gt;
&lt;h2&gt;A cyclist&lt;/h2&gt;
&lt;p&gt;On my way back to our car, I stepped out behind a parked van, looked the wrong way and a cyclist hit me full pelt. This was totally my fault. A van then ran over his glasses.&lt;/p&gt;
&lt;p&gt;Thankfully, it appears everyone is fine, save a few cuts and bruises, and some cash. Owen, I’m sorry. I will replace your glasses.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Are you (an) experienced (developer)?</title>
    <link href="http://matthew-jackson.com/blog/are-you-experienced/"/>
    <updated>2019-01-12T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/are-you-experienced/</id>
    <content type="html">&lt;p&gt;What does it mean to be an experienced developer? It definitely doesn’t mean you know how to do everything.&lt;/p&gt;
&lt;p&gt;I think mostly, it means you know how to work out how to build pretty much anything (within reason).&lt;/p&gt;
&lt;p&gt;This came up this week at work when the design team wanted to build a pop up nav. You know the kind where you hover over a link on desktop and you get an extended menu below. A mega-ish-nav.&lt;/p&gt;
&lt;p&gt;Our awesome junior developer immediately thought “yeah looks great”. My spider sense started twitching. These things can look really simple in a comp, but have lots of hidden factors which without experience, you won’t think about until they punch you in the face.&lt;/p&gt;
&lt;p&gt;Generally for developments, I’ll go through a process (either written or sketched or in my head) to check off the following things. This gives me a better understanding of what it will take to build something.&lt;/p&gt;
&lt;h2&gt;Do I need to build anything?&lt;/h2&gt;
&lt;p&gt;Always question whether this is a necessary development for the user or business. This might get you the reputation of being an arsehole, but sometimes it’s not s given that functionality needs to exist. If it doesn’t help anyone, it’s better not to build it.&lt;/p&gt;
&lt;h2&gt;What does it do?&lt;/h2&gt;
&lt;p&gt;Take some time to work out how it works. This will usually involve sitting with the designer and working out what happens in every scenario.&lt;/p&gt;
&lt;p&gt;In our example: What is the expected behaviour when you click the top level links? Should this open the menu, or hyperlink to the next page? If it should hyperlink, how do you access the menu on a tablet? Should you have to manually close the menu, or should it close by clicking off? What is the expected behaviour when we’re in the mobile design? Can I use the same nav, or will they be sufficiently different that we need to have 2? And so on…&lt;/p&gt;
&lt;h2&gt;What’s the semantic/progressive enhanced way to build this?&lt;/h2&gt;
&lt;p&gt;I like to work out how I can build this in HTML. If we need buttons or links for things. What native elements we can use for stuff to make it work with as few moving parts as possible. Ultimately, it should work as a nav without CSS or JS.&lt;/p&gt;
&lt;p&gt;Once I’ve worked out the basic HTML, I like to work through styling and basic JS and how we’re going to build  up the functionality in layers. That means it’ll probably be more robust.&lt;/p&gt;
&lt;h2&gt;What is the accessibility story for this sort of thing?&lt;/h2&gt;
&lt;p&gt;Anything with showing/hiding and navigation will have some form of accessibility concerns to address. As an example, you may think having the menu show/hide when the parent link is hovered/focused, is enough. The issue here would be, if the user wants to get to the last link, they need to tab through every link in every menu to get to it. Therefore you need to allow users to tab over the top level links, and provide a means of them entering the sub-menus. You’ll need to work out what the conventions are for this. Is it using arrow keys? The space bar? How would you announce that to a screen reader? 😫&lt;/p&gt;
&lt;p&gt;You also have to try and figure out what ARIA&lt;sup&gt;*&lt;/sup&gt;spell you need to summon the accessibility gods.&lt;/p&gt;
&lt;p&gt;This stuff is hard. I find it hard to test, and there isn’t always one correct answer. Experience helps you work out what information to trust.&lt;/p&gt;
&lt;p&gt;* &lt;em&gt;ARIA is a standard for helping add accessibility to applications. For example you can show that a button has a popup attached, or that it is expanded etc. It’s bonkers and, confusingly, has weird support among screen readers.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Do I have to build this?&lt;/h2&gt;
&lt;p&gt;So by this stage I’ve probably worked out how much of an arse-ache this will be to make. It’s usually around this time I check if anyone else has made one of these (and made it well).&lt;/p&gt;
&lt;p&gt;You will need to consider plenty of things when deciding if you will use someone else’s code. Is it accessible? Does it meet your functional requirements? Is it well built? Is it going to have performance implications. What’s the compromises (there will be plenty) compared to the time savings. You’ll need to make a call on how much trust you have in the developer. What will the support story be?&lt;/p&gt;
&lt;p&gt;Experience means I trust my judgement more and know better when to lean on third party code, and when to roll my own.&lt;/p&gt;
&lt;h2&gt;How do we build it in the simplest way possible?&lt;/h2&gt;
&lt;p&gt;So you’ve decided to build it your damn self. Good for you! Now you need to plan out how your going to do it. What will you be doing in CSS and what will be JS? Sometimes you can just use JS to change your ARIA attributes and classes for styling. Sometimes, JS will be more involved, for example to manage the tabbing/keyboard functionality.&lt;/p&gt;
&lt;p&gt;Simplest could mean time to build, ease of maintenance, flexibility, or all of the above. I like to do as little as possible. Fewer moving parts generally means easier to build and maintain. It should be as simple as possible, but not simpler.&lt;/p&gt;
&lt;h2&gt;Can I build this so I never have to build it again?&lt;/h2&gt;
&lt;p&gt;Lastly, can I build whatever it is, to be flexible enough and reusable. This way we can put the effort in once and get multiple uses out of the code. In the old days, this might be a jQuery plugin. Now we might make a module or a react component.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I think certainly, all of these things can explain a perceived lack of enthusiasm for building new features.    It definitely means you are better able to estimate the time and effort  it will take. I think this process can be enjoyable… sometimes.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>How Monzo Hire Product Designers</title>
    <link href="http://matthew-jackson.com/blog/how-monzo-hire-product-designers/"/>
    <updated>2019-01-20T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/how-monzo-hire-product-designers/</id>
    <content type="html">&lt;p&gt;On Friday, someone I follow shared a post about the kind of &lt;a href=&quot;https://monzo.com/blog/2019/01/17/monzo-product-designer-jobs/?utm_content=buffer0f188&amp;amp;utm_medium=social&amp;amp;utm_source=twitter&quot;&gt;application process a Product Designer can expect when applying to Monzo&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Over the last three years we’ve hired 11 product designers. And with each new member of the team, we’ve learned something new about how to hire designers.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;For other companies who are starting to scale their design teams, and designers who want to work at Monzo, we thought it’d be valuable to share what our hiring process looks like and the things we look for in a product designer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The process: an application form, a phone interview, a design challenge (which they review with a feedback call), an in-person workshop (with an engineer, a designer and manager), a general interview (with 2 people “disassociated with product or design”).&lt;/p&gt;
&lt;p&gt;This must be expensive and time consuming for the company (none of my business), but also the candidates. I’ll give them the benefit of the doubt and assume they pay for people’s time for the design challenge…&lt;/p&gt;
&lt;p&gt;They say the design challenge will probably take “an evening or two”. The kicker though:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;it’s fine to take as much time as you need to &lt;em&gt;think&lt;/em&gt; about the problem&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Emphasis mine. Here’s what they are expecting for your couple of evenings, plus thinking time:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We’ll send you a brief, and in return we’re looking for an end-to-end design of how you think this could look and work. Your app can be designed for iOS or Android, and we welcome any amount of research that helps you come to your solution. The ultimate result we’re after is a set of functional, polished screens with a clear write-up of how your solution works and the choices you’ve made.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;OK. I wonder how much we would charge for this process at work or how long we would take to do a good job? A couple of evenings is 5ish hours. Seems tight… Either way, we certainly charge for thinking time, because &lt;strong&gt;that’s the job&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Sounds like Monzo want to hire people with time on their hands.&lt;/p&gt;
&lt;p&gt;Does the task give a good insight into your candidates? The issues with design tasks are plentiful. &lt;a href=&quot;https://productmatters.design/hiring-a-product-designer-dont-use-design-exercises-4768235b3da9&quot;&gt;This post by Faruk Ates&lt;/a&gt; articulates a lot of the issues with design tasks, better than I am able to.&lt;/p&gt;
&lt;p&gt;I can’t help feeling the time and effort being asked of candidates (and Monzo) seems to be to avoid hiring the wrong person, rather than the right one.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>True Blue Bollocks</title>
    <link href="http://matthew-jackson.com/blog/true-blue-bollocks/"/>
    <updated>2021-01-31T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/true-blue-bollocks/</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;https://www.theguardian.com/football/blog/2021/jan/30/thomas-tuchel-not-true-blue-chelsea-frank-lampard&quot;&gt;Jonathon Wilson in The Guardian&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;He is one of the world’s brightest coaching prospects, but he is not Lampard. He does not ooze “Chelseaness”. Worse, he arrives as an ascetic vegan intellectual into a world that has had quite enough of experts, as a German when the German authorities have doubted “Britain’s” brave vaccine.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The vast majority of fans will be sad that Lampard didn’t work out. Some will be sad but feel it’s for the best. Some will feel he wasn’t given enough time. I don’t see how that will make Tuchel the villain by default.&lt;/p&gt;
&lt;p&gt;Any hostile reception to the new regime at Chelsea will be directed at the board (or possibly players). I think most fans think Thomas Tuchel is probably fine. If he had replaced almost any other manager he would been greeted with the usual mix of trepidation and excitement (believe me we are used to new managers). As long as the football is not boring, the kids get a chance, and the results are reasonable, he’ll be fine. Just like any manager.&lt;/p&gt;
&lt;p&gt;I keep hearing similar sentiments regarding either fans won’t like him because they’re xenophobic knuckle dragging idiots. “Will they accept a vegan with a brain?”. I’m also hearing it’ll be like Sarri and he’ll get a massive backlash. Presumably because the hipster football writer thinks that the problem with Sarri was that he had a cultured footballing philosophy and Chelsea fans are philistines, who only like direct, stick-it-up-to-the-big-man football.&lt;/p&gt;
&lt;p&gt;Firstly, if any fan base are used to having (and loving) foreign managers and players, it’s Chelsea so I’m not sure where the xenophobic angle comes from (narrator: he was sure it comes from lazy journalism).&lt;/p&gt;
&lt;p&gt;Second, Sarri was disliked because the football was turgid, and it did not produce good results. We finished 3rd
In a poor season and did everything we  could to finish outside the top 4. We were (just about) the least shit of the other 18 teams outside of City and Liverpool.&lt;/p&gt;
&lt;p&gt;Yes we won a trophy. In the Europa League campaign, we only played 270 minutes against any kind of genuine opposition (if you are kind enough to include Arsenal in that). Without a generational player bailing us out every other week, his season would have been very different.&lt;/p&gt;
&lt;p&gt;The press would love us to implode again, because Chelsea drama fills a lot of word counts. I’m just not sure it’s justified here.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Using Apple&#39;s New York font in CSS</title>
    <link href="http://matthew-jackson.com/blog/using-apples-new-york-font-in-css/"/>
    <updated>2021-02-11T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/using-apples-new-york-font-in-css/</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;#code&quot;&gt;I don&#39;t care, Matt. Show me the code&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Had a bit of a spring clean on the old web log this week. I wanted to keep things speedy, but wanted to mix up the fonts a bit.&lt;/p&gt;
&lt;p&gt;I&#39;ve been using system fonts for a while, as I really like Apple&#39;s San-Francisco font and I like the fact thats its nice a quick as no files to download (sorry if your are on Windows). Recently(ish) Apple introduced a serif sister font to San Francisco, New York, which I also like.&lt;/p&gt;
&lt;p&gt;Using San Francisco requires a bit of a hacky method to use it on the web:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; -apple-system&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; BlinkMacSystemFont&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Helvetica Neue&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Helvetica&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Arial&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sans-serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a id=&quot;code&quot;&gt;Using New York is basically the same:&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; -apple-system-ui-serif&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ui-serif&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Georgia&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I&#39;ve also added a style block in the head, where I can insert custom CSS within the post front-matter. In this one, I&#39;ve set the headings to also use New York. 🤝&lt;/p&gt;
&lt;h2&gt;Update - SF Mono is pretty easy to add too 🤖&lt;/h2&gt;
&lt;p&gt;Its the same principle. Here&#39;s my new code font stack:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ui-monospace&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; SFMono-Regular&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ui-monospace&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Monaco&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Andale Mono&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Ubuntu Mono&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; monospace&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>Adding your latest post to your homepage in Eleventy</title>
    <link href="http://matthew-jackson.com/blog/adding-latest-post-homepage-eleventy/"/>
    <updated>2021-02-15T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/adding-latest-post-homepage-eleventy/</id>
    <content type="html">&lt;p&gt;This weekend I wanted to add my most recent blog post to my homepage. I googled how to do it but couldn&#39;t find the cut and paste code I wanted, so here it is.&lt;/p&gt;
&lt;p&gt;In your &lt;code&gt;index.njk&lt;/code&gt; or &lt;code&gt;index.liquid&lt;/code&gt; file, you&#39;ll need to get your most recent post like this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt; posts &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; collections&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;blog &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; reverse &lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt; post &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; posts&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You may need to change &lt;code&gt;collections.blog&lt;/code&gt; to whatever your collection is. You can the output anything from your post variable. I&#39;m using a snippet, but you could output the whole post. You do you!&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Developer has mixed opinions about technology</title>
    <link href="http://matthew-jackson.com/blog/developer-has-mixed-opinions-tailwind/"/>
    <updated>2021-02-16T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/developer-has-mixed-opinions-tailwind/</id>
    <content type="html">&lt;p&gt;Trevor Davis:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;So as a reluctant grump old web developer who has finally given Tailwind a chance, here are a few thoughts on what I love and hate about it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Excuse the title. I can&#39;t tell you how nice it is to read a balanced post about &lt;em&gt;anything&lt;/em&gt; on the internet 👏.&lt;/p&gt;
&lt;p&gt;If you think a technology generating as much traction and controversy as Tailwind is either good or bad, you are being a bit silly. I would much rather read a nuanced opinion and understand what the grey areas are.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Heroicons by Tailwind</title>
    <link href="http://matthew-jackson.com/blog/hero-icons/"/>
    <updated>2021-02-16T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/hero-icons/</id>
    <content type="html">&lt;p&gt;Speaking of Tailwind, they have a cool icon repository now (although it looks like there was a &amp;quot;classic&amp;quot; version so maybe they&#39;ve done them forever). Easily just cut and paste the SVG code from your browser.&lt;/p&gt;
&lt;p&gt;This is my favourite way to add icons, because its so much simpler than any other method, but also you can style and animate them. Its odd there are no social icons included. The Twitter and Github icons on the site seem like they are the same format and size... 👀&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Fewer Favicons</title>
    <link href="http://matthew-jackson.com/blog/fewer-favicons/"/>
    <updated>2021-02-18T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/fewer-favicons/</id>
    <content type="html">&lt;p&gt;Andrey Sitnik&#39;s post on &lt;a href=&quot;https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs&quot;&gt;how to favicon in 2021&lt;/a&gt; is right up my street as ostensibly its a lot less faff than doing all of the files we make as standard.&lt;/p&gt;
&lt;p&gt;Weirdly this was on my mind this week as we are beginning to modernise our dev workflow &lt;a href=&quot;https://bluegg.co.uk/&quot;&gt;at the office&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I&#39;m not sure for most of the work I do (websites) that anything more than a &lt;code&gt;favicon.ico&lt;/code&gt; is really necessary. However, I do like the idea of making sure things are finished nicely (like a cabinet maker caring what the back of the unit looks like).&lt;/p&gt;
&lt;p&gt;Mostly our icon generation isn&#39;t manual; we use &lt;a href=&quot;http://realfavicongenerator.net/&quot;&gt;The Real Favicon Generator&lt;/a&gt;, integrated with our build step. Seen as favicons are usually a set it and forget it deal, this new way is actually a little bit more cumbersome. I like the simplicity of it though, and I like the idea of providing light and dark icons via SVG with a media query in it.&lt;/p&gt;
&lt;p&gt;Maybe time to write a little Node CLI...&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>I don&#39;t miss the office</title>
    <link href="http://matthew-jackson.com/blog/i-dont-miss-the-office/"/>
    <updated>2021-02-18T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/i-dont-miss-the-office/</id>
    <content type="html">&lt;p&gt;I love this essay by Paul Ford. I just don&#39;t love &lt;em&gt;going&lt;/em&gt; to work. This quote is absolutely me:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;And I find that the people who don’t want to go back to pre-pandemic office culture are the people who are the most concerned about their time. Sometimes this is their personality; they are engineers who look at travel as a waste, who seek efficiencies in their work and health. Sometimes they’re people with other stress, like parents of young children who triangulate between the day care’s schedule, their boss’s expectations, and kids’ needs...&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The idea of sitting in my car for 2 hours to get to another room and do the same thing I can do at home feels like madness.&lt;/p&gt;
&lt;p&gt;I love my job, I love the people I work with. I also love working from home.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>SmolCSS - modern css snippets</title>
    <link href="http://matthew-jackson.com/blog/smol-css-small-snippets/"/>
    <updated>2021-02-18T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/smol-css-small-snippets/</id>
    <content type="html">&lt;p&gt;Interesting and handy. Bookmarked.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Webcams are bad. iPhone cameras are good</title>
    <link href="http://matthew-jackson.com/blog/webcams-are-bad-iphone-cameras-are-good/"/>
    <updated>2021-02-19T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/webcams-are-bad-iphone-cameras-are-good/</id>
    <content type="html">&lt;p&gt;Reincubate are the makers of Camo, an app which lets you use your iPhone as a webcam. This is a good rundown of how and why webcams are always bad.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;After consulting numerous webcam buying guides and reviews, purchasing a handful of the most popular models, and testing them in varying lighting situations, I can&#39;t escape the grim truth: there are no good webcams. Even webcams recommended by reputable outlets produce poor quality imagery—a significant failing, given it’s the one job they&#39;re supposed to provide.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;True story, 2 weeks ago, I bought a webcam. I didn&#39;t want to spend loads. I read through a lot of reviews and ended up spending £50 on a Logitech one. It was awful and I returned it the next day. I used the money to buy a phone stand for my desk.&lt;/p&gt;
&lt;p&gt;I was on Camo&#39;s beta over the summer and really liked it, then completely forgot about it. The free tier is perfectly good enough for me and the faff of having to plug my phone in and put it in a stand is worth it for the picture quality.&lt;/p&gt;
&lt;p&gt;The kicker:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Apple&#39;s research and development budget over six months is more than Logitech&#39;s gross yearly revenue, because Apple realized that the iPhone&#39;s camera could be a serious competitive advantage.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
  </entry>
  
  <entry>
    <title>Scabs</title>
    <link href="http://matthew-jackson.com/blog/scabs/"/>
    <updated>2021-04-19T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/scabs/</id>
    <content type="html">&lt;p&gt;You could make the argument that the outpouring of emotion and vitriol about the announcement yesterday is misplaced or disproportionate. Given everything that is wrong in the world, sport doesn&#39;t matter.&lt;/p&gt;
&lt;p&gt;But that is to say a shared history, relationships, culture, don&#39;t matter. I&#39;ve supported Chelsea for nearly 30 years. Those 3 decades are like a long relationship. Memories, friendships, family connections, some to people who are no longer alive. All in the bin because some very rich men want to have more money.&lt;/p&gt;
&lt;p&gt;It is obvious that fans mean little to big clubs. Supporters only recourse is to vote with their feet and boycott games. Assuming all fans refused to return (unlikely due to the tourists and corporate seats) why would the clubs care? In 2018/19, the last season Chelsea played a full campaign in front of supporters, their match day revenue was &lt;a href=&quot;https://www.statista.com/statistics/251147/revenue-of-fc-chelsea-london-by-stream/&quot;&gt;75 million euros&lt;/a&gt;. Reportedly every club involved in the super league will earn &lt;a href=&quot;https://www.nytimes.com/2021/04/18/sports/soccer/super-league-united-liverpool-juventus-madrid.html&quot;&gt;400 million euros&lt;/a&gt;. Why would a largely faceless corporation give a fuck about losing supporters?&lt;/p&gt;
&lt;p&gt;I&#39;m currently angry, and disappointed, and sad, but cynically, not that surprised. I&#39;m not sure what will happen when the dust settles on all of this, but the genie is very much out of the bottle.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Mobs</title>
    <link href="http://matthew-jackson.com/blog/mobs/"/>
    <updated>2021-04-20T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/mobs/</id>
    <content type="html">&lt;p&gt;Mob handed, people can achieve anything.&lt;/p&gt;
&lt;p&gt;Never forget.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>I am return</title>
    <link href="http://matthew-jackson.com/blog/i-am-return/"/>
    <updated>2022-09-26T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/i-am-return/</id>
    <content type="html">&lt;p&gt;I’m back. Not now. But soon. After 2 and a half years of the world ending, I&#39;m now ready to get my shit together. I’ve got big plans to write more. I’m working on replacing tweeting and insta with some kind of easy micro blogging. I’ve started work on a &lt;a href=&quot;http://matthew-jackson.com/bookshelf&quot;&gt;bookshelf&lt;/a&gt;. I’ve done some dev and shortcuts tinkering to remove publishing friction. For now though… I’m back. Soon...&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>the beauty of standing still</title>
    <link href="http://matthew-jackson.com/blog/the-beauty-of-standing-still/"/>
    <updated>2022-09-29T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/the-beauty-of-standing-still/</id>
    <content type="html">&lt;p&gt;I largely missed/avoided needing to build any single page applications. I didn’t reframe my entire perspective on websites to JavaScript first. It feels like the pendulum swung as far that way as it could and has now swung back. Server rendering is important again. Now it’s called rendering on “the edge”. It sounds cool.&lt;/p&gt;
&lt;p&gt;It’s nice that things move and evolve. Change is inevitable. I’m not sure much of what I built in the last 5 years would have been better as a single page app though. I’m not sure much of what I’m building now would be better rendered on the edge. I am pretty sure that sending HTML down the wire, making it look good with CSS and making it do stuff with JS is the past, present and future.&lt;/p&gt;
&lt;p&gt;If you stand still long enough everyone catches up eventually.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>The Exclusive Design Principles</title>
    <link href="http://matthew-jackson.com/blog/the-exclusive-design-principles/"/>
    <updated>2022-11-08T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/the-exclusive-design-principles/</id>
    <content type="html">&lt;p&gt;This post resonated with me. Some great points, like designing for one person. I especially love the  “Add nonsense” principle.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;So in order to break out of the antiquated idea that designing for accessibility is a form of charity, I always use the principle that you need to add nonsense to the design process as well.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;More nonsense please.&lt;/p&gt;
&lt;p&gt;It also got me thinking about people who experience the web in a different way to me and how we could bring that nonsense and whimsy to them.&lt;/p&gt;
&lt;p&gt;I’ve often thought about how we could create experiences that were not just equal, but different. A user experience that is great for screen readers, with its own unique characteristics and capacity for surprise and delight. For example a unique experience for users of screen readers using the &lt;a href=&quot;https://www.w3.org/TR/css-speech-1/#voice-char-props&quot;&gt;CSS Speech module&lt;/a&gt; maybe.&lt;/p&gt;
&lt;p&gt;I guess first we need to make sure the things we build are baseline functional. However it feels like a whole world to be explored.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Change and hope</title>
    <link href="http://matthew-jackson.com/blog/change/"/>
    <updated>2024-07-10T00:00:00-00:00</updated>
    <id>http://matthew-jackson.com/blog/change/</id>
    <content type="html">&lt;p&gt;It feels like a new years resolution vibe for me at the moment. So much is changing in and around me. Enough good, that I am hopeful fo rthe first time in a while. I feel excited, positive, and uneasy with it all. Stressed and anxious.&lt;/p&gt;
&lt;p&gt;On the positive fronts, a new government. I am no huge fan of Starmer but have been holding out hope the (small c) conservative approach to the party&#39;s election campaign, has merely been to not rock the boat and to ensure they get into power. There are small signs of a more progressive and radical approach based on some of the appointments, if not the rhetoric. I will take actionsover words any day.&lt;/p&gt;
&lt;p&gt;I&#39;ve also agreed to take part in a 10k run in 8 weeks which has forced me to get off my arse and start training. Combined with gettign back on my bike for the bi-weekly commute to Cardiff, and continuing with the bi-weekly visit to the climbing gym, I&#39;m hopeful of shifting into some kind of shape in the coming months.&lt;/p&gt;
&lt;p&gt;A challenging year at work in a difficult market is hopefully turning a corner. Many things to fix and overcome but I&#39;m hoping we can all be buoyed by a sense that something good is round the corner.&lt;/p&gt;
&lt;p&gt;And so back to the blog, where I&#39;m hopeful I can change the pattern of short burst of activity followed by years of neglect.&lt;/p&gt;
&lt;p&gt;We shall see on all of the above.&lt;/p&gt;
</content>
  </entry>
</feed>