Skip to content

Instantly share code, notes, and snippets.

View Karytonn's full-sized avatar
💻
Writing code

Karytonn Karytonn

💻
Writing code
View GitHub Profile
@Karytonn
Karytonn / fisherYates.md
Last active April 13, 2024 11:22
Algoritimo de embaralhamento - Fisher Yates

Algoritmo de embaralhamento - Fisher Yates

Essa função fisherYates(array) recebe um array como entrada e retorna o mesmo array, mas com seus elementos misturados aleatoriamente. O algoritmo funciona percorrendo o array da direita para a esquerda, trocando cada elemento com um elemento aleatório que aparece antes dele na sequência. Isso garante que cada elemento tenha a mesma probabilidade de estar em qualquer posição do array embaralhado.

function fisherYates(code: string) {

  // Convert the code to an array of numbers
@Karytonn
Karytonn / server.ts
Last active April 13, 2024 11:25
Notion API with Deno Deploy
import { serve } from "https://deno.land/std@0.156.0/http/server.ts"; // from Deno
interface Link {
id: number;
label: string;
url: string;
target: string;
}
const NOTION_DATABASE_ID = Deno.env.get("NOTION_DATABASE_ID")
@Karytonn
Karytonn / WhatsAppCTA.vue
Last active December 1, 2022 16:44
Nuxt JS - WhatsApp Card
<template>
<div class="fixed right-6 bottom-6">
<transition
enter-active-class="animate__animated animate__fadeInRight"
mode="out-in"
>
<!-- CARD TO SEND MESSAGE -->
<div v-if="isOpen">
<div class="w-96 max-w-[90vw] rounded-3xl overflow-hidden shadow-2xl shadow-[#075E54]/50 bg-[#E7E7E7]">
@Karytonn
Karytonn / whatsapp.html
Last active December 1, 2022 16:38
Botão + Card WhatsApp
<div class="fixed right-6 bottom-6">
<!-- CARD TO SEND MESSAGE -->
<div v-if="isOpen">
<div class="w-96 max-w-[90vw] rounded-3xl overflow-hidden shadow-2xl shadow-[#075E54]/50 bg-[#E7E7E7]">
<!-- Header and close button -->
<div class="h-20 p-5 flex items-center justify-between gap-4 bg-[#25D366]">
<div class="flex items-center gap-3">
<img class="w-7 h-28" src="@/assets/icon/header/whatsapp.svg" alt="WP">
@Karytonn
Karytonn / downloadFile.ts
Last active October 21, 2022 13:33
Trigger to download external file
downloadFile(url: string) {
fetch(url).then(res => res.blob()).then(file => {
let tempUrl = URL.createObjectURL(file);
const triggerToDownload = document.createElement("a");
triggerToDownload.href = tempUrl;
triggerToDownload.download = url.replace(/^.*[\\\/]/, '');
document.body.appendChild(triggerToDownload);
triggerToDownload.click();
URL.revokeObjectURL(tempUrl);
triggerToDownload.remove();
let msn = 'First';
// Without auto invocation
const write = (): string => {
console.log('Second');
return '...';
};
// With auto invocation
const message = write();
@Karytonn
Karytonn / tsconfig.json
Last active June 21, 2022 14:28
TypeScript fake declaration type
{
"compilerOptions": {
....
},
"types": [...]
},
// Include the source of fake type declaration
"include": ["src", "type.lib-name-here.ts"],
"exclude": [...]
}
@Karytonn
Karytonn / google_sheet-to-json.md
Last active November 4, 2021 11:13
How to get a Google Sheet as JSON

How to get a Google Sheet as JSON

Preparing Your Google Sheet

  1. The first row of your spreadsheet should be headers, and the rest is data under those headers (see example).
  2. Share the spreadsheet so anyone can see it (“Share” button in top right corner > “Anyone on the internet with this link can view”).

Preparing you url access

@Karytonn
Karytonn / isScroll.markdown
Last active October 20, 2021 15:46
Find out which element is creating horizontal scroll?

Find out which element is creating horizontal scroll?

Run the following code in your browser console to find out who is at fault:

let width = document.documentElement.offsetWidth;

[].forEach.call(
  document.querySelectorAll('*'),
 function(el) {
@Karytonn
Karytonn / Angular-dynamic-font-size.ts
Last active October 20, 2021 15:48
Angular: font-size and accessibility
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-header-accessibility',
templateUrl: './header-accessibility.component.html',
styleUrls: ['./header-accessibility.component.scss']
})
export class HeaderAccessibilityComponent implements OnInit {
//Default and reset font size