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
{ | |
"config": { | |
"view": { | |
"continuousWidth": 400, | |
"continuousHeight": 400, | |
"strokeWidth": 0, | |
"stroke": "#000000" | |
} | |
}, | |
"layer": [ |
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
# Some of my favorite color palettes, including the original sources and the code I used to customize them to my liking | |
# Used as reference: http://tsitsul.in/img/colors/all_palettes/tableau.20.colorblind.png | http://tsitsul.in/blog/coloropt/ | |
xgfs_normal11 = [(235, 172, 35), (184, 0, 88), (0, 140, 249), (0, 110, 0), (0, 187, 173), (209, 99, 230), (178, 69, 2), (255, 146, 135), (89, 84, 214), (0, 198, 248), (135, 133, 0), (0, 167, 108)] | |
xgfs_greys = [(88, 88, 88), (238, 238, 238)] | |
tableau_18 = [[ 31, 119, 180], [174, 199, 232], [255, 127, 14], [255, 187, 120], [ 44, 160, 44], [152, 223, 138], [214, 39, 40], [255, 152, 150], [148, 103, 189], [197, 176, 213], [140, 86, 75], [196, 156, 148], [227, 119, 194], [247, 182, 210], [188, 189, 34], [219, 219, 141], [ 23, 190, 207], [158, 218, 229]] | |
tableau_grey = [[127, 127, 127], [199, 199, 199]] | |
# Convert to Hex | |
from matplotlib import colors |
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
// Instructions: | |
// (1) Highlight file of interest. | |
// (2) Run code in Zotero's JavaScript console (found under Tools > Developer > Run Javascript) in sync mode. | |
function collections_output() { | |
zp = Zotero.getActiveZoteroPane() | |
items = zp.getSelectedItems() | |
collection_ids = items[0]["_collections"] | |
collections_cache = Zotero.Collections._objectCache |
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 pandas as pd | |
from bs4 import BeautifulSoup | |
# List of States | |
# source: https://gist.github.com/mshafrir/2646763#gistcomment-1583853 | |
states = {"al":"alabama","ak":"alaska","az":"arizona","ar":"arkansas","ca":"california","co":"colorado","ct":"connecticut","dc":"district of columbia","de":"delaware","fl":"florida","ga":"georgia","hi":"hawaii","id":"idaho","il":"illinois","in":"indiana","ia":"iowa","ks":"kansas","ky":"kentucky","la":"louisiana","me":"maine","md":"maryland","ma":"massachusetts","mi":"michigan","mn":"minnesota","ms":"mississippi","mo":"missouri","mt":"montana","ne":"nebraska","nv":"nevada","nh":"new hampshire","nj":"new jersey","nm":"new mexico","ny":"new york","nc":"north carolina","nd":"north dakota","oh":"ohio","ok":"oklahoma","or":"oregon","pa":"pennsylvania","ri":"rhode island","sc":"south carolina","sd":"south dakota","tn":"tennessee","tx":"texas","ut":"utah","vt":"vermont","va":"virginia","wa":"washington","wv":"west virginia","wi":"wisconsin","wy":"wyoming"} | |
states = |
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 json | |
import pandas as pd | |
def airtable_download(table, params_dict={}, api_key=None, base_id=None, record_id=None): | |
"""Makes a request to Airtable for all records from a single table. | |
Returns data in dictionary format. | |
Keyword Arguments: |
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
def find_locations_in_pandas_dataframe(dataframe, search_term, starts_with_search_term=False): | |
""" Returns an ordered list of (dataframe column, dataframe row, specific string) index values where `search_term` is | |
found in Pandas `dataframe` string data. | |
Keyword arguments: | |
starts_with_search_term: if set to True, then returns only strings that start with `search_term` | |
i.e., "Re" in "Rebecca" but not "González, Rebecca" | |
Source: https://gist.github.com/KalebNyquist/6781634b4ad307576046352696d2d194 | |
""" |
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 json | |
upload_data = json.dumps(upload_dict) | |
headers = { | |
"Authorization" : "Bearer INSERT AIRTABLE USER API KEY HERE", | |
'Content-Type': 'application/json', | |
} | |
URL = 'https://api.airtable.com/v0/INSERT AIRTABLE DOC KEY HERE/Online%20Media%20Hits' | |
response = requests.post(URL, headers=headers, data=upload_data) |
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
def convert_authors_to_ids(authors): | |
author_ids = [] | |
for author in authors: | |
author_ids.append(author_dict[author]) | |
return author_ids | |
upload_dict = { | |
"fields": { | |
"URL" : article.url, | |
"Title" : article.title, |
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
author_dict = create_author_dict() | |
for author in article.authors: | |
if author in list(author_dict.keys()): | |
print("Author already exists") | |
else: | |
print(add_new_author(author)) | |
author_dict = create_author_dict() |
NewerOlder