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
# Start by making sure your system is up-to-date: | |
yum update | |
# Compilers and related tools: | |
yum groupinstall -y "development tools" | |
# Libraries needed during compilation to enable all features of Python: | |
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel | |
# If you are on a clean "minimal" install of CentOS you also need the wget tool: | |
yum install -y wget | |
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 wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo | |
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key | |
sudo yum install jenkins |
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
'''Requires psutil package that's available from pip''' | |
import psutil | |
def find_processes_by_user(user_name): | |
user_processes = [proc for proc in psutil.process_iter(attrs=['pid', 'name', 'username']) if proc.info["username"] == user_name] | |
return user_processes |
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
'''A simple function to create a backup of a file with a date stamp and backup extension''' | |
import datetime | |
import shutil | |
import os | |
def create_backup_file(file_name, backup_extension=".bak", date=str(datetime.date.today())): | |
'''Create a backup of a file using the given backup extension''' | |
backup_file_name = os.path.join(file_name, backup_extension) | |
try: | |
shutil.copyfile(file_name, backup_file_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
'''Makes a directory; no exception if directory already exists, make parent directories as needed''' | |
def mkdir_p(path, mode = 0777): | |
try: | |
os.makedirs(path, mode) | |
except OSError as exc: # Python >2.5 | |
if exc.errno == errno.EEXIST and os.path.isdir(path): | |
print("%s already exists.", path) | |
else: | |
raise |
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
'''My preferred logging setup to log the filename, line number, function name, and time in messages''' | |
import logging | |
logger = logging.getLogger('metrics_logger') | |
logger.setLevel(logging.DEBUG) | |
# create formatter | |
formatter = logging.Formatter("%(levelname)s - %(filename)s - %(lineno)s - %(funcName)s - %(asctime)s - %(message)s", datefmt='%m/%d/%Y %I:%M:%S %p') | |
# create console handler with a higher log level | |
console_handler = logging.StreamHandler() | |
console_handler.setFormatter(formatter) |
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
/* source: https://stackoverflow.com/a/45275695/2154867 */ | |
#text_container { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
width: 100%; | |
height: 100vh; } | |
#text_container p { | |
margin: 0; | |
color: white; |
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
html{ | |
width: 100vw; height: 100vh; | |
} | |
body { | |
width: 100vw; | |
height: 100vh; | |
/*Replace with some_image with image url/path*/ | |
background: url("some_image.png"); | |
background-repeat: no-repeat; |
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 OpenSSL | |
def get_x509_subject_string(cert_name): | |
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, open(cert_name).read()) | |
subject_components = x509.get_subject().get_components() | |
subject_string = "" | |
for component in subject_components: | |
subject_string = subject_string + "/" + component[0] + "=" + component[1] | |
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 insert_between_nodes(current_node, new_node): | |
new_node.next = current_node.next | |
new_node.prev = current_node | |
current_node.next.prev = new_node | |
current_node.next = new_node | |
def SortedInsert(head, data): | |
new_node = Node(data) | |
current_node = head | |
OlderNewer