Category: Big Ball of Mud

  • Anti-pattern: Time Machine

    The nature of version control keeps track of every change in the source code give software technology team a perception of version control can be used as a time machine.  Thus you’ll hear the saying like “I should be able to check out any version of the history and reproduce the system at that point”. However, […]

  • calculate sum and average of lines of number

    Assuming a file contains a bunch of numbers, one number per line, like this: 1 2 3 4 5 6 One can easily calculate the sum and average of all these numbers, by using awk: cat numbers | awk ‘{sum += $1; count += 1} END {print “sum:” sum ” avg:” sum/count}’  

  • Copy current git branch into pasteboard (the Clipboard) on Mac OS X

    git branch|grep ‘*’|tr -d ‘* \n’|pbcopy

  • How not to conduct a bad technical interview

    This note is primarily written for myself to reference. Most of them are the mistakes I observed (and still remembered of course) during the software developer’s technical interviews. I don’t expect it has any commons with your situation, but if you figured something useful, it must be a coincident. Interview is not a process to […]

  • Flattening an array in JavaScript

    If you have an mutidementional array(or nested array) you want to flattern, you can do it this way. var flatten = function(array) { var result = [], self = arguments.callee; array.forEach(function(item) { Array.prototype.push.apply( result, Array.isArray(item) ? self(item) : [item] ); }); return result; }; So now you can run it //The result of console.log(flatten([1,2,[3,4,[5,6]]])); //Should […]