Skip to content

Instantly share code, notes, and snippets.

View murarisumit's full-sized avatar
🎩
Welcome here

Sumit Murari murarisumit

🎩
Welcome here
View GitHub Profile
@murarisumit
murarisumit / vim-cheatsheet.md
Created April 2, 2018 06:00
Vim cheatsheet

Vim Cheatsheet

Disclaimer: This cheatsheet is summerized from my own experience and other publich information. It should not be considered official advice.

Global

:help keyword # open help for keyword
:o file       # open file
:saveas file  # save file as
:close        # close current pane
@murarisumit
murarisumit / kill_redis_idle_connection.py
Created March 31, 2018 05:24
KIll redis idle connection
import redis
import re
idle_max = 300
r = redis.Redis(host="localhost", port=6379, password=None)
cl = r.execute_command("client", "list")
pattern = r"addr=(.*?) .*? idle=(\d*)"
regex = re.compile(pattern)
@murarisumit
murarisumit / puppetmaster.install
Created March 31, 2018 04:52
Install puppt master for 16.04
wget https://apt.puppetlabs.com/puppet5-release-xenial.deb
sudo dpkg -i puppet5-release-xenial.deb
sudo apt update
apt-get install puppetserver -y
# for puppet agent:
sudo apt-get install puppet-agent -7
sudo apt install ruby # Need to install this for isntall r10k gem
sudo gem install r10k --verbose
mkdir /etc/puppetlabs/r10k/
@murarisumit
murarisumit / Dockerfile
Created January 30, 2018 18:37
sample dockerfile
FROM node:0.10
MAINTAINER Sumit Murari <[email protected]>
USER root
ENV AP /data/app
ENV SCPATH /etc/supervisor/conf.d
RUN apt-get -y update
@murarisumit
murarisumit / xargs-sample.sh
Last active January 10, 2018 14:48
Xargs command snippets
#list the file opened by process-id
ps aux | grep 'index.js' | grep -v 'grep' | awk '{ print $2 }' | xargs -I {} sh -c "lsof -p {}"
#list the file opened by process other than specified pid
ps aux | grep 'index.js' | grep -v 'grep' | awk '{ print $2 }' | xargs -I {} sh -c "lsof -p ^{}"
# list network services by process-id
ps aux | grep 'index.js' | grep -v 'grep' | awk '{ print $2 }' | xargs -I {} sh -c "lsof -i | grep {}"
@murarisumit
murarisumit / root_logger_settings.py
Created November 12, 2017 23:18 — forked from st4lk/root_logger_settings.py
Python logging settings for root logger
"""
Settings for root logger.
Log messages will be printed to console and also to log file (rotated, with
specified size). All log messages from used libraries will be also handled.
Three approaches for defining logging settings are used:
1. using logging classes directly (py25+, py30+)
2. using fileConfig (py26+, py30+)
3. using dictConfig (py27+, py32+)
Choose any variant as you like, but keep in mind python versions, that
@murarisumit
murarisumit / Vagrantfile
Created September 15, 2017 23:31
Vagrantfile
# -*- mode: ruby -*-
# # vi: set ft=ruby :
#
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/xenial64"
@murarisumit
murarisumit / crawlers.sh
Created May 23, 2017 08:30
Requests made to nginx server, aggregated by IP, and sorted by the number of requests made.
tail -n 300000 /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -n
@murarisumit
murarisumit / list_only_ip.sh
Created May 19, 2017 07:02
List only ip address
ip addr ls eth0 | awk '/inet / {print $2}' | cut -d"/" -f1
This file has been truncated, but you can view the full file.
{
"id": 4965121040,
"stacking_relative_position": [
0,
0
],
"intrinsic_inline_sizes": {
"minimum_inline_size": 29860,
"preferred_inline_size": 140578
},