Securiplay.com

  • Location
  • Contact Us
  • Blog
    • Securiplay.com

Category Archives: Live tweet

Live tweeting with Python in Powerpoint

Posted on October 3, 2013 by brasscount Posted in Live tweet .

Acquired from >>

http://nbviewer.ipython.org/urls/raw.github.com/sanand0/ipython-notebooks/master/Office.ipynb

 

I have to try this:

Live tweeting

Just for kicks, let’s use PowerPoint as a dashboard to show live tweets.

I picked TwitterAPI to get streaming results, but twython and Python Twitter Tools look fine too.

In [13]:
from TwitterAPI import TwitterAPI

# I'm keeping my keys and secrets in a secret file.
from secret_twitter import consumer_key, consumer_secret, access_token_key, access_token_secret
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret)

This function will draw a tweet in a reasonably nice way on a slide. There’s a block each for the profile picture, the text of the tweet, and the name of the user.

In [16]:
def draw_tweet(Base, item, pos):
    y = 40 + (pos % 4) * 120

    image = Base.Shapes.AddPicture(
        # To get the larger resolution image, just remove _normal from the URL
        item['user']['profile_image_url'].replace('_normal', ''),
        LinkToFile=True,
        SaveWithDocument=False,
        Left=20, Top=y,
        Width=100, Height=100)

    try:
        status = item['text'].encode('cp1252')
    except UnicodeEncodeError:
        status = item['text']
    text = Base.Shapes.AddShape(msoShapeRectangle, 130, y, 460, 100)
    text.Fill.ForeColor.ObjectThemeColor = msoThemeColorText1
    text.Fill.ForeColor.Brightness = +0.95
    text.Line.Visible = msoFalse
    text.TextFrame.TextRange.Text = status
    text.TextFrame.TextRange.Font.Color.ObjectThemeColor = msoThemeColorText1
    text.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignLeft

    user = Base.Shapes.AddShape(msoShapeRectangle, 600, y, 100, 100)
    user.Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent6
    user.Line.Visible = False
    user.TextFrame.TextRange.Text = '@' + item['user']['screen_name']

Let’s track requests for specific words, and see what we get.

In [17]:
Base = Presentation.Slides.Add(1, ppLayoutBlank)
api.request('statuses/filter', {'track': 'beer'})

for pos, item in enumerate(api.get_iterator()):
    draw_tweet(Base, item, pos)
    if pos > 10:
        break

 

More info on IPython website . The code for this site is licensed under BSD. Some icons from Glyphicons Free, built thanks to Twitter Bootstrap

Leave a comment .

Recent Securiplay Posts

  • Bartles vs. Keirsey September 28, 2014
  • Ancient Egyptian D20 September 22, 2014
  • Game software as an exploitation vector August 19, 2014
  • The business of gaming is not the gaming of business July 30, 2014
  • How a gamer is gaming YouTube to become the top channel June 19, 2014

Twitterisms

Follow @brasscount Spence Wilcox
@brasscount

  • Thanks @securitymag for such a nice gesture. I truly appreciate the recognition for the hard work that my teams an… https://t.co/TUtcdnr4fP
    about 4 days ago
    Reply Retweet Favorite
  • @wimremes Sometimes your power works on gas too.
    about 2 weeks ago
    Reply Retweet Favorite
  • @thecaitcode Started Philosophy...
    about 3 weeks ago
    Reply Retweet Favorite
  • @langnergroup It tends to go up. Buy on the “cyber-dip.”
    about 3 months ago
    Reply Retweet Favorite
  • Dive into the tragedy of tyranny in the Americas and you often find, long before the consolidation of power, suppor… https://t.co/7qcbEAQlRX
    about 4 months ago
    Reply Retweet Favorite
  • NEED CPE’s? Hacker Halted is free, and online this year. If you sign up now too, you get an annual subscription t… https://t.co/NlkCGwjCs0
    about 5 months ago
    Reply Retweet Favorite
  • @HackingDave Wait til your beard goes grey and you get hair on your ears... Or so I hear....
    about 6 months ago
    Reply Retweet Favorite
  • I'm starting to write a web-book on cyber strategy development and delivery. Check out https://t.co/ZJwG1vIY06. First post is live!
    about 6 months ago
    Reply Retweet Favorite
  • @varcharr Update your resume.
    about 6 months ago
    Reply Retweet Favorite
  • @infracritical Its influence ops, its vulnerabilities, its threats....
    about 6 months ago
    Reply Retweet Favorite

Securiplay Archives

Categories

  • adversarial gamification
  • game theory
  • gamification of awareness / knowledge
  • gamification of function
  • gamification of performance
  • gamification of results
  • gamification theory
  • gamifying management
  • geo-loc
  • Geo-location
  • Live tweet
  • strategy
  • Uncategorized

Pages

  • Location
  • Contact Us
  • Blog
    • Securiplay.com

Archives

  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • June 2013

Categories

  • adversarial gamification (8)
  • game theory (3)
  • gamification of awareness / knowledge (8)
  • gamification of function (7)
  • gamification of performance (12)
  • gamification of results (5)
  • gamification theory (12)
  • gamifying management (3)
  • geo-loc (4)
  • Geo-location (3)
  • Live tweet (1)
  • strategy (4)
  • Uncategorized (14)

WordPress

  • Log in
  • WordPress

CyberChimps WordPress Themes

© Securiplay.com