Skip to content

Instantly share code, notes, and snippets.

@shandou
Created February 23, 2020 13:50
Show Gist options
  • Save shandou/cb83135e301478f88688f21f078b6bdd to your computer and use it in GitHub Desktop.
Save shandou/cb83135e301478f88688f21f078b6bdd to your computer and use it in GitHub Desktop.
Snippet for adding code snippet to Wix blog
<!-- CSS style sheets for Prism.js -->
<link
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/themes/prism.min.css"
rel="stylesheet"
/>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/plugins/line-numbers/prism-line-numbers.min.css"
rel="stylesheet"
/>
<!-- Code snippet content -->
<pre class="line-numbers">
<code style="font-family: Monaco, sans-serif" class="language-python">import subprocess
import pathlib
import requests
from tqdm import tqdm
import pandas as pd
# Destination folder for the downloaded files
dir_dest = pathlib.Path(__file__).absolute().parent.parent / "dataset"
try:
# Send GET request to Github API
r = requests.get(
(
"https://api.github.com/repos/shandou/"
"data-sets/contents"
)
)
r.raise_for_status()
except requests.exceptions.HTTPError as e:
print(f"requests failed with error {e}")
else:
# When requests succeed, pack returned JSON into pandas dataframe
df = pd.read_json(r.content)
</code>
</pre>
<!-- Javascript for Prism.js core, line number display, and python syntax highlight -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/components/prism-python.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment