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 lxml import html | |
import requests | |
import csv | |
import sys | |
def fetchResult(z): | |
print("Starting ... "+str(z)) | |
resultList = [] | |
drugnum = str(z) |
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 num_to_words(num): | |
units = ["", "one", "two", "three", "four", "five", | |
"six", "seven", "eight", "nine "] | |
teens = ["", "eleven", "twelve", "thirteen", "fourteen", | |
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen"] | |
tens = ["", "ten", "twenty", "thirty", "forty", | |
"fifty", "sixty", "seventy", "eighty", "ninety"] |
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
# Calling | |
print 'allowed input - any string without number(s) i.e. (^[[\S|\s][\d+][\S|\s]])' | |
string_input = raw_input('Enter String: ') | |
# using regex to validate the input | |
import re | |
if re.search(r'\d+', string_input): | |
exit('error - string must not consist any 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
# To Get the list of all the processes | |
show processlist; | |
# kill connection or current query of a connection | |
kill connection <connection_id> | |
kill query <connection_id> | |
# Currently Connections Count | |
show status where `variable_name` = 'Threads_connected'; |
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
sudo rabbitmqctl list_connections pid | while read pid ; do sudo rabbitmqctl close_connection ${pid} "go away" ; done |
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 dowload_view(request): | |
from django.http import HttpResponse | |
rows = [['name', 'city', 'email'], ['Nitin', 'Bengaluru', '[email protected]']] | |
response = HttpResponse(content_type='text/csv') | |
response['Content-Disposition'] = 'attachment; filename="download.csv"' | |
writer = csv.writer(response) | |
for row in rows: | |
writer.writerow(row) | |
return response |
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
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add - | |
# create new file | |
sudo vi /etc/apt/sources.list.d/newrelic.list | |
# and write this line in above opened file | |
deb http://apt.newrelic.com/debian/ newrelic non-free | |
sudo apt-get update |
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
# Import EmailMessage class - https://docs.djangoproject.com/en/1.9/topics/email/#django.core.mail.EmailMessage | |
from django.core.mail import EmailMessage | |
email = EmailMessage('... Subject ...', '... Body ...', 'from-email', | |
['to-email-1', 'to-email-2'], ['bcc-email-1', 'bcc-email-2']) | |
# now let's create a csv file dynamically | |
import csv, StringIO | |
attachment_csv_file = StringIO.StringIO() | |
writer = csv.writer(attachment_csv_file) |
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 | |
if [ "$#" -ne 2 ]; then | |
echo "usage error: sh nmonitor.sh <pid> <time_to_monitor_in_seconds>";exit 1 | |
fi | |
pid=$1 | |
time=$2 | |
#read -p "Please enter your process Id: " pid |
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 do_telnet(host, port, message): | |
import telnetlib | |
tn = telnetlib.Telnet(host, port) | |
ret = tn.write(message + '\n') | |
print "sent the message: %s" % message | |
tn.close() | |
def send_thru_socket(host, port, message): | |
TCP_IP = host |
OlderNewer