Skip to content

Instantly share code, notes, and snippets.

Doug Coburn doug-numetric

Block or report user

Report or block doug-numetric

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lab.js
const fetch = require('node-fetch');
const url = 'https://www.random.org/decimal-fractions/?num=1&dec=10&col=1&format=plain&rnd=new';
fetch(url).then(response => response.text())
.then(textNumber => {
console.log(textNumber);
});
// write implementation fo threeRandomNumbers here
View c++17.cpp
// compile with c++ --std=c++17 ./c++17.cpp
#include <iostream>
#include <vector>
#include <stdexcept>
#include <tuple>
#include <type_traits>
template <class T> using il = std::initializer_list<T>;
auto reduce = [](const auto& reducer, const auto& collection, auto&& init) -> auto {
@doug-numetric
doug-numetric / functionalFibonacci.js
Created Jul 25, 2017
Efficient fibonacci calculator without loops or recursion
View functionalFibonacci.js
const { reduce, range, map } = require('lodash/fp')
const fibinacci =
num => reduce(
acc => [
acc[0] + acc[1],
acc[0]
],
[1,0],
range(0, num)
@doug-numetric
doug-numetric / conditionalExpression.js
Created Jul 24, 2017
ESLint friendly conditional expression
View conditionalExpression.js
const branch = function(b) {
return b.if ? b.then : b.else;
}
const fizzbuzz = function(num) {
return branch({
if: num % 3 === 0 && num % 5 === 0,
then: 'fizzbuzz',
else: branch({
if: num % 3 === 0,
@doug-numetric
doug-numetric / conditionalFormatting.js
Created Jul 24, 2017
ESList and nested conditional operators
View conditionalFormatting.js
/*
* What are your thoughts on nested conditionals?
* replacing with if/else if/else statements removes your ability to use const
* ESLint doesn't like them, but for cascading if/else flows, I think proper formatting
* eliminates readability concerns
*/
const word =
isFoo ? 'a' : // if isFoo
isBar ? 'b' : // else if isBar
You can’t perform that action at this time.