How to set environment variables from .env file

If your lines are valid, trusted shell but for the export command This requires appropriate shell quoting. It’s thus appropriate if you would have a line like foo=’bar baz’, but not if that same line would be written foo=bar baz set -a # automatically export all variables source .env set +a If your lines are … Read more

Docker compose won’t find $PWD environment variable

You don’t need ${PWD} for this, you can just make the path relative and compose will expand it (one major difference between compose paths and those processed by docker run). version: ‘2’ services: couchpotato: build: context: ./couchpotato dockerfile: Dockerfile ports: – 5050:5050 volumes: – “./couchpotato/data:/home/CouchPotato/data/” – “./couchpotato/config:/home/CouchPotato/config/” As for why compose doesn’t see this variable, … Read more

How do I extract the created date out of a Mongo ObjectID

getTimestamp() The function you need is this one, it’s included for you already in the shell: ObjectId.prototype.getTimestamp = function() { return new Date(parseInt(this.toString().slice(0,8), 16)*1000); } References Check out this section from the docs: Extract insertion times from _id rather than having a separate timestamp field This unit test also demostrates the same: mongo / jstests … Read more

unzip password protected zip in unix

unzip -P your-password zipfile.zip man unzip -P password use password to decrypt encrypted zipfile entries (if any). THIS IS INSECURE! Many multi-user operating systems provide ways for any user to see the current command line of any other user; even on stand-alone systems there is always the threat of over-the-shoulder peeking. Storing the plaintext password … Read more

How to remove trailing whitespaces for multiple files?

You want sed –in-place ‘s/[[:space:]]\+$//’ file That will delete all POSIX standard defined whitespace characters, including vertical tab and form feed. Also, it will only do a replacement if the trailing whitespace actually exists, unlike the other answers that use the zero or more matcher (*). –in-place is simply the long form of -i. I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)