Skip to content

Instantly share code, notes, and snippets.

View jdavidbakr's full-sized avatar

J David Baker jdavidbakr

View GitHub Profile
@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 / 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 / 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 / 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 <[email protected]> (based off yumupdatesd)
# Jason Koppe <[email protected]> adjusted to read sysconfig,
# use supervisord tools to start/stop, conditionally wait
# for child processes to shutdown, and startup later
# Erwan Queffelec <[email protected]>
# make script LSB-compliant
@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 / 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
#!/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
#!/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"