This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.workdays_delta(days) | |
# Finds the date shifted by 'days' workdays. | |
current_day = Date.today | |
weekend = [6, 7] | |
counter = days.abs | |
while counter > 0 | |
if days > 0 | |
current_day += 1.day else current_day -= 1.day end | |
if not weekend.include? current_day.cwday and not Holiday.where(holiday_date: current_day).first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mechanize | |
import cookielib | |
br = mechanize.Browser() | |
browser = br | |
# Cookie Jar | |
cj = cookielib.LWPCookieJar() | |
br.set_cookiejar(cj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding:utf-8 -*- | |
"""Utilities to evaluate pairwise distances or metrics between 2 | |
sets of points. | |
Distance metrics are a function d(a, b) such that d(a, b) < d(a, c) if objects | |
a and b are considered "more similar" to objects a and c. Two objects exactly | |
alike would have a distance of zero. | |
One of the most popular examples is Euclidean distance. | |
To be a 'true' metric, it must obey the following four conditions:: |