Skip to content

Instantly share code, notes, and snippets.

View narwanimonish's full-sized avatar

Monish Narwani narwanimonish

View GitHub Profile
@narwanimonish
narwanimonish / get-quotes-momentum.js
Created July 3, 2022 12:13
Get the list of all quotes from Momentum dashboard using JQuery script
let quotes = [];
$('.cquote').each((i, el) => {
const body = $($(el).find('.cquote-body')[0]).text();
const author = $($(el).find('.cquote-source')[0]).text();
quotes.push(`${body} -- ${author}`)
});
copy(quotes);
@narwanimonish
narwanimonish / delete.sh
Created June 8, 2022 06:19
Deleting un-tagged docker images
#/bin/bash/
docker rmi $(docker images | grep none | awk '{print $3}')
#!/usr/bin/env bash
funnyCommit() {
commitMessage=$(echo $(curl --silent --fail whatthecommit.com/index.txt))
echo "Your Commit Message is -> ${commitMessage}"
echo "Do you wish to procced with this commit message 😅 (y/n/o = other)?"
old_stty_cfg=$(stty -g)
stty raw -echo ; answer=$(head -c 1) ; stty $old_stty_cfg
if echo "$answer" | grep -iq "^y" ;then
git add -A && git commit -m "${commitMessage}"
#!/bin/bash
# declare an array called array and define 3 vales
databases=( drupal fresh lasalle_wp_fts )
username=root
password=password
filepath=/home/amitavroy/code/backup
for i in "${databases[@]}"
do
filename=${i}_$(date +"%m%d%Y-%k%M")
mysqldump -u${username} -p${password} ${i} > ${filepath}/${filename}.sql
@narwanimonish
narwanimonish / nginx.conf
Created February 8, 2020 13:45
Enable GZip config in Nginx
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;
@narwanimonish
narwanimonish / consume-cpu.py
Created January 11, 2020 14:55
Simulate CPU load on all cores
from multiprocessing import Pool
from multiprocessing import cpu_count
import signal
stop_loop = 0
def exit_chld(x, y):
global stop_loop
@narwanimonish
narwanimonish / print_element.js
Created December 12, 2019 10:47
How to print single elment (div) of tab in any browser in javascript
function PrintElem(elem)
{
var mywindow = window.open('', 'PRINT', 'height=400,width=600');
mywindow.document.write('<html><head><title>' + document.title + '</title>');
mywindow.document.write('</head><body >');
mywindow.document.write('<h1>' + document.title + '</h1>');
mywindow.document.write(document.getElementById(elem).innerHTML);
mywindow.document.write('</body></html>');
@narwanimonish
narwanimonish / install-docker.sh
Last active January 9, 2020 09:04
Install docker on Ubuntu 16.04 or Ubuntu 18.04
#!/bin/bash
sudo apt-get update -y
sudo apt-get remove docker docker-engine docker.io -y
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo usermod -aG docker $(whoami)
@narwanimonish
narwanimonish / user-data-nginx.sh
Created November 30, 2019 12:30
Install Nginx 1.12 on Amazon Linux AMI 2
#!/bin/bash
sudo su
yum update -y
amazon-linux-extras install nginx1.12 -y
systemctl start nginx
echo "Hello from $(hostname -f)" > /usr/share/nginx/html/index.html
@narwanimonish
narwanimonish / user-data.sh
Created November 30, 2019 12:28
Install Apache ( httpd ) on Amazon Linux AMI 2
#!/bin/bash
sudo su
yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo "Hello from $(hostname -f)" > /var/www/html/index.html