Skip to content

Instantly share code, notes, and snippets.

View chales's full-sized avatar

Chris Hales chales

View GitHub Profile
@chales
chales / drupal-email-test.php
Created November 14, 2013 23:36
Test Drupal email. Edit and add to the Drupal docroot to see if you can send a message. Note that this will not hook phpmailer or other libs that may be in use. Mainly for a quick proof of life type of check.
<?php
// Replace <user>@<host>, place in a drupal docroot, hit it with a browser.
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$message = array(
'id' => 'email_tester',
'to' => '<user>@<host>',
'subject' => t('Test subject'),
'body' => t('This is a test message to fill in the body.'),
@chales
chales / db-sync.sh
Created January 26, 2014 06:13
Simple database backup script. Splits structure and data dumps.
#!/bin/bash
# Database User
USER="my-db-user"
# Database Password
PASSWORD="my-db-passwd"
# Database Name
DB="my-db-name"
@chales
chales / cron-deploy
Created January 28, 2014 14:45
Cron job to run a simple deploy via git pull, drush fra, and recompiling sass. Good for some dev/staging setups but not for production. Makes assumptions that no files have been modified on the site.
# Git Pull and Drush Feature revert all
* * * * * cd /var/www/example.com && /usr/bin/git pull --rebase > /var/www/example.com/deploy.log; /usr/bin/drush -y fra > /var/www/example.com/deploy.log 2>&1
# Recompile Sass
* * * * * /bin/bash -c ". /home/webadmin/.bash_profile > /var/www/example.com/deploy.log 2>&1; cd /var/www/example.com/docroot/sites/all/themes/custom/example && /home/webadmin/.rvm/gems/ruby-2.1.0/bin/bundle exec compass compile > /var/www/example.com/deploy.log 2>&1"
@chales
chales / php-overrides.ini
Last active August 29, 2015 13:58
Common php.ini overrides for production. Added at the end of a main php.ini or in /etc/php5/conf.d/
; RESOURCES
max_execution_time = 120
max_input_time = 120
memory_limit = 260M
; UPLOAD
file_uploads = 1
;upload_tmp_dir = '/tmp'
upload_max_filesize = 150M
post_max_size = 150M
@chales
chales / Mavericks-usb.txt
Created April 13, 2014 23:57
Creating an OS X 10.9.X Mavericks bootable installation on a USB flash drive.
Download a copy of Mavericks from the Apple Store. It will save in your /Applications directory and will open once the download is complete. Just quit the installation. If you run the installer it will delete itself so move it to keep a copy.
Format an 8G+ (needs about 6G of space) USB stick with the 'Mac OS X Extended Journaled' format and leave it named 'Untitled' but be sure that you do not have another volume named "Untitled" or the next step could erase something!
Open the Terminal app and run the following command. This copies the resources over to the USB stick and makes it a bootable drive. Check the path, if you moved the file correct the paths.
sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction
You should see something like the following, the "Copying installer files..." will take about 20 minutes with not progress indication. Just wait for it.
@chales
chales / s3-db-backup.sh
Last active March 7, 2019 15:08
Based on script from http://getlevelten.com/blog/randall-knutson/yet-another-simple-amazon-s3-backup-script-drupal Requires the s3cmd library (apt-get install s3cmd, s3cmd --configure) http://s3tools.org/s3cmd
#!/bin/bash
# Requires s3cmd be installed, http://s3tools.org/s3cmd
echo 'Enter the database name you would like to backup:'
read DBNAME
# Setup vars
TMP="/tmp"
DBUSER="root"
@chales
chales / db-connect-test.php
Last active March 29, 2025 09:10
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@chales
chales / db-dump.sh
Last active August 29, 2015 14:00
Database dump and load bash scripts specifically setup to skip common extraneous data from a Drupal DB. This is beta at the moment, I need to fix the "PROCEED" check. For DB load "pv" is used and should be installed which gives you a progress meter.
#!/bin/bash
# Simple dump script. Requires a user .my.cnf file that includes the basic default
# username, password and host.
echo 'DB Name to Dump:'
read DBNAME
###################################
# Setup vars
#!/bin/bash
for branch in `git branch -r | grep -v HEAD | grep -v master`; do
echo ${branch##*/} $branch
done
echo "Fetching..."
git fetch --all
echo "Pulling..."
git pull -v
echo "Results: Branches"
git branch -a
@chales
chales / mysql-search.sql
Last active July 24, 2018 17:39
Procedure to search through all databases, tables and columns in MySQL DB Server.
# Search through all databases, tables, and columns in a MySQL db.
# From http://kedar.nitty-witty.com/blog/search-through-all-databases-tables-columns-in-mysql
## Table for storing resultant output
CREATE TABLE `temp_details` (
`t_schema` varchar(45) NOT NULL,
`t_table` varchar(45) NOT NULL,
`t_field` varchar(45) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;