<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Principal Software Engineer | Ben Holland</title>
    <description>Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
</description>
    <link>https://benholland.me/</link>
    <atom:link href="https://benholland.me/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 09 Aug 2021 17:28:48 +0100</pubDate>
    <lastBuildDate>Mon, 09 Aug 2021 17:28:48 +0100</lastBuildDate>
    <generator>Jekyll v3.7.2</generator>
    
      <item>
        <title>Cleaning up an Angular module that is using ES6</title>
        <description>&lt;p&gt;After working primarily with vanilla JavaScript over the past year, it&amp;#39;s been a bit of shock to return to an AngularJS (v1.4.9) application and re-learn the pain of dependency injection, especially in an almost fully compatibilty ES6 world.&lt;/p&gt;

&lt;p&gt;I&amp;#39;ve taken an example module that I can across and have &amp;quot;cleaned&amp;quot; it up to follow my preference along with comments as to why. Ideally, I would have posted the tests as well to show how they would be simplified in conjunction with this clean up.&lt;/p&gt;

&lt;h4&gt;Original module&lt;/h4&gt;

&lt;script src=&quot;https://gist.github.com/benhoIIand/2f1b9e6797befdbf39b5/532a160adf3214c69a0ea469374d662c7187b746.js&quot;&gt;&lt;/script&gt;

&lt;h4&gt;&amp;quot;Cleaned&amp;quot; module&lt;/h4&gt;

&lt;script src=&quot;https://gist.github.com/benhoIIand/2f1b9e6797befdbf39b5/5a2d350f4863103ab2afbe921eed6c1f6b48b854.js&quot;&gt;&lt;/script&gt;

&lt;h4&gt;&amp;quot;Cleaned&amp;quot; module without comments&lt;/h4&gt;

&lt;script src=&quot;https://gist.github.com/benhoIIand/2f1b9e6797befdbf39b5/ee271c647e888ca1a2c184acc16f98842ef88ee5.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;Feel free to let me know your thoughts/suggestions by commenting &lt;a href=&quot;https://gist.github.com/benhoIIand/2f1b9e6797befdbf39b5&quot;&gt;on the gist&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 10 Feb 2016 00:00:00 +0000</pubDate>
        <link>https://benholland.me/javascript/2016/02/10/cleaning-up-an-angular-module-that-is-using-es6.html</link>
        <guid isPermaLink="true">https://benholland.me/javascript/2016/02/10/cleaning-up-an-angular-module-that-is-using-es6.html</guid>
        
        <category>javascript</category>
        
        <category>angular</category>
        
        <category>es6</category>
        
        <category>es2015</category>
        
        <category>esnext</category>
        
        
        <category>javascript</category>
        
      </item>
    
      <item>
        <title>Setting up my Mac and iTerm... again!</title>
        <description>&lt;p&gt;Over the last three years I&amp;#39;ve setup three new Macbooks for myself and found myself repeating the same steps pretty much every time. This month I setup my fourth, but did things slightly differently. Here&amp;#39;s a few quick shortcuts I take to get setup quicker:&lt;/p&gt;

&lt;h3&gt;Automate it stupid&lt;/h3&gt;

&lt;p&gt;A short while back I came across &lt;a href=&quot;https://twitter.com/OliverJAsh&quot;&gt;Oliver J. Ash&amp;#39;s mac setup repo&lt;/a&gt;, a set of scripts to help automate the initial faff of customising the new machine to your preferences - fantastic! I forked this and made some changes to &lt;a href=&quot;https://github.com/benhoIIand/mac-setup&quot;&gt;tailor my Mac settings and applications&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you take a look at the &lt;code&gt;install-deps.sh&lt;/code&gt; script, you&amp;#39;ll see it installs &lt;a href=&quot;http://www.sublimetext.com/3&quot;&gt;Sublime Text&lt;/a&gt;, my editor of choice. A massive annoyance of a new machine was re-installing all the packages I use, swapping key bindings and copying over snippets.&lt;/p&gt;

&lt;p&gt;Oliver&amp;#39;s script has a handy bit of code that clones a GitHub repository containing all the user settings for a Sublime instance. This means that with my new machine, it&amp;#39;ll grab all my packages and settings from [my GitHub repo][sublime-settings-repo) and replace the install user folder with my own. It works surprisingly well and means that I could have my own Sublime setup up and running on any machine.&lt;/p&gt;

&lt;p&gt;The only thing is, you&amp;#39;ve got to remember to occasionally push any changes back up to GitHub.&lt;/p&gt;

&lt;h3&gt;Customising iTerm&lt;/h3&gt;

