Skip to content

Instantly share code, notes, and snippets.

View fahimbabarpatel's full-sized avatar

Fahim Babar Patel fahimbabarpatel

View GitHub Profile
@fahimbabarpatel
fahimbabarpatel / Node.js + Nginx + Passenger setup (Ubuntu).md
Last active August 14, 2016 09:55
Node.js + Nginx + Passenger setup (Ubuntu)

Follow Phusion Passenger URL for Ubuntu setup https://www.phusionpassenger.com/library/install/nginx/install/oss/trusty/ ( If in future above URL is not present then visit to Phusion Passenger site to select Ubuntu OS and futher instaltion steps.)

Install our PGP key and add HTTPS support for APT
  • sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
  • sudo apt-get install -y apt-transport-https ca-certificates
Add our APT repository
@fahimbabarpatel
fahimbabarpatel / Node.js + Nginx setup + Amazon Linux.md
Last active September 30, 2015 14:14
Node.js + Nginx setup + Amazon Linux
sudo yum install -y nginx
sudo npm install -g forever
Open /etc/nginx/nginx.conf in sudo edit mode and replace http block
 http {
  include mime.types;
  default_type application/octet-stream;
  sendfile on;
@fahimbabarpatel
fahimbabarpatel / Sort JavaScript Object(hash) by value.md
Last active September 30, 2015 14:14
Sort JavaScript Object(hash) by value.
var res = [{"s1":5},{"s2":3},{"s3":8}].sort(function(obj1,obj2){ 
 var prop1;
 var prop2;
 for(prop in obj1) {
  prop1=prop;
 }
 for(prop in obj2) {
  prop2=prop;
 }
@fahimbabarpatel
fahimbabarpatel / Mongodb restore and dump commands via json, bson and csv.md
Last active June 1, 2023 10:11
Mongodb restore and dump commands via json, bson and csv

NOTE -

  • Remove -h option if you are doing operation on same machine
  • Remove -u , -p option if your database don't have username and password

Binary

Import database

mongorestore -h IP:port -d DB_Name -u user_name -p password <input db directory>
@fahimbabarpatel
fahimbabarpatel / convert hours minutes seconds to seconds
Created October 16, 2015 11:49
convert hours minutes seconds to seconds
var hms = '02:04:33'; // your input string
var a = hms.split(':'); // split it at the colons
// minutes are worth 60 seconds. Hours are worth 60 minutes.
var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
console.log(seconds);
require 'open-uri'
require 'aws-sdk'
Aws.config.update({
region: 'us-west-2',
credentials: Aws::Credentials.new('akid', 'secret'),
})
s3 = Aws::S3::Resource.new

nvm alias default VERSION

Example
nvm alias default v0.12.7
``````````````````````````
openssl genrsa 2048 > SSL.pem
openssl req -new -key SSL.pem -out CSR.pem
``````````````````````````````````````

sudo nano /etc/.monit.conf for For RHEL

sudo nano /etc/monit/monitrc For Dabian


 set httpd port 2812 and
     allow admin:monit      # require user 'admin' with password 'monit'
     allow @monit           # allow users of group 'monit' to connect (rw)
 allow @users readonly # allow users of group 'users' to connect readonly