Skip to content

Instantly share code, notes, and snippets.

View Visgean's full-sized avatar

martin Visgean

View GitHub Profile
#!/usr/bin/env python
import sys
import operator
from collections import Counter
def highess_likeness(words):
letter_count = Counter(''.join(words))
word_score = [
date commits
2014-08-29 7
2013-07-21 1
2013-02-08 2
2015-05-14 12
2013-10-09 3
2013-04-29 4
2014-05-27 18
2014-11-05 3
2013-04-05 44
import os
from distutils.sysconfig import get_python_lib
from distutils.dir_util import copy_tree
def resolve_pip_data_files(fix_packages=None):
"""
See http://stackoverflow.com/questions/20298729/pip-installing-data-files-to-the-wrong-place/20370738#20370738 # noqa
and http://stackoverflow.com/questions/30980682/djangos-locale-files-installed-in-weird-place # noqa
def get_context_data(self, search_term, **kwargs):
kwargs['search_term'] = search_term.strip()
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Visgean subscriptions in feedly Cloud</title>
</head>
<body>
<outline text="IT" title="IT">
<outline type="rss" text="Ars Technica" title="Ars Technica" xmlUrl="http://feeds.arstechnica.com/arstechnica/index/" htmlUrl="http://arstechnica.com"/>
<outline type="rss" text="hexadecimální doupě" title="hexadecimální doupě" xmlUrl="http://dex.bloguje.cz/rss.xml"/>
@Visgean
Visgean / all_months_like_ever.py
Last active November 24, 2015 16:52
weeks/months range
from datetime import timedelta, datetime
from dateutil.relativedelta import relativedelta
def get_months_range(base_date=None, months_back=0):
"""
Returns calendar month for given date
Args:
base_date: date to be used, date.today is default
import os
def get_block_range (filename, lookupValue):
"""
Returns the index of the first line that contain ``lookupValue``
and end of the file
# here the value was at line 941 and the file had 1000 lines.
>>> get_block_range('example.txt', 'example')
(941, 1000)
def date_range(first_date, second_date):
"""
Returns range of dates between first and second date
:type first_date: datetime.date
:type second_date: datetime.date
:return: list of dates
"""
if first_date == second_date:
return []
elif first_date > second_date:
def date_range(first_date, second_date):
"""
Returns range of dates between first and second date
:type first_date: datetime.date
:type second_date: datetime.date
:return: list of dates
"""
if first_date == second_date:
return []
elif first_date > second_date:
>>> voting_round_instance = models.VotingRound.objects.first()
>>> voting_round_instance.vote_set.values('vote').annotate(count=Count('vote')).distinct()
[{'vote': u'decline', 'count': 1}, {'vote': u'neutral', 'count': 1}, {'vote': u'decline', 'count': 1}, {'vote': u'approve', 'count': 1}, {'vote': u'approve', 'count': 1}]