Skip to content

Instantly share code, notes, and snippets.

Avatar
🔳
.

Dayman Novaes Daymannovaes

🔳
.
View GitHub Profile
View morse-to-word-converter.js
const symbolToMorse = {
a: '.-',
b: '-...',
c: '-.-.',
d: '-..',
e: '.',
f: '..-.',
g: '--.',
h: '....',
i: '..',
@Daymannovaes
Daymannovaes / light-tester.js
Created Apr 21, 2021
light tester implementation (describe, it, assert)
View light-tester.js
const path = require('path');
const chalk = require('chalk');
const fileToTest = process.argv[2];
if(!fileToTest) throw new Error('define the file to test');
let PADDING = -4;
let success = 0;
let fails = 0;
function describe(suite, fn = function(){}) {
@Daymannovaes
Daymannovaes / equation-calculator-challenge.js
Last active Apr 21, 2021
Equation Parser and Calculator
View equation-calculator-challenge.js
const _ = require('lodash');
function getEquationVariables(equation) {
variables = equation.match(/[a-z]/g);
return _.chain(variables).compact().uniq().value();
}
function getAllVariables(equations) {
return _.chain(equations)
.map(getEquationVariables)
View bitcoin_fake_transaction_example.json
{
"version": 1,
"hash": "b657e22827039461a9493ede7bdf55b01579254c1630b0bfc9185ec564fc05ab",
"block_height": 477230,
"inputs": [
{
"n": 0,
"address": "1GLctvTi81GDYZF5F6nif2MdbxUnAGHATZ",
View sleep-setpoint-calculator.js
const dayOfMonth = d => `${d.getDate()}/${d.getMonth()}/${d.getFullYear()}`;
const midnightDistance = d => Math.abs(realMidnightDistance(d));
const realMidnightDistance = d => (d.getHours() - 12) > 0 ? -midnightDistancePM(d) : midnightDistanceAM(d);
const midnightDistanceAM = d => (d.getHours() * 60) + d.getMinutes();
const midnightDistancePM = d => ((24 - d.getHours()) * 60) - (60 - d.getMinutes());
const excludeDistLessThan = threshold => d => realMidnightDistance(d) > threshold;
const closestToMidnight = d =>
View aggregate-promoter-io-data.js
/*
go to Promoter.io, go to a campaign and use the filter to search the time range that you want
Go to chrome dev tools and search for the url like:
https://app.promoter.io/org/YOUR_ORG_ID/campaign/YOUR_CAMP_ID/report/?start_date=2017%2F04%2F15&end_date=2018%2F03%2F28&method_name=load_es_nps_graph
be aware of the method name: load_es_nps_graph.
--
*/
View prettyJson.js
function prettyJson(object, indent = 4, stack = []) {
stack.push(object);
let result = "{\n";
let indentString = (new Array(indent+1)).join(" ");
let indentEnd = (new Array(indent-3)).join(" ");
let keys = Object.keys(object);
keys.forEach((key, i) => {
View keybase.md

Keybase proof

I hereby claim:

  • I am daymannovaes on github.
  • I am daymannovaes (https://keybase.io/daymannovaes) on keybase.
  • I have a public key ASDlvLfGWNsHvoN0VmEUYJ42-59zwmH5_2j_sX5Ii34hXgo

To claim this, I am signing this object:

View tenfold-code-challenge.js
function arrayDiffToHtmlTable(prevArray = [], currArray = []) {
let ALL_KEYS = getAllKeys(prevArray, currArray);
let mappedObjects = mapObjects(prevArray, currArray);
let table = '<table>' + buildTableHeader();
for(let key of Object.keys(mappedObjects)) {
let prevObj = mappedObjects[key][0];
let currObj = mappedObjects[key][1];
table += buildHtmlRow(prevObj, currObj);
View majaWalk.js
// (x, y)
let stepActionByType = {
'down': [0, 1],
'left down': [-1, 1],
'left up': [-1, 0],
'up': [0, -1],
'right up': [1, -1],
'right down': [1, 0]
};
let stepTypeOrder = [