Skip to content

Instantly share code, notes, and snippets.

View fahimbabarpatel's full-sized avatar

Fahim Babar Patel fahimbabarpatel

View GitHub Profile
@timoxley
timoxley / gist:1721593
Created February 2, 2012 04:58
Recursively run all tests in test directory using mocha
// this will find all files ending with _test.js and run them with Mocha. Put this in your package.json
"scripts": {
"test": "find ./tests -name '*_test.js' | xargs mocha -R spec"
},
@joost
joost / ruby_google_analytics_server_to_server.md
Last active November 27, 2023 15:43
Google Analytics API (server-to-server) using Ruby
@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 / Mongodb restore and dump commands via json, bson and csv.md
Last active May 10, 2025 09:57
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>
require 'open-uri'
require 'aws-sdk'
Aws.config.update({
region: 'us-west-2',
credentials: Aws::Credentials.new('akid', 'secret'),
})
s3 = Aws::S3::Resource.new
openssl genrsa 2048 > SSL.pem
openssl req -new -key SSL.pem -out CSR.pem
``````````````````````````````````````
app.get('/login', function(req, res, next) {
  passport.authenticate('local', function(err, user, info) {
    if (err) { return next(err); }
    if (!user) { return res.redirect('/login'); }
    req.logIn(user, function(err) {
      if (err) { return next(err); }
      return res.redirect('/users/' + user.username);
    });
  })(req, res, next);
@fahimbabarpatel
fahimbabarpatel / commands_to_find_out_live_ssh_session.md
Created March 1, 2016 12:48
commands_to_find_out_live_ssh_session
ps aux | grep ssh
last |grep "logged in"
ps aux | grep ssh | grep pts/
@fahimbabarpatel
fahimbabarpatel / ruby_mongoid_setup.md
Created March 10, 2016 17:17
ruby_mongoid_setup
# mongoid.yml
development:
  clients:
    default:
      database: test
      hosts:
        - localhost:27017