Updated .gitignore But Files Are Still Tracked?

Git has a simple feature to ignore files and folders.  Create a .gitignore file and using basic glob syntax, you can tell Git what files you do not want tracked in the repository.

But what happens when you've already submitted stuff you no longer want tracked?  You can update the .gitignore file, but Git still holds on to the items you've already submitted.

Let's say you're using ReSharper (you should, it's awesome) and you've accidentally submitted the ReSharper project files into the repo.

You update your .gitignore as follows:
# Ignore ReSharper stuff
_ReSharper*
Easy.  Now, to get Git to release the already tracked stuff, run this:
git rm -r --cached *_ReSharper*
And all the ReSharper associated stuff will now be flagged for removal.  Commit your changes (along with the .gitignore of course) and you're done.

Protocol-Relative URLs

One of the things I love about programming and development in general is that, no matter how well you think you know something, there's always something that can surprise you.

It doesn't matter what language/domain/stack/toolset you're working with, there are often ways of doing things you haven't thought of.  Sometimes these other ways of doing things are obscure or different to your normal way of thinking.  That's why you've missed them to begin with.

Other times, well...you can't see why you haven't thought of them.  I like it when the surprises are so simple, so immediately effective, that you can be pretty sure you'll remember them from then on.

So to the point.

I'm currently reading Javascript Web Applications.  An excellent book by Alex MacCaw, the author of Spine.  Aside from the book being pretty well written, there are some awesome nuggets of information in there.  In a section discussing the benefits of using a CDN, the following example code is used:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
Just double check that again, did you see it? There's no protocol declared for the script request. This makes it a protocol-relative URL.  The request for the script will be completed over the same protocol as the current page.

Relative URLs? Got that.  Protocol-relative URLs? Why haven't I thought of that before!?

The advantage of this is that you can prevent virtually all annoying mixed content warnings!  Paul Irish has some more info and highlights one or two quirks with IE (of course) and stylesheets.  But the trick can be used for any extra content to load into the page.  It can also be used in pretty much every browser.  IE 3.0 supported it, why didn't I learn this in Web Dev 101?

A Simple LocalStorage Model

I've been playing around with Google Chrome extensions again (you should too, they are really simple).

Chrome extensions at their most basic level consist of HTML and Javascript; allowing full utilisation of HTML5 APIs such as WebStorage, IndexedDb and everything else. Chrome sandboxes extensions just as it does with each tab you have open, so an extension follows the HTML5 requirements of only having access to it's own 'domain' of data.

When creating an extension, you'll likely want to store some data. The HTML5 WebStorage spec allows a site (or extension in this case) to store simple key value pairs. This is ideal for extensions looking to keep track of simple things such as user preferences. It shouldn't be used for complex data or data that you'll be expecting to search over. Use IndexedDb for that.

The following is a simple mechanism which can be used in an extension to store and retrieve data using localStorage. It provides no data validation or verification other than returning null if no data is found and storing values as JSON.

Stored properties are added by calling the settings.implement function. The function will take any number of parameters, so additional properties can be added with ease. Properties are checked to see if they already exist before being created.

As the model is in Javascript, it can of course be utilised by any web page as well :-)

GiveCampUK - Excited Doesn't Cover It

GiveCamp is coming to the UK and I'm incredibly nervously excited to be taking part!

I'll be heading up a team of five developers from work, developing on a project for The Prison Phoenix Trust. It looks to be an interesting project involving some data migration, custom reporting and a simple front end.

The weekend is set to be a busy, highly focussed, caffeine-swilling, sleep-depriving flurry of development, but I'm confident we'll be able to produce something that hits the target.

https://twitter.com/#!/Kieranties/status/126658064173633539 The event is being organised by Paul Stack and Rachel Hawley who have both done a fantastic job in gathering a host of people from around the UK to attend the event.

Tomorrow the fun begins!

A successful Git branching model » nvie.com

A really quite excellent blog post by Vincent Driessen which provides a clear process and direction for users of any Distributed Version Control System (DVCS). Focussing on Git and demonstrating the process through neat visual diagrams as well as the simple commands to use, this is a highly recognised and valued strategy.
... I present the development model that I’ve introduced for all of my projects ... which has turned out to be very successful... I won’t talk about any of the projects’ details, merely about the branching strategy and release management.
A successful Git branching model » nvie.com
I'm hoping I will be able to take the time at work to revise our current branching strategy.  We already implement close to 80% of what Vincent discusses, but I'm convinced implementing the whole process will aid supporting live systems as well as tidying up the general dev-test-deploy procedure.

