journal (Mon Jul 06 2020)

Today I learnt

  • #javascript
  • #nodejs
  • #webdev
  • #docker
  • #devops

  • Use new Date("2011/11/30") instead of new Date("2011-11-30"). The latter produces inconsistent results on calling getMonth. - More notes in this article.

  • Set env variable in linux export FOO=bar.

  • Learnt about the download attribute on the anchor tag. If present, it makes the href resource downloadable, but only if the resource is from the same origin. The downloaded file will be renamed to the value of this attribute, if provided.

  • To send an image response from a nodejs server, use the following

res.writeHead(200,{'Content-type':'image/jpg'});
res.end(content);

  • You can specify environment variables in the env_file property in docker-compose. But for some reason this variable is not available in the ports section.
  • Environment variable set in the current shell are accessible within the docker container.
  • if you only want the postgres client, use sudo apt-get install postgresql-client. Handy if your postgres server is already managed by docker. Reference
  • When defining volumes, the first part defines the path in the host, the second part(after the colon) defines the path in the container.
  • Docker network - apps within a network can communicate with each other via name.