&lt;p&gt;In amongst the series of applications that are installed is &lt;a href=&quot;https://www.iterm2.com/&quot;&gt;iTerm&lt;/a&gt;, a fantastic terminal replacement. Along with that, I install &lt;code&gt;zsh&lt;/code&gt; and &lt;code&gt;oh-my-zsh&lt;/code&gt;, all of which you should checkout if you don&amp;#39;t currently use them. Unfortunately there&amp;#39;s a few quirks with iTerm that slowdown my obsessive need to only use the keyboard.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Home/End shortcuts&lt;/strong&gt;
If you don&amp;#39;t have a full width keyboard, chances are you will use &lt;code&gt;⌘+←&lt;/code&gt; and &lt;code&gt;⌘+ →&lt;/code&gt; to go to the start and end of the line. Those keys aren&amp;#39;t mapped automatically in iTerm, but you can add them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open iTerm&amp;#39;s preferences (&lt;code&gt;⌘+,&lt;/code&gt;), click on &lt;code&gt;Profiles&lt;/code&gt; and then &lt;code&gt;Keys&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;code&gt;+&lt;/code&gt; button below the list of mappings and hit the keyboard shortcut you wish to use (either &lt;code&gt;⌘+←&lt;/code&gt; or &lt;code&gt;⌘+ →&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;In the action dropdown, select &lt;code&gt;Send Hex Code&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Set the value as &lt;code&gt;0x01&lt;/code&gt; for moving to the beginning of the line and &lt;code&gt;0x05&lt;/code&gt; for the end of the line.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;https://benholland.me/assets/2016/01/15/adding-new-key-maps-in-iterm.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deleting a word&lt;/strong&gt;
Another huge annoyance is not being able to delete a single word using the popular keyboard shortcut &lt;code&gt;⌥+⌫&lt;/code&gt;. To enable this, follow steps 1-3 above and use the code &lt;code&gt;0x17&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deleting the whole line&lt;/strong&gt;
Again, if you wish to delete an entire line using &lt;code&gt;⌘+⌫&lt;/code&gt; then follow steps 1-3 above and use the code &lt;code&gt;0x15&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maintain current directory when splitting a pane&lt;/strong&gt;
This is a real pane (whey!). Simple fix. Got preferences and click the &lt;code&gt;profiles&lt;/code&gt; tab again but make sure that you are on the &lt;code&gt;General&lt;/code&gt; tab. Look down to wear it says &lt;code&gt;Working Directory&lt;/code&gt; and click &lt;code&gt;Edit&lt;/code&gt; next to &lt;code&gt;Advanced configuration&lt;/code&gt;. The bottom option should be what to do when you split a pane. Select &lt;code&gt;Reuse previous session&amp;#39;s directory&lt;/code&gt;. Done!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://benholland.me/assets/2016/01/15/iterm-advanced-working-directory-settings.png&quot; alt=&quot;image&quot;&gt;
&lt;img src=&quot;https://benholland.me/assets/2016/01/15/maintaining-cwd-when-splitting-tabs-in-iterm.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;
</description>
        <pubDate>Fri, 15 Jan 2016 17:08:31 +0000</pubDate>
        <link>https://benholland.me/productivity/2016/01/15/setting-up-my-mac-and-iterm-again.html</link>
        <guid isPermaLink="true">https://benholland.me/productivity/2016/01/15/setting-up-my-mac-and-iterm-again.html</guid>
        
        <category>setup</category>
        
        <category>productivity</category>
        
        
        <category>productivity</category>
        
      </item>
    
      <item>
        <title>My Goals for 2016</title>
        <description>&lt;p&gt;New years resolutions aren&amp;#39;t really for me, but this year is going to be different. My life has become stagnant, repetitive and focused too much on one thing. It&amp;#39;s time for change and the beginning of a new year is a great opportunity to make those changes.&lt;/p&gt;

&lt;p&gt;I&amp;#39;ve decided to make a list of targets (not resolutions) for the coming year. It&amp;#39;s something that&amp;#39;s been encourage at various times in my career using techniques such as &lt;a href=&quot;https://en.wikipedia.org/wiki/OKR&quot;&gt;OKRs&lt;/a&gt; and &lt;a href=&quot;http://uk.businessinsider.com/salesforce-v2mom-process-2015-2&quot;&gt;V2MOMs&lt;/a&gt;. They appear to work well, but only if you make the goals measurable - saying &amp;quot;I&amp;#39;m going to do more exercise&amp;quot; won&amp;#39;t work as it&amp;#39;s not measurable. Saying &amp;quot;I&amp;#39;ll run 10 miles a week&amp;quot; is a measurable goal. Here are the 4 goals I&amp;#39;m going to achieve this year...&lt;/p&gt;

&lt;h3&gt;Write more about my personal experiences&lt;/h3&gt;

&lt;p&gt;I&amp;#39;ve had this site for a while, and apart from a short spell of writing during my free time at University, I&amp;#39;ve never really got in the flow of regularly posting content, and when I have, it&amp;#39;s always generally been centered around my work. This forms my first goal for the year, to write consistently about various aspects of both work and life. I&amp;#39;ll be aiming to average one post a week throughout the year (that&amp;#39;s 52 for anyone struggling with the maths).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Aim&lt;/strong&gt;: Write consistently&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Target&lt;/strong&gt;: 52 posts&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Finish in a sprint triathlon&lt;/h3&gt;

