Skip to content

Instantly share code, notes, and snippets.

View natanfeitosa's full-sized avatar

Natanael dos Santos Feitosa natanfeitosa

View GitHub Profile
type GetArrayIndexValue<A extends [], K extends number | string> = K extends `.${infer I}` ? GetArrayIndexValue<A, I> : K extends number ? A[K] : never
type GetObjectPathValue<O extends object, P extends string> = P extends `${infer A}.${infer B}` ? A extends keyof O ? O[A] extends object ? GetObjectPathValue<O[A], B> : O[A] : never : P extends keyof O ? O[P] extends [] ? GetArrayIndexValue<O[P], P> : O[P] : never
const obj = {
a: {
b: 1,
c: [1, 2],
d: [
[12],
import { useState, useEffect } from 'react';
export default function useSearchParams() {
const getSearchParams = () => {
const queryString = window.location.search;
return new URLSearchParams(queryString);
};
const [searchParams, setSearchParams] = useState(getSearchParams);
function stringToNumber(str: string) {
str = str.trim()
if (/[^\d]/.test(str)) {
throw new Error('Deve conter apenas numeros')
}
return Array.from(str).reverse().reduce((acc, cur, idx) => {
let val = (cur.charCodeAt(0) - 48)
return acc + (val * 10 ** idx)
document.addEventListener('click', e => {
if(e.target.tagName.toUpperCase() == 'A') {
e.stopPropagation()
e.preventDefault()
var data_container=jquery(e.target).attr('data-container');
if(data_container){
var title=jquery(e.target).attr('title');
var url=jquery(e.target).attr('href');
jquery('body').html('');
path=url.split('/')[1];

Qualquer texto que não tiver uma das seguintes regras e tiver uma linha em branco no final, no início ou ambos, será um parágrafo assim

Este é um Heading h1

Este é um Heading h2

Este é um Heading h6

Enfase

Texto em itálico
Texto também em itálico

from flask import Flask, request, make_response
app = Flask(__name__)
@app.route('/')
def visit_counter():
visits = int(getattr(request.cookies, 'visits', 0)) + 1
msg = f'''
<h1>
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="utf-8">
<title>Hello World em Vue3</title>
<script type="text/javascript" src="https://unpkg.com/vue@3"></script>
</head>
<body>
<div id="app"></div>
<script type="text/javascript">
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="utf-8">
<title>Hello World em Vue3</title>
<script type="text/javascript" src="https://unpkg.com/vue@3"></script>
</head>
<body>
<div id="app">
<input type="text" v-model="nome" >
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="utf-8">
<title>Hello World em Vue3</title>
<script type="text/javascript" src="https://unpkg.com/vue@3"></script>
</head>
<body>
<div id="app">
<h1>{{ message }}</h1>
@natanfeitosa
natanfeitosa / keyword const.js
Last active October 16, 2021 20:58
Arquivo gist para exemplificar e explicar a diferença entre var, const e let
const test = function () {
if (true) {
const stringTest = 'hello'
console.log(stringTest)
}
console.log(stringTest)
}
test()