Friday, December 9, 2016

How To Create a Twitter App and API Interface Via Python

This tutorial illustrates how to use a Python API to connect to a Twitter account using the Twitter library. Specifically, this API allows a user to extract high quantities of data pertaining to a specific Twitter account, as well as directly control Twitter posts from the Python platform (such as posting multiple tweets at once).

Even if you’re not a regular Python user, using one of Python’s Twitter libraries is quite useful when it comes to analytics. For instance, while web developers might be more inclined to use a language such as PHP in connecting to the API, Python offers more flexibility in analyzing trends and statistics with the data. Therefore, data scientists and other analysts would find Python to be a better fit for this purpose.

In this tutorial, we’ll start with some basic steps in connecting Python to the Twitter API, and then look at how to stream the desired data. Note that, while the Twitter library (and other Python libraries such as Tweepy and Twython) can carry out a multitude of different tasks with the data, I'll focus on some of the more basic (and useful) queries in this article. Specifically, I'll walk through how to:

  1. connect Python to the Twitter API using the appropriate credentials
  2. download tweets associated with the specific account
  3. download a list of all following and followed users for an account
  4. post multiple tweets at once
  5. customize a search for instances of a specific term on Twitter.

1. Connect Python to the Twitter API

This tutorial uses iPython as the Python interface to connect to Twitter. In order to connect to the API, we need to obtain the Consumer Key, Consumer Secret, and Access Token Secret.

To obtain these, you need to sign into your account at apps.twitter.com. Once there, you’ll be prompted to create an application:

create application

Once you have the application created, you’ll find the relevant keys and tokens under the Keys and Access Tokens section.

consumer key

access token

Firstly, we install the python-twitter library in our terminal as follows:

pip install python twitter

Once we’ve done that, we import the Twitter library and enter the credentials as follows:

import twitter
api = twitter.Api(consumer_key='your_consumer_key',
  consumer_secret='your_consumer_secret',
    access_token_key='your_access_token_key',
    access_token_secret='your_access_token_secret')

print(api.VerifyCredentials())

As soon as the correct credentials are entered, the connection to the API is complete, and we’re now able to control our Twitter account through the Python platform!

2. Download User Timeline

Now that we have connected Python to the Twitter API, we can go ahead and start utilizing different Twitter functions remotely. For instance, if we wish to download a user timeline of tweets, we do this using api.GetUserTimeline as below (and specifying the screen name for the appropriate account), and then using the print() function to display the results:

statuses = api.GetUserTimeline(screen_name='Michael Grogan')
print([s.text for s in statuses])

Once we’ve inputted the above, we see the respective timeline displayed in the Python interface:

get user timeline

Continue reading %How To Create a Twitter App and API Interface Via Python%


by Michael Grogan via SitePoint

Leeway

Leeway

'Leeway' is a One Page WordPress theme suited for a freelancer or digital agency portfolio. Features include a fixed header navigation (that smooth scrolls to sections), intro big image slideshow, portfolio gallery with category filter, team, skills infographic, pricing table, big testimonial slider, blog feed, client logos and contact form. Awesome to know the WordPress theme comes with powerful Visual Composer (valued at $34) page builder and popular Slider Revolution (valued at $19) plugins bundled in.

by Rob Hope via One Page Love

Ryan Michael J.

Ryan Michael J.

Minimal, personal One Pager for Ryan Michael J - an Art Directory over at Nerdworx. Neat touch with the contact form overlay when clicking the contact link in his bio.

by Rob Hope via One Page Love

Why Entrepreneurs Should Start Strength Training (and Where to Begin)

Weight training

This is the age of the entrepreneur.

Just check your social media feeds. Everyone is seemingly "hustling," trying to make their hobby or side-passion into a legit and profitable 9-to-5 career. At least for a year or two, until their plans for "world domination" come to fruition and they can retire to some tropical island, free to post poolside selfies to their hearts content.

Of course, for those who actually live the entrepreneurial life and don’t just tweet about it, the reality isn't so rosy. Things like 9-5 schedules, stress-free vacations, even weekends with the family are a pipe dream.

Instead it's 4 am wake-ups, insurmountable email, and a seemingly endless stream of fires to put out, often at the expense of less urgent but far more important priorities. Like health.

Most entrepreneurs who actually survive the grind to the top realize that neglecting their health and fitness is a mistake. Because if you're not keeping your body healthy, you're actually wasting time in terms of lost productivity, not to mention quality of life.

That's why virtually every successful person, when queried "what do you do every day to stay on top of your business?" will list "exercise" as one of their top "must-do's," whether it's a spin class, a three mile jog, or even a yoga session.

But lately more and more entrepreneurs are turning to weight training.

It seems like an odd choice. Weight training? That requires gym memberships and daily commutes and fumbling around a cavernous stadium full of complicated equipment, or scheduled torture sessions with a slave driver in spandex named Brittney.

Plus, it takes forever to build big muscles, and bulging biceps look kinda silly in a corporate environment. And is any of that even healthy?

The short answer is, it is healthy. And if you're an entrepreneur, I argue that weight training should take priority over any elective exercise you could do. Here's why.

1. Weight Training Builds Muscle

I know, duh. But this isn't about a building a back as wide as a barn door. With just a little extra muscle, you'll be able to do everyday tasks like lifting, carrying the groceries, and sprinting up stairs like a frisky 14 year-old.

Weight training is also the perfect antidote to all the lousy things sitting at a desk does to your hips, lower back, and posture. If that's not enough, the amount of muscle you carry is your number one defense against the wasting forces of age.

2. Weight Training Is Ridiculously Healthy

Weight training is about more than muscle. Think cardio is the only thing that strengthens your heart or improves your bloodwork? Here's a snippet of the health benefits weight training can provide:

  • Improved cholesterol
  • Lowered risk of diabetes
  • Lowered risk of cardiovascular disease
  • Decreased blood pressure
  • Decreased risk of breast cancer
  • Reduced stress and anxiety
  • Strengthened immune system

All that and tighter shirtsleeves? Sounds good to me.

3. Weight Training Improves Flexibility

Musclebound is a myth. By working the muscles through a full range of motion, weight training can improve your flexibility. This greatly reduces the risk of muscle pulls and back pain.

4. Weight Training Burns Fat

Cardio burns calories and helps you lose weight. But too much cardio combined with no weight training can leave you looking like a smaller, softer version of your current self, something the bros call "skinny fat."

However, by increasing the amount of lean body mass you have, weight training improves your body composition, or muscle to fat ratio. So while the scale may not change as much versus a cardio-only approach, in a few months your body could look dramatically different.

5. Weight Training Reinforces Structure

Entrepreneurs are often very regimented. Most will confess to waking at the exact same time every day (even weekends), working in finite blocks, and avoiding time leaks like the plague.

The cool thing about weight training is, it works incredibly well with this kind of mindset. Training regularly can help establish and reinforce structure, not to mention making you tired enough to sleep at night.

6. Weight Training Engages Your Brain

All exercise increases your heart rate and dilates your blood vessels, pumping more blood to your brain. However, using specific muscle groups engages parts of your brain related to fine motor control, which further helps "turn on" your higher-level circuitry.

As a writer, I can't count how many ideas for blog posts and articles have "come to me" while straining under a heavy squat or bench press. It seems counter intuitive, but the very act of clearing one's mind and just focusing on performing an exercise seems to cause ideas to just "appear."

7. Weight Training Is the Perfect Stress Reliever

Weight training is basically a controlled battle against resistance. As you get stronger, the weights get heavier. It's a non-stop war, with every workout providing an opportunity to improve upon your previous outing — if you have the fortitude to venture past your comfort zone. Which is the perfect analogy for succeeding in business.

Arnold Schwarzenegger famously said he learned "everything he needed to succeed" from bodybuilding, and he's made millions in three different careers.

8. You'll Look Better

And looks matter. Many entrepreneurs are on the introverted side, a quality that may actually help them during the initial "rise & grind" days.

However, at some point even the most reclusive entrepreneur will have to step out from behind their computer and make an impression. And this is a lot less stressful if you can look in the mirror and confidently declare that you're in damn good shape.

Of course, appearances shouldn't count this much in the business world, but they do — especially when your persona is an integral part of your company. It might not be right, but as the kids say "don't hate the player, hate the game."

The How-To

So you're sold. You've ordered a closet full of gym clothes and are ready to pump up to Men's Health cover proportions.

Continue reading %Why Entrepreneurs Should Start Strength Training (and Where to Begin)%


by Bryan Krahn via SitePoint

Epicurrence No.5

Another banger One Pager by Dann Petty and his team for the fifth Epicurrence event, this time in Jackson Hole, WY. The Single Page website features a wonderfully subtle parallax effect with the layered mountains and logo - all while snow falls and clouds drift by - stunning. Other highlights include a slick colorful submission form and a unique speaker infographic that impressively adapts to a grid on mobile. If you missed the previous Epicurrence One Pagers, we have a neat archive of them all.

by Rob Hope via One Page Love

Gitscout

Slick One Pager with crisp screenshots promoting a new macOS Github issue tracker called Gitscout. Had a good chuckle seeing the download link includes "marshmallows" in the URL

by Rob Hope via One Page Love

Make Creating Websites Fun Again With Hugo