Skip to content

Instantly share code, notes, and snippets.

View bobturneruk's full-sized avatar

Robert (Bob) Turner bobturneruk

View GitHub Profile
# Required libraries
from twython import Twython
import json
import pandas as pd
# Access Twitter API using twython
APP_KEY = '' # Use your API KEY
APP_SECRET = '' # Use your secret
twitter = Twython(APP_KEY, APP_SECRET, oauth_version=2)
ACCESS_TOKEN = twitter.obtain_access_token()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bobturneruk
bobturneruk / extract_code.py
Created April 4, 2023 14:33
pulls code out of carpentries episodes - not the most reliable!
import re
with open("_episodes/08-connected-components.md") as f:
content = f.read()
content = re.sub("(\>[ |\n])", "", content) # strip all "> "
content = re.sub("(\%matplotlib widget)", "", content) # strip notebook magics
matches = re.findall(
"(\~\~\~\n)(?!{)([\w\W]*?)(\~\~\~\n)(.*)",
content,