Skip to content

Instantly share code, notes, and snippets.

View davisvictorns's full-sized avatar

Davis Nascimento davisvictorns

  • Infoprime Sistemas
View GitHub Profile
import networkx as nx
import matplotlib.pyplot as plt
G = nx.read_graphml("football_network.graphml")
retorno = get_tunnel()
print(retorno)
!python my_dash_app.py
download_ngrok()
%%writefile my_dash_app.py
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd
import numpy as np
import json
from dash.dependencies import Input, Output
fig = px.scatter_mapbox(df,
lat='centroid_lat',
lon='centroid_lon',
text='text',
size='approxim',
size_max=40,
zoom=15,
mapbox_style='carto-positron')
fig.update_layout(margin={'r':0,'t':0,'l':0,'b':0})
fig.show()
# dataset example
df = pd.DataFrame(data={'centroid_lat':[48.858412],
'centroid_lon':[2.294492],
'approxim':[50],
'text':['Torre Eiffel']})
df
Response = namedtuple('Response', ['url', 'error'])
def get_tunnel():
try:
Tunnel = subprocess.Popen(['./ngrok','http','8050'])
session = requests.Session()
retry = Retry(connect=3, backoff_factor=0.5)
adapter = HTTPAdapter(max_retries=retry)
session.mount('http://', adapter)
def download_ngrok():
if not os.path.isfile('ngrok'):
!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
!unzip -o ngrok-stable-linux-amd64.zip
pass
import os.path
import sys, json
import requests
import subprocess
import numpy as np
import pandas as pd
import plotly.express as px
from requests.exceptions import RequestException
# Install Plotly
!pip install Plotly==4.12
# Install Dash
!pip install dash
!pip install dash-html-components
!pip install dash-core-components
!pip install dash-table