Skip to content

Instantly share code, notes, and snippets.

View hdemers's full-sized avatar

Hugues Demers hdemers

  • Orford, Quebec, Canada
View GitHub Profile
cd $HOME
# Create the installation directory
export DIR=$HOME/.local
export SRC=$HOME/src
mkdir -p $DIR
mkdir -p $SRC
# Download libevent, ncurses and tmux
cd $SRC
wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
@hdemers
hdemers / keybase.md
Created January 10, 2017 17:03
Keybase.io - GitHub ownership proof

Keybase proof

I hereby claim:

  • I am hdemers on github.
  • I am hdemers (https://keybase.io/hdemers) on keybase.
  • I have a public key whose fingerprint is D2D0 47F8 1BFD D447 2400 FCA1 FC21 2198 8E36 D320

To claim this, I am signing this object:

@hdemers
hdemers / hdemers-gpg-pubkey
Last active June 24, 2016 15:47
Hugues Demers GnuPG public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.9 (GNU/Linux)
mQGhBEqdGmsRBACATgfXCQEbnW+OEjVxC41zALr9onmMeKiMIK1HT0D44Wm2BK4A
+w0CFgp+86FLFx+BBQlnWwmHAJDhietAgkcrKpbhh/bK2KsZcRLiL7qtu/ljuHVK
ZOryVCnGomDOSIkg4gyNJaSFqxh0u8rm/iHqA7Emdzh9qvVC1cZAgnWCewCg6INj
Ca2JUcD42wagxE66uvWRNQcD+M4bTYjdghMKjWdw4MvzXNrx3ewuJIsZoEvHQvkS
S4jDxRuubp6qVDiGFdGkgWO/mrWThuWMpmOrqY0AXdvzxstmQa2X4lhkpoj444II
XVQ91R29lIZWNV7j4UBOR5Kncpn0ZS5bt2P1yOlFcMswbryhK2AZgu8B4mi7CmJ/
trED/1kwTrwehIYxer/hxnTwGKqr+CsRNRTaO4800ftUoD/dmSWEOc7Kxpuo/V/d
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Connect to database
import os
import pandas as pd
from sqlalchemy import create_engine
hostname = "127.0.0.1"
username = os.environ['DB_USERNAME']
db_name = os.environ['DB_NAME']
password = os.environ['MYSQL_PWD']
{
"metadata": {
"name": "",
"signature": "sha256:b558204f751fde84d16bf429dd76b6bd17dc0901bd51c746c7dbfc3e3a09f71e"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hdemers
hdemers / utctime.py
Created April 14, 2013 17:34
I never remember how to convert to/from UTC datetime and epoch. Now I don't have to.
"""UTC time conversion functions.
"""
from calendar import timegm
from datetime import datetime
def utcdt2epoch(utcdatetime):
"""Convert a datetime object expressed in UTC to a Unix timestamp expressed
in seconds since the epoch (Jan 1st 1970).
"""
@hdemers
hdemers / decorators.py
Created April 10, 2013 19:17
Python decorator cheat sheet.
from functools import wraps
def decorator(fn):
"""A function that *is* a decorator.
Use it like so:
@decorator
def foobar(arg):
return arg
@hdemers
hdemers / listchunker.py
Created April 8, 2013 19:11
A Python generator yielding a list in chunks. Cf. http://stackoverflow.com/a/312464
def chunks(l, n):
""" Yield successive n-sized chunks from l.
Cf. http://stackoverflow.com/a/312464
"""
for i in xrange(0, len(l), n):
yield l[i:i+n]