Skip to content

Instantly share code, notes, and snippets.

View fahimbabarpatel's full-sized avatar

Fahim Babar Patel fahimbabarpatel

View GitHub Profile
@fahimbabarpatel
fahimbabarpatel / nodejs_default_memory_check.md
Last active June 28, 2024 10:22
This JS script will help you to know default memory allowed to NodeJS runtime on the basis of your hardware and system OS
  1. save below code in nodejs_default_memory_check.js,
  2. execute it - node nodejs_default_memory_check.js . You can see this script fails and thats default RAM limit of NodeJS. Plz check screenshot in below comment. In Latest NodeJS versions default RAM is 4GB (still on the basis of your hardware and system OS, RAM will differ)
  3. use max-old-space-size option if you want to increase memory limit. It accepts value in MB. In this example we are setting 8GB RAM node --max-old-space-size=8192 nodejs_default_memory_check.js
function allocateMemory(size) {
  // Simulate allocation of bytes
  const numbers = size / 8;
  const arr = [];
 arr.length = numbers;
@fahimbabarpatel
fahimbabarpatel / docker_commands.md
Last active September 6, 2017 13:23
Docker commands

One liner to stop / remove all of Docker containers:

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

Remove only stopped containers can be listed using:

docker rm $(docker ps -f "status=exited")
@fahimbabarpatel
fahimbabarpatel / git_branch_name.md
Created July 5, 2017 07:48
git branch name on terminal for Ubuntu 14.04

Put below code in .bashrc or .bash_profile. Close and start again all terminal or hit source ~/.bashrc to specific tab if you don't want to close terminal

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
@fahimbabarpatel
fahimbabarpatel / deployment_using_shipit.md
Created March 5, 2017 07:00
Deployment using Javascript shipit npm
Shipit-cli - Command line utility to execute shipit scripts. 
shipit-deploy - Npm to do actual code movement and publishing.
shipit-npm - Npm to install npms on servers during deployment.
shipit-shared - Npm to access symlinks file and directory on servers.


module.exports = function (shipit) {
  require('shipit-deploy')(shipit);
 require('shipit-shared')(shipit);
@fahimbabarpatel
fahimbabarpatel / socket_io_covered.md
Last active March 5, 2017 09:15
Socket.io covered
npm install --save socket.io

---------------------------------SERVER CODE START------------------------------------------
var express = require('express');
var app = express();
var server = http.createServer(app);
io = require("socket.io").listen(server);
server.listen(3000)
@fahimbabarpatel
fahimbabarpatel / know_creation_time_on_ext4_filesystem.md
Last active September 21, 2016 14:41
know_creation_time_on_ext4_filesystem.md
  • Know the inode of the directory by ls -i command (lets say for example its X)

  • Know on which partition your directory is saved by df -T /path command ( lets say its on /dev/sda1 )

  • Now use this command : sudo debugfs -R 'stat ' /dev/sda1 You will see in the output :

  • crtime: 0x4e81cacc:966104fc -- mon Sep 27 14:38:28 2013

@fahimbabarpatel
fahimbabarpatel / node.js with passenger-install-nginx-module.md
Last active August 14, 2016 10:15
Node.js setup with passenger-install-nginx-module

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 / ssh_special_commands.md
Last active August 13, 2016 17:58
ssh_special_commands
ssh remote_host

The remote_host in this example is the IP address or domain name that you are trying to connect to.

This command assumes that your username on the remote system is the same as your username on your local system.

If your username is different on the remote system, you can specify it by using this syntax: