<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.5">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2024-06-30T12:23:32+00:00</updated><id>/feed.xml</id><title type="html">Danny Weeks Blog</title><subtitle>Personal website and blog moved to GitHub Pages</subtitle><entry><title type="html">Muse 30 Day Song Challenge (Complete)</title><link href="/my-thoughts/2016/04/18/muse-30-day-song-challenge.html" rel="alternate" type="text/html" title="Muse 30 Day Song Challenge (Complete)" /><published>2016-04-18T00:00:00+00:00</published><updated>2016-04-18T00:00:00+00:00</updated><id>/my-thoughts/2016/04/18/muse-30-day-song-challenge</id><content type="html" xml:base="/my-thoughts/2016/04/18/muse-30-day-song-challenge.html"><![CDATA[<p>I was browsing the <a href="https://reddit.com/r/muse">/r/muse</a> subreddit and came across a fun Muse <a href="http://seirius.tumblr.com/post/140926951763/muse-30-day-song-challenge">‘30 Day Song Challenge’</a>. It reminded me of back in the day when you would answer loads of questions and then forward it on or tag friends.</p>

<p>Anyway I thought it would be fun! I’m impatient and just did the lot in one go!</p>

<p><a class="button small spoiler-toggle">Toggle Spoilers</a></p>

<h3 id="the-song-that-got-you-into-muse">The song that got you into Muse</h3>

<p><span class="spoiler">
    <strong>Plug In Baby</strong>
</span></p>

<h3 id="the-song-that-makes-you-happiest">The song that makes you happiest</h3>

<p><span class="spoiler">
    <strong>Glorious</strong>
</span></p>

<h3 id="the-song-youd-want-opening-the-film-of-your-life">The song you’d want opening the film of your life</h3>

<p><span class="spoiler">
    <strong>MK Ultra</strong>
</span>, just like the start of my <a href="/blog/2016/03/08/dream-muse-setlist">dream setlist</a></p>

<h3 id="the-song-youd-want-closing-the-film-of-your-life">The song you’d want closing the film of your life</h3>

<p><span class="spoiler">
    <strong>Starlight</strong>
</span></p>

<h3 id="the-song-that-gives-you-goosebumps">The song that gives you goosebumps</h3>

<p><span class="spoiler">
    <strong>Isolated System</strong>
</span></p>

<h3 id="the-song-you-didnt-like-at-first-but-love-now">The song you didn’t like at first, but love now</h3>

<p><span class="spoiler">
    <strong>Animals</strong>
</span></p>

<h3 id="the-song-thats-your-guilty-pleasure">The song that’s your guilty pleasure</h3>

<p><span class="spoiler">
    <strong>I Belong To You</strong>
</span></p>

<h3 id="the-song-you-can-fall-asleep-to">The song you can fall asleep to</h3>

<p>Any but if I had to pick one… 
<span class="spoiler">
    <strong>Isolated System</strong>
</span></p>

<h3 id="the-song-that-makes-you-want-to-dance">The song that makes you want to dance</h3>

<p><span class="spoiler">
    <strong>Panic Station</strong>
</span></p>

<h3 id="the-song-youd-recommend-to-someone-thats-never-listened-to-muse">The song you’d recommend to someone that’s never listened to Muse</h3>

<p>It really depends on the person but maybe <span class="spoiler">
    <strong>Plug In Baby</strong>
</span></p>

<h3 id="your-favourite-live-performance">Your favourite live performance</h3>

<p><span class="spoiler">
    <strong>Dead Star</strong>
</span></p>

<h3 id="the-song-that-youve-always-wanted-to-hear-them-play-live">The song that you’ve always wanted to hear them play live</h3>

<p><span class="spoiler">
    <strong>The Small Print</strong>
</span></p>

<h3 id="the-song-you-wish-you-could-play">The song you wish you could play</h3>

<p><span class="spoiler">
    <strong>The Handler</strong>
</span></p>

<h3 id="the-song-that-tells-your-favourite-story">The song that tells your favourite story</h3>

<p><span class="spoiler">
    <strong>Resistance</strong>
</span></p>

<h3 id="your-favourite-music-video">Your favourite music video</h3>

<p><span class="spoiler">
    <strong>Mercy or Isolated System</strong>
</span></p>

<h3 id="the-song-that-holds-a-lot-of-meaning-to-you">The song that holds a lot of meaning to you</h3>

<p><span class="spoiler">
    <strong>Dead Star</strong>
</span></p>

<h3 id="the-song-you-just-dont-like">The song you just don’t like</h3>

<p><span class="spoiler">
    <strong>Drones or Soldier’s Poem</strong>
</span></p>

<h3 id="the-song-youve-listened-to-the-most">The song you’ve listened to the most</h3>

<p><span class="spoiler">
    <strong>The Small Print or Sunburn</strong>
</span></p>

<h3 id="the-song-youre-currently-obsessed-with">The song you’re currently obsessed with</h3>

<p><span class="spoiler">
    <strong>The Handler</strong>
</span></p>

<h3 id="the-song-with-the-best-lyrics">The song with the best lyrics</h3>

<p><span class="spoiler">
    <strong>Animals</strong>
</span></p>

<h3 id="the-song-with-the-worst-lyrics">The song with the worst lyrics</h3>

<p><span class="spoiler">
    <strong>Pink Ego Box</strong>
</span></p>

<h3 id="the-song-youd-want-to-dance-to-at-your-wedding">The song you’d want to dance to at your wedding</h3>

<p><span class="spoiler">
    <strong>Invincible</strong>
</span></p>

<h3 id="the-song-you-listen-to-when-youre-angry">The song you listen to when you’re angry</h3>

<p><span class="spoiler">
    <strong>Bliss</strong>
</span></p>

<h3 id="your-favourite-cover">Your favourite cover</h3>

<p><span class="spoiler">
    <strong>Please Please Please, Let Me Get What I Want</strong>
</span></p>

<h3 id="your-favourite-acoustic-version">Your favourite acoustic version</h3>

<p><span class="spoiler">
    <strong>Sing For Absolution</strong>
</span></p>

<h3 id="your-favourite-remix">Your favourite remix</h3>

<p><span class="spoiler">
    <strong>Follow Me - Jacques Lu Cont’s Thin White Duke Mix or Isolated System (Adven Remix)</strong>
</span></p>

<h3 id="the-song-you-listen-to-when-youre-sad">The song you listen to when you’re sad</h3>

<p>Anything I can get lost in, currently <span class="spoiler">
    <strong>The Globalist</strong>
</span></p>

<h3 id="your-favourite-b-side">Your favourite b-side</h3>

<p><span class="spoiler">
    <strong>Glorious</strong>
</span></p>

<h3 id="the-song-that-always-gets-stuck-in-your-head">The song that always gets stuck in your head</h3>

<p><span class="spoiler">
    <strong>Unsustainable</strong>
</span></p>

<h3 id="the-song-youd-love-to-hear-them-cover">The song you’d love to hear them cover</h3>

<p><span class="spoiler">
    <strong>A Linkin Park song, maybe Without You</strong>
</span></p>

