Skip to content

Instantly share code, notes, and snippets.

View danyelhenrique's full-sized avatar
:octocat:
Always working ;)

danyel henrique danyelhenrique

:octocat:
Always working ;)
  • Brazilian
View GitHub Profile
@danyelhenrique
danyelhenrique / dragitem javascript.html
Created October 4, 2023 18:14
dragitem javascript html css
<!DOCTYPE html>
<html>
<head>
<style>
/* Estilize o botão arrastável */
.draggable-button {
width: 100px;
height: 40px;
background-color: #007bff;
@danyelhenrique
danyelhenrique / react-box-element.tsx
Last active September 9, 2023 02:51
mutate element in react to accept all html tags and props
import { ComponentProps, ReactNode, createElement } from "react";
type BoxProps<E extends React.ElementType = "div"> = {
component?: E;
children?: ReactNode;
} & Omit<ComponentProps<E>, "component">;
function Box<E extends React.ElementType = React.ElementType>({
component,
children,
@danyelhenrique
danyelhenrique / generate types from directorty.js
Created June 15, 2023 00:24
generate types from directorty . Get all interfaces / types from project and put on one file
const fs = require('fs')
const path = require('path')
const ts = require('typescript')
class DeclarationsExtractor {
constructor(srcDir, outputFilePath) {
this.srcDir = srcDir
this.outputFilePath = outputFilePath
}
@danyelhenrique
danyelhenrique / change-imports-lot.js
Created June 9, 2023 01:20
change-imports-lot.js
const fs = require("fs");
const path = require("path");
function processFile(filePath) {
fs.readFile(filePath, "utf8", (err, data) => {
if (err) {
console.error(`Erro ao ler o arquivo ${filePath}:`, err);
return;
}
@danyelhenrique
danyelhenrique / change folder and sub file extensions.js
Last active June 9, 2023 01:21
change folder and sub file extensions
const fs = require("fs");
const path = require("path");
function changeFileExtension(filePath, fileExtension) {
const fileExt = path.extname(filePath);
const newFilePath = path.join(
path.dirname(filePath),
path.basename(filePath, fileExt) + ".ts"
);
@danyelhenrique
danyelhenrique / .js
Created April 28, 2023 00:14
nodejs spawn promisse async
#!/usr/bin/env node
/**
* @param {string} command process to run
* @param {string[]} args command line arguments
* @returns {Promise<void>} promise
*/
const runCommand = (command, args) => {
const cp = require("child_process");
return new Promise((resolve, reject) => {
function pgto(tax, period, currentValue, valueFuture, type) {
let pmt, currentValueIf;
valueFuture || (valueFuture = 0);
type || (type = 0);
if (tax === 0)
return -(currentValue + valueFuture) / period;
currentValueIf = Math.pow(1 + tax, period);
@danyelhenrique
danyelhenrique / .html
Created August 13, 2021 18:50
Troca cores Banner Secuity.ai
<!-- Lemrando de acionar a linha dois com cdn padrao somente se nao existir na loja -->
<!-- Mudar as cores para a preferencia de Loja -->
<link rel='stylesheet' type='text/css' href='https://cdn-prod.securiti.ai/consent/cookie-consent.css' />
<style>
.cc-btn{
background: #ff808b !important;
color: #fff !important;
}
li.is-active a{
@danyelhenrique
danyelhenrique / .css
Created August 13, 2021 18:45
mudar cor dos botao nos banner do botao do security.ai
/* securiti.ai Banner*/
/* Lembrando que essas são somente as classes mudar para cor desejada*/
.cc-btn{background: #000 !important;color: #fff !important;}
.cmp-body li.is-active a{background: #000 !important;color: #fff !important;}
.cmp-switch.readonly input .cmp-switch__slider{background: #000 !important;}
.cmp-switch__slider{background: #000 !important}
.cmp-save-btn {background: #000 !important;color: #fff !important;}
.cmp-body a[href=""],.cmp-body a[href="#"] {pointer-events: initial;}
@danyelhenrique
danyelhenrique / .js
Created August 12, 2021 19:46
vtex get serch url on page
function getSearchUrlVtex() {
var url, content, preg;
jQuery("script:not([src])").each(function () {
content = jQuery(this)[0].innerHTML;
preg = /\/buscapagina\?.+&PageNumber=/i;
if (content.search(/\/buscapagina\?/i) > -1) {
url = preg.exec(content);
return false;
}
});