This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>CSS Grid</title> | |
| <style> | |
| html, body { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Regex breakdown: | |
| // Group: define([ | |
| // Group: dependencies | |
| // Group: ], function ( | |
| // Group: arguments | |
| // Group: ) { | |
| var defineFuncBeginning = /(define\s*?\(\s*?\[)([\S|\s]*?)(\]\s*,\s*function\s*\()([\s|\S]*?)(\)\s*?{)/gmi, | |
| defineFuncBeginningResult = defineFuncBeginning.exec(file); | |
| console.log(defineFuncBeginningResult[2]); // output: string with all dependencies |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var output; | |
| for (var i = 1; i <= 100; i++) { | |
| output = ""; | |
| if (i % 3 == 0) | |
| output = "Fizz"; | |
| if (i % 5 == 0) | |
| output += "Buzz"; | |
| if (output === "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fib (n) { | |
| var sqrt5 = Math.sqrt(5) | |
| return Math.round(1/sqrt5 *(Math.pow((1+sqrt5)/2, n) - Math.pow((1-sqrt5)/2, n))); | |
| } | |
| // output large fib number | |
| console.log(fib2(1000)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fib (n) { | |
| return (n >= 2) ? fib(n-1) + fib(n-2) : n; | |
| } | |
| // Example of getting Nth fibonacci number | |
| fib(10); | |
| // Generate a sequense of fibonacci | |
| for (var i = 0; i < 20; i++) { | |
| console.log(fib(i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function SuperClass () {}; | |
| SuperClass.prototype = { | |
| constructor: SuperClass, | |
| a: 'Hello', | |
| b: 'super', | |
| c: function () { | |
| return this.a + ', ' + this.b + '!'; | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var escapeText = _.escape(insertText), | |
| preserveWhiteSpace = escapeText.replace(/ /g, '\u00a0'), | |
| preserveWhiteSpaceAndLineBreaks = preserveWhiteSpace.replace(/\n/g, '<br />'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function logStackTrace(levels) { | |
| var callstack = []; | |
| var isCallstackPopulated = false; | |
| try { | |
| i.dont.exist += 0; //doesn't exist- that's the point | |
| } catch (e) { | |
| if (e.stack) { //Firefox / chrome | |
| var lines = e.stack.split('\n'); | |
| for (var i = 0, len = lines.length; i < len; i++) { | |
| callstack.push(lines[i]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fit (targetWidth, targetHeight, containerWidth, containerHeight, options) { | |
| var settings = { | |
| cover: options && options.cover !== undefined ? options.cover : true, | |
| align: options && options.align !== undefined ? options.align : 'center middle' | |
| } | |
| var ratioWidth = containerWidth / targetWidth, | |
| ratioHeight = containerHeight / targetHeight, | |
| ratioTarget = targetWidth / targetHeight, | |
| ratioContainer = containerWidth / containerHeight; |