Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Code like a #FashionVictim

Code like a #FashionVictim

Beautiful code with CoffeeScript, Jade, LESS

David Nowinsky

April 18, 2014
Tweet

More Decks by David Nowinsky

Other Decks in Programming

Transcript

  1. fs.readdir(source, function(err, files) { if (err) { console. log('Error finding

    files: ' + err) } else { files.forEach(function(filename, fileIndex) { console. log(filename) gm(source + filename).size( function(err, values) { if (err) { console. log('Error identifying file size: ' + err) } else { console. log(filename + ' : ' + values) aspect = (values.width / values.height) widths. forEach(function(width, widthIndex) { height = Math.round(width / aspect) console. log('resizing ' + filename + 'to ' + height + 'x' + height) this.resize(width, height).write(destination + 'w' + width + '_' + filename, function(err) { if (err) console. log('Error writing file: ' + err) }) }.bind( this)) } }) }) } }) HTML, JavaScript & CSS are cool but... #WTF
  2. This is beautiful code def complex_function (a, b, c): if

    not a: return None # Raising an exception might be better if not b: return None # Raising an exception might be better if not x: # Some Plan-B computation of x return x # One single exit point short clean use indentation