This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
example data: | |
name: someText aFewMoreRandomThings aggregate_id: someNumber | |
if this error is found, the script will search for all related logs to this aggregate_id and the text Retries exceeded (RMQ specific). | |
script will then collect all this data and send it to email | |
error type: {} | |
aggregateid: {}\n | |
mq deadfinal log: \n{} | |
related log : \n{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Example format for sdp.csv file. | |
source,dest,port | |
10.0.x.x,10.0.x.y,80 | |
10.0.x.x,10.0.x.y,800 | |
''' | |
import csv | |
import base64 | |
import paramiko |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo script name: $0 | |
echo first argument: $1 | |
echo number of arguments passed: $# | |
echo all the arguments are: $@ | |
echo exit status of most recent process: $? | |
echo process id of the script: $$ | |
echo username: $USER | |
echo hostname: $HOSTNAME | |
echo a random number: $RANDOM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note that spaces cannot be used around the `=` assignment operator | |
whom_variable="World" | |
# Use printf to safely output the data | |
printf "Hello, %s\n" "$whom_variable" | |
> Hello, World | |
#If you want to bash to expand your argument, you can use Weak Quoting: | |
#!/usr/bin/env bash | |
world="World" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#to print column number: | |
STDIN | awk '{print $COLUMN_NUMBER}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#add below to ~/.bashrc | |
force_color_prompt=yes | |
color_prompt=yes | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
max_arr=max(arr) | |
arr=list(filter(lambda x: x!=max_arr, arr)) | |
print(max(arr)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fun(s): | |
# return True if s is a valid email, else return False | |
import re | |
rex = re.compile("^[\w\-\_]+\@[a-zA-Z0-9]+\.\w{1,3}$") | |
if rex.match(s): | |
return True | |
else: | |
return False | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
l=[1,2,3,4] | |
print(reduce(lambda x,y: x*y, l, -1)) | |
#> -24 | |
#reduce(func with 2 params, iterable, initial value ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
t1='Sat 02 May 2015 19:54:36 +0530' | |
t2='Fri 01 May 2015 13:54:36 -0000' | |
t1=datetime.strptime(t1,'%a %d %b %Y %H:%M:%S %z') | |
t2=datetime.strptime(t2,'%a %d %b %Y %H:%M:%S %z') | |
# print(t1-t2) | |
#> 1 day, 0:30:00 | |
print ((t1-t2).total_seconds()) |
OlderNewer