Skip to content

Instantly share code, notes, and snippets.

<?php
// Database Creds
$DB_NAME = "<database goes here>";
$DB_USER = "<username goes here>";
$DB_PASS = "<password goes here>";
$DB_HOST = "localhost";
// Get list of tables
$get_tables = "mysql "
#!/bin/sh
# padding output using printf
# reference: https://stackoverflow.com/questions/4409399/padding-characters-in-printf#4410103
pad=$(printf '%0.1s' "-"{1..60})
padlength=40
string2='bbbbbbb'
for string1 in a aa aaaa aaaaaaaa; do
printf '%s' "$string1"
printf '%*.*s' 0 $((padlength - ${#string1} - ${#string2} )) "$pad"
>>> out_files = []
>>> for dirpath, subidrs, files in os.walk('/home/kolby/Desktop'):
... for item in files:
... print dirpath + item
...
/home/kolby/Desktoplabsim1.3_kolby_heacock.pdf
/home/kolby/Desktopsteam.desktop
/home/kolby/Desktoplabsim1.2_kolby_heacock.pdf
/**
* fizzbuzz in javascript
* @return {string} - output of fizzbuzz coding challenge
*/
function fizzbuzz() {
let output = ''; // initialize return string
for (tmp=1; tmp<=100; tmp++) { // iterate from 1 to 100
if ((tmp % 15) === 0) { // if divisible by 3 and 5
output += 'fizzbuzz'; // add 'fizzbuzz'
} else if ((tmp % 3) === 0) { // if divisible by just 3
/**
* @file Defines Person class
* @version 1.0
* @author Kolby Heacock <[email protected]>
* @copyright Kolby Heacock 2017
*/
/**
* Representation of a person
* @class
@classmember
classmember / parse.py
Last active December 13, 2024 08:19
Parse fail2ban log for IP addresses
#!/usr/bin/env python
'''
Parse fail2ban log for IP addresses
Usage: $ ./parse.py log
'''
import re
import sys
import subprocess
import collections
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
@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
[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 / 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}\;