&lt;p&gt;In October 2014 I took on my biggest sporting challenge (outside of football) by running the Ealing half marathon with a few close friends. It was a great day and a fantastic event, but it wasn&amp;#39;t something I decided to carry forward. It became clear that long distance running wasn&amp;#39;t for me, but a multi-disciplined event excites me. By the end of the year, I&amp;#39;ll be aiming to enter and complete a sprint triathlon (750m swim, 20km bike, 5km run). Time to get back in the pool!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Aim&lt;/strong&gt;: Complete a sprint triathlon&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Target&lt;/strong&gt;: Get a shiny finishers medal&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Cook more frequently and don&amp;#39;t cut corners&lt;/h3&gt;

&lt;p&gt;The previous goal brings with it a few new challenges, one of which is to look after my body, and eating better is a great way to do that. I&amp;#39;ve been making excuses for years about why I rarely cook properly... &amp;quot;I&amp;#39;ve not got the time&amp;quot;, &amp;quot;It&amp;#39;s hard cooking for one&amp;quot; and &amp;quot;I&amp;#39;ll only cook something that requires 2 minutes of washing up&amp;quot;. This needs to change. Cooking is something I&amp;#39;ll be doing for the rest of my life, so it would be absurd to not improve my skills and learn to enjoy the process more.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Aim&lt;/strong&gt;: Cook more frequently, using fresh ingredients and taking less shortcuts&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Target&lt;/strong&gt;: One new meal a fortnight. No jars/shortcuts you lazy bastard!!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Side projects with a meaning&lt;/h3&gt;

&lt;p&gt;A great deal of my spare time over the past 3 years has been dedicated to my career by working on open source projects and doing a great deal of out of hours work. Although this has done a great things for me, I&amp;#39;d like to start applying that focus and effort towards my side projects, but not just any side projects. Giving back to my family and friends is something I&amp;#39;ve wanted to do for a while and I believe that using my skills can be a good way to do that. It can be anything from a simple application to help with managing their finances at home, to automating a mundane task at their workplace. I&amp;#39;ve no idea what kind of applications will come from this, but you never know, one could become something big (one can hope)!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Aim&lt;/strong&gt;: Develop side projects for friends and family&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Target&lt;/strong&gt;: 4 developed/finished projects&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 04 Jan 2016 00:00:00 +0000</pubDate>
        <link>https://benholland.me/life/2016/01/04/my-goals-for-2016.html</link>
        <guid isPermaLink="true">https://benholland.me/life/2016/01/04/my-goals-for-2016.html</guid>
        
        <category>goals</category>
        
        <category>aims</category>
        
        <category>targets</category>
        
        
        <category>life</category>
        
      </item>
    
      <item>
        <title>Checking I can still post to my blog</title>
        <description>&lt;p&gt;This is me checking if I can still easily create a new post on my blog... so hello I guess?? I&amp;#39;m planning to write more posts on here come the new year, but considering my last post was almost a year ago, we&amp;#39;ll see what happens.&lt;/p&gt;

&lt;p&gt;Speak soon.&lt;/p&gt;
</description>
        <pubDate>Mon, 14 Dec 2015 00:00:00 +0000</pubDate>
        <link>https://benholland.me/life/2015/12/14/checking-i-can-still-post-to-my-blog.html</link>
        <guid isPermaLink="true">https://benholland.me/life/2015/12/14/checking-i-can-still-post-to-my-blog.html</guid>
        
        
        <category>life</category>
        
      </item>
    
      <item>
        <title>The Importance of Being Part of a Community</title>
        <description>&lt;p&gt;Tonight was the first time I&amp;#39;ve been to a tech meetup in almost 8 months - I thought I didn&amp;#39;t miss attending them. Turns out I did and quite a lot.&lt;/p&gt;

&lt;p&gt;Since both moving house 9 months ago and moving offices to Wapping (East London), my interaction with central London, and in turn, the tech community came to a stand still. The need to travel further away from home and the lack of colleagues attending meetups after work meant that the motivation to attend them disappeared. It&amp;#39;s something that I didn&amp;#39;t think I&amp;#39;d really miss. I always enjoyed attending them but felt that I would learn just as much from reading articles and silently observing conversations on Twitter. Not only did I physical not attend events but my interactions over networks such as Twitter and Reddit became almost none exist. I didn&amp;#39;t feel like this was a problem, at least I wasn&amp;#39;t missing it.&lt;/p&gt;

&lt;p&gt;That brings me to tonight. I&amp;#39;m currently heading back home from London Web Standards, an event I was invited to attend last minute by an old colleague and good friend &lt;a href=&quot;https://twitter.com/jcatterfeld&quot;&gt;John Catterfeld&lt;/a&gt;. In a show of support for his first talk (and to hear the latest gossip at my old office) I attended. The gossip was fantastic - (there was some story about a bath and a stripper) and the talk wasn&amp;#39;t bad either - well done John.&lt;/p&gt;

