Skip to content

Instantly share code, notes, and snippets.

View file_type_enum.jsonl
{
"name" : "FT ICR-MS analysis results",
"description" : "FT ICR-MS-based metabolite assignment results table",
"filter" : "{\"url\": {\"$regex\": \"nom\\\\/results\"}, \"description\": {\"$regex\": \"FT ICR-MS\"}}",
"id" : "nmdc:sys045mx19"
}
{
"name" : "GC-MS Metabolomics Results",
"description" : "GC-MS-based metabolite assignment results table",
"filter" : "{\"url\": {\"$regex\": \"metabolomics\\\\/results\"}}",
@dwinston
dwinston / sensor.py
Created Jun 23, 2021
dagster resource in a sensor via preset definition run config
View sensor.py
from dagster import (
ModeDefinition, PresetDefinition, resource, StringSource,
build_init_resource_context, RunRequest, sensor,
)
class ApiClient:
def __init__(self, base_url: str, site_id: str, client_id: str, client_secret: str):
self.base_url = base_url
self.site_id = site_id
self.client_id = client_id
@dwinston
dwinston / all_your_zulip_are_belong_to_us.py
Last active Feb 26, 2021
get all Zulip messages sent by non-bot users to public streams
View all_your_zulip_are_belong_to_us.py
"""
A script developed to get all Zulip messages sent by non-bot users to public streams.
Need to pip install pymongo tqdm zulip, and run a local MongoDB server.
But you can also adapt the script to append to an in-memory Python list, and not need MongoDB or pymongo.
I found that the total volume of data in my case (see in-script comments) was 700MB uncompressed.
Developed at the Recurse Center (https://www.recurse.com/) in order to apply PageRank to Zulip entities.
Licensed as <https://opensource.org/licenses/MIT>(year=2021, copyright_holder="Donny Winston").
"""
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@dwinston
dwinston / lisp_parser.py
Created Jul 8, 2019
Code that takes some Lisp code and returns an abstract syntax tree (AST). The AST represents the structure of the code and the meaning of each token.
View lisp_parser.py
"""
Code that takes some Lisp code and returns an abstract syntax tree (AST).
My lisp knows about the following types of tokens:
- the expression delimiters `(` and `)`
- strings (delimited by quote characters)
- numbers
- boolean values `true` (corresponding to Python's `True`) and `false` (corresponding to Python's `False`)
- the null value `null` (corresponding to Python's `None`)
@dwinston
dwinston / mprester_bulk_query.py
Last active Jul 16, 2020
bulk query of Materials Project data via pymatgen MPRester, and saving to local MongoDB
View mprester_bulk_query.py
from pymatgen import MPRester
try:
from pydash import chunk as get_chunks
except ImportError:
from math import ceil
def get_chunks(array, size=1):
chunks = int(ceil(len(array) / float(size)))
return [array[i * size:(i + 1) * size]
for i in range(chunks)]
@dwinston
dwinston / csv-to-vcard.py
Created Jan 19, 2018
Convert a CSV file of people to vCard files for updating iOS contacts
View csv-to-vcard.py
"""
Convert a CSV file of the form
```
name, email, cell
First Last, bob@example.com, 800-555-1234
...
```
to vCard (vcf) files suitable for creating/updating iOS contacts.
Based on https://codereview.stackexchange.com/questions/3517/converting-a-csv-to-vcards-in-python
@dwinston
dwinston / dns_check_email_domain.py
Created Jan 11, 2018
Use dnspython library to validate an email domain via DNS MX, AAAA, and A records. A sanity check that avoids abusing the email server.
View dns_check_email_domain.py
import re
import dns.resolver
def dns_check_email_domain(domain):
"""
Query DNS records to verify that email server is possible on domain.
If no DNS records are found, user should confirm email address.
"""
response = {}
View keybase.md

Keybase proof

I hereby claim:

  • I am dwinston on github.
  • I am dwinston (https://keybase.io/dwinston) on keybase.
  • I have a public key ASDlWFACdSLc3gOp8yLr1jda7bFkjDYmEGY8MhBypnNiXgo

To claim this, I am signing this object:

@dwinston
dwinston / nwordspass.py
Created Apr 3, 2017
Generate a password/passphrase that is just many words strung together
View nwordspass.py
"""Generate n-word (default n=5) passwords separated by sep (default '-').
Uses your friendly neighborhood words file by default.
Simple Use: `python nwordspass.py`
Help: `python nwordspass.py --help`
"""
import argparse
import random