This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const admin = require("firebase-admin") | |
/* | |
const serviceAccount = require("./../key.json"); | |
const { exit } = require("process"); | |
admin.initializeApp({ | |
credential: admin.credential.cert(serviceAccount) | |
}) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
/* | |
* Copyright 2020 Stripe, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* https://www.apache.org/licenses/LICENSE-2.0 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require('node-fetch') | |
const { TwitterApi } = require( 'twitter-api-v2') | |
const getTabNews = async () => { | |
const response = await fetch(`https://www.tabnews.com.br/api/v1/contents?page=1&per_page=50&strategy=relevant`) | |
return await response.json() | |
} | |
const tweet = async (text,links) => { | |
console.log('tweet tab news ranking started') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shuffle = (array) => array.map((a) => ({sort: Math.random(), value: a})) | |
.sort((a, b) => a.sort - b.sort) | |
.map((a) => a.value) | |
console.log(shuffle([1,2,3,4,5])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const toSeoUrl = (name) => { | |
return name.toString() // Convert to string | |
.normalize('NFD') // Change diacritics | |
.replace(/[\u0300-\u036f]/g,'') // Remove illegal characters | |
.replace(/\s+/g,'-') // Change whitespace to dashes | |
.toLowerCase() // Change to lowercase | |
.replace(/&/g,'-and-') // Replace ampersand | |
// eslint-disable-next-line | |
.replace(/[^a-z0-9\-]/g,'') // Remove anything that is not a letter, number or dash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Esse InputSearch faz o search / request / qq coisa depois de 500ms que parou de digitar a última letra. | |
Isso evita gerar requests desnecessários e entupir o backend com requests. Essa técnica de delay evita | |
fazer múltiplos requests e faz o request apenas quando parar de digitar. | |
Use: | |
<InputSearch open={true} close={()=>setSearching(false)} /> | |
*/ | |
import React, { useState, useEffect } from 'react'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(){ | |
int size=5,*array; | |
array=(int*)malloc(size * sizeof(int)); | |
for(int i=0;i<size;i++){ | |
array[i] = i; | |
} | |
for(int i=0;i<size;i++){ | |
printf("dobro de %d é %d\n",i,array[i]*2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const test = async () => { | |
const url = new URL('https://example.com?foo=1&bar=2'); | |
const params = new URLSearchParams(url.search); | |
console.log(params.get('foo')) | |
console.log(params.get('bar')) | |
const entries = params.entries() | |
for (const item of entries) { |
NewerOlder