&lt;p&gt;The highlight of the talks tonight were from &lt;a href=&quot;https://twitter.com/jcatterfeld&quot;&gt;John Catterfeld&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/torgo&quot;&gt;Dan Appelquist&lt;/a&gt; and &lt;a href=&quot;https://twitter.com/danielknell&quot;&gt;Daniel Knell&lt;/a&gt; who all presented something interesting and/or educational. The magic didn&amp;#39;t happen at the event though but instead before and after. When I was younger, people would always tell me that&amp;#39;s where you learn the most and they have always been right. A catchup with the always enthusiastic &lt;a href=&quot;https://twitter.com/patrickhamann&quot;&gt;Patrick Hamann&lt;/a&gt; reminded me of something I&amp;#39;d forgotten - I love what I do and I love talking to like minded people who are pushing the boundaries of our industry. Work is life is work is life. I came away from that conversation feeling more motivated than I&amp;#39;ve felt in a long while; ready to push the boundaries of what we can do at &lt;a href=&quot;http://www.rightmove.co.uk/&quot;&gt;Rightmove&lt;/a&gt; (my new workplace and home).&lt;/p&gt;

&lt;p&gt;Committing to events on a regular basis can be tricky, but I urge you to attend a few once in a while - it might just give you the boost you need. Encourage a few team members to come along as well. The more the merrier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here are some of the regular events in London that I attend. Checkout &lt;a href=&quot;http://lanyrd.com/&quot;&gt;Lanyrd&lt;/a&gt; and &lt;a href=&quot;https://www.eventbrite.co.uk/&quot;&gt;Eventbrite&lt;/a&gt; for the events nearest you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.frontendlondon.co.uk/&quot;&gt;Front-end London&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://funjs.co.uk/&quot;&gt;FunctionalJS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://londonwebstandards.org/&quot;&gt;London Web Standards&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://twitter.com/ldn_sass&quot;&gt;LDN Sass&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 14 Jan 2015 22:30:00 +0000</pubDate>
        <link>https://benholland.me/life/2015/01/14/the-importance-of-being-part-of-a-community.html</link>
        <guid isPermaLink="true">https://benholland.me/life/2015/01/14/the-importance-of-being-part-of-a-community.html</guid>
        
        
        <category>life</category>
        
      </item>
    
      <item>
        <title>Detecting When A User Clicks Outside of An Element</title>
        <description>&lt;p&gt;I was recently working on a complex problem involving a popup element. I wanted the popup to disappear when the user interacted with any other element on the page, except for the popup itself.&lt;/p&gt;

&lt;p&gt;Like most, I Googled the problem and very few elegant solutions came up. There was one however. Take a look below:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mouseup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;container&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;SELECTOR&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;is&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;has&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The snippet of code checks if the click element is either the popup itself or one of it&amp;#39;s children. You can read more about the &lt;code&gt;has&lt;/code&gt; method in the &lt;a href=&quot;http://api.jquery.com/has&quot;&gt;jQuery API documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;EDIT&lt;/h3&gt;

&lt;p&gt;It was pointed out by &lt;a href=&quot;http://benhowdle.im&quot;&gt;Ben Howdle&lt;/a&gt; and &lt;a href=&quot;http://danharper.me/&quot; target=&quot;_blank&quot;&gt;Dan Harper&lt;/a&gt; that there is an even simpler way to solve this problem. Check it out:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;popup&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'#popup'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'click'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;popup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;popup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stopPropagation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can &lt;a href=&quot;http://jsfiddle.net/benhoIIand/RqPfV/1/&quot;&gt;see this in action&lt;/a&gt; and readup about &lt;a href=&quot;http://api.jquery.com/has&quot; target=&quot;_blank&quot;&gt;e.stopPropagation&lt;/a&gt; in the jQuery documentation.&lt;/p&gt;
</description>
        <pubDate>Wed, 13 Mar 2013 15:30:00 +0000</pubDate>
        <link>https://benholland.me/javascript/2013/03/13/detecting-when-a-user-clicks-outside-of-an-element.html</link>
        <guid isPermaLink="true">https://benholland.me/javascript/2013/03/13/detecting-when-a-user-clicks-outside-of-an-element.html</guid>
        
        
        <category>javascript</category>
        
      </item>
    
      <item>
        <title>The Best Packages, Shortcuts and Customisations in Sublime Text 2</title>
        <description>&lt;p&gt;The best thing about Sublime Text 2 is the amount of customization it gives the user and the ease in which it does this. Here are a list of the best features I use on a day-to-day basis...&lt;/p&gt;

&lt;h3&gt;Projects&lt;/h3&gt;

&lt;p&gt;During the day I can work on up to 5 or 6 various tasks, so having my different codebases setup into projects is extremely useful. All you need to do to create a new project is drag a folder into your sidebar, go to Project in the menu bar and click save as. You can add multiple folders to a project.&lt;/p&gt;

&lt;p&gt;To easily switch between projects, hit &lt;code&gt;Ctrl+Alt+P&lt;/code&gt; (Cmd+Shift+P on Mac) and start searching for the project you&amp;#39;re after.&lt;/p&gt;

&lt;p&gt;Once within a project, you can hit &lt;code&gt;Ctrl+P&lt;/code&gt; (Cmd+P) and search for any filename within that project. Pretty cool stuff!&lt;/p&gt;

&lt;h3&gt;Packages&lt;/h3&gt;

