Cloud & Web Development

Convert JSON to YAML in one command

I’ve been playing around with AWS CloudFormation recently, which supports both JSON and YAML. I prefer to use YAML, but a lot of the examples I was looking at were based in JSON. Fortunately there’s a quick way to convert a JSON file to it’s YAML equivalent. ruby -ryaml -rjson -e ‘puts YAML.dump(JSON.load(ARGF))’ < linux-bastion.template […]

Mongo DB

Selecting partial elements of mongo db documents

By default, when you find documents on mongo it returns the entire document, similar to what SELECT * FROM TABLE; would do in a relational world. You can retrieve partial document info by using something known as a projection (see mongo docs here). Use find() with an empty query, but specify the fields you want […]