This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "iTunes" | |
set elapsed_seconds to player position | |
set this_elapsed_minutes to round elapsed_seconds / 60 rounding down | |
set N to result | |
if N < 10 then | |
set N to 0 & N | |
end if | |
set this_elapsed_seconds to elapsed_seconds mod 60 | |
if {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} contains this_elapsed_seconds then | |
set this_elapsed_seconds to "0" & (this_elapsed_seconds as string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With thanks to https://stackoverflow.com/questions/42190691/python-how-to-find-google-drive-filetype & @egh | |
import requests | |
from tqdm import tqdm | |
def download_file_from_google_drive(id, destination): | |
""" General method for downloading from Google Drive. | |
Doesn't require using API or having credentials | |
:param id: Google Drive id for file (constant even if filename changes) | |
:param destination: directory where to download the file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With thanks to https://stackoverflow.com/questions/17904097/python-difference-between-two-strings | |
# Describes difflib-detected differences in easy-to-understand English | |
import difflib | |
cases = [('apple', 'apples'), ('banaana', 'bananas')] | |
for a, b in cases: | |
print('{} => {}'.format(a, b)) | |
for i, s in enumerate(difflib.ndiff(a, b)): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
def get_all_pmc_dois(retstart=0, retmax=80000, count=None): | |
"""Query the entrez database to get a comprehensive list of all PMCIDs associated with all PLOS journals, | |
individually included in the search url. | |
See https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESearch for more info on search parameters | |
:return: the full list of PMCIDs in PMC for PLOS articles | |
""" | |
pmc_allplos_query_url = ('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pmc&term=' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This renames annotation article files in an existing local copy of corpusdir to fit the new naming scheme. | |
See https://github.com/PLOS/allofplos/issues/28 | |
""" | |
import os | |
import re | |
from plos_corpus import listdir_nohidden, corpusdir | |
from plos_regex import validate_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" This small script will return a list of every PLOS article DOI. | |
It uses regular expressions to return only DOIs to full articles. | |
For more information on text and data-mining PLOS content, see http://api.plos.org/text-and-data-mining/ | |
""" | |
import requests | |
def get_all_solr_dois(): | |
""" | |
Get every article published by PLOS, up to 500,000, as indexed by Solr on api.plos.org. | |
URL includes regex to exclude sub-DOIs and image DOIs. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError | |
try: | |
TIMEZONE = ZoneInfo("America/Los_Angeles") | |
except ZoneInfoNotFoundError: | |
print("\nTimezone info not found. Please run `pip install tzdata` and try again.\n", file=sys.stderr) | |
sys.exit() | |
""" |