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
#!/usr/bin/env python | |
''' | |
Simple example of how to use the crypto library for AES encryption and | |
decryption. | |
Make sure that the Crypto (pycrypto) module is installed: | |
$ pip-2.7 install pycrypto | |
$ pip-3.5 install pycrypto |
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
#!/usr/bin/env python | |
''' | |
Copy a large file showing progress. | |
MIT License | |
Copyright (c) 2015 Joe Linoff | |
Permission is hereby granted, free of charge, to any person | |
obtaining a copy of this software and associated documentation |
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 | |
# Download RPM files from the base and epel repositories. | |
for Repo in base epel ; do | |
OutDir=/opt/shared/repo/$Repo | |
[ ! -d $OutDir ] && mkdir -p $OutDir | |
for RPM in $(repoquery -qa --repoid=$Repo) ; do | |
yum install $RPM -y --downloadonly --downloaddir=$OutDir | |
done | |
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
#!/usr/bin/env python | |
''' | |
Python example that shows how to run non-interactive shell commands using | |
two different subprocess implementations. | |
Works in Python 2.7 and Python 3.x. | |
LICENSE (MIT Open Source) | |
Copyright (c) 2016 Joe Linoff |
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 debug(msg): | |
''' | |
Display a debug message with the file name, function | |
name and line number. | |
''' | |
import inspect | |
parent_frame = inspect.currentframe().f_back | |
lineno = parent_frame.f_lineno | |
fctname = parent_frame.f_code.co_name | |
filename = parent_frame.f_code.co_filename |
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 | |
# | |
# Some useful path functions. Modelled after Python. | |
# | |
# License: MIT Open Source | |
# Copyright (c) 2016 Joe Linoff | |
# | |
# Normalize a path. | |
# Similar to Python's os.path.normpath() |
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 | |
# | |
# Function to measure and report progress. | |
# A bit like PV but for general things like copying N files. | |
# Use it as a starting point to created your own. | |
# | |
# License: MIT Open Source | |
# Copyright (c) 2016 Joe Linoff | |
# Show the progress of N items with an estimate of the time remaining. |
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
#!/usr/bin/env python | |
# License: MIT Open Source | |
# Copyright (c) 2016 Joe Linoff | |
''' | |
The tool runs ssh or scp as a child process with a connected psuedo | |
terminal (pty). | |
It will automatically answer yes to the "Are you sure you want to | |
continue connecting (yes/no)?" if it comes up. |
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
#!/usr/bin/env python | |
# License: MIT Open Source | |
# Copyright (c) 2016 Joe Linoff | |
''' | |
This example shows how to find and report all open files on a linux | |
system by reading /proc/<pid>/fd. | |
It is similar to the basic functionality provided by the command line | |
tool lsof but lsof is much faster and provides a lot more | |
capabilities. |
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 | |
# | |
# This image will fix all of the partitions in a disk image. | |
# | |
# Usage: | |
# fix-image.sh test.img | |
# | |
# License: MIT Open Source | |
# Copyright (c) 2016 by Joe Linoff |
OlderNewer