001 |
Mar 30, 2017 |
script to check if tip already submitted to @python_tip |
Urlopen, 2vs3, csv parsing, namedtuples, contextlib |
002 |
Mar 31, 2017 |
script to print out valid IPs of a specified user specified network |
ipaddress, simplifying and automating tedious/manual process |
003 |
Apr 01, 2017 |
script to generate a gif from various png/jpg images |
useful for blog, awesome: pip install imageio, cli arg interface is more code :) |
004 |
Apr 02, 2017 |
script that converts a text list to a text string |
useful for tedious sysadmin tasks. Pyperclip is used to read in a list copied to clipboard and convert it to a single line string separated by spaces. |
005 |
Apr 03, 2017 |
script to create a 100DaysOfCode tweet |
takes a date or defaults to today, reads this LOG file in and creates a tweet about our progress (to be automated) |
006 |
Apr 04, 2017 |
simple reusable code snippet to print a dict |
reusable code snippet to print the keys and values of a dict. Includes a demo dict. Short and sweet. |
007 |
Apr 05, 2017 |
script to automatically tweet 100DayOfCode progress tweet |
twitter API, manage config outside source, logging, date parsing and timezones |
008 |
Apr 06, 2017 |
reusable python flask html template for printing a dict |
reusable python flask html template that uses a for loop to print dict contents - flask |
009 |
Apr 07, 2017 |
interactive script to create a new Pelican blog article |
lot of known concepts, but nice to bring a lot of functionality together, and above all a really useful script for our blog |
010 |
Apr 08, 2017 |
script to spot cheap @transavia flights using their #API |
this was a nice exercise, and a very useful script for a monitoring cron job. TODO: wrap it in a Flask web app. Some modules I explored: calendar, datetime, dateutil.relativedelta, requests_cache |
011 |
Apr 09, 2017 |
generic script to email the contents of a text file |
a script that uses your gmail account to email the contents of a text file. Current use case is to email web scraped data. smtplib, email, MIME |
012 |
Apr 10, 2017 |
using OpenWeatherMap #API to compare weather in Australia vs Spain |
OpenWeatherMap API, pytz for timezone handling, datetime.utcfromtimestamp to parse unix timestamp to datetime, Google confirms sunset / sunrise times correct :) |
013 |
Apr 11, 2017 |
simple #Flask app to compare weather of 2 cities (using OpenWeatherMap #API) |
This was a nice follow-up of 012, making it more generic (support any city), using Jinja templating, Flask form handling, and of course a good chunk of timezone handling (for sunset and sunrise) |
014 |
Apr 12, 2017 |
script to automatically tweet out new @lynda (#Python) titles |
feedparser is awesome. Want to run it with filter on Python. Abstracted twitter config away in repo's common dir (re-use). |
015 |
Apr 13, 2017 |
script to calculate the number of posts on @pybites |
small script but some interesting things: urllib.request.urlretrieve (stdlib), test and cache option (using os.start for cache file age), re.findall, dict comprehension. |
016 |
Apr 14, 2017 |
script to #ssh to specified IPs and check their hostnames |
Generic script to ssh to a list of IPs and run a command using paramiko. This can obviously be altered for many purposes, not just hostname checks. The code is quite flexible. |
017 |
Apr 15, 2017 |
script to automatically tweet out new @safari Python titles |
like the Lynda one, parsing an RSS feed, but only stdlib, so no feedparser, using xml.etree.ElementTree, no requests, using urllib. Also nice exercise converting and calculating with datetime / timedelta |
018 |
Apr 16, 2017 |
using #pytest to write tests for @safari RSS scraper (day 017) |
testing is a good skill to keep honing. It lets you define your design better and look for edge cases that saves debug headaches later on. pytest is nice, to be further explored ... |
019 |
Apr 17, 2017 |
paste in a list of numbers from the clipboard, sort to ascending then copy back to clipboard @AlSweigart #pyperclip #script |
simple yet useful script to read in a list of numbers from the clipboard, sort them into ascending order then copy the sorted list back to clipboard. Numbers need to initally be copied with a new line between them |
020 |
Apr 18, 2017 |
monitor #Twitter and post to #slack each time our domain gets mentioned |
useful script and exercise. Twitter + Slack API combined == awesome. Aim was to clone/ replace mediatrigger.io (got bothered free trial will end one day ...) |
021 |
Apr 19, 2017 |
script to make an index of modules used for this challenge (stdlib >50%) |
collections (defaultdict, Counter), os.path, regex, glob, os.listdir, is_std_lib function (from SO), f-strings. Nice to see we heavily use stdlib, Python == batteries included |
022 |
Apr 20, 2017 |
create and paste #Amazon affiliation link to clipboard #pyperclip @AlSweigart |
nice little utility to copy an take Amazon link from clipboard, convert it into an affiliation link and paste it back to clipboard |
023 |
Apr 21, 2017 |
use Counter to count the most common words in a file |
we did some time ago, collections module is awesome |
024 |
Apr 22, 2017 |
generate color hex codes from random RGBs and color terminal text |
nice play with generators, RGB to hex with format, and colorizing the terminal with the colored package. This could be useful for future cli apps |
025 |
Apr 23, 2017 |
Simple test #database generator script #python #sqlite #contextmanager |
Script to generate a quick, test sqlite3 database with 1 table and 3 columns. Can be customised and expanded to suit your needs. Definitely useful for playing around with persistent data. |
026 |
Apr 24, 2017 |
Simple script to retrieve #movie data from OMDb #API |
Get OMDB for movie data, query API by IMDB ID or title. Returns text or html. Uses request_cache to limit repeated calls to API. Could help some folks taking this this week's challenge |
027 |
Apr 25, 2017 |
rough script to query the #warcraft #API for a character's mounts |
A VERY rough and simple script to query the World of Warcraft API and pull the collected mounts of a specific character. Lots of room to expand this with stripping of JSON data and specifying which data to pull. Just some fun with a new and unconmmon API! |
028 |
Apr 26, 2017 |
Jupyter notebook to plot and list new #Python titles on @safari by month |
Learning: parsing a Twitter CSV backup dump (@newsafaribooks account), matplotlib, collections, hacking iPython css |
029 |
Apr 27, 2017 |
Traffic Lights script to demo #itertools cycle |
A nice and easy script to simulate traffic lights using itertools.cycle and other stdlib modules cycle. Itertools rocks! |
030 |
Apr 28, 2017 |
Script to import movie csv file into an sqlite database |
sqlite3, csv, nice groundwork for Flask auto-complete I am working on |
031 |
Apr 29, 2017 |
Simple and reusable #Python #script to move all files from one folder to another |
A simple but useful script to move all files from one diretory to another using shutil and os. Currently using this in a cron job to mv server log files into an archive folder to keep the log dir clean. |
032 |
Apr 30, 2017 |
#Flask #jQuery movie autocomplete |
Used DB of day 30. Learned Jinja template extending / inheritance. Nice plugin for mixing Flask/JS: Flask-JSGlue. TODO: upon select movie direct to page showing movie info. |
033 |
May 01, 2017 |
I need to drink more water at work so I wrote a #Python #script to remind (spam) me every hour |
A simple script using MIME and a cron job (read the readme.txt) to remind me to drink more water at work! Doesn't email on the weekends or before/after hours. Over the top? Maybe. Satisfying? Hell yes. |
034 |
May 02, 2017 |
Import a #podcast feed into a DB table with #SQLAlchemy |
Part of the this week's code challenge solution. Found it useful enough to extract this bit as separate nudget |
035 |
May 03, 2017 |
Text replacer script using #pyperclip by @AlSweigart |
A simple script that will replace any text or characters in text that you have copied to the clipboard. Check out the readme.txt file for more detail. |
036 |
May 04, 2017 |
Use #Python #pickle to store and retrieve a defaultdict |
Nice and easy persistence tool. Using it with context manager to write random log entries. Each time the script is run the data pickle file gets updates. To get random entries I used a generator. |
037 |
May 05, 2017 |
#Python script to pull down an #XML feed and save it |
This is an extremely simple script that uses the requests module to pull down an XML feed and write it as is to your local disk for later use by a scraper etc. Created while working on PCC17 |
038 |
May 06, 2017 |
Simple #Twitter login for your #Flask app using flask_oauthlib |
This was a nice addition to myreadinglist app: easy authentication flow. Also want to leverage it to show recommended books from followers of the Twitter logged in user. |
039 |
May 07, 2017 |
#Python script to give you every valid dictionary match of a specified letter sequence |
A script that uses itertools permutations to check whether a user specified sequence of letters (could be a word!) can be used to make a word or words from the English dictionary. |
040 |
May 08, 2017 |
PyBites podcast challenge 17 in less than 100 LOC using #scheduler and #shelve |
Rewriting a script with different modules (originally we used SQLAlchemy/SQlite) and with LOC constraint, was fun |
041 |
May 09, 2017 |
Script to check all possible combinations of letters and match against a dictionary. Great for #scrabble |
Similar to day 039 but this time it checks all combinations of letters of all lengths, not just the length of the given string. It's a great way to ruin a game of Words with Friends! |
042 |
May 10, 2017 |
Using #Python icalendar module to parse FB birthdays cal (ics file) |
Prework to download all birthdays into a Flask SQLAlchemy app |
043 |
May 11, 2017 |
Script to read in a list and reverse its contents |
I thought it'd be fun to see if I could read in a list of excel cells and reverse their order then paste them out. It's not perfect but it works! |
044 |
May 12, 2017 |
Random name generator, reading in a bunch of names from a CSV file |
I used this for Flask SQLAlchemy birthday app to anonymize the data (real dates, fake names), csv source here (TODO: could use faker module) |
045 |
May 13, 2017 |
#steam XML feed scraper for new #game releases |
A simple script to parse the Steam XML feed for new game releases. Script will store the title and URL data in an SQLite DB. Readme.txt for more info. |
046 |
May 14, 2017 |
Get friends updates from Goodreads #API #books |
Base work for this week's challenge 18 to get book recommendations from Goodreads (requires oauth) |
047 |
May 15, 2017 |
Customisable script for pulling down XML feeds with a cron job |
This is the accompanying script for Day 045 to automate the pull of the XML feed. It uses requests and a cron job. |
048 |
May 16, 2017 |
Use the Faker module to get (random) fake Dutch names |
Refactored random name generator of day 44 = much less LOC, and you can specify a "localized provider" to get names in a particular language, very cool. Reminder to self: don't re-invent the wheel, use PyPI more! |
049 |
May 17, 2017 |
Email contents of an #sqlite db |
Code snippet to email data from an sqlite db then flag the data as Emailed to avoid sending it multiple times. Handy for an emailer service. |
050 |
May 18, 2017 |
Use folium to draw a map with cities I traveled to |
Folium is awesome and easy to use, definitely will use it for more stuff later on (as well as Bokeh) |
051 |
May 19, 2017 |
Use #Python #requests module on a page behind a login |
Wrote a quick script to pull web page data from a page behind a login. In this example I pull my post data from freecycle.org. Will write a detailed post about it this week. |
052 |
May 20, 2017 |
Build a user focused REPL with prompt_toolkit (source @amjithr) |
Code from PyCon2017 Awesome Commandline tools session |
053 |
May 21, 2017 |
Script to start automating posting to our PyBites FB group |
Also 'a' possible solution for challenge 19 of this week |
054 |
May 22, 2017 |
Script to create a person #class and calculate BMI |
A simple script to demo basic Python Classes. It calculates the BMI of an individual |
055 |
May 23, 2017 |
Parse/store #PyCon2017 talks meta data in DB - #BeautifulSoup #sqlite |
Fun little exercise to get an index of PyCon talk meta data and load them into a sqlite DB to query them and what not |
056 |
May 24, 2017 |
#Python #Flask BMI calculator |
A quick but useful BMI calculator created with Python Flask. Will have to run this on Heroku just for the experience! |
057 |
May 25, 2017 |
Using the #YouTube #API to determine most popular #PyCon2017 talks |
PyCon videos watch / like stats = nice to know, but also data prep to maybe do some data visualization with Bokeh |
058 |
May 26, 2017 |
Playing with OOP and dunder methods in Python |
Some practice / example code because this week we have an OOP challenge |
059 |
May 27, 2017 |
Using the #Twilio #API to send SMS messages |
Prework for another app where I want to use Twilio to send reminder notification and text friends :) |
060 |
May 28, 2017 |
#Python #Flask Pay Calculator using a session object |
A simple pay calculator (wage x hours) that demos the use of a Flask Session object so the wage is remembered throughout the session. Very cool stuff! |
061 |
May 29, 2017 |
Plan your next book read using the @twilio SMS API (cc @mattmakai) |
Fun exercise for our OOP challenge (#20) using the Twilio API for SMS, click for nice and easy command line argument handling, pytest for testing, and schedule for cron. Using this live now to facilitate a 'reading date' with some friends. They get weekly task lists / goals via SMS, lets see if they read more thanks to this script :) |
062 |
May 30, 2017 |
#Python #Flask friends list with #sqlite db |
Essentially an address book to track friends with. It utilises sqlite3 for a persistent DB and was particularly tricky to make as it creates a pull down menu for you to select which friend to view! Need to improve the handling of people with the same name though. |
063 |
May 31, 2017 |
Coding an account class using properties, dunders and pytest |
Good exercise to explore properties (for today's article) and alo did some magic method goodness to deposit/withdraw amounts from account. |
064 |
Jun 01, 2017 |
Prework code challenge #21: ApplianceCost class to calc energy cost |
This will be the data model for a simple flask app to calculate cost per appliance given minutes consumption in period, also want to give a dropdown of energy prices per country. This will be fun |
065 |
Jun 02, 2017 |
Use #Python #webbrowser to simplify #Flask testing |
Just a nifty little snippet I use to make testing my Flask apps one step easier and faster. Use the webbrowser module to save you time opening and refreshing your Flask app after every code change |
066 |
Jun 03, 2017 |
Use Selenium to login to a site and show content |
Work in progress: trying to login to Packt and show ebooks and maybe even make a download manager. |
067 |
Jun 04, 2017 |
#Python script to pull a random entry from an #sqlite db |
A script that pulls a random movie from an sqlite db of movies. Just to demo the random pull procedure. |
068 |
Jun 05, 2017 |
@mohhinder translated our 'from PyBites import newsletter' into code |
In his own words: Written on iPhone with the Pythonista 3 app as a joke for the PyBites guys, I don't see why it wouldn't work anywhere else though. They always start off their newsletter annoucements with: from @PyBites import newsletter , so I turned it into actual code that pulls their feed and opens their latest newsletter in a browser :) - original source and tweet |
069 |
Jun 06, 2017 |
#Python CLI based #Pomodoro Timer with #webbrowser alarm |
Very simple Pomodoro Script I made for myself that launches an alarm tone on YouTube (using the Python webbrowser module) when the time is up. |
070 |
Jun 07, 2017 |
How to parse html tables with #pandas (#jupyter notebook) |
Prep work for tomorrow's article where I will show you how Pandas can relieve the pain of parsing nasty html tables |
071 |
Jun 08, 2017 |
How to calculate the # of days between two dates #Python #datetime |
Simple CLI script to calculate the number of days between two dates. It uses datetime and dateutils to do this. Still need to strip out the timestamp in the final output though. Maybe a regex? Needs investigation. |
072 |
Jun 09, 2017 |
Packt ebook download manager |
Using requests to login to Packt, BeautifulSoup to parse the account/ebooks page for links, letting user download his/her books via interactive script |
073 |
Jun 10, 2017 |
#Python script to download a file using #FTP |
A simple and quick script to download a file from an FTP server using ftplib. Would ideally be matched with a cron job. |
074 |
Jun 11, 2017 |
Using Pillow to add text and opacity to an image = your own cards |
Played with the Pillow module. Script to let user enter an image path (or url) and text to put on the image. Pillow does the rest. Could be a useful recipe to make your own Birthday cards :) |
075 |
Jun 12, 2017 |
#Python script to take screenshots using #pyscreeze @AlSweigart |
A Simple script that uses PyScreeze (written by Al Sweigart) to take a screenshot. Handy for any code that may require a screenshot to be taken. Also includes code to allow you to change dirs to save the screenshot somewhere else. |
076 |
Jun 13, 2017 |
Script to scrape Packt free ebook site and send html notification mail |
Using requests, BeautifulSoup, namedtuple, datetime. Cronjob script to send out a nice html email with image and metadata of the book, and how long till free offer expires. As it's hard to automate this now with the new captcha at least we get notified about each new title. |
077 |
Jun 14, 2017 |
Blank template of a #Python #class and #subclass |
A blank template I created that shows the framework of a Python Class and Subclass. Easy to just copy and customise. |
078 |
Jun 15, 2017 |
Use a context manager to rollback a transaction |
An example for the use of the with statement = resource management. |
079 |
Jun 16, 2017 |
#Python script to capture exceptions when creating an #sqlite db |
A simple but useful script I use to create an sqlite db and check to see if it exists on subsequent runs. The use of exception allows me to capture any other errors too. |
080 |
Jun 17, 2017 |
"Is this Bob or Julian?" - script to reveal who of @pybites tweets |
Fun little exercise that started with Anthony Shaw asking who he was talking to - it actually became more involved turning/testing out location on our tweets and adding exception handling ... nice practice! (and a funny new service for our PyBites community) |
081 |
Jun 18, 2017 |
Using unittest mock patch to test Tweepy code without calling the API |
I took my code of day 80 and wrote tests for it. But as it involves an API we don't want to call it and depend on the network. So you can use the mock patch decorator. I did have to save some test data (cache decorator in main script), but once that was done, it was pretty easy. Here is another Twitter API mock I did some time ago |
082 |
Jun 19, 2017 |
#Python script to list all #timezones and their current time |
Simple script using pytz and Pendulum to print a list of every timezone as well as the associated CURRENT time. |
083 |
Jun 20, 2017 |
#Python #Flask app to print the current time in a given timezone |
Useful and cool little Flask app to print the current time for a timezone selected from a drop down menu. Does it exist already? Of course! But so satisfying to make it yourself! |
084 |
Jun 21, 2017 |
Use PyGithub to retrieve some basic stats for a GH user |
Conclusion: PyGithub makes it really easy to work with the GH API |
085 |
Jun 22, 2017 |
#Python script to list out the current exchange rate |
Script that uses the openexchangerates.org API to pull and print a list of the current exchange rate relative to US$1 |
086 |
Jun 23, 2017 |
Script to pull some quick stats from a #Twitter Archive CSV |
Using Counter and csv.Dictreader. Simple exercise, yet useful data. You can run it yourself downloading your Twitter Archive in Settings |
087 |
Jun 24, 2017 |
Currency Conversion script using openexchangerates API |
A basic but expensive script to convert one currency to another using the openexchangerates API. To use this you'll need an Unlimited subscription. TODO: do this myself using the free plan by performing math conversions myself. |
088 |
Jun 25, 2017 |
Using #Slack Real Time Messaging #API to capture all messages |
Groundwork for our new karmabot project. |
089 |
Jun 26, 2017 |
#Python #Flask overtime hours tracker. #sqlite |
I wrote a simple Flask app to track the overtime hours that I work. It uses an sqlite db and prints existing overtime data on the main page. |
090 |
Jun 27, 2017 |
Playing with TheTVDB API to scrape some movies/series info |
thetvdb, various good wrappers pip installable - today's script lists episodes for a show |
091 |
Jun 28, 2017 |
Showing the broadcasting network for a show using TheTVDB API |
More thetvdb - I know from friends they need this lookup :) |
092 |
Jun 29, 2017 |
#Python script to ping every IP on a specified #network |
A simple script that'll ping every IP on a user specified network. Uses the ipaddress and os modules. |
093 |
Jun 30, 2017 |
Refactored day 86's Tweet Achive Stats script into a Package |
Modularized Twitter Archive script of day 86 turning it into a package. This will serve our post of this week on packaging. |
094 |
Jul 01, 2017 |
Simple Python script to #scp get a file from a remote host |
Script uses the Paramiko package and SCP to pull a log file from a remote host. Can be easily modified and expanded. |
095 |
Jul 02, 2017 |
Class to cache moviedb API responses #shelve #decorator #namedtuple |
Part of challenge 25 solution where we query themoviedb API to get upcoming/now-playing movies or airing tv series to send out mail alerts |
096 |
Jul 03, 2017 |
Script to measure which 100Days tweets were most successful (RTs / Favs) |
Using csv module to parse downloaded archive, tweepy to query status for each tweet, parsing out retweet_count and favorite_count. I add those up and sort the result descending on this combined number. Curious to see what our most popular tweets were ... |
097 |
Jul 04, 2017 |
Create a default #Flask App dir structure for new projects |
Unpythonic and simple. A rough script I threw together that creates a basic Flask App directory structure (templates and static folder) with required base files. Will refactor this later but for now it works! |
098 |
Jul 05, 2017 |
Script to use the #Instagram #API to authenticate and pull your media |
Experimentation with the Instagram API - hit some bugs which I documented in README, considering making my own wrapper ... |
099 |
Jul 06, 2017 |
Simple #Flask app to display photos in a directory |
This is a very basic app to demonstrate displaying images using Flask and Jinja templates. All photos need to be stored in the "static" dir within the Flask folder structure. The glob module is used to parse the photo dir. The app can and will be expanded and refactored. |
100 |
Jul 07, 2017 |
100DaysOfCode done! 5K LOC!! Day #100 Special: a Histogram of LOC/day |
Glob through all our day directories, counting lines per python script. Then pip installed matplotlib and Plot a histogram from a Dictionary, very easy to do with Python :) - see you for our next 100 Days PyBites Project / Challenge |