This file contains hidden or 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
set now to (current date) | |
-- midnight this morning | |
set today to now - (time of now) | |
-- midnight tomorrow morning | |
set future to (today) + (336 * 60 * 60) | |
tell application "Calendar" | |
-- delete existing events in Sage Copy calendar |
This file contains hidden or 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 as r | |
import responses # type: ignore | |
from requests import Response | |
""" | |
This sample code provides two test functions, one using responses, the other does not. | |
If you run this code whilst online, both test functions will pass, but if you attempt | |
to run this script whilst offline, only the test function using responses will succeed, | |
demonstrating that we have managed to mock the API call successfully. |
This file contains hidden or 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
function respondToFormSubmit(e) { | |
var settings = PropertiesService.getDocumentProperties(); | |
var authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL); | |
// Check if the actions of the trigger require authorizations that have not | |
// been supplied yet -- if so, warn the active user via email (if possible). | |
// This check is required when using triggers with add-ons to maintain | |
// functional triggers. | |
if (authInfo.getAuthorizationStatus() == | |
ScriptApp.AuthorizationStatus.REQUIRED) { |
This file contains hidden or 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
from glob import glob | |
def get_note_title(filename): | |
title = filename.split(".")[0] | |
return title | |
files = glob("nv-bear-import/*") | |
for f in files: | |
title = get_note_title(f.replace("nv-bear-import/","")) | |
with file(f, 'r') as original: data = original.read() |
This file contains hidden or 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 random | |
from collections import defaultdict | |
attendees = ["nathan", "chris"] | |
run_number = 1000 | |
attendees_result = defaultdict(int) | |
for i in range(run_number): | |
attendees_result[random.choice(attendees)] +=1 | |
This file contains hidden or 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 credentials as creds | |
customer_endpoint = "https://api.dlcs.io/customers/12" | |
r = requests.get(customer_endpoint, auth = (creds.KEY, creds.SECRET)) | |
print r.status_code | |
print r.text |
This file contains hidden or 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
<?xml version="1.0" encoding="ISO-8859-1" ?> | |
<rss version="2.0"> | |
<channel> | |
<title>eLife</title> | |
<link>http://elifesciences.org/rss/recent.xml</link> | |
<atom:link rel="self" type="application/rss+xml" href="http://elifesciences.org/rss/recent.xml"/> | |
<description>Articles published in eLife</description> | |
<pubDate/> | |
<language>en</language> | |
<item> |
This file contains hidden or 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
mkdir test_data_extraction | |
cd test_data_extraction | |
git clone https://github.com/elifesciences/elife-articles.git | |
sudo STATIC_DEPS=true pip install lxml==3.4.1 | |
pip install elifetools | |
git clone https://gist.github.com/a47afc60d30d22bed33d.git | |
cp a47afc60d30d22bed33d/demo-data-extraction.py . |
This file contains hidden or 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
from elifetools import parseJATS as parser | |
import glob | |
articles = glob.glob("elife-articles/*.xml") | |
def data_components(articles): | |
for article in articles: | |
soup = parser.parse_document(article) | |
print parser.media(soup) | |
def titles(articles): |
This file contains hidden or 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
... | |
[] | |
[{'mimetype': u'application', 'parent_ordinal': 1, 'sibling_ordinal': 1, 'parent_type': 'supplementary-material', 'mime-subtype': u'pdf', 'xlink_href': u'elife00067s001.pdf', 'ordinal': 1, 'position': 1, 'parent_component_doi': u'10.7554/eLife.00067.017', 'parent_sibling_ordinal': 1, 'type': 'media', 'parent_asset': 'supp'}] | |
[{'mimetype': u'application', 'parent_ordinal': 1, 'sibling_ordinal': 1, 'parent_type': 'supplementary-material', 'mime-subtype': u'xls', 'xlink_href': u'elife00068s001.xls', 'ordinal': 1, 'position': 1, 'parent_component_doi': u'10.7554/eLife.00068.026', 'parent_sibling_ordinal': 1, 'type': 'media', 'parent_asset': 'supp'}] | |
[{'mimetype': u'application', 'parent_ordinal': 1, 'sibling_ordinal': 1, 'ordinal': 1, 'p_parent_type': 'fig', 'parent_type': 'supplementary-material', 'mime-subtype': u'xlsx', 'p_parent_ordinal': 4, 'xlink_href': u'elife00070s001.xlsx', 'p_parent_component_doi': u'10.7554/eLife.00070.006', 'position': 1, 'p_parent_sibling_ordinal': 4, 'parent_component_doi': u |