Parsing Twitter Geo Data and Mocking API Calls by Example

Posted by Bob on Sat 17 June 2017 in Learning • Tagged with twitter, API, mock, geo, data, unittest, pickle, tweepy, testing, 100days • 2 min read

"Is this Bob or Julian?!" ... yeah tweeting from our shared @pybites Twitter account can be confusing! So I made a little script to parse the location of our tweets. Then I extended it to make it testable. I wrote a decorator to cache a couple of API outputs to be used with the unittest.mock patch decorator I learned about. A simple script turned into a good learning exercise.


Continue reading

Next Time I Will Use Pandas to Parse Html Tables

Posted by Bob on Thu 08 June 2017 in Concepts • Tagged with BeautifulSoup, regex, Pandas, parsing, data, data cleaning, energy, json, csv, html • 2 min read

Last week I did some html table parsing with BeautifulSoup and regex. It turns out there is an easier way to do this: Pandas.


Continue reading

OOP Beyond the Basics: Using Properties for Encapsulation, Computation and Refactoring

Posted by Bob on Wed 31 May 2017 in Concepts • Tagged with oop, property, decorators, encapsulation, computation, dunder, refactoring, pytest, 2vs3, getter, setter • 4 min read

In this article I share my learning of the property decorator coding a simple Account class. I think it's an unmissable tool in your (Python) OOP toolkit.


Continue reading

PyCon 2017 - Digest, Impressions, Reflection

Posted by Bob on Wed 24 May 2017 in Reviews • Tagged with conference, pycon, learning, community, networking, bokeh, parallel, mentoring, photos • 3 min read

PyCon 2017 was such a great conference, I made so many good connections, got to see many good things the community is working on. It was very inspiring. In this article a digest.


Continue reading

Building a Simple Birthday App with Flask-SQLAlchemy

Posted by Bob on Thu 11 May 2017 in Flask • Tagged with Flask-SQLAlchemy, SQLAlchemy, Flask, Facebook, birthday, calendar, icalendar, datetime • 3 min read

In this article I teach you how to get started with Flask-SQLAlchemy. I will set up a model, create the DB, retrieve birthdays from FB and import them into the DB. Lastly I will query the birthdays by date range.


Continue reading

How to Write a Simple Slack Bot to Monitor Your Brand on Twitter

Posted by Bob on Tue 25 April 2017 in Tools • Tagged with Twitter, Slack, Automation, monitoring, twython, TwythonStreamer, slacker, configparser, logging, brand, triggers • 3 min read

In this article I show you how to monitor Twitter and post alerts to a Slack channel. We built a nice tool to monitor whenever our domain gets mentioned on Twitter. The slacker and twython modules made this pretty easy. We also use configparser and logging.


Continue reading

Simple Flask app to compare the weather of 2 cities

Posted by Bob on Thu 20 April 2017 in Flask • Tagged with Flask, weather, API, OpenWeatherMap, learning, Heroku, pytz, deploy, Jinja, CSS • 3 min read

In this post I show you how to build a simple Flask app to compare the weather of 2 cities using the OpenWeatherMap API. Maybe this aids you in solving this week's challenge.


Continue reading

How to Write a Decorator with an Optional Argument?

Posted by Bob on Tue 11 April 2017 in Tips • Tagged with decorators, arguments, tricks, tips, cookbook • 3 min read

When playing with decorators (this week's challenge) I got stuck: how do you write a decorator that takes an optional argument? Python cookbook 3rd ed edition to the rescue. In this post how I failed my way to the right solution.


Continue reading

How we Automated our 100DaysOfCode Daily Tweet

Posted by Bob on Wed 05 April 2017 in Tools • Tagged with twitter, automation, tools, 100days, logging, tweepy, pytz • 4 min read

In this article I show you a way to automatically tweet your #100DaysOfCode Challenge progress. This saves you some extra time to focus on the coding. Isn't that all what matters?


Continue reading

How to Build a Simple Slack Bot

Posted by Bob on Tue 04 April 2017 in Tools • Tagged with slack, API, bot, chatbot, deployment, shell, nohup, automation • 3 min read

I was playing with Slack's Real Time Messaging API the other day. Building a bot is pretty easy. In this article a simple example.


Continue reading