Exemplo n.º 1
0
#!/usr/bin/env python
"""
Random walk face generator

Dependends on:
    * numpy 1.7
    * matplotlib
"""
import numpy
from matplotlib import pyplot
from morpher import Morpher


if __name__ == "__main__":
    # Initialize face generator
    morpher = Morpher()

    # Make sure I/O doesn't hang when displaying the image
    pyplot.ion()

    # Build visualization window
    fig = pyplot.figure(figsize=(1, 1), dpi=300)
    im = pyplot.imshow(X=morpher.generate_face(),
                       interpolation='nearest',
                       cmap='gray')
    pyplot.axis('off')
    pyplot.show()

    # Program loop
    print "Press CTRL+C to stop"
    while True:
Exemplo n.º 2
0
#!/usr/bin/env python
"""
Random walk face generator
tested this
Dependends on:
    * numpy 1.7
    * matplotlib
"""
import numpy
from matplotlib import pyplot
from morpher import Morpher

if __name__ == "__main__":
    # Initialize face generator
    morpher = Morpher()

    # Make sure I/O doesn't hang when displaying the image
    pyplot.ion()

    # Build visualization window
    fig = pyplot.figure(figsize=(1, 1), dpi=300)
    im = pyplot.imshow(X=morpher.generate_face(),
                       interpolation='nearest',
                       cmap='gray')
    pyplot.axis('off')
    pyplot.show()

    # Program loop
    print "Press CTRL+C to stop"
    while True:
        Z = morpher.get_Z()
Exemplo n.º 3
0
#!/usr/bin/env python
"""
Interactive face generator

Dependends on:
    * numpy 1.7
    * matplotlib
"""
from morpher import Morpher
from matplotlib import pyplot


if __name__ == "__main__":
    # Initialize face generator
    morpher = Morpher()

    # Make sure I/O doesn't hang when displaying the image
    pyplot.ion()

    # Build visualization window
    fig = pyplot.figure(figsize=(1, 1), dpi=300)
    im = pyplot.imshow(X=morpher.generate_face(),
                       interpolation='nearest',
                       cmap='gray')
    pyplot.axis('off')

    def onmove(event):
        width, height = fig.canvas.get_width_height()
        x = 2 * event.x / float(width) - 1
        y = 2 * event.y / float(height) - 1
        morpher.set_coordinates(x, y)
Exemplo n.º 4
0
Бот, собирает существительные из ленты одного пользователя, подставляет их в
шаблон из environ и постит несколько твитов
"""

import sys
import os
from apscheduler.schedulers.blocking import BlockingScheduler
from twitterbot_utils import Twibot, get_maximum_tweets
from morpher import Morpher

__author__ = "@strizhechenko"

SCHED = BlockingScheduler()
BOT = Twibot()
READER = Twibot(username=os.environ.get('reader_name'))
MORPHY = Morpher()
TIMEOUT = int(os.environ.get('timeout', 30))
TEMPLATE = unicode(os.environ.get('template', u''), 'utf-8')
TWEET_GRAB = int(os.environ.get('tweet_grab', 3))
TWEETS_PER_TICK = int(os.environ.get('tweets_per_tick', 2))
POSTED = get_maximum_tweets(BOT.api.home_timeline)


@SCHED.scheduled_job('interval', minutes=TIMEOUT)
def do_tweets():
    """ периодические генерация и постинг твитов """
    print 'New tick'
    tweets = READER.api.home_timeline(count=TWEET_GRAB)
    string = " ".join([tweet.text for tweet in tweets])
    words = MORPHY.process_to_words(string, count=TWEETS_PER_TICK)
    posts = [TEMPLATE % (word) for word in words]