Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
'''
MegaPy - MegaCLI wrapper
'''
import sh
import os
import subprocess
import argparse
__version__ = 'MegaPy v.1'
#!/usr/bin/python
'''
MegaPy - MegaCLI wrapper
The Python wrapper is an attempt to make RAID management easier
for the MegaRAID line of RAID devices.
MegaRAID and MegaCLI are currently supported by Broadcom.
LSI Documentation on MegaCLI:
@classmember
classmember / MegaPy.py
Created August 11, 2017 15:07
MegaPy - MegaCLI wrapper
#!/usr/bin/env python
'''
MegaPy - MegaCLI wrapper
'''
import os
import subprocess
import argparse
# import sh
__version__ = 'MegaPy v.1'
#!/bin/bash
# controlling a screen session from the terminal
screen_name="fab_session_${RANDOM}" # Generate unique screen session name
screen -S ${screen_name} -d -m # Open detached screen session
# Send commands to the screen session
screen -S ${screen_name} -p 0 -X stuff "echo \'hello world\!\'^M"
screen -S ${screen_name} -p 0 -X stuff "echo -n \'Still here, \!\'^M"
screen -S ${screen_name} -p 0 -X stuff "echo -n \' Still selling real fake doors\!\'^M"
#!/bin/bash
# parse echo command using Perl with
# many calls to the "${RANDOM}" internal bash function
# redirect command to a bash session
bash<<<$(
perl -e '
print "echo ";
print "\$\{RANDOM\}"'x40
)
@classmember
classmember / importing databases
Created August 22, 2017 14:15
importing databases
# List of databases
# \ls -A | grep sql | sed 's/\.sql//g' | xargs | fold -w 80 -s | tr ' ' '|' | column -s'|' -t
dbs="admin_wp11 admin_music admin_bestsat admin_exot admin_geek admin_girl
admin_tabs admin_birds admin_frogs admin_liveagle admin_exampl admin_practical
admin_productive admin_reviews admin_rich admin_sites"
# Create databases and users
mysql<<<$(
for db in ${dbs}; do
echo CREATE DATABASE ${db}\;
[Tue Aug 29 00:17:59.561312 2017] [php7:error] [pid 3665] [client 216.54.31.82:8132] PHP Fatal error: Uncaught Zend\\ModuleManager\\Exception\\RuntimeException: Module (Application) could not be initialized. in /var/www/html/application/vendor/zendframework/zend-modulemanager/src/ModuleManager.php:203\nStack trace:\n#0 /var/www/html/application/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(175): Zend\\ModuleManager\\ModuleManager->loadModuleByName(Object(Zend\\ModuleManager\\ModuleEvent))\n#1 /var/www/html/application/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(97): Zend\\ModuleManager\\ModuleManager->loadModule('Application')\n#2 /var/www/html/application/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\\ModuleManager\\ModuleManager->onLoadModules(Object(Zend\\ModuleManager\\ModuleEvent))\n#3 /var/www/html/application/vendor/zendframework/zend-eventmanager/src/EventManager.php(171): Zend\\EventManager\\EventManager->triggerListeners(Object(Zend\\Module
@classmember
classmember / npm depedencies
Last active September 6, 2017 17:08
npm test "Error: Cannot find module" solution - this shell script installs all missing npm packages
#!/bin/sh
# npm test wouldn't run due to missing or unresolved packages.
# This script installs all missing packages from error messages.
# Fix missing packages
missing_package="$(
npm test 2>&1 |
grep 'Cannot find module' |
cut -d\' -f2)"
while [ -n "${missing_package}" ] ; do # while missing packages
2016-03-16 15:35:51,527 fail2ban.filter [1986]: INFO [sshd] Found 1.2.3.4
2016-03-16 15:35:51,817 fail2ban.filter [1986]: INFO [sshd] Found 1.2.3.4
2016-03-16 15:35:52,537 fail2ban.actions [1986]: NOTICE [sshd] Ban 1.2.3.4
/**
* @file Defines Person class
* @version 1.0
* @author Kolby Heacock <kolby@fasterdevops.com>
* @copyright Kolby Heacock 2017
*/
/**
* Representation of a person
* @class