Skip to content

Instantly share code, notes, and snippets.

View garaud's full-sized avatar
🚀
(learn 'model)

Damien Garaud garaud

🚀
(learn 'model)
View GitHub Profile
@garaud
garaud / sqlalchemy-orm-query-to-dataframe.py
Last active April 11, 2024 04:08
Example to turn your SQLAlchemy Query result object to a pandas DataFrame
# -*- coding: utf-8 -*-
"""From a Query.all(), turn this result to a pandas DataFrame
Table creation and example data come from the official SQLAlchemy ORM
tutorial at http://docs.sqlalchemy.org/en/latest/orm/tutorial.html
Just take a look at the 'query_to_dict' function and the last part of the __main__.
"""
@garaud
garaud / pipe-to-emacs.py
Last active October 3, 2023 13:11
Pipe to Emacs: Insert a result from an UNIX command into a new Emacs buffer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Damien Garaud
# Date: 2014-2015
# License: Simplified BSD
"""Allow you to pipe command results into an Emacs buffer. Suppose you have an
Emacs server since you launch 'emacsclient'.
date clicks
2020-07-01 1
2020-07-02 2
2020-07-03 0
2020-07-04 2
2020-07-05 2
2020-07-06 0
2020-07-07 0
2020-07-08 0
2020-07-09 2
@garaud
garaud / rank-by-date.py
Last active May 31, 2017 20:55
Rank some elements by ascending date
# coding: utf-8
"""rank by ascending date
"""
from datetime import date
from faker import Factory
import pandas as pd
@garaud
garaud / clojurenews-email-digest.py
Last active January 4, 2017 10:22
Simple snippet to get the latest entries from the MongoDB ClojureNews data in order to send a weekly digest email
# -*- coding: utf-8 -*-
from datetime import datetime
from dateutil.relativedelta import relativedelta
import pymongo
from pymongo import MongoClient
from jinja2 import Template
@garaud
garaud / pandas-plotting-with-highcharts.ipynb
Last active August 29, 2015 14:16
Pandas DataFrame plotting with Highcharts
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@garaud
garaud / Brownian-motion-pandas.ipynb
Last active August 29, 2015 14:15
Brownian Motion IPython notebook with pandas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@garaud
garaud / getmodulepath.py
Created December 16, 2014 10:22
Get the file path of a class, function or Python module as pydoc and open it into your editor
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Damien Garaud
# Date: 2014
# License: Simplified BSD
"""Open a Python module in you editor when you're looking for a class, function
or module name.