Function to print ascii tables out.
wb = Workbook()
wb.country_code = 61
data = [['a','b','c'],[1,2,3],[4,5,6]]
write_sheet(wb, data, "test_sheet", print_to_screen=True) # add one sheetFunction to print ascii tables out.
wb = Workbook()
wb.country_code = 61
data = [['a','b','c'],[1,2,3],[4,5,6]]
write_sheet(wb, data, "test_sheet", print_to_screen=True) # add one sheetBasic processing
import psycopg2
from prettytable import PrettyTable
conn = psycopg2.connect("dbname=databasename user=postgres")
cur = conn.cursor()
conn.autocommit = True| # from http://glowingpython.blogspot.com.au/2012/09/weighted-random-choice.html | |
| from numpy import cumsum, sort, sum, searchsorted | |
| from numpy.random import rand | |
| from pylab import hist,show,xticks | |
| def weighted_pick(weights,n_picks): | |
| """ | |
| Weighted random selection | |
| returns n_picks random indexes. |
| from math import log10, floor | |
| def round_sig(x, sig=2): | |
| ''' | |
| >>> round_sig(0.0232) | |
| 0.023 | |
| >>> round_sig(0.0232, 1) | |
| 0.02 | |
| >>> round_sig(1234243, 3) |
| from random import randrange | |
| from datetime import timedelta, datetime | |
| def random_date(start, end): | |
| """ | |
| This function will return a random datetime between two datetime | |
| objects. | |
| """ | |
| delta = end - start |
| #!/usr/bin/env python | |
| from datetime import date | |
| from calendar import monthrange | |
| def by_month(start, end): | |
| day_of_month = start.day |
| SELECT | |
| '2010-01-01'::DATE + day - 1 AS day | |
| FROM | |
| generate_series(1, '2011-01-01'::DATE - '2010-01-01'::DATE) AS day; |
| namespace io = boost::iostreams; //<-- good practicetypedef | |
| std::vector<char> buffer_t; | |
| void CompressionUtils::Inflate(const buffer_t &compressed, buffer_t &decompressed){ | |
| io::filtering_ostream os; | |
| os.push(io::gzip_decompressor()); | |
| os.push(io::back_inserter(decompressed)); | |
| io::write(os, &compressed[0], compressed.size()); | |
| } |
| # ######################################################################### | |
| # This bash script adds tab-completion feature to django-admin.py and | |
| # manage.py. | |
| # | |
| # Testing it out without installing | |
| # ================================= | |
| # | |
| # To test out the completion without "installing" this, just run this file | |
| # directly, like so: | |
| # |
| "\e[A": history-search-backward | |
| "\e[B": history-search-forward | |
| set show-all-if-ambiguous on | |
| set completion-ignore-case on |