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
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 =>
@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 / 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)
@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 / 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 / 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) {