Skip to content

Instantly share code, notes, and snippets.

@ianlintner-wf
ianlintner-wf / vhost.sh
Created March 24, 2014 17:49
Create a ideal vhost for drupal via shell script. Customize for your site / var web directory.
#!/usr/bin/env bash
tmpfile=/tmp/vhostfile
vhost=/etc/apache2/sites-available/$1
echo "creating $vhost for directory /var/sites/$2"
echo "<VirtualHost *:80>" > $tmpfile
echo " DocumentRoot /var/sites/$2" >> $tmpfile
echo " ServerName $1" >> $tmpfile
echo " RewriteEngine On" >> $tmpfile
echo " RewriteOptions inherit" >> $tmpfile
@ianlintner-wf
ianlintner-wf / pollpull.sh
Last active August 29, 2015 13:58
Poll the remote git repository using git fetch & then git status && pull from git hub based on the status of the branch.
#!/bin/bash
#Current (Remote) Branch
currentbranch=""
#Fetch from the remote branch
echo "polling..."
if [ -n "$currentbranch" ]; then
git fetch $currentbranch
else
@ianlintner-wf
ianlintner-wf / restore_db_dir.sh
Last active August 29, 2015 13:58
Read all mysql dumps in a directory and restore them to database that matches filename.
#!/bin/bash
#Load all mysql backups in directory
FILES=/you/restore/db/*.mysql
if [ ${#FILES[@]} -gt 0 ]; then
#Loop through files
for f in $FILES
do
#Alert the user
@ianlintner-wf
ianlintner-wf / makedev.sh
Created April 5, 2014 04:08
Takes a production drupal database and runs drush settings for dev
#!/bin/bash
drush vset cache 0
drush vset preprocess_css 0
drush vset preprocess_js 0
sudo drush dl drush --destination='/usr/share'
#!/bin/bash
#Load all mysql backups in directory to mysql
#database is filename
#drop existing database, import database
#clear database script folder
#
#Takes parameters $1 -u $2 username_value $3 -p $4 password_value (example for $files) -f database/folder/*.mysql
#Set $FILES value to location of your database file or use parameter $5 $6
#FILES="$6"
@ianlintner-wf
ianlintner-wf / devel_sql_select.php
Created August 14, 2014 15:56
Set of Devel Data Debugging for Production
<?php
$query = "SELECT * FROM node";
$result = db_query($query);
if ($result) {
while ($row = $result->fetchAssoc()) {
dpm($row);
}
@ianlintner-wf
ianlintner-wf / csv_import.mysql
Created September 2, 2014 20:18
Gists is an example for the mysql command line client to import csv file.
LOAD DATA LOCAL INFILE '/path/to/file/zip.csv'
INTO TABLE zip_code
FIELDS TERMINATED BY ','
ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
(zip_code, latitude, longitude, city, state, county, type);
@ianlintner-wf
ianlintner-wf / programming.sh
Created September 22, 2014 15:16
ZSH Tips / Recipes
#Example for loop zsh
myVar=('foo' 'bar' 'baz')
for i in $myVar; do
print $i
done