Skip to content

Instantly share code, notes, and snippets.

Leonardo Antunes antunesleo

Block or report user

Report or block antunesleo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View geoquery-user-location-radius-300m-response.json
{
"took": 12,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
View geoquery-user-location-radius-300m.json
GET user_location/_search
{
"query": {
"bool" : {
"filter" : {
"geo_distance" : {
"distance" : "300m",
"location" : "-25.442987, -49.239504"
}
}
View indexing-user_location.json
POST user_location/_doc/1
{
"name": "William",
"location": "-25.443053, -49.238396"
}
POST user_location/_doc/2
{
"name": "Robert",
"location": "-25.440173, -49.243169"
View creating-user_location-index.json
PUT user_location
{
"mappings": {
"_doc": {
"properties": {
"name": {
"type" : "text"
},
"location": {
"type": "geo_point"
@antunesleo
antunesleo / delete-all-branches-except-master
Created Feb 11, 2019
Delete all branches on current directory except master
View delete-all-branches-except-master
git branch | grep -v "master" | xargs git branch -D
@antunesleo
antunesleo / gist:dc2552f2c578670a67a57d79d357851e
Created Dec 11, 2018
Installing python3-pip and python3-venv
View gist:dc2552f2c578670a67a57d79d357851e
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
sudo apt-get install -y python3-venv
python3 -m venv elasticsearch_loader
source elasticsearch_loader/bin/activate
pip3 install elasticsearch_loader
View strings-concat-join.py
nomes = ["Leonardo", "Jao", "Ana"]
# Mais lento, usa mais memória pois cada vez que nomes_string
# recebe um valor um novo objeto em memória criado
nomes_string = ""
for nome in nomes:
nomes_string += nome
nomes_string = ''.join(nomes) # Mais rápido, pythonico e usa menos memória
View loops-e-lists-comprehensions.py
nomes = ["Leonardo", "Jao", "Ana"]
# Mais lento, não pythonico
nomes_com_o = []
for nome in nomes:
if 'o' in nome:
nomes_com_o.append(nome)
nomes_com_o = [nome for nome in nomes if 'o' in nomes] # Mais rápido, legível e pythonico
@antunesleo
antunesleo / item-ta-na-lista.py
Last active Nov 4, 2018
Como verificar se um item faz parte de uma lista de maneira mais performatica em python
View item-ta-na-lista.py
nomes_list = ["Leonardo", "Jao", "Ana"] # Mais devagar, usando list
if "Pythonson" in nomes_list:
print("Pythonson ta na lista de nomes")
else:
print("Pythonson nao ta na lista de nomes")
nomes_set = {"Leonardo", "João", "Ana"} # Mais rápido, usando set
View response-movies-2015.json
{
"took": 10,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
You can’t perform that action at this time.