&lt;p&gt;There are loads of packages out there for Sublime. The number is always growing, and to keep most of them in one place, Package Control was created.&lt;/p&gt;

&lt;p&gt;You first need to install &lt;a href=&quot;http://wbond.net/sublime_packages/package_control&quot;&gt;Package Control&lt;/a&gt;. Once that&amp;#39;s done, hit &lt;code&gt;Ctrl+Shift+P&lt;/code&gt; (Cmd+Shift+P). This is the command palette and lists all available commands currently installed. Start typing &amp;quot;Install Package&amp;quot; and hit enter. From here you can search for packages within the Package Control repo. You can even manually install them using a link (usually a public GitHub link).&lt;/p&gt;

&lt;p&gt;Here are the packages I used often:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SublimeCodeIntel&lt;/strong&gt; - Code intelligence plugin ported from Open Komodo Editor&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SublimeLinter&lt;/strong&gt; - SublimeLinter comes with built in linters for loads of languages&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prefixr&lt;/strong&gt; - A Sublime Text 2 plugin to run CSS through the Prefixr API&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Emmet&lt;/strong&gt; - (previously Zen Coding) lets you use shortcuts to generate HTML and CSS&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Clipboard History&lt;/strong&gt; - Saves previously copied text for easy retrieval&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Code Alignment&lt;/strong&gt; - Easily align code using colons, commas etc&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JsFormat&lt;/strong&gt; - Formats given JavaScript code&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CssLisible&lt;/strong&gt; - Tidy up CSS based on given rules&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;FileDiffs&lt;/strong&gt; - Compares two given files&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LESS build&lt;/strong&gt; - Adds a build engine to compile LESS&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Markdown Previewer&lt;/strong&gt; - Lets you see a temp file of your markdown code. Comes with GitHub flavoring option&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sidebar Enhancements&lt;/strong&gt; - Adds windows functionality to the sidebar (right-click menu)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Themes&lt;/strong&gt; - &lt;a href=&quot;https://github.com/daylerees/colour-schemes&quot;&gt;Colour Schemes&lt;/a&gt; : &lt;a href=&quot;https://github.com/chriskempson/tomorrow-theme&quot;&gt;Tomorrow Theme&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There a loads more out there, so let me know if you find some more useful ones&lt;/p&gt;

&lt;h3&gt;Special Customizations&lt;/h3&gt;

&lt;p&gt;Sublime comes with lots of various options that you can configure to your needs. You&amp;#39;ll find all the available settings in the default settings file (Preferences &amp;gt; Settings - Default). It&amp;#39;s filled with comments explaining what each option does, so if some of the ones below don&amp;#39;t make sense, do a quick search for them:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;&quot;font_face&quot;: &quot;Consolas&quot;,
&quot;font_size&quot;: 9,
&quot;caret_style&quot;: &quot;phase&quot;,
&quot;highlight_line&quot;: true,
&quot;line_padding_top&quot;: 1,
&quot;line_padding_bottom&quot;: 1,
&quot;bold_folder_labels&quot;: true,
&quot;highlight_modified_tabs&quot;: true,
&quot;tab_size&quot;: 4,
&quot;translate_tabs_to_spaces&quot;: true,
&quot;trim_trailing_white_space_on_save&quot;: true,
&quot;dictionary&quot;: &quot;Packages/Language - English/en_GB.dic&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;These are some more handy settings to look into:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;&quot;spell_check&quot;: false,
&quot;gutter&quot;: true,
&quot;line_numbers&quot;: true,
&quot;save_on_focus_lost&quot;: false,
&quot;highlight_modified_tabs&quot;: false,
&quot;folder_exclude_patterns&quot;: [&quot;.svn&quot;, &quot;.git&quot;, &quot;.hg&quot;, &quot;CVS&quot;],
&quot;file_exclude_patterns&quot;: [&quot;*.pyc&quot;, &quot;*.pyo&quot;, &quot;*.exe&quot;, &quot;*.dll&quot;, &quot;*.obj&quot;,&quot;*.o&quot;, &quot;*.a&quot;, &quot;*.lib&quot;, &quot;*.so&quot;, &quot;*.dylib&quot;, &quot;*.ncb&quot;, &quot;*.sdf&quot;, &quot;*.suo&quot;, &quot;*.pdb&quot;],
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can have specific settings set for each project as well. So I have a project which contains all my blog posts. Within this project, I have the option &lt;code&gt;spell_check&lt;/code&gt; turned on. You can enable settings for projects by going to &lt;em&gt;Projects &amp;gt; Edit Project&lt;/em&gt; and adding your settings&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;folders&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;s2&quot;&gt;&quot;path&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/C/folder/project_location&quot;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;settings&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;s2&quot;&gt;&quot;spell_check&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;s2&quot;&gt;&quot;dictionary&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Packages/Language - English/en_GB.dic&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Shortcuts&lt;/h3&gt;

&lt;p&gt;Knowing shortcuts in any program can increase productivity massively. Here are the ones I use most often (replace Ctrl for Cmd on a Mac). Again, all the key bindings live in &lt;em&gt;Settings &amp;gt; Key Bindings - Default&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;Ctrl+P                 =&amp;gt; Search for file in project
Ctrl+Shift+P       =&amp;gt; Launch command palette

