microbiomedata / nmdc_notebooks

Jupyter Notebooks demonstrating R and Python-based access to NMDC metadata and data
Creative Commons Zero v1.0 Universal
4 stars 0 forks source link

Rename `.txt` file to `.txt.js` to enable syntax highlighting #20

Closed eecavanna closed 7 months ago

eecavanna commented 7 months ago

File

https://github.com/microbiomedata/notebook_hackathons/blob/soil-contig-tax/taxonomic_dist_by_soil_layer/python/mongodb_query.txt

Syntax highlighting difference (excerpt)

As .txt:

db.getCollection("biosample_set").aggregate(
    [
        { $match: { 'soil_horizon': { '$in': ['O horizon', 'M horizon'] } } },
        {
            $project: {
                "id": 1,
                "soil_horizon": 1
            }
        },

As .js (or .txt.js or .anything.that.ends.with.js):

db.getCollection("biosample_set").aggregate(
    [
        { $match: { 'soil_horizon': { '$in': ['O horizon', 'M horizon'] } } },
        {
            $project: {
                "id": 1,
                "soil_horizon": 1
            }
        },
eecavanna commented 7 months ago

In this case, I like the suffix .txt.js as a way of signaling to the reader that this isn't a regular JavaScript script—it's a portion of one (something that can be copy/pasted into a MongoDB client).

brynnz22 commented 7 months ago

Thanks Eric! I will change this. I wasn't sure how to save this query, but this is great to know.

brynnz22 commented 7 months ago

Okay, this is changed and can be found here: https://github.com/microbiomedata/notebook_hackathons/blob/soil-contig-tax/taxonomic_dist_by_soil_layer/python/mongodb_query.txt.js. Thanks @eecavanna