Skip to content

Instantly share code, notes, and snippets.

View seiteta's full-sized avatar

Frédéric Bardolle seiteta

View GitHub Profile
fortune | ponysay
import docx
from subprocess import Popen, PIPE
def doc_to_txt(filename):
'''
Get the path of a Word document and returns the text of this document
:param filename: The filename of the doc or docx document
:type filename: str
:return: The text of the document
@seiteta
seiteta / dataframe_gist.py
Last active September 13, 2017 14:40
Various pandas command
# List the column of a DataFrame
list(my_dataframe)
# Rename columns
my_dataframe.columns = ['new_name_1', 'new_name_1']
@seiteta
seiteta / gist:d8123bdd895fa89465a50eef91d1bf2d
Last active September 13, 2017 12:29
Delete an index in Elasticsearch
# List all indices:
curl -XGET 'localhost:9200/_cat/indices?v&pretty'
# Delete the index (here `myindex`):
curl -XDELETE 'localhost:9200/myindex?pretty'
@seiteta
seiteta / gist:df4cee0310004f40aa883bbd93be62ef
Created September 13, 2017 12:21
Drop a mongo database
# Launch the mongo shell:
mongo
# List all databases:
show dbs
# Switch to the database you want to drop (here `mydb`):
use mydb
# Drop it:
@seiteta
seiteta / gist:3f0491a2ef849d4e2e5da431cf123b3f
Last active May 10, 2017 10:08
Create a new conda virtual environment
# Create a new virtual environment (source: https://github.com/ContinuumIO/anaconda-issues/issues/305)
conda create -n my-venv python=3.4
source activate my-venv
# List all virtual environments (source: https://conda.io/docs/using/envs.html#list-all-environments)
conda info --envs
@seiteta
seiteta / image_croper.py
Created February 3, 2017 17:41
Image cropper
import os
from PIL import Image
# Parameters to be specified:
origin_folder = "path"
destination_folder = "path"
top_ratio = 0.15
# Create the destination folder if it doesn't exist
if not os.path.exists(destination_folder):