Ctrl+F                  =&amp;gt; Find
Ctrl+H                 =&amp;gt; Find and Replace
Ctrl+Shift+F        =&amp;gt; Find in Project

Ctrl+D                 =&amp;gt; Select current word
Ctrl+Shift+D       =&amp;gt; Duplicate line or selected text

Ctrl+Shift+Up         =&amp;gt; Move line up
Ctrl+Shift+Down    =&amp;gt; Move line down

Alt+Shift+1        =&amp;gt; Split into 1 of columns
Alt+Shift+2        =&amp;gt; Split into 2 of columns
Alt+Shift+3        =&amp;gt; Split into 3 of columns
Alt+Shift+4        =&amp;gt; Split into 4 of columns

Alt+Shift+5        =&amp;gt; Split into a grid of 4

Alt+Shift+8        =&amp;gt; Split into a 2 rows
Alt+Shift+9        =&amp;gt; Split into a 3 rows

Ctrl+B                  =&amp;gt; Build
Ctrl+R                  =&amp;gt; Shows all methods/functions/selectors in that file
Ctrl+K, Ctrl+B      =&amp;gt; Hide/Show sidebar
Shift+F11             =&amp;gt; Distraction Free Mode
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;One shortcut that gets it&amp;#39;s own special mention is &lt;code&gt;Ctrl+T&lt;/code&gt;. This bad boy allows you to create a new file relative to the file you are in now. A small bar will appear at the bottom of the window allowing you to type the folder and file names. Here are some examples:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;// Lets say we are currently editing the file' /css/main.css' and we hit Ctrl+T
// If we create a new file from here with the following paths...

fonts.css                =&amp;gt; creates the file 'fonts.css'
module/file.css     =&amp;gt; creates the file 'file.css' in the 'modules' folder
../index.html         =&amp;gt; creates the file index.html in the parent folder

// if a folder doesn't exist, Sublime will create it for us
// you can't create a new file which already exists
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Snippets&lt;/h3&gt;

&lt;p&gt;Snippets are incredible useful. They are the things that popup in the autocomplete box as you type. If you find yourself writing the same code over and over, put it into a snippet.&lt;/p&gt;

&lt;p&gt;To create a snippet, go to &lt;em&gt;Tools &amp;gt; New Snippet&lt;/em&gt;. A new window will open with some code and some options.&lt;/p&gt;

&lt;p&gt;Firstly, the snippet content is the code we want to produce. The text mark with a &lt;code&gt;$&lt;/code&gt; signifies a tab point. So when the user selects the snippet, the cursor moves to position one &lt;code&gt;${1:this}&lt;/code&gt;. If tab is hit, then the cursor moves to position 2 &lt;code&gt;${2:snippet}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The text within the brackets is the default values and will be highlighted when you get to that position. Alternatively, if you don&amp;#39;t want a default value, just use &lt;code&gt;$1&lt;/code&gt; or &lt;code&gt;$2&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;snippet&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;content&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;![CDATA[
Hello, ${1:this} is a ${2:snippet}.
]]&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/content&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Optional: Set a tabTrigger to define how to trigger the snippet --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- &amp;lt;tabTrigger&amp;gt;hello&amp;lt;/tabTrigger&amp;gt; --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Optional: Set a scope to limit where the snippet will trigger --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- &amp;lt;scope&amp;gt;source.python&amp;lt;/scope&amp;gt; --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/snippet&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can set a tabTrigger, which is the word or phrase to trigger than snippet showing up in the autocomplete results. Pick something you will easily remember. The final option is scope which only shows that snippet up for a certain syntax&lt;/p&gt;

&lt;p&gt;Here are a few examples I created...&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;// creates console.log('') and places the cursor inside of the parentheses

&lt;span class=&quot;nt&quot;&gt;&amp;lt;snippet&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;content&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;![CDATA[
console.log('$1');
]]&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/content&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;tabTrigger&amp;gt;&lt;/span&gt;console&lt;span class=&quot;nt&quot;&gt;&amp;lt;/tabTrigger&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;scope&amp;gt;&lt;/span&gt;source.js&lt;span class=&quot;nt&quot;&gt;&amp;lt;/scope&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;description&amp;gt;&lt;/span&gt;console.log&lt;span class=&quot;nt&quot;&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/snippet&amp;gt;&lt;/span&gt;


// quickly adds jQuery source to a file