Of course, the usual problems with this procedure arise through confusion over which version is next to be deployed or what branch contains what feature. Fortunately, many others have had the same issues; bringing about the creation of the git-flow collection of extensions. These extensions really refine the workflow process and I'm sure will be key to reduce the friction when bringing the rest of the team up to speed.

txt2re: Regular Expression Generator

[Link]
A pretty awesome page to help when creating regular expressions.  Type in the string you want to match, then use the selectors to create a snippet of code with the regex and validation process pre-populated, allowing you to drop the code straight into your application. (full credit to Zoe Nolan for the link!)

This is a cracking starting point for some simple regex work (or when your head just isn't wrapping itself around the joys of regex), but for more detailed help, pointers and tips I'd suggest taking a look at the following:

Building Mobile Javascript Webapps With BackboneJS & jQuery: Part 1


Addy Osmani talks through a sample photo gallery built with Backbone.js and the JQuery Mobile framework.
He discusses a complete overview of Backbone 0.5.2's components introducing plenty of clear code samples, as well as talking through the issues surrounding routing when coupled with jQuery Mobile.
The two part series should prove to be an excellent starting point for those looking to create a pure Javascript driven web application.
It'll be interesting to see how things compare to an implementation using Spine.js and/or the Zepto.js framework

Quick And Simple NodeJS Setup

Getting up and running with Node is pretty simple.  Here's a quick script (with the largest part of help from here) to move things along that little bit quicker.  This isn't the best way if you want to stay up to date with releases, this will just get Node installed and ready to play

CDN JS - The Missing CDN

What is it? Everyone loves the Google CDN right? Even Microsoft runs their own CDN. The problem is, they only host the most popular libraries. We host the other stuff.

A CDN designed to cater for the other javascript libraries people use.

Cdnjs.com is a CDN governed by users/developers. You can request a library to be added where it will be peer-reviewed and if successful, made available to all.

Looks to be a simple way to add functionality while developing as well as provide an easy deployment process, amongst all the other benefits CDNs offer.

TameJS

Note Tame is not an attempt to dumb down async programming. It's just a cleaner way to write it. Further, your programs will likely have lower latency; with Tame it's a lot easier to keep parallel calls parallel.

Tame JS doesn't just 'dumb down' async programming in Javascript, it makes it beautiful, simple and incredibly elegant.

The sample code demonstrating parallel dns lookups in Node show just how simple it is.

Definitely one to play with in the future.

(again thanks to Steve Pope for the link)

Essential Javascript Design Patterns For Beginners

In this book, we will take a look at a number of popular JavaScript design patterns and explore why certain patterns may be more suitable for your projects than others. Remember that patterns can be applied not just to vanilla JavaScript, but also to abstracted libraries such as jQuery or Dojo as well. Before we begin, let’s look at the exact definition of a ‘pattern’ in software design.

A free mini book from Addy Osmani available as a straight htm download, or (if you navigate up the site tree) as an ePub.

Osmani also writes some cracking articles on HTML5, jQuery and Javascript in general

DotNetZip Library

DotNetZip is an easy-to-use, FAST, FREE class library and toolset for manipulating zip files or folders. Zip and Unzip is easy: with DotNetZip, .NET applications written in VB, C# - any .NET language - can easily create, read, extract, or update zip files. For Mono or MS .NET.

By far, the easiest .NET zip library I've used to date

To echo Node’s evolutionary nature, we have refreshed the identity to help mark an exciting time for developers, businesses and users who benefit from the pioneering technology.

Building a brand

We began exploring elements to express Node.js and jettisoned preconceived notions about what we thought Node should look like, and focused on what Node is: kinetic,connectedscalablemodularmechanical and organic. Working with designer Chris Glass, our explorations emphasized Node’s dynamism and formed a visual language based on structure, relationships and interconnectedness.

Inspired by process visualization, we discovered pattern, form, and by relief, the hex shape. The angled infrastructure encourages energy to move through the letterforms.

This language can expand into the organic network topography of Node or distill down into a single hex connection point.

This scaling represents the dynamic nature of Node in a simple, distinct manner.

We look forward to exploring this visual language as the technology charges into a very promising future.

We hope you’ll have fun using it.

To download the new logo, visit nodejs.org/logos.

I'm no designer, I wouldn't say I have a keen eye for good looks, style or art. But I find the new logo rather... jarring. Something just makes my eyes hurt.

Full credit to the node team though. The requirement for building a brand as they put it means node is continuing it's progression to the fabled 1.0 release

New NodeJS Logo - A Little Fugly?

To echo Node’s evolutionary nature, we have refreshed the identity to help mark an exciting time for developers, businesses and users who benefit from the pioneering technology.

Building a brand

We began exploring elements to express Node.js and jettisoned preconceived notions about what we thought Node should look like, and focused on what Node is: kinetic,connectedscalablemodularmechanical and organic. Working with designer Chris Glass, our explorations emphasized Node’s dynamism and formed a visual language based on structure, relationships and interconnectedness.

Inspired by process visualization, we discovered pattern, form, and by relief, the hex shape. The angled infrastructure encourages energy to move through the letterforms.

This language can expand into the organic network topography of Node or distill down into a single hex connection point.

This scaling represents the dynamic nature of Node in a simple, distinct manner.

We look forward to exploring this visual language as the technology charges into a very promising future.

We hope you’ll have fun using it.

To download the new logo, visit nodejs.org/logos.

I'm no designer, I wouldn't say I have a keen eye for good looks, style or art. But I find the new logo rather... jarring. Something just makes my eyes hurt.

Full credit to the node team though. The requirement for building a brand as they put it means node is continuing it's progression to the fabled 1.0 release

Extension API Updates in Chrome 13

...you can now make cross-origin XMLHttpRequest calls with the privileges of the extension directly from your content script. You will no longer need to relay these requests through a background page; this should simplify your code. In some cases, it may even eliminate your need to use a background page. Here’s a sample extension which demonstrates the old way a content script could make a cross domain request. As you can see, the extension required a background page to route the cross-origin calls through a chrome.extension.onRequest listener. Using the new content script cross-origin capabilities, we were able to successfully rewrite the extension to completely eliminate the background page requirement. This reduces the memory required to run the extension, and reduces code complexity as well...

You can now (as of Chrome 13) directly execute cross-origin XMLHttpRequest calls from content script pages, as opposed to routing calls through the extension background page.

This is a real performance gain as the background page does not have to be riddled with listeners and in some cases can be removed from the extension all together.  Content scripts are injected based on match patterns in the extensions manifest file.

Further advances include additional match pattern options and advances to the Proxy API

YUI Theater — Ryan Dahl: “Introduction to NodeJS”

NodeJS is going from strength to strength in both recognition and adoption. And rightfully so.

An event driven, dynamic, robust server architecture that can turn its hand to near any task deserves a good deal of credit. Ryan Dahl, its creator, deserves much of this credit.

NodeJS sparked an interest in me some time ago and I'm hoping to one day add it to a list of my proficiencies.
Credit to Steve Pope for spotting the vid

Hello? Hello? Is This Thing On?


So it's that time again.

That time when I think I should sort myself out.  Write those blogs posts.  Finish that code snippet.  Make a note of that interesting site.  Leave a reminder to myself (and others) of how I fixed that random edge-case bug.

I've tried this before and I think it didn't work for two reasons:

  • I'm a coder at heart - I love it - but I used to be in a job that was killing that love.
  • Time.  I sometimes dedicate too much time to things that are fun, but less productive.  Having recognised that I'm hoping I can change it.

The plan is to use this domain to keep track of my projects and brain waves, anything that I think will be of future use to myself or others.  On occasion it will just be somewhere that I can start a conversation or a bit of a debate.

Posts will largely be centered around coding and most likely only be snippets that have helped me get through a task.  But I'd like to dedicate some time to do a series of posts on a given topic (maybe Chrome extensions) and perhaps get a long post out once a fortnight.

I don't consider myself to be on the bleeding edge of most tech - there's a lot of tech out there after all.  There are also many, many people out there that have a considerably larger understanding of topics that I intend to cover and teach myself (some I have even had the pleasure of meeting or even working with).

This blog will be an avenue of opportunity for me to add my small voice to an overcrowded conversation but perhaps in joining the conversation I'll be able to further my own knowledge as well as help educate others.

So let's see how things go, eh?