Skip to content

Instantly share code, notes, and snippets.

View doug-numetric's full-sized avatar

Doug Coburn doug-numetric

View GitHub Profile
@doug-numetric
doug-numetric / conditionalFormatting.js
Created July 24, 2017 21:50
ESList and nested conditional operators
/*
* 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
@doug-numetric
doug-numetric / conditionalExpression.js
Created July 24, 2017 22:56
ESLint friendly conditional expression
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 / functionalFibonacci.js
Created July 25, 2017 06:21
Efficient fibonacci calculator without loops or recursion
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 / c++17.cpp
Last active July 25, 2018 18:58
modern c++
// 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 / lab.js
Created December 17, 2018 18:26
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
@doug-numetric
doug-numetric / bamboo-violentmonkey.js
Last active October 25, 2023 14:05
bamboo download combined ci logs
// ==UserScript==
// @name Download all
// @namespace Violentmonkey Scripts
// @include https://bamboo.internal.numetric.com/*/ci_test_logs
// @grant none
// @version 1.0
// @author -
// @description 10/24/2023, 1:01:20 PM
// ==/UserScript==