Skip to content

Instantly share code, notes, and snippets.

View chasemc's full-sized avatar
:octocat:

Chase Clark chasemc

:octocat:
View GitHub Profile
@chasemc
chasemc / rmarkdown.md
Last active January 18, 2021 21:04
Count how many lines/rows contain X, from many files

Counting Lines

The Problem

I have a lot of files, in a lot of nested directories: 347430 directories, 379286 files

To anonymize what I’m doing we’ll say I have two types of files: apples.csv.gz and oranges.csv.gz (if you don’t know- “gz” means the

@chasemc
chasemc / rich_print_table.py
Created December 3, 2020 23:35
Print delimited files to terminal with https://github.com/willmcgugan/rich (Dependencies= pandas, rich)
import os
import pathlib
from rich.console import Console
from rich.table import Table
from rich.table import Column
import pandas as pd
def make_rich(df, title="mytitle"):
table = Table(title=title)
@chasemc
chasemc / update_idbac_db.R
Created September 4, 2020 13:51
Update to new IDBAc db schema (currently need "prioritizer" git branch of IDBac)
old_files_path <- "/home/user/Downloads/db/old"
a <- list.files(old_files_path, full.names = FALSE)
a <- tools::file_path_sans_ext(a)
for(i in a) {
pool <- IDBacApp::idbac_connect(fileName = i,
filePath = old_files_path)[[1]]
IDBacApp::idbac_update_db(pool = pool,
copy_overwrite = "copy")
library(ggplot2)
library(data.table)
library(geofacet)
library(magrittr)
raw_data <- data.table::fread("http://covidtracking.com/api/states/daily.csv")
raw_data$date <- as.Date(as.character(raw_data$date), "%Y%m%d")
raw_data <- raw_data[date > "2020-03-15", ]
library(ggplot2)
library(data.table)
library(geofacet)
library(magrittr)
raw_data <- data.table::fread("http://covidtracking.com/api/states/daily.csv")
raw_data$date <- as.Date(as.character(raw_data$date), "%Y%m%d")
raw_data <- raw_data[date > "2020-03-15", ]
@chasemc
chasemc / Abbreviate Journal Names in Bibtex Database.py
Created August 3, 2020 03:26 — forked from trevismd/Abbreviate Journal Names in Bibtex Database.py
Using the translation table from the Jabref program, finds and replaces all scientific journal names to their standardized abbreviated form. First argument is the file to be processed; outputs safely to 'abbreviated.bib'
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# Supporting Python 3 and JabRef csv file
import os
import re
import sys
try:
bibtexdb = open(sys.argv[1]).read()
library(ggplot2)
library(data.table)
library(geofacet)
library(magrittr)
raw_data <- data.table::fread("http://covidtracking.com/api/states/daily.csv")
raw_data$date <- as.Date(as.character(raw_data$date), "%Y%m%d")
raw_data <- raw_data[date > "2020-03-15", ]
library(remotes)
pkg <- "electricShine"
repo <- "chasemc/electricShine"
remote <- lapply(repo, remotes:::github_remote, ref = "master", subdir = NULL,
auth_token = remotes:::github_pat(quiet), host = "api.github.com")
remote_sha <- remotes:::remote_sha(remote[[1]],
remotes:::local_sha(pkg))
local_sha <- remotes:::local_sha(pkg)
@chasemc
chasemc / idbac_mirror_plot.R
Created July 2, 2020 01:55
Use IDBac to create an interactive mirror plot comparing two samples
a <- IDBacApp::assembleMirrorPlots(
sampleID1 = "apples",
sampleID2 = "oranges",
minFrequency = 1,
lowerMassCutoff = 100,
upperMassCutoff = 3000,
minSNR = 6,
tolerance = 0.002,
pool1 = pool,
@chasemc
chasemc / shiny-oauth.r
Created June 30, 2020 13:34 — forked from hadley/shiny-oauth.r
Sketch of shiny + oauth
library(shiny)
library(httr)
# OAuth setup --------------------------------------------------------
# Most OAuth applications require that you redirect to a fixed and known
# set of URLs. Many only allow you to redirect to a single URL: if this
# is the case for, you'll need to create an app for testing with a localhost
# url, and an app for your deployed app.