Skip to content

Instantly share code, notes, and snippets.

View jdavidbakr's full-sized avatar

J David Baker jdavidbakr

View GitHub Profile
#!/bin/bash
if [ "$#" -ne 3 ]; then
echo "Scan a database for credit card numbers and social security numbers, outputting to an html file with the numbers highlighted in their database insert statements."
echo "Usage: sensitivescan.sh [db-server] [database] [output-html-filename]"
echo "Requires mysqldump, grep, and aha installed on the server."
exit
fi
echo "Scanning server $1 database $2 for sensitive information"
#!/bin/bash
# usage
# ./fix-pdf-s3.sh bucket path/to/folder/to/scan
# No trailing slash on the bucket or path
bucket=$1
path=$2
origin=$1
@jdavidbakr
jdavidbakr / config
Created October 20, 2020 00:44 — forked from justinpawela/config
AWS CodeCommit Multiple Account Config
# This file is: ~/.ssh/config
# You may have other (non-CodeCommit) SSH credentials stored in this
# config file – in addition to the CodeCommit settings shown below.
# NOTE: Make sure to run [ chmod 600 ~/.ssh/config ] after creating this file!
# Credentials for Account1
Host awscc-account1 # 'awscc-account1' is a name you pick
Hostname git-codecommit.us-east-1.amazonaws.com # This points to CodeCommit in the 'US East' region
@jdavidbakr
jdavidbakr / fix-website-permissions
Last active December 7, 2017 17:02
Script to repair website permissions
#!/bin/bash
LOCK_FILE=/tmp/permission-repair-lock
if [ ! -e $LOCK_FILE ]; then
trap "rm -f $LOCK_FILE; exit" 0 1 2 3 15
touch $LOCK_FILE
for d in /var/www/html/*
do
@jdavidbakr
jdavidbakr / gist:cffb6fe70bf76fc15ecc436c1de146ee
Created November 29, 2017 14:52
EC2 Supervisor Init Script
#!/bin/bash
#
# supervisord Startup script for the Supervisor process control system
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
# Jason Koppe <jkoppe@indeed.com> adjusted to read sysconfig,
# use supervisord tools to start/stop, conditionally wait
# for child processes to shutdown, and startup later
# Erwan Queffelec <erwan.queffelec@gmail.com>
# make script LSB-compliant
@jdavidbakr
jdavidbakr / fix-websites-permissions.sh
Created August 7, 2017 20:14
Script to fix website permissions when multiple users are publishing with npm install + deployer
#!/bin/bash
# Run this script on a regular basis to clean up permissions in all website projects.
# It makes sure all files are group-writable, and that the group is apache.
# The lock file prevents it from running on top of another process.
LOCK_FILE=/tmp/permission-repair-lock
if [ ! -e $LOCK_FILE ]; then
trap "rm -f $LOCK_FILE; exit" 0 1 2 3 15
@jdavidbakr
jdavidbakr / TextCountdown.js
Created September 22, 2015 21:40
JavaScript: TextCountdown
var TextCountdown = {
Update: function(field, target_id) {
var maxlength = field.getAttribute('maxlength');
var length = field.value.length;
var remaining = maxlength - length;
document.getElementById(target_id).innerHTML = remaining;
}
};
@jdavidbakr
jdavidbakr / hidden_subform.js
Last active September 15, 2015 19:26
JavaScript: Hidden Subform
var HiddenSubform = {
update: function(object) {
switch(object.nodeName) {
case 'SELECT':
this.updateSelect(object);
break;
case 'INPUT':
if(object.getAttribute('type') == 'checkbox') {
this.updateCheckbox(object);
}
@jdavidbakr
jdavidbakr / page_change_warning.js
Last active August 29, 2015 14:24
JavaScript: Page change warning - alerts the user before allowing the window to close
var PageChangeWarning = {
unload_message: "You have unsaved changes on this page.",
display_warning: function() {
return this.unload_message;
},
change_made: function() {
window.onbeforeunload = this.display_warning.bind(this);
},
saved: function() {
window.onbeforeunload = null;
@jdavidbakr
jdavidbakr / field_multiplier.js
Created June 8, 2015 21:42
JavaScript: Field Multiplier
var FieldMultiplier = {
makeSum: function(e) {
/**
* Look for any elements with the same class as this one
* and sum them, multiplying by the multiplier attribute.
* The sum will go into the elements that match the sum attribute.
*/
var sum = 0;
var sum_selector = '.'+e.getAttribute('class');
var elements = document.querySelectorAll(sum_selector);