Skip to content

Instantly share code, notes, and snippets.

View SebastianoF's full-sized avatar

Sebastiano Ferraris SebastianoF

  • London
View GitHub Profile
@SebastianoF
SebastianoF / b001_05.py
Last active April 24, 2022 14:44
b001_05.py
config = {
'version': 'v1',
'config': {
'mapState': {
'latitude': 51.536265,
'longitude': -0.039740,
'zoom': 10
}
}
}
@SebastianoF
SebastianoF / b001_06.py
Last active April 24, 2022 14:43
b001_06.py
osmnx.config(use_cache=True, log_console=True)
def gdf_concat(list_gdf: list):
return gpd.GeoDataFrame( pd.concat(list_gdf, ignore_index=True))
query_city = {'city': 'City of London'}
query_london = {'city': 'London'}
gdf = gdf_concat([osmnx.geocode_to_gdf(query_city), osmnx.geocode_to_gdf(query_london)])
@SebastianoF
SebastianoF / b001_07.py
Last active April 24, 2022 14:43
b001_07.py
gdf_epsg = gdf.to_crs(epsg=3857)
ax = gdf_epsg.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
cx.add_basemap(ax)
@SebastianoF
SebastianoF / b001_08.py
Created April 24, 2022 14:42
b001_08.py
try:
from kepler_config import config_map_2
except ImportError:
config_map_2 = config
map_2 = KeplerGl(data={'london' :gdf_epsg}, config=config_map_2, height=800) # kepler knows what to do when fed with a geodataframe
display(map_2b)
@SebastianoF
SebastianoF / counter.py
Created October 14, 2018 15:22
Count words in latex
import os
import subprocess
'''
Counts the words in the manually selected latex files in the list list_file
Commands to obtain the number of words in a .tex file:
'detex my_file.tex | wc -w'
where my_file.tex is one of the string in the list list_files
@SebastianoF
SebastianoF / permutation_insights.md
Last active August 16, 2018 16:55
permutations.py

For future reference after the discussion https://codereview.stackexchange.com/questions/201725/disjoint-cycles-of-a-permutation

How to go from Cauchy notation to cyclic notation of a permutation with python

After insights from @Accumulation (working but with extra loop and with no inverse) and @Martin R (not working but with cool insight and inverse), here is what I have got: (it seems to work, but is far from the pythonic-elegance suggested by Martin R).

def permutation_from_cauchy_to_disjoints_cycles(cauchy_perm):
@SebastianoF
SebastianoF / gist:5a43eec688674f1b885bf1dda77c17c1
Created September 4, 2017 09:15
Python, upload to pypi the latest code release
# setup.py must be there
# create the latest version
python setup.py bdist_wheel
# upload to pypi
twine upload dist/<your_code_name>_<your_version>.whl -r pypi