Skip to content

Instantly share code, notes, and snippets.

The Importance of SemVer

SemVer or Semantic Versioning is an important tool to help us build large modular systems. Most modern programming languages have a package manager of some description to go with them. This lets you install dependencies easilly, and it allows those dependencies to have their own dependencies and so on. The advantage of this is that modules can share code, which saves time and speeds up bug fixing.

For the Library Consumer

OK, so lets imagine your building a large web-app and you've got lots of dependencies because you know that's better than re-writing or copy and paste programming. You have broadly 3 options for how you lock down your dependency versions:

  1. Use * to always get the latest
  2. Use an exact version number to always stay on the same version
function humanize(num){
var ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine',
'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen',
'seventeen', 'eighteen', 'nineteen'];
var tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty',
'ninety'];
var numString = num.toString();
if (num < 0) throw new Error('Negative numbers are not supported.');
@ForbesLindesay
ForbesLindesay / permutation.js
Created April 26, 2013 15:57
Generate permutations of an array in lexicographic order (using http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order)
function next(start) {
start = start;
//Find the largest index k such that a[k] < a[k + 1].
var k = start.length - 2;
while (k >= 0 && start[k] >= start[k + 1]) k--;
//If no such index exists, the permutation is the last permutation.
if (k < 0) return null;
//Find the largest index j such that a[k] < a[j].
var jade = require('jade');
var hljs = require('highlight.js');
function highlightJavaScript(js) {
return hljs.highlight('javascript', js).value;
}
function escape(src) {
return src.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')

Different people seem to go with vastly different release strategies for software. When and how often you release has knock on affects on how you test and how you develop or consider new features.

Assumptions

  1. Releasing a new version of your software is fast and easy.
  2. Downloading an updated version of your software is fast and easy.

Both these points should almost always be under your control. If they aren't true, do everything in your power to make them true. If you're going through an App Store, point 2 should be implicitly true. Point 1 is usually true in that submitting is pretty quick and easy. It might take a few weeks to actually get reviewed and published, but there's nothing to stop you following up with a new release in the mean time: it's a pipeline.

If you manage the whole software stack, make downloading updates fully transparent (think Google Chrome). If it's a library, then use and rely on SemVer. Ma

@ForbesLindesay
ForbesLindesay / MD5.js
Created May 12, 2013 09:18
Modified to only support data as a string
/*
Javascript MD5 library - version 0.4
Coded (2011) by Luigi Galli - LG@4e71.org - http://faultylabs.com
Thanks to: Roberto Viola
The below code is PUBLIC DOMAIN - NO WARRANTY!
*/
/*
console.dir = function (obj) {
console.log(require('util').inspect(obj, false, 15, true))
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ForbesLindesay
ForbesLindesay / usage.js
Created May 21, 2013 05:20
This script monitors my internet usage and prints out the results to the console every time it changes. You can get a session token by going to check your usage in the browser and looking for `?session=<SESSION TOKEN>` in the address bar
var Q = require('q')
var sprom = require('sprom')
var hyperquest = require('hyperquest')
var format = require('format-number')({truncate: 2})
var session = '<Session Token>'
//Limits in MB
var dailyLimit = 5000
var weeklyLimit = 15000
var fs = require('fs')
var read = fs.readFileSync
var write = fs.writeFileSync
var readdir = fs.readdirSync
var stat = fs.statSync
var path = require('path')
var join = path.join
var relative = path.relative
processDir(process.cwd())