<p><a class="button small spoiler-toggle">Toggle Spoilers</a></p>]]></content><author><name></name></author><category term="my-thoughts" /><category term="muse" /><summary type="html"><![CDATA[I was browsing the /r/muse subreddit and came across a fun Muse ‘30 Day Song Challenge’. It reminded me of back in the day when you would answer loads of questions and then forward it on or tag friends.]]></summary></entry><entry><title type="html">If It’s Bad Stop Watching</title><link href="/film-tv/2016/03/28/if-its-bad-stop-watching.html" rel="alternate" type="text/html" title="If It’s Bad Stop Watching" /><published>2016-03-28T00:00:00+00:00</published><updated>2016-03-28T00:00:00+00:00</updated><id>/film-tv/2016/03/28/if-its-bad-stop-watching</id><content type="html" xml:base="/film-tv/2016/03/28/if-its-bad-stop-watching.html"><![CDATA[<p>As the season approaches where TV returns to our screens it has made me think about what I am excited to watch and what has become more of a chore.</p>

<!--more-->

<p><strong>Have no fear; no <a href="/blog/2014/06/19/spoilers-you-have-no-right/">spoilers</a> here.</strong></p>

<p>In general my take on watching new films and TV shows is quite cut throat. If a film hasn’t caught me by 30 minutes in I will turn it off. A controversial victim to that soft rule was Anchorman. After hearing so much about it we threw it on and 30 minutes in I just wasn’t enjoying it. So it got scrapped.</p>

<p>I will give a new TV show a little more wiggle room; a very fair amount of time to hook me as they are longer in general. I will take a slow start and amazing character developments over blow things up to get me hooked quickly every time. For example watching the first episode of The Wire isn’t enough to take in how good it really is. There isn’t a number of episodes but if a show hasn’t got me after some time it’s time to throw in the towel which is what happened to Sense 8.</p>

<p>You have to be careful not to get stuck in the trap of being hooked into a series. The little fuckers tease you for 38 minutes and then the last two minutes is filled with everything you have been waiting for. Then it goes off so you let Netflix play the next episode. Sense 8 got us with this then we realised not much was happening for the majority of the show.</p>

<p><img src="/images/uploads/2016/03/dont-care.gif" alt="" /></p>

<p>Game Of Thrones is amazing at this, I have realised this even more recently after finally getting round to watching Vikings (more on this later). It teases all through the season then the second to last episode something finally happens.</p>

<p>So what do we do when we have been watching something for years and then it starts getting bad?</p>

<p>2015 was a bad year for a lot of the shows I have been watching. I think that the majority of people will continue to watch shows as they perpetually get worse and worse as they have invested all that time into them. I take the opposite stance. Cut all ties and not waste any more time on it.</p>

<p>The Walking Dead is the most recent casualty to be cut from my ‘Watching’ list after it has just become repetitive and fails to deliver anything interesting. It lost me half way through season 5 and I haven’t looked back. The zombie thing has been done now and any draw it has on me is countered it’s repetitive stories/themes.</p>

<p><img src="/images/uploads/2016/03/boring.gif" alt="" /></p>

<p>If a show has been good up until one point I will give it the benefit of the doubt. It has a season to redeem itself. Orange Is The New Black and Game Of Thrones both fall into this category this year.</p>

<p>Another trap to fall into which is often the case with a show that has established itself (such as Game Of Thrones and The Walking Dead) is the idea of the show becoming better than the actual show you are sitting down and watching. When you think of Game Of Thrones how would you describe it? epic in terms of scale, shocking, unpredictable, visually gorgeous. While all these are true to get these moments you have to sit through hours of build up and useless dialogue.</p>

<p>So in conclusion: if something gets bad and you stop enjoying it do yourself a favour; stop watching it. Put something else on. Marco Polo and Vikings are brilliant replacements if Game Of Thrones fails to deliver this year.</p>]]></content><author><name></name></author><category term="film-tv" /><summary type="html"><![CDATA[As the season approaches where TV returns to our screens it has made me think about what I am excited to watch and what has become more of a chore.]]></summary></entry><entry><title type="html">Repositories In Laravel</title><link href="/web-dev/2016/03/10/repositories-in-laravel.html" rel="alternate" type="text/html" title="Repositories In Laravel" /><published>2016-03-10T00:00:00+00:00</published><updated>2016-03-10T00:00:00+00:00</updated><id>/web-dev/2016/03/10/repositories-in-laravel</id><content type="html" xml:base="/web-dev/2016/03/10/repositories-in-laravel.html"><![CDATA[<p>Amazingly the first commit to the <a href="https://github.com/dannyweeks/laravel-base-repository">laravel-base-repository</a> was way back in December 2014. This was really just a way of me storing it for reuse rather than it being a package. It was just the basics; mainly get type requests but they haven’t changed much since.</p>

<p>Back in October last year I decided to update it and publish it as a <a href="https://getcomposer.org/">composer</a> package.</p>

<h2 id="version-1-has-landed">Version 1 has landed!</h2>

<p>With Version 1 ten methods are provided out of the box. These methods assume the most common use case by default. An example of this is the default column fetching by column name is <code class="language-plaintext highlighter-rouge">slug</code>.</p>

<p>Looking at the the repository from a <a href="https://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD</a> prospective the methods can be categorised into the following areas:</p>

<h4 id="create">Create</h4>
<ul>
  <li><code class="language-plaintext highlighter-rouge">create(array $data);</code></li>
</ul>

<h4 id="read">Read</h4>
<ul>
  <li><code class="language-plaintext highlighter-rouge">getById($id);</code></li>
  <li><code class="language-plaintext highlighter-rouge">getItemByColumn($term, $column = 'slug');</code></li>
  <li><code class="language-plaintext highlighter-rouge">getActively($term, $column = 'slug');</code> *</li>
  <li><code class="language-plaintext highlighter-rouge">getAll($columns = null, $orderBy = 'created_at', $sort = 'DECS');</code></li>
  <li><code class="language-plaintext highlighter-rouge">getPaginated($paged = 15, $orderBy = 'created_at', $sort = 'DECS');</code></li>
  <li><code class="language-plaintext highlighter-rouge">getForSelect($data, $key = 'id', $orderBy = 'created_at', $sort = 'DECS');</code> **</li>
  <li><code class="language-plaintext highlighter-rouge">getCollectionByColumn($term, $column = 'slug');</code></li>
</ul>

<h4 id="update">Update</h4>
<ul>
  <li><code class="language-plaintext highlighter-rouge">updateOrCreate(array $identifiers, array $data);</code> ***</li>
</ul>

<h4 id="delete">Delete</h4>
<ul>
  <li><code class="language-plaintext highlighter-rouge">delete($id);</code></li>
</ul>

<p><small></small></p>

<p>* If <code class="language-plaintext highlighter-rouge">$term</code> is numeric it assumes it is an ID; otherwise search by column.</p>

<p>** Returns array where key is the row id &amp; value is the data requested. Intended for use in a &lt;select&gt; element.</p>

<p>** Standard update is usually done on a model item itself.</p>

<p>&lt;/small&gt;</p>

<h2 id="how-to-use">How To Use</h2>

<p>Taking advantage of the base repository couldn’t be easier!</p>

<p>After installing using <a href="https://getcomposer.org/">Composer</a> <code class="language-plaintext highlighter-rouge">composer require dannyweeks/laravel-base-repository</code> it’s just a case of creating your repositories.</p>

<p>All that is necessary is have you repository extend the <code class="language-plaintext highlighter-rouge">BaseEloquentRepository</code> class and set the <code class="language-plaintext highlighter-rouge">model</code> property to a string representation of the eloquent class you want the repository to represent.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>

<span class="kn">namespace</span> <span class="nn">App\Repositories</span><span class="p">;</span>

<span class="kd">class</span> <span class="nc">PostRepository</span> <span class="k">extends</span> <span class="err">\</span><span class="nc">Weeks\Laravel\Repositories\BaseEloquentRepository</span>
<span class="p">{</span>
    <span class="k">protected</span> <span class="nv">$model</span> <span class="o">=</span> <span class="err">\</span><span class="nc">App\Models\Post</span><span class="o">::</span><span class="n">class</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Now creating a new repository gives you access to the base methods.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$postsRepo</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">PostRepository</span><span class="p">();</span>
<span class="nv">$post</span> <span class="o">=</span> <span class="nv">$postsRepo</span><span class="o">-&gt;</span><span class="nf">getById</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> <span class="c1">// Fetched post with id of 1.</span>
</code></pre></div></div>

<h2 id="use-case-example">Use Case Example</h2>

<p>Using the repository we created above how could we use it? Lets picture our <code class="language-plaintext highlighter-rouge">PostsController</code>.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span> 

<span class="kn">namespace</span> <span class="nn">App\Http\Controllers</span><span class="p">;</span>

<span class="kn">use</span> <span class="nc">App\Models\Post</span><span class="p">;</span>
<span class="kn">use</span> <span class="nc">App\Repositories\PostRepository</span><span class="p">;</span>

<span class="kd">class</span> <span class="nc">PagesController</span> <span class="kd">extends</span> <span class="nc">Controller</span>
<span class="p">{</span>
    <span class="k">protected</span> <span class="nv">$posts</span><span class="p">;</span>

    <span class="k">public</span> <span class="k">function</span> <span class="n">__construct</span><span class="p">(</span><span class="kt">PostRepository</span> <span class="nv">$posts</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="n">posts</span> <span class="o">=</span> <span class="nv">$posts</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="k">public</span> <span class="k">function</span> <span class="n">index</span><span class="p">()</span>
    <span class="p">{</span>
        <span class="nv">$posts</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="n">posts</span><span class="o">-&gt;</span><span class="nf">getAll</span><span class="p">();</span>

        <span class="c1">// Or if we wanted to paginate the posts collection we could use </span>
        <span class="c1">// $posts = $this-&gt;posts-&gt;getPaginated();</span>

        <span class="k">return</span> <span class="nf">view</span><span class="p">(</span><span class="s1">'posts.index'</span><span class="p">,</span> <span class="nb">compact</span><span class="p">(</span><span class="s1">'posts'</span><span class="p">));</span>
    <span class="p">}</span>

    <span class="k">public</span> <span class="k">function</span> <span class="n">show</span><span class="p">(</span><span class="nv">$id</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="nv">$post</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="n">posts</span><span class="o">-&gt;</span><span class="nf">getById</span><span class="p">(</span><span class="nv">$id</span><span class="p">);</span>

        <span class="k">return</span> <span class="nf">view</span><span class="p">(</span><span class="s1">'posts.show'</span><span class="p">,</span> <span class="nb">compact</span><span class="p">(</span><span class="s1">'post'</span><span class="p">));</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>

<p>As you can see it is very clean to access the repository and it provides the benefit of using its default parameters such as not having to specify what we want the posts on our index page to be ordered by the date they were created starting with the most recent.</p>

<h2 id="relationships">Relationships</h2>

<p>Early on in the development of this base repository I had to figure out how to include relationships such as the author of the post etc. The first choice (and obvious one in retrospect) was to either eagerly load relationships or have the developer choose what to load.</p>

<p>I came up with a solution which I think covers all bases.</p>

<p>After defining the relationships in the repository <code class="language-plaintext highlighter-rouge">protected $relationships = ['comments', 'author', 'tags'];</code> you can include them in three different ways.</p>

<h3 id="grab-em-all">Grab ‘Em All</h3>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$postsRepo</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">PostRepository</span><span class="p">();</span>
<span class="nv">$post</span> <span class="o">=</span> <span class="nv">$postsRepo</span><span class="o">-&gt;</span><span class="n">with</span><span class="o">-&gt;</span><span class="p">(</span><span class="s1">'all'</span><span class="p">)</span><span class="o">-&gt;</span><span class="nf">getById</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> 
</code></pre></div></div>

<p>This eagerly loads all the relationships defined in the repository’s <code class="language-plaintext highlighter-rouge">$relationships</code> property.</p>

<h3 id="just-the-one">Just The One</h3>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$postsRepo</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">PostRepository</span><span class="p">();</span>
<span class="nv">$post</span> <span class="o">=</span> <span class="nv">$postsRepo</span><span class="o">-&gt;</span><span class="n">with</span><span class="o">-&gt;</span><span class="p">(</span><span class="s1">'author'</span><span class="p">)</span><span class="o">-&gt;</span><span class="nf">getById</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> 
</code></pre></div></div>

<p>Providing a string (with the exception of all) will attempt to load that relationship. E.g.the above eagerly loads just the author with the post.</p>

<h3 id="gettin-specific">Gettin’ Specific</h3>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$postsRepo</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">PostRepository</span><span class="p">();</span>
<span class="nv">$post</span> <span class="o">=</span> <span class="nv">$postsRepo</span><span class="o">-&gt;</span><span class="n">with</span><span class="o">-&gt;</span><span class="p">([</span><span class="s1">'author'</span><span class="p">,</span> <span class="s1">'comments'</span><span class="p">])</span><span class="o">-&gt;</span><span class="nf">getById</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> 
</code></pre></div></div>

<p>Passing an array of relationships into the with method will just include them in the query.</p>

<h2 id="optional-helpers">Optional Helpers</h2>

<p>Version 1 ships with two traits that can be added into your repository to give it additional functionality without any extra configuration. I have dubbed these traits <a href="/blog/2016/02/19/magic-traits-with-laravel/">magic traits</a> and have written a blog about them and how Laravel itself uses them.</p>

<h3 id="throw-http-exceptions">Throw HTTP Exceptions</h3>

<p>Using the <code class="language-plaintext highlighter-rouge">ThrowsHttpExceptions</code> trait in your repository it will throw HTTPException (404). For example if we were to use this trait in the repository being used in our use case example above if the user tried to navigate to the show method with an <code class="language-plaintext highlighter-rouge">$id</code> that doesn’t exist they will be shown a 404 page.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>

<span class="kn">namespace</span> <span class="nn">App\Repositories</span><span class="p">;</span>

<span class="kn">use</span> <span class="nc">Weeks\Laravel\Repositories\BaseEloquentRepository</span><span class="p">;</span>
<span class="kn">use</span> <span class="nc">Weeks\Laravel\Repositories\Traits\ThrowsHttpExceptions</span><span class="p">;</span>

<span class="kd">class</span> <span class="nc">PostRepository</span> <span class="kd">extends</span> <span class="nc">BaseEloquentRepository</span>
<span class="p">{</span>
    <span class="kn">use</span> <span class="nc">ThrowsHttpExceptions</span><span class="p">;</span>

    <span class="k">protected</span> <span class="nv">$model</span> <span class="o">=</span> <span class="nc">App\Models\Post</span><span class="o">::</span><span class="n">class</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<h3 id="cache-results">Cache Results</h3>

<p>Similarly to the http error trait you can add the <code class="language-plaintext highlighter-rouge">CacheResults</code> trait to your repository. This will then cache results of the call using Laravel’s cache. See the <a href="https://github.com/dannyweeks/laravel-base-repository#caching">Cache section</a> of the README to learn more.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>

<span class="kn">namespace</span> <span class="nn">App\Repositories</span><span class="p">;</span>

<span class="kn">use</span> <span class="nc">Weeks\Laravel\Repositories\BaseEloquentRepository</span><span class="p">;</span>
<span class="kn">use</span> <span class="nc">Weeks\Laravel\Repositories\Traits\CacheResults</span><span class="p">;</span>

<span class="kd">class</span> <span class="nc">PostRepository</span> <span class="kd">extends</span> <span class="nc">BaseEloquentRepository</span>
<span class="p">{</span>
    <span class="kn">use</span> <span class="nc">CacheResults</span><span class="p">;</span>

    <span class="k">protected</span> <span class="nv">$model</span> <span class="o">=</span> <span class="nc">App\Models\Post</span><span class="o">::</span><span class="n">class</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>The <a href="https://github.com/dannyweeks/laravel-base-repository#http-exceptions">HTTPException</a> and <a href="https://github.com/dannyweeks/laravel-base-repository#caching">CacheResults</a> traits can be disabled programatically see the README for more information.</p>

<h2 id="testing">Testing</h2>

<p>I decided to not only unit test this repository but it also tests against a real database using Eloquent to ensure all the features are working as expected.</p>

<h2 id="future-development">Future Development</h2>

<p>As I use it more and more and run into new situation I may think of other methods that need adding or even new Traits which could be used.</p>

<p>Contributions are welcomed, just send a pull request or open an issue!</p>]]></content><author><name></name></author><category term="web-dev" /><category term="laravel" /><category term="repositories" /><category term="open source" /><summary type="html"><![CDATA[Amazingly the first commit to the laravel-base-repository was way back in December 2014. This was really just a way of me storing it for reuse rather than it being a package. It was just the basics; mainly get type requests but they haven’t changed much since.]]></summary></entry><entry><title type="html">My Dream Muse Set List</title><link href="/my-thoughts/2016/03/08/dream-muse-setlist.html" rel="alternate" type="text/html" title="My Dream Muse Set List" /><published>2016-03-08T00:00:00+00:00</published><updated>2016-03-08T00:00:00+00:00</updated><id>/my-thoughts/2016/03/08/dream-muse-setlist</id><content type="html" xml:base="/my-thoughts/2016/03/08/dream-muse-setlist.html"><![CDATA[<p><em>Note: This setlist is subject to change. Muse, if you’re reading.. I am open to suggestions.</em></p>

<p>I have seen Muse live countless times and thoroughly enjoy it every time but given the chance; this is the setlist I would choose. You can browse below or go stright to the <a href="https://www.youtube.com/playlist?list=PLhhcDa9jtYeR_veNQV20maXyummv1EfEc">playlist</a></p>

<p>Let’s set the scene. The lights go off. It’s pitch black. Silence. Then the first song starts, lasers sweep up from the floor to a foot above the crowd.</p>

<ul>
  <li><a href="https://www.youtube.com/watch?v=27ixLv3Lw1M">MK Ultra</a>: <em>I have been lucky enough to see this live at Wembley. A great way to kick off my setlist!</em></li>
  <li><a href="https://www.youtube.com/watch?v=HBe9vkmD-Os">Take A Bow</a></li>
  <li><a href="https://www.youtube.com/watch?v=AR6A3dap6MI">Map Of The Problematique</a></li>
  <li><a href="https://www.youtube.com/watch?v=tFG_5PBl2K8">Animals</a>: <em>Wasn’t a fan of this until I saw it live.</em></li>
  <li><a href="https://www.youtube.com/watch?v=nhODaNiaKMA">Liquid State</a>: <em>Possibly a marmite song but it was great live.</em></li>
  <li><a href="https://www.youtube.com/watch?v=iNJv6jsBuf8">Helsinki Jam</a></li>
  <li><a href="https://www.youtube.com/watch?v=yhci-MG4DNE">Dead Star</a>: <em>Saw this in the pissing down rain in the middle of a park with the laser cutting through the rain. Awesome experience.</em></li>
  <li><a href="https://www.youtube.com/watch?v=x2UyRS5cPJk">Glorious</a>: <em>An awesome B-Side that has only been performed live 10 times.</em></li>
  <li><a href="https://www.youtube.com/watch?v=5kH0OEJxUlE">Follow Me</a></li>
  <li><a href="https://www.youtube.com/watch?v=R6f_7G71p_w">Starlight</a></li>
  <li><a href="https://www.youtube.com/watch?v=BF1DQr5dKW8">The Handler</a>: <em>At the time of writing I am yet to see this live but know it will be amazing.</em></li>
  <li><a href="https://www.youtube.com/watch?v=pvzliBdl6KE">Thoughts of a Dying Atheist</a></li>
</ul>

<p><strong>They leave… <em>that can’t be it?!</em></strong></p>

<ul>
  <li><a href="https://www.youtube.com/watch?v=3oNm-XDEwdc">Resistance</a></li>
  <li><a href="https://www.youtube.com/watch?v=-1_Ri9dms8o">The Small Print</a></li>
  <li><a href="https://www.youtube.com/watch?v=QNdiNsOlqaQ">Showbiz</a></li>
  <li><a href="https://www.youtube.com/watch?v=4qagaaZfwXA">The Globalist</a></li>
</ul>

<p><strong>And the encore…</strong></p>

<ul>
  <li><a href="https://www.youtube.com/watch?v=VXPoJAyeF8k">The 2nd Law: Isolated System</a>: <em>During the interlude with the music video. Love it!</em></li>
  <li><a href="https://www.youtube.com/watch?v=9h1B-ydAIBk">In Your World</a>: <em>As the previous song is fading out, this slowly fades in.</em></li>
  <li><a href="https://www.youtube.com/watch?v=gXN9acC9edU">Stockholm Syndrome</a></li>
  <li><a href="https://www.youtube.com/watch?v=iAmCXUh-Aos">Bliss</a></li>
</ul>

<h2 id="what-no-koc">WHAT! NO KoC?!</h2>

<p>This has to be addressed as I think the majority of people would have it as their finale. I feel like it has become a bit cliché that the setlist ends on Knights of Cydonia and everyone has a good old fashioned mosh. I love the song but would like to see a different end to the show if I had my way.</p>

<h2 id="what-would-you-change">What would you change?</h2>
<p>It’s tough because there isn’t a song I dislike so choosing the ones I would want at a gig is what I have gone for.</p>

<p>This is mine; what would you have instead?</p>

<p>Don’t forget, you can listen to my setlist on my <a href="https://www.youtube.com/playlist?list=PLhhcDa9jtYeR_veNQV20maXyummv1EfEc">Youtube</a> playlist.</p>]]></content><author><name></name></author><category term="my-thoughts" /><category term="muse" /><summary type="html"><![CDATA[If I had may way this is the setlist which would make my night!]]></summary></entry><entry><title type="html">Magic Traits with Laravel</title><link href="/web-dev/2016/02/19/magic-traits-with-laravel.html" rel="alternate" type="text/html" title="Magic Traits with Laravel" /><published>2016-02-19T00:00:00+00:00</published><updated>2016-02-19T00:00:00+00:00</updated><id>/web-dev/2016/02/19/magic-traits-with-laravel</id><content type="html" xml:base="/web-dev/2016/02/19/magic-traits-with-laravel.html"><![CDATA[<p>The traditional use of traits is to reduce code duplication by extracting common methods into its own ‘class’. The trait can then be used in multiple classes to add some functionality.</p>

<p>To give a brief example, let’s think about a spaceship class, specifically the Battlestar Galactica…</p>

<p>All spaceships need a way to move so how about we make a trait that will be used my multiple ships giving it the FTL capabilities.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>

<span class="kn">namespace</span> <span class="nn">BSG\Ships\Components</span><span class="p">;</span>

<span class="kd">trait</span> <span class="nc">FTLDrive</span>
<span class="p">{</span>
    <span class="k">public</span> <span class="k">function</span> <span class="n">startJumpDrive</span><span class="p">()</span>
    <span class="p">{</span>
        <span class="c1">// Do FTL related stuff here.</span>
    <span class="p">}</span>
<span class="p">}</span>

</code></pre></div></div>

<p>Now Galactica uses the trait giving it the ability to spin up it’s newly installed FTL drive.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="kn">namespace</span> <span class="nn">BSG\Ships</span><span class="p">;</span>

<span class="kn">use</span> <span class="nc">BSG\Ships\Components\FTLDrive</span><span class="p">;</span>

<span class="kd">class</span> <span class="nc">Galactica</span>
<span class="p">{</span>
    <span class="kn">use</span> <span class="nc">FTLDrive</span><span class="p">;</span>
<span class="p">}</span>

<span class="nv">$galactica</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">Galactica</span><span class="p">;</span>
<span class="nv">$galactica</span><span class="o">-&gt;</span><span class="nf">startJumpDrive</span><span class="p">();</span>
</code></pre></div></div>

<h2 id="laravels-magic-traits">Laravel’s Magic Traits</h2>

<p><em>Disclaimer: Laravel might not have been the first to do this but it is where I learnt about it and how to implement it in this particular way.</em></p>

<p>In contrast to the traditional way of using traits, simply using Laravel’s ‘magic’ traits in a class the class performs extra functionality automatically.</p>

<p>A real example of Laravel using this is its testing suite. Taking a look at Laravel’s <a href="https://github.com/laravel/laravel/blob/master/tests/ExampleTest.php">ExampleTest</a> you can see it has three <code class="language-plaintext highlighter-rouge">use</code> statements.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>

<span class="kn">use</span> <span class="nc">Illuminate\Foundation\Testing\WithoutMiddleware</span><span class="p">;</span>
<span class="kn">use</span> <span class="nc">Illuminate\Foundation\Testing\DatabaseMigrations</span><span class="p">;</span>
<span class="kn">use</span> <span class="nc">Illuminate\Foundation\Testing\DatabaseTransactions</span><span class="p">;</span>

<span class="kd">class</span> <span class="nc">ExampleTest</span> <span class="kd">extends</span> <span class="nc">TestCase</span>
<span class="p">{</span>
    <span class="c1">//</span>
<span class="p">}</span>
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">WithoutMiddleware</code>, <code class="language-plaintext highlighter-rouge">DatabaseMigrations</code>, and <code class="language-plaintext highlighter-rouge">DatabaseTransactions</code> are all traits which can help with testing.</p>

<p>For instance, if we <code class="language-plaintext highlighter-rouge">use DatabaseMigrations</code> the database will be refreshed automatically before each test without having to do anything else. This makes for such a good user experience as it is totally painless to use.</p>

<p>Behind the scenes the <code class="language-plaintext highlighter-rouge">TestCase</code> takes the following steps to implement this flawless functionality.</p>

<p>The <code class="language-plaintext highlighter-rouge">startUp</code> method of the <code class="language-plaintext highlighter-rouge">TestCase</code> calls a method called <a href="https://github.com/laravel/framework/blob/5.2/src/Illuminate/Foundation/Testing/TestCase.php#L93">setUpTraits</a>. First off it figures out what traits are being used.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$uses</span> <span class="o">=</span> <span class="nb">array_flip</span><span class="p">(</span><span class="nf">class_uses_recursive</span><span class="p">(</span><span class="nb">get_class</span><span class="p">(</span><span class="nv">$this</span><span class="p">)));</span>
</code></pre></div></div>

<p>Then if a trait is being used it calls a method to perform the intended actions.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="p">(</span><span class="k">isset</span><span class="p">(</span><span class="nv">$uses</span><span class="p">[</span><span class="nc">DatabaseMigrations</span><span class="o">::</span><span class="n">class</span><span class="p">]))</span> <span class="p">{</span>
    <span class="nv">$this</span><span class="o">-&gt;</span><span class="nf">runDatabaseMigrations</span><span class="p">();</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Now, this could always be done manually. You add the trait and then call the method yourself but automating this process has it’s advantages.</p>

<ul>
  <li>It saves time, drop a trait in and it’s all set up and ready to go now crack on with the real development.</li>
  <li>Reduces <a href="https://en.wikipedia.org/wiki/Cognitive_load">Cognitive load</a>. At a glance the perfectly named traits make it easy to consume that the class is (for example) using database migrations with no other fluff getting in the way.</li>
</ul>

<h2 id="using-magic-traits">Using Magic Traits</h2>

<p>Once I had discovered this way of improving a classes API by using this ‘Magic Trait’ pattern I decided to implement it in one of my own projects. Taking inspiration from Laravel’s TestCase my <a href="https://github.com/dannyweeks/laravel-base-repository">Base Repository</a> now allows a developer to drop a trait in and have a repository throw exceptions or cache it’s results but more on that when I release Version 1 soon!</p>]]></content><author><name></name></author><category term="web-dev" /><category term="laravel" /><category term="php" /><summary type="html"><![CDATA[The traditional use of traits is to reduce code duplication by extracting common methods into its own ‘class’. The trait can then be used in multiple classes to add some functionality.]]></summary></entry><entry><title type="html">Our 100 Film Challenge</title><link href="/film-tv/2016/02/03/our-100-film-challenge.html" rel="alternate" type="text/html" title="Our 100 Film Challenge" /><published>2016-02-03T00:00:00+00:00</published><updated>2016-02-03T00:00:00+00:00</updated><id>/film-tv/2016/02/03/our-100-film-challenge</id><content type="html" xml:base="/film-tv/2016/02/03/our-100-film-challenge.html"><![CDATA[<p>At the start of the year Helen and I decided to set ourselves a little challenge. We need to watch 100 films to expand the films we have seen and push the limits as to what we would usually watch.
 The basic rules were simple:</p>

<ul>
  <li>Must be a film we either haven’t seen OR haven’t seen in a long time.</li>
  <li>We can’t veto every film that isn’t to our taste.<small>*</small></li>
</ul>

<p><small><em>* I don’t expect Helen to sit and watch people’s hearts be ripped out in <a href="http://www.imdb.com/title/tt0472043">Apocalypto</a>.. 10/10 would watch again! I have thankfully manged swerved some too because of this loophole!</em> 😅</small></p>

<p>During Christmas we asked everyone for recommendations and started jotting them down on Helen’s phone. We quickly compiled quite the watch list!</p>

<p>I’m not going to go into any <a href="https://github.com/dannyweeks/100-films">nerdy detail</a> but I decided to throw together a quick website so we could keep track of what we wanted to watch as well as rate what we have watched. I thought it would be nice to look back on at the end of the year and see what we have watched and what we have enjoyed!</p>

<p>Check out our progress and ratings at <a href="http://100films.dannyweeks.com">http://100films.dannyweeks.com</a>!</p>

<p>When telling people about our little challenge we have received mixed reactions, some say <em>that’s easy, it’s only 2 films a week</em> and on the flip side is the same sentence but a more pessimistic spin.</p>

<p>Personally, I look forward to the challenge as it will push us to watch them films that we have always said we would watch <em>some day</em>.</p>

<h2 id="a-month-in">A Month In</h2>

<p>At the time of writing this we are 14 films into the challenge which is 6 films over target of what we should be. I’m pretty happy with the progress and some of the films we have watch have been great.. others not so much.</p>

<p>I anticipate it will be harder to hit the month target of 8.2 a month around April with all the TV shows starting their new seasons around then so it is good we have made some headway now!</p>

<p>That’s it for now, I will try to do a little update every few months but until then…</p>

<p><strong>Got any recommendations?!</strong></p>]]></content><author><name></name></author><category term="film-tv" /><category term="100-film-challenge" /><summary type="html"><![CDATA[Let's try and watch 100 films in one year!]]></summary></entry><entry><title type="html">My Personal Website Build With Sculpin</title><link href="/web-dev/2016/01/15/using-sculpin.html" rel="alternate" type="text/html" title="My Personal Website Build With Sculpin" /><published>2016-01-15T00:00:00+00:00</published><updated>2016-01-15T00:00:00+00:00</updated><id>/web-dev/2016/01/15/using-sculpin</id><content type="html" xml:base="/web-dev/2016/01/15/using-sculpin.html"><![CDATA[<p>As I mentioned in my <a href="/blog/2015/12/23/website-relaunch">website relaunch post</a> I eventually settled on using <a href="https://sculpin.io">Sculpin</a> a static site generator. In this post I will go over some of the challenges I faced and over came molding Sculpin into something I can enjoy using. My aim for this build was to make it very easy to blog without having to do lots of fiddling with settings.</p>

<h2 id="features">Features</h2>

<p>I had a number of requirements coming into re-building my personal website:</p>

<ul>
  <li>Category icons on homepage</li>
  <li>Featured Images w/ thumbnails</li>
  <li>Blog galleries</li>
  <li>Spoiler protection</li>
  <li>Syntax highlighting</li>
  <li>Excerpts</li>
</ul>

<h2 id="category-icons">Category Icons</h2>

<p>A little design accent that I wanted to bring into this build for was posts to have category icons on the homepage. In the past the icon was generated in PHP but with my little experience using Sculpin this was the first challenge.</p>

<p><img src="/images/uploads/2016/01/icons.png" alt="icons" /></p>

<p>The implementation I ended up going for was creating custom fontawesome classes using SCSS. Having an array of each category details all inheriting from a base <em>category</em> class.</p>

<div class="language-scss highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$categories</span><span class="p">:</span> <span class="p">(</span>
    <span class="p">(</span><span class="s2">"category"</span><span class="o">,</span> <span class="s2">"#3498db"</span><span class="o">,</span> <span class="n">null</span><span class="o">,</span> <span class="s2">"\f075"</span><span class="p">)</span><span class="o">,</span>
    <span class="p">(</span><span class="s2">"my-thoughts"</span><span class="o">,</span> <span class="n">null</span><span class="o">,</span> <span class="n">null</span><span class="o">,</span> <span class="s2">"\f075"</span><span class="p">)</span><span class="o">,</span>
    <span class="p">(</span><span class="s2">"web-dev"</span><span class="o">,</span> <span class="s2">"#2c3e50"</span><span class="o">,</span> <span class="s2">"#2ecc71"</span><span class="o">,</span> <span class="s2">"\f120"</span><span class="p">)</span><span class="o">,</span>
    <span class="p">(</span><span class="s2">"film-tv"</span><span class="o">,</span> <span class="n">null</span><span class="o">,</span> <span class="n">null</span><span class="o">,</span> <span class="s2">"\f008"</span><span class="p">)</span><span class="o">,</span>
    <span class="p">(</span><span class="s2">"photography"</span><span class="o">,</span> <span class="s2">"#EB9532"</span><span class="o">,</span> <span class="n">null</span><span class="o">,</span> <span class="s2">"\f030"</span><span class="p">)</span><span class="o">,</span>
    <span class="p">(</span><span class="s2">"projects"</span><span class="o">,</span> <span class="s2">"#D24D57"</span><span class="o">,</span> <span class="n">null</span><span class="o">,</span> <span class="s2">"\f286"</span><span class="p">)</span><span class="o">,</span>
    <span class="p">(</span><span class="s2">"gaming"</span><span class="o">,</span> <span class="s2">"#212121"</span><span class="o">,</span> <span class="s2">"#FFF176"</span><span class="o">,</span> <span class="s2">"\f11b"</span><span class="p">)</span><span class="o">,</span>
<span class="p">);</span>

<span class="k">@each</span> <span class="nv">$category</span> <span class="n">in</span> <span class="nv">$categories</span> <span class="p">{</span>
    <span class="nc">.</span><span class="si">#{</span><span class="nf">nth</span><span class="p">(</span><span class="nv">$category</span><span class="o">,</span> <span class="m">1</span><span class="p">)</span><span class="si">}</span><span class="nc">-icon</span> <span class="p">{</span>
        <span class="nc">.background-icon</span> <span class="p">{</span>
            <span class="nl">color</span><span class="p">:</span> <span class="si">#{</span><span class="nf">nth</span><span class="p">(</span><span class="nv">$category</span><span class="o">,</span> <span class="m">2</span><span class="p">)</span><span class="si">}</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="nc">.main-icon</span> <span class="p">{</span>
            <span class="nl">color</span><span class="p">:</span> <span class="si">#{</span><span class="nf">nth</span><span class="p">(</span><span class="nv">$category</span><span class="o">,</span> <span class="m">3</span><span class="p">)</span><span class="si">}</span><span class="p">;</span>
            <span class="k">&amp;</span><span class="nd">:before</span> <span class="p">{</span>
                <span class="nl">content</span><span class="p">:</span> <span class="s2">"</span><span class="si">#{</span><span class="nf">nth</span><span class="p">(</span><span class="nv">$category</span><span class="o">,</span> <span class="m">4</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>

<h2 id="syntax-highlighting">Syntax Highlighting</h2>

<p>I wanted syntax highlighting to totally painless. In Sculpin actually came with a perfect syntax highlighting javascript plugin aptly named <a href="https://highlightjs.org/">highlightjs</a>. Highlighting is as simple as initialising the plugin and then throwing your code in markdown code tags.</p>

<h2 id="featured-images">Featured Images</h2>

<p>Featured images came in two parts. First off actually having images associated to a blog post and it being output in various places. Secondly, having images optimised for the homepage where the image is not full size.</p>

<h3 id="attaching-featured-images">Attaching Featured Images</h3>

<p>Sculpin makes it easy to add meta data to a blog posts with a yml block at the top of your post files. By adding <code class="language-plaintext highlighter-rouge">featured_image: sculpin.jpg</code> to the top of this post I easily have access to this data in the templates. I make the assumptions that the file is located in the uploads folder in the corresponding month that the post is published.</p>

<h3 id="thumbnails">Thumbnails</h3>

<p>I came across a fantastic Sculpin plugin called <a href="https://github.com/beryllium/icelus">Icelus</a>. Installing and using this is so seamless it’s laughable. I ended up going for a macro which creates a 500px wide version of the provided image.</p>

<h2 id="galleries">Galleries</h2>

<p>This was a big challenge since there is no way of doing this in markdown without some trickery but I’m happy with the result. Like I said it’s all about making witting a post as easy as possible.</p>

<p>My idea was to hook into the alt tag of images to build a gallery out of taged images. This solution is a mixture of CSS and javascript. The CSS portion is mainly a fall back in case javascript is disabled.</p>

<div class="language-scss highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">img</span><span class="o">[</span><span class="nt">alt</span><span class="o">^=</span><span class="s2">"gallery-"</span><span class="o">]</span> <span class="p">{</span>
  <span class="nl">width</span><span class="p">:</span> <span class="m">150px</span><span class="p">;</span>
  <span class="nl">display</span><span class="p">:</span> <span class="n">inline-block</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>The desired API I wanted was to markup galleries with <code class="language-plaintext highlighter-rouge">gallery-1</code> as the alt tag. Note the ‘1’, I knew I would need to accommodate for multiple galleries on one pages due to an already published post about different version of the <a href="/blog/2013/08/01/the-seven-wonders-of-the-world">7 Wonders of the World</a>.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>![gallery-1](/link/to/first/image.jpg)
![gallery-1](/link/to/second/image.jpg)
</code></pre></div></div>

<p>This produces images with the same alt tags which I can search for and manipulate.</p>

<p>I won’t go into details about how this all works; you can find exactly how in the <a href="https://github.com/dannyweeks/dannyweeks.com">source code</a> of this website (‘assets/javascript/gallery.js’). The gist of how this works is:</p>

<ul>
  <li>The javascript searches for all images that have an alt tag starting with ‘gallery-‘.</li>
  <li>The images are then grouped by their gallery name gallery-1, gallery-2 etc.</li>
  <li>The markup for each gallery is then generated and injected below the last image found the corresponding gallery.</li>
  <li>The original images are removed from the DOM.</li>
</ul>

<h2 id="spoiler-protection">Spoiler Protection</h2>

<p><a href="/blog/2014/06/19/spoilers-you-have-no-right">Spoilers</a> are a big issue to me so I want to ensure my readers don’t unknowingly happen upon a spoiler. Inspired by the above solution I thought to hook into the alt tag once again but this time using a simple ‘spoiler’ alt tag.</p>

<p>A nice API solution for text based spoilers is still to be addressed but for the time being a simple span tag with the class of spoiler has the desired effect.</p>

<h2 id="excerpts">Excerpts</h2>

<p>Coming from Wordpress one thing I did like was being able to choose where the excerpt came from. I implemented this and took it one step further. There are three ways to get the excerpt one taking priority of the other.</p>

<ul>
  <li>Use the excerpt property defined in the yml block</li>
  <li>Take the content before the <code class="language-plaintext highlighter-rouge">&lt;!--more--&gt;</code> tag</li>
  <li>If no more tag exists take the first 200 characters of the post its self.</li>
</ul>

<p>This is achieved with a simple if statement and the below twig macro.</p>

<h2 id="conclusion">Conclusion</h2>

<p>On the whole I am pretty happy with how using Sculpin has turned out with this build. I’d like to thank <a href="http://whateverthing.com/blog/tags/sculpin/">Kevin Boyd</a> for sharing a lot of Sculpin based solutions I took advantage of.</p>]]></content><author><name></name></author><category term="web-dev" /><category term="sculpin" /><category term="scss" /><category term="foundation" /><category term="javascript" /><summary type="html"><![CDATA[As I mentioned in my website relaunch post I eventually settled on using Sculpin a static site generator. In this post I will go over some of the challenges I faced and over came molding Sculpin into something I can enjoy using. My aim for this build was to make it very easy to blog without having to do lots of fiddling with settings.]]></summary></entry><entry><title type="html">Website Relaunch</title><link href="/my-thoughts/web-dev/2015/12/23/website-relaunch.html" rel="alternate" type="text/html" title="Website Relaunch" /><published>2015-12-23T00:00:00+00:00</published><updated>2015-12-23T00:00:00+00:00</updated><id>/my-thoughts/web-dev/2015/12/23/website-relaunch</id><content type="html" xml:base="/my-thoughts/web-dev/2015/12/23/website-relaunch.html"><![CDATA[<h2 id="renouncing-freelance">Renouncing Freelance</h2>

<p>After a around about a year of freelancing I decided I wanted that it wasn’t for me. It was nice to have extra money on the side of course but pack it in for two reasons.</p>

<p>I felt like it wasn’t challenging at all. Getting Wordpress set up and then throwing together a custom theme was becoming mundane. A long the way I built a Wordpress <a href="https://wordpress.org/plugins/simple-custom-website-data/stats/">plugin</a> to make it less painful but it didn’t cure the itch.</p>

<p>Second of all the projects were the same, a small website with a blog. Nothing was helping me move forward with my career. I felt like I needed to be spending my spare time either relaxing or developing things I enjoy and at the same time developing my portfolio. I think it’s safe to say every developer has ten side projects for every one that makes it into the wild. My latest being <a href="/blog/2015/11/19/introducing-mersey-a-server-management-tool">mersey</a> a tool that makes interacting with servers much less painful.</p>

<p>This isn’t to say freelance is totally off the table but it’s certainly off the back burner and in the freezer.</p>

<h2 id="phase-one---purge-the-old">Phase One - Purge The Old</h2>
<p>My portfolio site in it’s current form had to go. It wasn’t reflective of my new goals and It’s main focus was on getting freelance clients.</p>

<p>My personal website is a playground and was the first time I used Laravel. I’m sure you have looked at work two years later and been embarrassed by it! It wasn’t something I wanted to open source!</p>

<p>Initiate <em>Phase One</em>! I put a redirect on dannyweeks.com to send everyone to my blog to stop people from being exposed to that monster.</p>

<h2 id="phase-two---prettify-the-new">Phase Two - Prettify The New</h2>

<p>With my portfolio gone it was time to figure out what I wanted to do. A lot of the <em>‘<a href="https://philsturgeon.uk">industry</a> <a href="https://mattstauffer.co">leaders</a>‘</em> I follow have their websites as basically a blog with a little information about themselves. This was the direction I wanted to go down. I then had a choice. Create a new website entirely. Being a Laravel enthusiast it was my first thought. But it felt like overkill and would be a lot of time to invest just a blog.</p>

<h2 id="why-move-away-from-wordpress">Why Move Away From Wordpress?</h2>

<p>I was stopped doing freelance because I was installing Wordpress and then creating a theme. I didn’t want to become the client! There is more to it than that. My blog website was already built in Wordpress and had a custom theme but there was some aspects of the theme I wasn’t happy with and some issues with Wordpress itself.</p>

<p>So, let’s look at the current theme. I like the colours. Parts of the layout I wasn’t happy with. The sidebar on posts had to go; it was useless and just took away from the post. The homepage was dated and boring.</p>

<p>Adding custom css for individual posts or adding features such as hiding spoilers was hacky. A combination of shortcode and spans with classes was the only way to do it but this was heavily dependant upon the theme being used. Change the theme and you have spoilers exposed to the world… <a href="/blog/2014/06/19/tv-spoilers-you-have-no-right">a big no no</a>!</p>

<p>I was using a plugin for syntax highlighting which worked well but you had to go around the world to get it looking right and had to insert it in using a menu which felt clunky.</p>

<p>The final nail in the coffin was having to use either the WYSIWYG editor or bog standard html. I would never use the WYSIWYG as it just adds too much crap but I am so used to <a href="http://emmet.io/">Emmet</a> I hated using the plain html editor. What I wanted was markdown</p>

<p>Let’s find something new!</p>

<h2 id="octobercms">OctoberCMS</h2>

<p>When OctoberCMS was released I was intrigued, had a little look but never really got round to tinkering with it on a real project. With my website getting updated it was a perfect opportunity. Hey, I can wait as long as I need to to get exactly what I’m looking for so if I waste my time with OctoberCMS nobody’s loss!</p>

<p>Straight of the bat I knew the blog aspect would be a pleasure to use with markdown and a live preview.</p>

<p>In general the backend cms was very nice to use getting the pages set up using static files. As I started trying to add more and more customisation the cracks started to show.</p>

<p>There was some additional functionality on blog posts I wanted. I wanted access to a  cropped version of the featured image for the index page. Keeping in line with a feature of the original blog each category needed to have an associated icon.</p>

<p>The recommended solution was to create my own plugin that would extend the default blog plugin with the extra functionality I wanted. That was fine so after doing that I was pretty happy with how things were going. The next stop was to tackle deployment.</p>

<p>To set environment variable I had to modify the source code of OctoberCMS which in general is a big no no. With it being Laravel I am used to committing the whole project to version control but with OctoberCMS it didn’t seem right. I was confused as to what the best deployment method was.</p>

<p>Honestly, my approach was wrong. I wanted one ‘Website Project’ but it seems like the project needs to be split up into different smaller projects. Develop a theme I want to use. Develop any plugins I want to use and then have them included in a OctoberCMS install which is modified for use on the production server.</p>

<p>For what I wanted, a small maintainable site for my blog this CMS just didn’t fit.</p>

<h2 id="intrigued-by-static-site-generators">Intrigued By Static Site Generators</h2>

<p>My first exposure to a static site generator was <a href="http://jekyllrb.com/">Jekyll</a>, by far the <a href="https://www.staticgen.com">most popular</a> tool. What put me off was the fact it used ruby. I don’t have a lot of experience with ruby, that, a long with it being a pain when I was using it to build SCSS I wasn’t excited to use it.</p>

<p>Meet <a href="https://sculpin.io">Sculpin</a>, a PHP/Symfony based generator. It was easy to get set up and it didn’t take long to notice the work flow would be great. Add a new markdown file, commit it and it could be published easily.</p>

<p>I’m not going to go into too much detail with Sculpin as I plan on dedicating a post to this great little tool.</p>

<p>With Sculpin being based upon Symfony and using composer it is much more familiar territory. Like OctoberCMS, my initial thoughts with were positive. It’s only when you really start digging in the challenges start being apparent. Being static I was forced to do a lot of the functionality in Javascript/CSS rather than using PHP. I was happy to do this as it felt a lot less hacky than what I had to do with OctoberCMS.</p>

<p>There is still some development to do and things to work out but enough is in for me to get blogging again!</p>]]></content><author><name></name></author><category term="my-thoughts" /><category term="web-dev" /><category term="wordpress" /><category term="sculpin" /><category term="octobercms" /><summary type="html"><![CDATA[A new shiny website, built in something new for fun!]]></summary></entry><entry><title type="html">The Truth About LAN - Insomnia 56</title><link href="/gaming/2015/12/21/the-truth-about-lan-insomnia-56.html" rel="alternate" type="text/html" title="The Truth About LAN - Insomnia 56" /><published>2015-12-21T00:00:00+00:00</published><updated>2015-12-21T00:00:00+00:00</updated><id>/gaming/2015/12/21/the-truth-about-lan-insomnia-56</id><content type="html" xml:base="/gaming/2015/12/21/the-truth-about-lan-insomnia-56.html"><![CDATA[<p>An extended weekend with a room full of gamers. Stereotype would predict that room is full of a room full of fat, greasy haired, spotty faced male teenage virgins. This is so far from the truth its laughable.</p>

<!--more-->

<p>I have always been intrigued by these type of events. It’s hard to actually think about what you ACTUALLY do for a whole weekend! Surely you don’t play all weekend! So what the fuck do you do? I want to shed some light on what it’s really like to attend a LAN gaming festival.</p>

<p>I have been to three <a href="http://insomniagamingfestival.com">Insomnia</a> events (i53, i55, i56) so far and feel that I have had enough exposure to the different aspects to do it justice.</p>

<h2 id="my-first-time">My First Time</h2>
<p>In 2014 I convinced myself to give it a try after being invited to go by a friend to see if it is for me. Insomnia 53 (shortened to i53) had TAKEN OVER the <a href="http://www.ricoharena.com/">Ricoh Arena</a>. The whole venue was full of gamers. While walking through the main corridor it hit me. These are my people. We all share the same passion. Usually you are judged when you say you are a gamer. Not here. It was normal.</p>

<p><img src="/images/uploads/2015/12/my-people.gif" alt="my people" /></p>

<p>It reminds me of something I noticed a little while back, any two people who follow football can have a bond instantly with each other, they can have a meaningful conversation that lasts more than 5 minutes. Just like football, gaming can break boundaries and people can just be themselves.</p>

<h2 id="byoc--the-gaming-hall">BYOC &amp; The Gaming Hall</h2>

<p><img src="/images/uploads/2015/12/lan-hall.jpg" alt="byoc" /></p>

<p>Bring Your Own Computer. Yes, you take your own computer these events. Aside from the fact that it would be impractical for the event organisers to provide thousands of computers for gamers many people enjoy it for other reasons.</p>

<p>Personally I like comfort. Having my own PC, set up the way I like it is the only option to me. You have the proud (some would say show offs) gamers who have put days and day of work creating a custom PC. I enjoy walking down the rows and rows of pc browsing the unique pcs that people have on display.</p>

<p>A concern someone may have regarding taking their own PC and peripherals to LAN is that it could be stolen. Being very modest there is over a £1,000,000 (700 per gamer * 1700 gamers) worth of equipment knocking about. I have been three times and am yet to hear of anything being stolen from the gaming hall. The thing that must be realised is to gain entrance to the PCs you have to have one in there yourself. Everyone is in the same boat. That along with good security. It just doesn’t happen.</p>

<p>Would it shock you that at 6am people are still awake in the gaming hall? Maybe not since we are basement dwelling nerds! Would it shock you that at 6am on a lot of screens you could see people crowding round screens to watch a live UFC fight? See this stereotype is just false.. I will touch upon this later!</p>

<p>Im not going to shy away from the fact that a serious amount of gaming is done during the course of this weekend.</p>

<p>Gamers come in all different kinds of shapes, sizes, personalities. They aren’t droids that follow the same programming. Therefore everyone in there enjoys gaming in different ways. To share my experience of the more recent Insomnia I participated in the Counter-Strike tournament a long with 4 of the lads that were there with me. We entered knowing without a doubt we wouldn’t win.</p>

<p>We had no actual competitive practice, only the online matches we play. We entered for the fun of competing together. It’s great looking down the row and seeing the guys you are competing with, cheering when you win a round etc.</p>

<p>In between CS (Counter-strike) games or when I was waiting on someone I started playing a new game I had picked up in a recent Steam sale. A single player puzzle game. Just chilling out and every now and then talking to someone about it who was curious at what I was playing.</p>

<h2 id="the-social-aspect">The Social Aspect</h2>
<p>One pet hate of mine is that because I don’t go to town every weekend and get pissed in a club were the music is so loud that I would have to scream down someones ear for them to hear me therefore means I don’t socialise. I need to get out more. Meet people. Oh I beg to differ!</p>

<p>Playing games online forces you to meet new people, finding that community who you have a shared interest by default because you are playing the same game is the start of great, real friendships.</p>

<p>What happens at LAN is you finally get to meet these folks you have known for years in person!</p>

<p>The summer meeting pulls the majority of our group to LAN. A group 10 strong, ok what else do we do? Surely we don’t just play games!?</p>

<h3 id="drinking">Drinking</h3>
<p>Yes, nerds enjoy the nectar of gods too.</p>

<h3 id="boardgames">Boardgames</h3>
<p>It isn’t unheard of for board games to be played.. real board games, no casual monopoly here. Playing a game called Resistance until 6am was highly enjoyable. Even if it proved that some of the group has serious lying issues!</p>

<h3 id="pub-quiz">Pub Quiz</h3>
<p>One of my favourite aspects of Insomnia is the geeky pub quiz filled with questions stretching the full geek range.</p>

<p><img src="/images/uploads/2015/12/pub-quiz.jpg" alt="pub quiz" /></p>

<h3 id="expo-hall">Expo Hall</h3>
<p>To break the day up we would go for a little explore around the <a href="https://www.flickr.com/photos/mpuk/albums/72157662285747386">exhibition hall</a> with the latest and greatest games, hardware and geek related merch.</p>

<h3 id="watch-live-tournaments">Watch Live Tournaments</h3>
<p>Plenty of games are played at the professional level and it is truly a pleasure to watch such skill in the presents of a hyped up crowd.</p>

<p><img src="/images/uploads/2015/12/csgo.jpg" alt="csgo final" /></p>

<h2 id="the-stereotype">The Stereotype</h2>

<p><img src="/images/uploads/2015/12/stereotype.jpg" alt="stereotype" /></p>

<p>Now to address the stereotype, you do get people who get close to the stereotype and I’d have to admit it males do outnumber females by at least 100-1. I’d say it’s a given that there will be more males. More males play games. How is this any different than an event where the female interest would be much higher?</p>

<p>There is no such thing as normal and you get a great range of different people at these events.</p>

<h2 id="different-experiences">Different Experiences</h2>

<p>These events are what you make it. It is far more than just sitting in a room playing computer games all weekend. I would implore any group of gamers to give it a try.</p>]]></content><author><name></name></author><category term="gaming" /><category term="insomnia" /><category term="lan" /><summary type="html"><![CDATA[An extended weekend with a room full of gamers. Stereotype would predict that room is full of a room full of fat, greasy haired, spotty faced male teenage virgins. This is so far from the truth its laughable.]]></summary></entry><entry><title type="html">Introducing Mersey – A Server Management Tool</title><link href="/web-dev/2015/11/19/introducing-mersey-a-server-management-tool.html" rel="alternate" type="text/html" title="Introducing Mersey – A Server Management Tool" /><published>2015-11-19T00:00:00+00:00</published><updated>2015-11-19T00:00:00+00:00</updated><id>/web-dev/2015/11/19/introducing-mersey-a-server-management-tool</id><content type="html" xml:base="/web-dev/2015/11/19/introducing-mersey-a-server-management-tool.html"><![CDATA[<p>In my job I have to maintain a few servers with multiple projects. We have the old Ubuntu 12.04 running special software, two Ubuntu 14.04 servers (one is prettier than the other) and then throw in our VPS too and thats just the servers at work! Jumping between all of these was becoming tedious; a different password to remember at every turn. I had to do something for the sake of my sanity.</p>

<!--more-->

<p>I first set up aliases. Then SSH to replace the need for passwords. This worked fine but all it did was save me the need to type the full SSH command. I still had to do what ever I was doing which often was something I had done time and time again: look at server logs or <a href="/blog/2015/06/12/deployment-script-for-production-server">run a deployment script</a> etc.</p>

<p>My next bright idea was to write a small bash script that could automate this a little. Allow me to run the deployment script as well as connect to the server. This worked really well. It reminded me of when I first started tinkering with batch files back in the day.</p>

<p><img src="/images/uploads/2015/11/server-bash-script.png" alt="" /></p>

<blockquote>
  <p>The first draft</p>
</blockquote>

<h2 id="the-birth-of-mersey">The Birth Of <em>Mersey</em></h2>

<p>I’ll get this part out of the way. I’m not the best at <a href="http://core0.staticworld.net/images/idge/imported/article/itw/2013/10/23/programmers_hardest_tasks-600x700-100521914-orig.jpg">naming things</a> so I rolled with the first thing that had some logic behind it! Mersey, a river near Liverpool with two traffic tunnels. The tunnels connect one place to another, similar to how this tool connects you to your servers! That’s it! Moving on.</p>

<p>The bash script was a good start; it even had a little interface but it lacked the flexibility that higher level programming languages offer. I wanted it to be easy to get set up and use for other people; taking advantage of some kind of config file to load the servers on the fly. It is obviously possible to use bash but it would have taken me a long time. I needed something familiar. Queue using PHP.</p>

<p>I have had some exposure to <a href="http://symfony.com/doc/current/components/console/introduction.html">Symfony’s Console Component</a> via Laravel’s console commands but never used it directly so this was my chance to have a little tinker! For the config, I decided to go with json as I, along with most devs nowadays love working with it! After I was happy with the functionality and features the first version of <a href="https://github.com/dannyweeks/mersey">Mersey</a> and my first package was released to the world!</p>

<p><img src="/images/uploads/2015/11/project.gif" alt="" /></p>
<blockquote>
  <p>Quickly jump into a project root.</p>
</blockquote>

<p>Multiple servers can be stored in the config file with servers having optional projects and projects having optional scripts that can be run on them. A more detailed explanation of this and how to install it can be found in the <a href="https://github.com/dannyweeks/mersey#readme">readme</a> of Mersey.</p>

<p><img src="/images/uploads/2015/11/mersey-ping.gif" alt="" /></p>

<p>Additionally there are some commands which provide information such as the ping command showing the availability of the servers.</p>

<p>So far I’m pretty happy with it as it saves me so much time! You can find the Mersey server tool on <a href="https://github.com/dannyweeks/mersey">GitHub</a>. I welcome feature requests or if you want, feel free to <a href="https://github.com/dannyweeks/mersey/blob/master/CONTRIBUTING.md">contribute</a>!</p>]]></content><author><name></name></author><category term="web-dev" /><category term="composer" /><category term="php" /><category term="devops" /><category term="open source" /><summary type="html"><![CDATA[In my job I have to maintain a few servers with multiple projects. We have the old Ubuntu 12.04 running special software, two Ubuntu 14.04 servers (one is prettier than the other) and then throw in our VPS too and thats just the servers at work! Jumping between all of these was becoming tedious; a different password to remember at every turn. I had to do something for the sake of my sanity.]]></summary></entry></feed>