Skip to content

Instantly share code, notes, and snippets.

@cravecode
cravecode / install-php-5-6-fpm-and-drush.sh
Last active April 23, 2023 00:10
Install PHP 5.6 FPM on Ubuntu 14.04 and Drush via Composer
#!/bin/bash
# Install PHP 5.6 (FPM) on Ubuntu 14.04 LTS
sudo add-apt-repository ppa:ondrej/php -y
sudo add-apt-repository ppa:ondrej/php5-compat -y
sudo apt-get update
sudo apt-get install php5.6 php5.6-fpm php5.6-curl php5.6-gd -y
# Change PHP FPM from socket to tcp connection.
sudo sed -i "s/^listen = \/run\/php\/php5.6-fpm.sock/;listen = \/run\/php\/php5.6-fpm.sock\nlisten = 127.0.0.1:9000/g" /etc/php/5.6/fpm/pool.d/www.conf
sudo service php5.6-fpm restart
@cravecode
cravecode / uninstall-old-php.sh
Created August 11, 2016 14:58
Uninstalls all php related packages.
#!/bin/bash
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
@cravecode
cravecode / example.md
Last active June 21, 2016 18:51
Using jQuery with custom Drupal page callback that returns Drupal AJAX command.

JS:

// Add a custom
(function ($) {
  $(function () {
    /**
     * Add an extra function to the Drupal ajax object that is specific to our
     * custom Drupal menu callback for: "custom/ajax/%/%".
     */
    Drupal.ajax.prototype.customAjaxHandler = function (arg1, arg2) {
@cravecode
cravecode / selenium-hub-daemon
Last active March 15, 2016 02:56 — forked from bcap/start-stop-daemon-template
File for starting Seleniun Standalone Server Hub as a linux services using the start-stop-daemon.
#!/bin/bash
### BEGIN INIT INFO
# Provides: selenium-hub
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: The Selenium Standaline Server ran as a hub.
### END INIT INFO
@cravecode
cravecode / start-stop-example.sh
Created March 14, 2016 20:56 — forked from alobato/start-stop-example.sh
start-stop-example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar
#!/bin/bash
cat /dev/urandom | hexdump | awk '{printf "%c", $1%74+48}'
@cravecode
cravecode / civicrm-issue-549.patch
Last active December 28, 2015 01:29
Corrects the issue that causes non-billing primary address from showing in the my account drupal profile fields.
diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php
index e721f2c..25c50c3 100644
--- a/CRM/Core/BAO/UFGroup.php
+++ b/CRM/Core/BAO/UFGroup.php
@@ -2128,6 +2128,16 @@ AND ( entity_id IS NULL OR entity_id <= 0 )
$defaults[$fldName] = $details[$name];
}
}
+ else if($locTypeId == 1 && is_string($value)) {
+ $trimmed_field_name = str_replace('-Primary', '', $fldName);
#!/bin/bash
path=${1%/}
user=${2}
group="www-data"
help="nHelp: This script is used to fix permissions of a drupal installationnyou need to provide the following arguments:nt 1) Path to your drupal installationnt 2) Username of the user that you want to give files/directories ownershipnNote: "www-data" (apache default) is assumed as the group the server is belonging to, if this is different you need to modify it manually by editing this scriptnnUsage: (sudo) bash ${0##*/} drupal_path user_namen"
if [ -z "${path}" ] || [ ! -d "${path}/sites" ] || [ ! -f "${path}/modules/system/system.module" ]; then
echo "Please provide a valid drupal path"
echo -e $help
@cravecode
cravecode / apache_drupal_host
Created August 17, 2011 22:16
Apache Drupal Template Host File
# $Id: dist-apache2.conf,v 1.2 2009/09/16 07:37:27 deniver Exp $
#
# Keywords used by the densite script:
#
# server_name
# document_root
# allow_ip
# site_root
#
<VirtualHost *:80>
@cravecode
cravecode / Drush-7-Install.sh
Created August 3, 2011 17:08
Shell Drush Install Script
#!/bin/bash
# Update user
echo "Drush is now downloading via HTTP"
# move to home dir
cd ~
# remove current drush (if existent)
rm -rf ~/.drush/
# create drush directory (and hide it)