Skip to content

Instantly share code, notes, and snippets.

View Daymannovaes's full-sized avatar
🔳
.

Dayman Novaes Daymannovaes

🔳
.
  • Belo Horizonte, MG Brazil
View GitHub Profile
@Daymannovaes
Daymannovaes / bitcoin_fake_transaction_example.json
Last active February 16, 2024 12:15
A fake bitcoin transaction
{
"version": 1,
"hash": "b657e22827039461a9493ede7bdf55b01579254c1630b0bfc9185ec564fc05ab",
"block_height": 477230,
"inputs": [
{
"n": 0,
"address": "1GLctvTi81GDYZF5F6nif2MdbxUnAGHATZ",
@Daymannovaes
Daymannovaes / convert-number-to-list.js
Created May 3, 2022 13:20
Given a integer, convert it to a list where each item is a digit of the number; without converting to String
function getLastDigit(n) {
const n10 = n/10;
return Math.round((n10 - Math.floor(n10)) * 10);
}
function removeLastDigit(n) {
return parseInt((n - getLastDigit(n))/10);
}
function splitDigits(n) {
@Daymannovaes
Daymannovaes / morse-to-word-converter.js
Created April 21, 2021 15:19
morse-to-word-converter.js
const symbolToMorse = {
a: '.-',
b: '-...',
c: '-.-.',
d: '-..',
e: '.',
f: '..-.',
g: '--.',
h: '....',
i: '..',
@Daymannovaes
Daymannovaes / light-tester.js
Created April 21, 2021 15:03
light tester implementation (describe, it, assert)
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 April 21, 2021 14:55
Equation Parser and Calculator
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)
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 =>
/*
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.
--
*/
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) => {

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:

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);