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
javascript:void(function(){setInterval(function(){document.querySelectorAll('iframe').forEach(function(element){console.log('Iframe Killa - Removing Element:', element);element.parentNode.removeChild(element)})},100)}()); |
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
library(tidyverse) | |
# 2017 monthly | |
x <- tempfile("col") | |
dir.create(x) | |
download.file("https://download.catalogueoflife.org/col/monthly/2017-02-27_dwca.zip", file.path(x, "dwca.zip")) | |
unzip(file.path(x, "dwca.zip"), exdir = x) | |
fs::dir_ls(x) | |
taxa <- readr::read_tsv(file.path(x, "taxa.txt"), guess_max=1e6, quote="", col_types = readr::cols(.default = "c")) | |
taxa %>% filter(specificEpithet == "sapiens", taxonomicStatus == "accepted name", genus=="Homo") |
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
""" | |
Reportlab sandbox. | |
""" | |
from reportlab.lib.enums import TA_JUSTIFY | |
from reportlab.lib.pagesizes import letter, landscape | |
from reportlab.lib.enums import TA_JUSTIFY | |
from reportlab.lib.pagesizes import letter | |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image | |
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle |
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/local/bin/python3 | |
""" | |
Will backup all the databases listed, will put files in same DIR as script' | |
To run: $ python dbbackup.py | |
""" | |
import configparser | |
import os | |
import time |
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 pandas as pd | |
from tabulate import tabulate | |
def pandas_df_to_markdown_table(df): | |
# Dependent upon ipython | |
# shamelessly stolen from https://stackoverflow.com/questions/33181846/programmatically-convert-pandas-dataframe-to-markdown-table | |
from IPython.display import Markdown, display | |
fmt = ['---' for i in range(len(df.columns))] | |
df_fmt = pd.DataFrame([fmt], columns=df.columns) | |
df_formatted = pd.concat([df_fmt, df]) |
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 base64 | |
import json | |
import datetime | |
def push_to_repo_branch(gitHubFileName, fileName, repo_slug, branch, user, token): | |
''' | |
Push file update to GitHub repo | |
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 | |
params = {'access_token': '<your-access-token>'} | |
# Create the deposit resource | |
url = "https://sandbox.zenodo.org/api/deposit/depositions" | |
headers = {"Content-Type": "application/json"} | |
res = requests.post( | |
url, |
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
COMPOSE := docker-compose -p demouuid | |
start: | |
$(COMPOSE) up -d | |
sleep 3 | |
while $(COMPOSE) ps | grep -q database; do \ | |
$(COMPOSE) logs 2>/dev/null| grep -q 'MySQL init process done.' && break;\ | |
$(COMPOSE) logs 2>/dev/null| grep -i error && break;\ | |
$(COMPOSE) ps | grep -q Exit && break;\ | |
done |
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
from __future__ import print_function | |
import time | |
def query_10k(cur): | |
t = time.time() | |
for _ in range(10000): | |
cur.execute("SELECT 1,2,3,4,5") | |
res = cur.fetchall() | |
assert len(res) == 1 | |
assert res[0] == (1,2,3,4,5) |
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
""" | |
Code to write data read from a URL to a file | |
Based on an answer on SO: | |
http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python/22721 | |
""" | |
import urllib2 | |
mp3file = urllib2.urlopen("http://www.example.com/songs/mp3.mp3") |