If you want the last 5 records of a collection with latest coming first
db.getCollection('collection-name').find().limit(5).sort({$natural:-1})
If you want the last 5 records of a collection with latest coming first
db.getCollection('collection-name').find().limit(5).sort({$natural:-1})
After modifying the configuration files for nginx, type
sudo nginx -t
to check for any syntax errors.
sudo nginx -s reload
There are many ways out there to manage a Linux service depending on the distribution you are using.
This mainly boils down to if your distribution uses systemd or init. Based on that, systemctl
and service
are two officially adopted service managers for controlling services.
Intrestingly, service command still works even for those distributions that have migrated to systemd and systemctl.
Lets take the example of restarting nginx service to see how this can be done.
Type the below commands in the terminal to restart nginx for the changes to take effect.
As a developer / administrator, its important to know which ports are listening on the server's network interfaces. They are important for a variety of reasons. To name a few,
To determine if a port is in use under an Unix-like system you can use lsof, netstat, nmap commands.
robots.txt file controls what pages of your allplications gets crawled by the serach engine bots. As part of robots.txt file we can allow or disallow single pages or directories within the application.
robots.txt file lives in the root folder of your application. A simple, static solution in Rails would be, to put a robots.txt file into you /public folder in your rails app but then you can't dynamically set the content of this file.
If you want a different file for staging and production server or want some dynamic routes in your robots.txt, then you need to generate this file with rails. Make sure you remove/rename robots.txt from /public folder.
This assumes that you have Homebrew installed in first place and used it to install Node. To manage multiple Node versions on your development server, first search for your desired pacakage
brew search node
Pick a version of your choice and run
brew install node@6
Installing Node.js and NPM is pretty straightforward using Homebrew. Assuming that you have Homebrew and XCode installed on your Mac, open Terminal and type
brew install node
To see if Node and NPM are installed, type
node -v
npm -v
To make sure MySQL server listens to remote requests (other than orginating from localhost), edit MySQL configuration file using sudo
/etc/mysql/my.cnf
OR
any other file mentioned in the config file w/ includedir directives
and update
bind-address = 127.0.0.1
TO
The default “certbot” client will not work on older versions of Ubuntu because of outdated python and openssl versions. Here is a quick script that does the job. https://github.com/Neilpang/acme.sh
After installing the script, run
acme.sh --issue -d domain.in -d www.domain.in -w /var/www/document-root \
--certpath /etc/ssl/certs/domain.in.crt \
--keypath /etc/ssl/certs/domain.in.key \
--fullchainpath /etc/ssl/certs/intermediate.pem \