Enter GitHub username and your GitHub API token to see a breakdown of all your total repos by language.
Color scheme provided by GitHub.
Apologies for loading time- this uses React, React-DOM, Babel, jQuery, and D3.
Peace and love.
const ackermann = (m, n) => { | |
if (m === 0) { | |
return n+1 | |
} | |
if (n === 0) { | |
return ackermann((m - 1), 1); | |
} | |
if (m !== 0 && n !== 0) { |
Enter GitHub username and your GitHub API token to see a breakdown of all your total repos by language.
Color scheme provided by GitHub.
Apologies for loading time- this uses React, React-DOM, Babel, jQuery, and D3.
Peace and love.
function getType(obj) { | |
// slice first 8 characters of, e.g., "[object String]" or "[object Object]" to get type | |
return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase(); | |
} | |
getType("foo"); // "string" | |
getType([]); // "array" | |
getType({}); // "object" | |
getType(new Set()); // "set" | |
getType(true); // "boolean" |
// Generates Pascal's triangle of any number of rows | |
// | |
// https://en.wikipedia.org/wiki/Pascal%27s_triangle | |
function nextRow(row) { | |
const right = row.concat(0) | |
const left = [0].concat(row) | |
return left.map((x, i) => x + right[i]); | |
} |
// https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80 | |
// | |
// Requires lodash or underscore for the `range` function | |
function calculatePi(nTerms) { | |
var numerator = 4; | |
var denominator = 1; | |
var operation = 1; | |
var pi = 0; | |
const range = _.range(nTerms); |
body { | |
font-family: 'Helvetica'; | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
} | |
div.container { | |
width: 1050px; | |
min-width: 1050px; |
<!-- based on the pioneering graphic design of Josef Müller-Brockmann --> | |
<!-- see the basis for this here: | |
https://i1.wp.com/www.grapheine.com/wp-content/uploads/2013/03/MULLER-BROCKMANN-music-geometric-poster.jpg?quality=90&strip=all&ssl=1 | |
--> | |
<!-- learn more about Josef Müller-Brockmann here: https://www.grapheine.com/en/history-of-graphic-design/graphic-designer-muller-brockmann-swiss-style --> | |
<div class="poster-container"> | |
<div class="poster"> | |
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"> |
// Use the reduce method in combination with the concat method to | |
// “flatten” an array of arrays into a single array that has all | |
// the elements of the original arrays. | |
// My original "solution": | |
let arrays = [[1, 2, 3], [4, 5], [6]]; | |
arrays.reduce((accumulator, currentValue) => accumulator.concat(currentValue),[]); // [1, 2, 3, 4, 5, 6] | |
// This solution works on the sole test case in Chapter 5 of Eloquent JavaScript; but it doesn't work with nested arrays. |
// Remove duplicate words in a string | |
// Uses ES5 | |
function removeDuplicates(str) { | |
const split = str.split(' '); | |
const newArray = split.reduce((accumulator, currentValue) => { | |
if (!accumulator.includes(currentValue)) { | |
accumulator.push(currentValue); | |
} |
// Write a higher-order function loop that provides something like a for loop statement. | |
// It takes a value, a test function, an update function, and a body function. Each | |
// iteration, it first runs the test function on the current loop value and stops if | |
// that returns false. Then it calls the body function, giving it the current value. | |
// Finally, it calls the update function to create a new value and starts from the beginning. | |
// When defining the function, you can use a regular loop to do the actual looping. | |
const loop = (value, testFunc, updateFunc, bodyFunc) => { | |
if (testFunc(value)) { |