Skip to content

Instantly share code, notes, and snippets.

@shandou
Last active February 23, 2020 13:44
Show Gist options
  • Save shandou/8975797deac91401173d40ca9fe4f8c4 to your computer and use it in GitHub Desktop.
Save shandou/8975797deac91401173d40ca9fe4f8c4 to your computer and use it in GitHub Desktop.
For more information about CND-available PrismJS features:1. Basic documentation and plugin utilities: https://prismjs.com/index.html2. CDN css and js: https://cdnjs.com/libraries/prism
<!-- 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