Skip to content

Instantly share code, notes, and snippets.

module.exports = {
consumer_key:process.env.CONSUMER_KEY,
consumer_secret:process.env.CONSUMER_SECRET,
access_token:process.env.ACESS_TOKEN,
access_token_secret:process.env.ACESS_TOKEN_SECRET
}
corpus = [
"Food Trucks em Manaus", # Consulta
"Conheça alguns dos principais food parks espalhados por toda a cidade de Manaus", # Página 1 do Google
"O melhor food truck de Manaus (Em novo endereço)", # Página 1 do Google
"Como chegar a Bambina Food Truck em Manaus de Ônibus?", # Página 4 do Google
"Projeto de Lei regulamenta Food Trucks em Manaus" # Página 4 do Google
]
vectorizer = TfidfVectorizer(analyzer='word')
x = vectorizer.fit_transform(corpus)
'Corpus: ' + ' '.join(vectorizer.get_feature_names())
# Distancia Euclidiana
for i in range(1, 5):
dist = norm((x[0, :] - x[i, :]).A)
print(f"Distância(Consulta, Documento {i}) = {dist:.2f}")
# Função Auxiliar
def cosine_similarity(x, y):
x = x.A.ravel()
y = y.A.ravel()
return np.dot(x, y) / (norm(x) * norm(y))
@vncsna
vncsna / beautiful.rest.api.docs.in.markdown.md
Created April 30, 2021 23:09 — forked from azagniotov/beautiful.rest.api.docs.in.markdown.md
Example to create beautiful REST API docs in Markdown, inspired by Swagger API docs.
@vncsna
vncsna / bash_strict_mode.md
Created June 6, 2021 01:59 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@vncsna
vncsna / ecs-docker-ckeanup.sh
Last active November 24, 2023 13:02
ecs-docker-cleanup.sh
date;
docker ps -q --filter "status=exited" | xargs --no-run-if-empty docker rm;
docker volume ls -qf dangling=true | xargs -r docker volume rm;
# CRON
# */5 * * * * /home/ec2-user/ecs-docker-cleanup.sh >> /home/ec2-user/docker-cleanup.log
# Reference
# https://medium.com/@_ifnull/aws-ecs-no-space-left-on-device-ce00461bb3cb
@vncsna
vncsna / create_ts_index.py
Created November 25, 2021 15:09
Create a `index.ts`
# Usage `python create_ts_index.py <folder-name>`
# TODO: Convert to bash script
import sys
from pathlib import Path
def create_index(rootpath):
rootpath = Path(rootpath)
indexpath = rootpath / "index.ts"
@vncsna
vncsna / SOS.md
Created May 30, 2022 13:21 — forked from vodik/SOS.md
_Never_ -Sy when installing!

Once upon a time there was a user that wanted to install firefox.

The user tried to do pacman -S firefox but it didn't work. The all mighty pacman reported that firefox-3.2.4-1.i686.pkg.tar.gz could not be found on his mirror. So the user tried pacman -Sy firefox. It worked and the user rejoiced since he could once again go and troll /h/.

But all was not good. The user had made a grave error!

See, when the user told the almighty pacman to -Sy firefox, pacman did

@vncsna
vncsna / py-comp-to-js.md
Created December 10, 2022 14:11 — forked from dschep/py-comp-to-js.md
Python Comprehensions to JS

Python list & dict comprehensions translated to JavasScript

Comprehensions are a really useful feature of Python that aren't available in JavaScript (or many languages). These concepts of course can be tranlsated into using map instead. But especially the dictionaries are a bit trickier.

Lists / Arrays

>>> foobar = range(5)
>>> [x + 1 for x in foobar]
[1, 2, 3, 4, 5]