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
#!/usr/bin/env python | |
from __future__ import with_statement # needed for python 2.5 | |
from fabric.api import * | |
from fabric.contrib.console import confirm | |
# ================================================================ | |
# NOTE: | |
# using this fabfile expects that you have the python utility | |
# fabric installed locally, ssh access to reamea.com, and your | |
# ssh public key associated with the account '[email protected]' |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
fabfile for Django | |
------------------ | |
see http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/ | |
modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle) | |
several additions, corrections and customizations, too |
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 queryset_to_dict(qs, key='pk'): | |
""" | |
Given a queryset will transform it into a dictionary based on ``key``. | |
""" | |
return dict((getattr(u, key), u) for u in qs) | |
def distinct(l): | |
""" | |
Given an iterable will return a list of all distinct values. | |
""" |
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
""" | |
Scanner: match text to generate tokens. | |
Adam Blinkinsop <[email protected]> | |
First, construct a scanner with the tokens you'd like to match described as | |
keyword arguments, using Python-syntax regular expressions. | |
WARNING: Group syntax in these expressions has an undefined effect. | |
>>> simple = Scan(ID=r'\w+') | |
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
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
__author__ = 'Filip Wasilewski <[email protected]>' | |
from pywt import Wavelet, dwtn, dwt_max_level | |
from pywt.numerix import as_float_array | |
def wavedecn(data, wavelet, mode='sym', level=None): | |
data = as_float_array(data) |
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 get_node_paths(level=1): | |
""" | |
Lists node paths on the given level. | |
Order of the paths is the same as order of nodes | |
returned by `WaveletPacket2D.get_leaf_nodes`. | |
""" | |
paths = [""] | |
for i in range(level): | |
paths = [ | |
path + name |
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
User.objects.filter( | |
pk__in=Follow.objects.filter( | |
user=self.user, | |
content_type=ContentType.objects.get_for_model(User) | |
).extra(select={"user_ids": "object_id::integer"}).values_list("user_ids") | |
) |
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 pywt | |
data = [1, 3, 4, 1, 2, 5, 3, 2] | |
a2, d2, d1 = pywt.wavedec(data, 'db1', level=2) | |
a1 = pywt.upcoef('a', a2, 'db1', level=1) + \ | |
pywt.upcoef('d', d2, 'db1', level=1) |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import webbrowser | |
from threading import Timer | |
os.environ["DJANGO_SETTINGS_MODULE"] = "webapp.settings" | |
import cherrypy |
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 -*- | |
from __future__ import unicode_literals | |
import sys | |
import logging | |
logging.captureWarnings(True) |
OlderNewer