Skip to content

Instantly share code, notes, and snippets.

View gdmachado's full-sized avatar
:shipit:

Gustavo Machado gdmachado

:shipit:
  • London, UK
View GitHub Profile
@gdmachado
gdmachado / gist:7815608bf539f3a058fb
Created March 17, 2015 18:27
Python period generator
from datetime import datetime
import calendar
def genDatePeriods(startDate, endDate, format='%Y-%m-%d'):
dt1 = datetime.strptime(startDate, format)
dt2 = datetime.strptime(endDate, format)
for year in range(dt1.year, dt2.year + 1):
for month in range(1, 13):
day0 = dt1.day if month == dt1.month and year == dt1.year else 1
def genDateWeeks(startDate, endDate):
dt1 = datetime.datetime.strptime(startDate, "%Y-%m-%d")
dt2 = datetime.datetime.strptime(endDate, "%Y-%m-%d")
# first day of startDate's week
dt1 = dt1 - datetime.timedelta(days = dt1.weekday())
totalWeeks = int(math.ceil(((dt2 + datetime.timedelta(1))-dt1).total_seconds()/60/60/24/7))
return [
[
def genDateRange(startDate, endDate):
dt0 = datetime.datetime.strptime(startDate, "%Y-%m-%d")
dt1 = datetime.datetime.strptime(endDate, "%Y-%m-%d")
for n in range(int ((dt1 - dt0).days) + 1):
yield (dt0 + datetime.timedelta(n)).strftime("%Y-%m-%d")
/**
* Kitteh!
*/
.img {
margin: 0px auto;
width: 185px;
height: 185px;
position: relative;
border-radius: 5px;
@gdmachado
gdmachado / dabblet.css
Created March 23, 2012 19:50
Playing with CSS
/**
* Playing with CSS
*/
* { margin: 0; }
body {
background-color: slategray;
font: 12pt "Cochin", Georgia, serif;
line-height: 1.5em;
@gdmachado
gdmachado / dabblet.css
Created March 23, 2012 01:41
Playing with CSS
/**
* Playing with CSS
*/
* { margin: 0; }
body {
background-color: slategray;
font: 12pt "Cochin", Georgia, serif;
line-height: 1.5em;
@gdmachado
gdmachado / dabblet.css
Created March 23, 2012 00:42
Learning stuff
/**
* Learning stuff
*/
body {
background-color: #555;
}
.button {
border: 1px solid rgba(0,0,0,.4);
background-color: #444;
color: #fff;
@gdmachado
gdmachado / dabblet.css
Created March 22, 2012 23:23
Learning stuff
/**
* Learning stuff
*/
body {
background-color: #555;
}
.button {
border: 1px solid rgba(0,0,0,.4);
background-color: #444;
color: #fff;