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 get_prime_numbers(n): | |
prime = [True for i in range(n+1)] | |
res = [] | |
p = 2 | |
while (p * p <= n): | |
# If prime[p] is not changed, then it is a prime | |
if (prime[p] == True): | |
res.append(i) | |
# Update all multiples of p | |
for i in range(p * p, n+1, p): |
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
cal_add_mod_dict = {} | |
cal_sub_mod_dict = {} | |
cal_mul_mod_dict = {} | |
cal_pow_mod_dict = {} | |
def cal_add_mod(a, b, n): | |
"""Calculates (a+b) mod n""" | |
t = (a,b,n) | |
if t not in cal_add_mod_dict: | |
cal_add_mod_dict[t] = (a % n + b % n) % 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
FROM nginx:latest | |
# dist includes the built output - npm build | |
COPY dist /usr/share/nginx/html | |
# nginx*conf to copy all the nginx configuration files to image. | |
COPY nginx*conf /opt/app-name/ | |
# copy app entrypoint shell script | |
COPY entrypoint.sh /opt/app-name/ |
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
downloadFile(dataToBeDownloaded): void { | |
let a = document.createElement("a"); | |
let dataURI = "data:text/plain;base64," + btoa(dataToBeDownloaded); | |
a.href = dataURI; | |
a['download'] = this._sddcInformation.id + ".pem"; | |
a.click(); | |
a.remove(); | |
} |
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 python:3 | |
ADD script.py / | |
CMD [ "python", "-u", "./script.py" ] |
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 os, time, sched | |
MB = 1048576 | |
def measure_write_speed(file_path): | |
string = "Let's test write speed..." | |
n = (100 * MB) // len(string) | |
start = time.time() | |
file = open(file_path, 'w') | |
for i in range(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
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 |
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
# 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
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 |