&lt;span class=&quot;nt&quot;&gt;&amp;lt;snippet&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;content&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;![CDATA[
&amp;lt;script src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js&quot;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
]]&amp;gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/content&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;tabTrigger&amp;gt;&lt;/span&gt;jQuery&lt;span class=&quot;nt&quot;&gt;&amp;lt;/tabTrigger&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;description&amp;gt;&lt;/span&gt;imports jQuery&lt;span class=&quot;nt&quot;&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/snippet&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
        <pubDate>Fri, 11 Jan 2013 06:17:15 +0000</pubDate>
        <link>https://benholland.me/resources/2013/01/11/the-best-packages-shortcuts-and-customisations-in-sublime-text-2.html</link>
        <guid isPermaLink="true">https://benholland.me/resources/2013/01/11/the-best-packages-shortcuts-and-customisations-in-sublime-text-2.html</guid>
        
        
        <category>resources</category>
        
      </item>
    
      <item>
        <title>Beware of Trailing Slashes When Using Disqus</title>
        <description>&lt;p&gt;I ran into a small bug with the commenting system &lt;a href=&quot;http://www.disqus.com&quot;&gt;Disqus&lt;/a&gt; today. After migrating all my posts from WordPress to Disqus, I noticed that comments weren&amp;#39;t appearing on some blog posts. With some further investigation, it turned out that my WordPress URLs all had a trailing slash at the end, whereas in the new build of my site, they don&amp;#39;t. This meant that the URLs I was serving visitors and those that were in the system didn&amp;#39;t match.&lt;/p&gt;

&lt;p&gt;It&amp;#39;s not a complicated bug to deal with, but something that can be easily missed. To solve the problem, I added this to my htaccess file. It redirects all URLs without a trailing slash to one does:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;# htaccess trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*[^/]$ /$0/ [L,R=301]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
        <pubDate>Thu, 10 Jan 2013 22:47:27 +0000</pubDate>
        <link>https://benholland.me/news/2013/01/10/beware-of-trailing-slashes-when-using-disqus.html</link>
        <guid isPermaLink="true">https://benholland.me/news/2013/01/10/beware-of-trailing-slashes-when-using-disqus.html</guid>
        
        
        <category>news</category>
        
      </item>
    
      <item>
        <title>How to Setup and Work with Virtual Hosts using WAMP Server</title>
        <description>&lt;p&gt;What you&amp;#39;ll need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Windows machine&lt;/li&gt;
