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 / docker_cheatsheet.md
Last active December 30, 2022 00:27
docker cheatsheet #docker #cheatsheet

Docker cheatsheet, usually has one-lines to delete containers.

  • Create a image from docker file: docker build -t image-name .
  • Run a container: docker run -it --name container-name image-name:latest
  • Run docker in backgroud: docker run --name container-name --hostname container-hostname -t -d container-name:latest
  • Connect to container: docker exec -it container_name bash
  • Remove all Exited containers: sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm
  • Remove all dangling images: docker rmi $(docker images -f 'dangling=true' -q)
@murarisumit
murarisumit / subprocess_piping_external_command.py
Last active September 9, 2022 18:27
Piping command using subprocess #subprocess #python
#!/bin/bin/env python
import subprocess
#Exeternal Command with args
DPKG = ['dpkg', '-l']
# Execute the command
dpkg_process = subprocess.Popen(DPKG, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Pipe output of dpkg to grep
grep_process = subprocess.Popen(['grep', 'lsof'], stdin=dpkg_process.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@murarisumit
murarisumit / subprocess_external_command.py
Last active August 3, 2021 07:07
Execute command using python subprocess #python #subprocess #external-commands
#!/bin/bin/env python
import subprocess
#Exeternal Command with args
DPKG = ['dpkg', '-l']
# Execute the command
dpkg_process = subprocess.Popen(DPKG, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Wait till process to exit
out, error = dpkg_process.communicate()
@murarisumit
murarisumit / msdeploy_sync_skip_file.bat
Created September 16, 2015 06:25
Msdeploy ignore some file
::Skip file with name .pdb, someFile.xml and .config$
msdeploy.exe -verb:sync -source:contentPath=SourcePath -dest:DestPath -skip:objectName=filepath,absolutepath="^*\.pdb$" -skip:objectName=filepath,absolutepath="^*\someFile.xml$" -skip:objectName=filepath,absolutepath="^*\someotherfile.aspx$" -skip:objectName=filepath,absolutepath=".config$"
@murarisumit
murarisumit / checkIfDNSRecordExist.py
Last active November 17, 2020 00:06
Check if DNS record exist in route53 #boto #aws #route53
def checkifDnsRecordExist(domain_name,dns_record):
'''
(str, str) --> (str)
Read your domain-name and dns_record and check if it exists or not
Returns recordSet and it's value in return
#If record exist
>>> checkifDnsRecordExist("domain_name.com", "mail.domain_name.com")
mail.domain_name.com : 5.3.5.3
@murarisumit
murarisumit / check_for_instance_protection.py
Last active June 26, 2019 16:30
Check for instance without termination protection #aws #boto #python #ec2
import boto
import sys, traceback
import os
print "=== Instance without terminate protection=============="
conn = boto.connect_ec2(aws_access_key_id='<aws access key>',aws_secret_access_key='<aws secret key>')
instances = conn.get_only_instances()
for instance in instances:
attrib = instance.get_attribute("disableApiTermination")
@murarisumit
murarisumit / everyday_python_logging.py
Last active May 4, 2019 01:46
basic logging python #python #logging
# `ref: https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
# create a file handler
handler = logging.FileHandler('hello.log')
@murarisumit
murarisumit / configparser.py
Last active May 4, 2019 01:37
Python configparser example #python
# definations.py
import os
import configparser
# Environment defination variable, this environment variable will use used to pick config file
ENV = os.environ["ENVIRONMENT"]
# settings
settings = configparser.ConfigParser()
BASEDIR = os.path.dirname(os.path.realpath(__file__))
@murarisumit
murarisumit / awscli-cheatsheet.md
Last active December 2, 2018 22:16
AWS cli cheatsheet #aws #cheatsheet

AWS CLI

  • Get ec2 instance with name and private ip: aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId,Tags[?Key=='Name']| [0].Value,PrivateIpAddress]" --output table

  • Get instance details in some human readable format: aws ec2 describe-instances --query 'Reservations[*].Instances[*].{ID:InstanceId,TYPE:InstanceType,Subnet:SubnetId,VPC:VpcId,IP:PublicDnsName,State:State.Name }' --output table

@murarisumit
murarisumit / grafana-prometheus-values.yaml
Created November 13, 2018 10:48 — forked from rohancme/grafana-prometheus-values.yaml
Values for the grafana helm chart to talk to an existing prometheus datasource
persistence:
enabled: true
accessModes:
- ReadWriteOnce
size: 5Gi
datasources:
datasources.yaml:
apiVersion: 1
datasources: