Skip to content

Instantly share code, notes, and snippets.

View jvwong's full-sized avatar
💭
Generally confused.

Jeffrey jvwong

💭
Generally confused.
View GitHub Profile
@jvwong
jvwong / crossref_query.sh
Last active May 23, 2023 18:27
Crossref: Query
QUERY="Inositol pyrophosphate dynamics reveals control of the yeast PHO starvation program through 1,5-IP8 and the SPX domain of Pho81"
curl --get --data-urlencode "query.bibliographic=${QUERY}" "https://api.crossref.org/works/?filter=type:journal-article,type:posted-content&rows=1" | jq '. | { title: .message.items[0].title[0], abstract: .message.items[0].abstract, doi: .message.items[0].DOI, publisher: .message.items[0].publisher }'
certbot certonly --webroot --webroot-path=<webroot path> --cert-name <certname> -d <domain>
@jvwong
jvwong / parse_dotenv.bash
Created August 14, 2020 18:36 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@jvwong
jvwong / feeds.xml
Created October 14, 2019 17:38 — forked from rossmounce/feeds.xml
My OPML bundle of academic journal RSS feeds related to my interests (phylogenetics, palaeontology), split into 4 different thematic sections.
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Ross's academic journal RSS feed subscriptions</title>
</head>
<body>
<outline text="General Biology Journals" title="General Biology Journals">
<outline type="rss" text="BioEssays" title="BioEssays" xmlUrl="http://onlinelibrary.wiley.com/rss/journal/10.1002/(ISSN)1521-1878" htmlUrl="http://onlinelibrary.wiley.com/resolve/doi?DOI=10.1002%2F%28ISSN%291521-1878"/>
<outline type="rss" text="Biol J Linn Soc" title="Biol J Linn Soc" xmlUrl="http://onlinelibrary.wiley.com/rss/journal/10.1111/(ISSN)1095-8312" htmlUrl="http://onlinelibrary.wiley.com/resolve/doi?DOI=10.1111%2F%28ISSN%291095-8312"/>
@jvwong
jvwong / cmd_line_opts.sh
Created June 7, 2019 17:05
Bash script for parsing cmd line args
#!/bin/bash
dflag=
iflag=
oflag=
while getopts 'dio:' OPTION
do
case $OPTION in
d) dflag=1
;;
#!/bin/bash
# Find row and print columns in tab-delimited file
#tax_id GeneID PubMed_ID
tax_id=9606
GeneID=9518
grep -Ei "^$tax_id\t$GeneID\t[0-9.]+$" ./data/gene2pubmed > result.txt
@jvwong
jvwong / faketimeout.js
Last active December 7, 2018 15:43
Promises and timers
const TIMEOUT = 5000;
const promiseTimeout = delay => new Promise( ( resolve, reject ) => setTimeout( () => reject( new Error('fake timeout') ), delay ) );
const doSomethingAsync = ( ) => {
return Promise.resolve()
.then( () => promiseTimeout( TIMEOUT ) );
};
@jvwong
jvwong / fishers.R
Created June 22, 2018 16:46
Fisher's exact for Miller et al.
# Probability of GO term (GeneSet) in gene hits (Hits) from a screen
# Initialize our relevant variables
nBackground <- 407 # Total genes screened
nGeneSet <- 18 # Genes in GO term that are in the bachground
nHits <- 60 # Genes enriched in screen in background
nOutsideGeneSet <- nBackground - nGeneSet # Genes not in GeneSet but in background
nQueryPathway <- 0:nGeneSet # Overlap between query genes ('Hits') and GO term (in background)
# Use the dhyper built-in function for hypergeometric probability
@jvwong
jvwong / enrichment.js
Created February 12, 2018 15:44
'enrichment' endpoint
// const request = require('request');
// const Promise = require('promise-simple');
// const csv = require('csvtojson');
// const fs = require('fs');
// const _ = require('lodash');
const enrichment = function (query) {
var promise = new Promise(function(resolve, reject) {
// do a thing, possibly async, then…
@jvwong
jvwong / gprofiler.js
Created February 6, 2018 21:09
Fetching from gProfiler
var request = require('request');
var formData = {
"output": "mini",
"organism": "hsapiens",
"significant": "1",
"sort_by_structure": "1",
"ordered_query": "0",
"as_ranges": "0",
"no_iea": "1",