&lt;li&gt;A working copy of WAMP server (&lt;a href=&quot;/tutorial/setting-up-a-wamp-server-on-windows&quot;&gt;go here if not&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;What is a virtual host?&lt;/h3&gt;

&lt;p&gt;The Wikipedia definition is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Virtual hosting is a method for hosting multiple domain names (with separate handling of each name) on a single server (or pool of servers)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In my workflow, I use the prefix &amp;#39;local&amp;#39; to keep my local sites separate from real ones. So for a site called &amp;#39;test-site&amp;#39;, I would create the virtual host &amp;#39;http://local.test-site&amp;#39;. This allows the site to act like it would if I pushed it to a live server.&lt;/p&gt;

&lt;h3&gt;Creating a Virtual Host&lt;/h3&gt;

&lt;p&gt;We&amp;#39;ll need to modify a few configuration files to do this. So open the WAMP directory and navigate to:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;C:\wamp\bin\apache\apache2.2.22\conf\
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Open up &lt;code&gt;httpd.conf&lt;/code&gt;, scroll to the bottom and uncomment the following line by removing the hash:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;Include conf/extra/httpd-vhosts.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now navigate to the &lt;code&gt;extra&lt;/code&gt; folder and open up &lt;code&gt;httpd-vhosts.conf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This file show be pre-populated with some dummy examples for you to use. Feel free to keep them, but I removed them. Add the following to create a new virtual host:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;VirtualHost&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;*:80&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    DocumentRoot &quot;c:/wamp/www/test-site&quot;
    ServerName local.test-site
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Directory&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;&quot;c:/wamp/www/test-site&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      Allow from all
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Directory&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here, we are defining a new virtual host with the server name we want to use, the root of our site and the settings for this directory.&lt;/p&gt;

&lt;p&gt;Now open up our machine host files, which can be found at &lt;code&gt;C:\Windows\system32\drivers\etc\hosts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This file keeps your host file entries. Here we tell the machine where to go if we request a certain URL. So here&amp;#39;s an example of routing Google to our local host:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;127.0.0.1       www.google.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Every request made to the url &amp;#39;www.google.com&amp;#39; from this machine will redirect it to the IP 127.0.0.1 (our localhost)&lt;/p&gt;

&lt;p&gt;To route to our test site, we create a new host entry:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;127.0.0.1       local.test-site
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will redirect any requests to &lt;code&gt;http://local.test-site&lt;/code&gt; to our localhost, which will then make the &lt;code&gt;test-site&lt;/code&gt; folder our default location.&lt;/p&gt;

&lt;p&gt;You will find that there is already an entry for &amp;#39;localhost&amp;#39;. Just add our new entry below this one.&lt;/p&gt;

&lt;h3&gt;Summary&lt;/h3&gt;

&lt;p&gt;Easy peesy. So whenever you add a new site, create a new virtual host by changing the server name and root location, then add the server name to your host entries.&lt;/p&gt;

&lt;p&gt;Our final step is to restart the WAMP server. You can do this by clicking on the WAMP icon in the system tray and hitting &amp;#39;Restart all services&amp;#39;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; All this switching between host files can get annoying, so if you use Sublime Text, here&amp;#39;s a neat tip - LINK&lt;/p&gt;
</description>
        <pubDate>Thu, 10 Jan 2013 22:36:19 +0000</pubDate>
        <link>https://benholland.me/tutorials/2013/01/10/how-to-setup-and-work-with-virtual-hosts-using-wamp-server.html</link>
        <guid isPermaLink="true">https://benholland.me/tutorials/2013/01/10/how-to-setup-and-work-with-virtual-hosts-using-wamp-server.html</guid>
        
        
        <category>tutorials</category>
        
      </item>
    
      <item>
        <title>Setting Up a WAMP Server on Windows</title>
        <description>&lt;p&gt;What you&amp;#39;ll need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Windows machine&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;What is a WAMP server?&lt;/h3&gt;

&lt;p&gt;WAMP stands for Windows, Apache, MySQL and PHP and is a set of applications allowing a web server to run locally on a Windows machine. This makes build websites with server side content (PHP in our case) super easy.&lt;/p&gt;

&lt;p&gt;This post, along with some others, is a guide to setting up a Linux server on your machine...&lt;/p&gt;

&lt;h3&gt;Installing WAMP&lt;/h3&gt;

&lt;p&gt;Firstly, we need to grab a copy of WAMP. Head over to the &lt;a href=&quot;http://www.wampserver.com/en/&quot;&gt;WampServer website&lt;/a&gt;, click the &amp;quot;start using WampServer&amp;quot; and download the correct version for you, depending on whether you&amp;#39;re running a 32 or 64 bit version of Windows. (to see your version, right-click on &amp;#39;My Computer&amp;#39; and find &amp;#39;System Type&amp;#39;). I normally select &amp;#39;WampServer (64 bits &amp;amp; PHP 5.4) 2.2E.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://benholland.me/assets/2013/01/wampserver-download.jpg&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;

&lt;p&gt;Install the program, leaving all settings as default.&lt;/p&gt;

&lt;p&gt;When the install is finished, launch &lt;a href=&quot;http://localhost&quot;&gt;http://localhost&lt;/a&gt; in your browser. You may be greeted by a pleasant message saying &amp;quot;Forbidden - You don&amp;#39;t have permission to access / on this server&amp;quot;. Let&amp;#39;s fix this.&lt;/p&gt;

&lt;p&gt;By default, the server we created will deny all incoming connections, so we need to change this. Click on the WAMP icon in the system tray, hover over &lt;code&gt;Apache&lt;/code&gt; then click &lt;code&gt;httpd.conf&lt;/code&gt;. Open this file and search for:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Directory&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;c:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;wamp&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;www&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;/&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Change this to &lt;code&gt;Allow from all&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, when you go to &lt;a href=&quot;http://localhost&quot;&gt;http://localhost&lt;/a&gt;, you should see the WAMP homepage!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://benholland.me/assets/2013/01/wampserver-localhost-homepage.jpg&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;

&lt;h3&gt;Creating A Site&lt;/h3&gt;

&lt;p&gt;Open the WAMP directory again, and go to &lt;code&gt;www&lt;/code&gt; folder. This is the where all your sites are going to be kept.&lt;/p&gt;

&lt;p&gt;You should already see a &lt;code&gt;index.php&lt;/code&gt; file in here. Open that within your text editor, add some text, save and close. Now head back to your browser and refresh the page to see the change.&lt;/p&gt;

&lt;p&gt;Create a new folder called &lt;code&gt;test-site&lt;/code&gt; and within this copy the &lt;code&gt;index.php&lt;/code&gt; file, delete everything in it and add some markup:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Welcome to Test-Site&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now go to &lt;code&gt;http://localhost/test-site&lt;/code&gt; in your browser. As you can see, we have created a new website on our local server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you are currently using Dropbox to sync projects across multiple machines, you can change the location of your Dropbox folder to the &lt;code&gt;www&lt;/code&gt; folder. This will allow all your environments to sync automatically. (I have this setup on my work/home PC and laptop).&lt;/p&gt;

&lt;h3&gt;Summary&lt;/h3&gt;

&lt;p&gt;Stopping here is fine. You can work using this directory format, but things can get tricky with larger sites when it comes to htaccess and image/file paths (they did for me). So to combat this we create &amp;#39;virtual hosts&amp;#39;. They allow you to point a custom URL to a certain project folder, i.e. &lt;code&gt;http://local.test-site&lt;/code&gt; redirects to our test-site folder.&lt;/p&gt;

&lt;p&gt;To read more about this, checkout this post on &amp;quot;&lt;a href=&quot;#&quot;&gt;How to Setup and Work with Virtual Hosts using WAMP Server&lt;/a&gt;&amp;quot;&lt;/p&gt;
</description>
        <pubDate>Thu, 10 Jan 2013 12:10:08 +0000</pubDate>
        <link>https://benholland.me/tutorials/2013/01/10/setting-up-a-wamp-server-on-windows.html</link>
        <guid isPermaLink="true">https://benholland.me/tutorials/2013/01/10/setting-up-a-wamp-server-on-windows.html</guid>
        
        
        <category>tutorials</category>
        
      </item>
    
  </channel>
</rss>
