Skip to content

Instantly share code, notes, and snippets.

View mertcetin's full-sized avatar

Mert Çetin mertcetin

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mertcetin on github.
  • I am mertcetin (https://keybase.io/mertcetin) on keybase.
  • I have a public key ASD_0AHhxeywDCIUWIjWDJ6vxnhR2_ILuHObMs1FSiqdlwo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am mertcetin on github.
  • I am mertcetin (https://keybase.io/mertcetin) on keybase.
  • I have a public key whose fingerprint is 988A 5137 E9DA 945B 0739 42DD 6112 8BE2 F4C3 52A2

To claim this, I am signing this object:

function Event() {
var subscribers = [];
this.subscribe = function(args) {
for (var i=0; i < arguments.length; i++) {
if (typeof(arguments[i]) === 'function'){
subscribers.push(arguments[i]);
}
}
};
@mertcetin
mertcetin / battleship-kata.js
Last active August 29, 2015 13:55
Battleship Validator Solution
function validateBattlefield(field) {
var count = [0,0,0,0], coord = [[],[],[],[]], hash = {}, i;
var transposedField = Object.keys(field[0]).map(function(c) {
return field.map(function(r) {return r[c];});
}); // transposes field matrix for easy column traversal
for (i = 0; i < 10; i++) {
identifyRow(field[i].join(''), false, coord, i);
identifyRow(transposedField[i].join(''), true, coord, i);
// Four-space, wrap at 120. Works with very long function names, survives
// renaming without reindenting, low on space.
goog.foo.bar.doThingThatIsVeryDifficultToExplain = function(
veryDescriptiveArgumentNumberOne, veryDescriptiveArgumentTwo,
tableModelEventHandlerProxy, artichokeDescriptorAdapterIterator) {
// ...
};
// Four-space, one argument per line. Works with long function names,
// survives renaming, and emphasizes each argument.