Skip to content

Instantly share code, notes, and snippets.

View mtrbean's full-sized avatar

Eric Wong mtrbean

  • San Francisco, CA
View GitHub Profile
@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).
"""
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: stratified.py
Author: SpaceLis
Email: Wen.Li@tudelft.nl
Github: http://github.com/spacelis
Description:
Sampling in a stratified way. That is sampling from each subpopulation to
make the sample set more representative than simple random sampling. For