Skip to content

Instantly share code, notes, and snippets.

View u8sand's full-sized avatar

Daniel J. B. Clarke u8sand

View GitHub Profile
@u8sand
u8sand / swagger.yaml
Created April 27, 2022 19:02
A demonstrative swagger.yaml for the Metabolomics Workbench REST API
openapi: 3.0.0
info:
title: Metabolomics Workbench REST API
version: "1.0.0"
description: |
The Metabolomics WorkBench REST service enables access to a variety of data (including metabolite structures, study metadata and experimental results) using HTTP requests. These requests may be carried out using a web browser or may be embedded in 3rd party applications or scripts to enable programmatic access. Most modern programming languages including PHP, Perl, Python, Java and Javascript have the capability to create HTTP request and interact with datasets such as this REST service.
license:
name: Metabolomics Workbench Terms of Use
url: https://www.metabolomicsworkbench.org/about/termsofuse.php
contact:
@u8sand
u8sand / create-hgnc-ttl.py
Last active April 4, 2022 17:01
A turtle file for identifiers.org-prefixed hgnc symbols
import json
import pandas as pd
df = pd.read_csv('https://www.genenames.org/cgi-bin/download/custom?col=gd_hgnc_id&col=gd_app_sym&col=gd_app_name&col=gd_status&col=gd_prev_sym&col=gd_aliases&col=gd_pub_chrom_map&col=gd_pub_acc_ids&col=gd_pub_refseq_ids&col=gd_pub_eg_id&col=gd_pub_ensembl_id&status=Approved&status=Entry%20Withdrawn&hgnc_dbtag=on&order_by=gd_app_sym_sort&format=text&submit=submit', sep='\t')
print('@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .')
print('@prefix gene_symbol: <https://identifiers.org/hgnc.symbol/> .')
print('@prefix semantic: <https://semanticscience.org/resource/> .')
print('')
print('semantic:SIO_001383 rdfs:comment "Gene Symbol"')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@u8sand
u8sand / get-vaxxed.md
Last active December 5, 2021 23:24
Just a write-up I created in an attempt to convince some people that they should get vaccinated. Obviously from the perspective of a male in their late 20s early 30s

On weighing COVID risks vs vaccination risk

The information in this article should be accurate but comes from external (while reputible) sources. It's possible I made a mistake, in which case i'll be happy for someone to correct it. Given that this write up is not peer reviewed please consider this opinion.

Covid Risks

The COVID Case fatality rate is 2%, ages 20-29 account for the vast majority of covid cases. This rate is higher in older individuals (4x in 30-39, 370x in 85+) (https://www.cdc.gov/coronavirus/2019-ncov/covid-data/investigations-discovery/hospitalization-death-by-age.html)

Estimates think about 1/10 cases are not reported (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7239078/), so overall risk of death by covid living your day to day life is probably 1/10 the case fatality or 0.2%.

@u8sand
u8sand / nginx.tmpl.patch
Created October 29, 2021 19:29
https://kubernetes.github.io/ingress-nginx/ case sensitive route patch /etc/nginx/template/ nginx.tmpl.patch
--- nginx.tmpl.orig 2020-05-12 13:18:43.000000000 -0400
+++ nginx.tmpl 2021-09-21 16:18:40.346643696 -0400
@@ -1015,7 +1015,12 @@
}
{{ end }}
+ # replace case insensitive with case sensitive
+ {{ if hasPrefix $path "~*" }}
+ location ~ {{ slice $path 2 }} {
+ {{ else }}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python
import nbformat as nbf
import click
from itertools import count
@click.command(help='Cleanup a jupyter notebook, putting `execution_counts` in order')
@click.option('-i', '--input', type=click.File('r'), default='-', required=True)
@click.option('-o', '--output', type=click.File('w'), default='-', required=True)
def cli(input, output):
@u8sand
u8sand / 00-june-16-lincs-rnaseq-demo-final.ipynb
Last active June 16, 2021 19:32
The jupyter notebook created as part of the June 16 LINCS RNA-seq Demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@u8sand
u8sand / two-way-rclone.py
Last active April 2, 2023 21:50
A CLI for two-way rclone syncing with safe conflict resolution
#!/usr/bin/env python3
__ETAG__ = '' # NOTE: replaced by update script
__version__ = '2.0.9'
__GIST__ = 'https://gist.githubusercontent.com/u8sand/498766e540939ca2c3550c1986deb5bd/raw/two-way-rclone.py'
__README__ = '''
This utility facilitates "smart" two-way-sync between two rclone stores.
The first location is considered the "localpath" & metadata about the previous
execution is stored in this location. This information can be used to determine
if changes were made on the local side or on the remote side since the last run.
@u8sand
u8sand / rdms.rs
Last active November 28, 2020 19:26
Python style slicing for large on disk matrices
// #!/usr/bin/env run-cargo-script
//! Uncomment first line & remove extension for use as cargo rust script, left as .rs for syntax highlighting on github.
//!
//! Use python-style slice notation to slice large files from disk;
//! this uses various techniques to do this fast and with as little
//! memory as possible.
//!
//! Caveats:
//! - After much investigation, I eventually decided that we should compute the matrix
//! "shape" (num cols & num rows) prior to slicing (iff your slices require it, i.e. negative slices).