Skip to content

Instantly share code, notes, and snippets.

View BibMartin's full-sized avatar

Martin Journois BibMartin

View GitHub Profile
@BibMartin
BibMartin / gist:f1833f134024ed276f4b
Created July 9, 2015 13:31
Watch and kill queries with pymongo
import pymongo
connection = pymongo.MongoClient()
# get running operations
list(connection.admin["$cmd.sys.inprog"].find())
# kill an operation by id
op_id = 123456
@BibMartin
BibMartin / folium_iframe_embed.py
Created July 10, 2015 22:24
Embed folium map in an iframe for jupyter nb
from IPython.display import HTML
def _repr_html_(self, figsize=(17,10), **kwargs):
"""Displays in the notebook a folium.folium.Map object.
"""
self._build_map(**kwargs)
width, height = figsize
iframe = '<iframe src="data:text/html;base64,{html}" width="{width}" height="{height}"></iframe>'\
ssh -N -f -L localhost:8800:localhost:8800 user@server
@BibMartin
BibMartin / GeoPandas.ipynb
Created December 10, 2015 11:17
Transform and plot shapefile data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BibMartin
BibMartin / gist:12244602ac0b1c5995c8
Created January 19, 2016 15:20
Using `xargs` and `sed` to apply a function to a set of files
Imagine you have a folder containing many files, and you want to apply a function to those files.
ls *.ipynb | sed 's/.ipynb//' | xargs -i echo {}.ipynb-{}.log
If you're in a folder containing `foo.ipynb`, `bar.ipynb`, 'baz.py`, you'll get:
foo.ipynb-foo.log
bar.ipynb-bar.log
@BibMartin
BibMartin / link.md
Last active January 23, 2016 10:18
Good tutorial for building `conda` packages
@BibMartin
BibMartin / main.md
Created January 26, 2016 13:45
Create and enable a kernel for jupyter notebook with conda
conda create -n py27 python=2.7 ipykernel
source activate py27

python -m ipykernel install --user --name py27 --display-name "Python 2.7"

@BibMartin
BibMartin / main.md
Created January 26, 2016 13:45
Create and enable a kernel for jupyter notebook with conda
conda create -n py27 python=2.7 ipykernel
source activate py27

python -m ipykernel install --user --name py27 --display-name "Python 2.7"

@BibMartin
BibMartin / Create Map label with folium.ipynb
Created January 31, 2016 14:55
Create map label with folium
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.