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 / prepare-commit-msg
Created September 24, 2015 16:28
Adds a GitHub Issue number to a commit message based on the branch name. I.e.: branch-name-123
#!/bin/bash
branchPath=$(git symbolic-ref -q HEAD) #Somthing like refs/heads/myBranchName
branchName=${branchPath##*/} #Get text behind the last / of the branch path
issueNumber=$(echo "$branchName" | grep -Po "\-\d+$" | grep -Po "\d+")
# If there was a issue number in the branch name, append it to the commit message.
if [ -n "$issueNumber" ]; then
# Write the issue number to the commit message.
echo "Issue: #$issueNumber" >> $1
@cravecode
cravecode / civicrm-remove-dupecheck-trxn.patch
Last active August 29, 2015 14:27
Removes the duplication check for a transaction via trxn_id or invoice_id from a CiviCRM contribution.
--- a/CRM/Contribute/BAO/Contribution.php 2015-08-10 12:54:11.213977480 -0400
+++ b/CRM/Contribute/BAO/Contribution.php 2015-08-10 12:54:31.000000000 -0400
@@ -773,6 +773,7 @@
* static
*/
static function checkDuplicate($input, &$duplicates, $id = NULL) {
+ return FALSE;
if (!$id) {
$id = CRM_Utils_Array::value('id', $input);
}
#!/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
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: GPGTools - https://gpgtools.org
mQINBFVnEeYBEADgRodb7om/S83TuYWZJtVhAcP2R91yi1+trwmKqftAJY0tChKa
2uM9uHtYvU6aKOyNhVaDiU9agm+PKVAuQqnpysVHWA2VokAYIePHtjHTjBorGudn
mid7mfIVaoWW+uJSMFbpxTEj5FH0WpeeNO51Jfpcq6T5jR87EXCHzkU7J2jBMWBw
pQS19Z0XB91pCru/TElY9komRcVvR1JQ2nVDDh6eVn3kLRalYUBYfLFjzMxO22G/
xXPXfATtLAZsh8/RUnuXzmZnMFa0jTbeQgGx9SlQQudr+rGWSVc3dMMA7G1DKE7F
5MKWBUFAIhCQL7VJQ8iLG38R4lGS0ZG3DgcFYUr5RgC/OojIROC1j1dkH7u2eRaR
3eXrRb7siH2dU8TxoVZjkButaFdpb7pM5OgbpVIEMNhuPjMuYaCaQBa7dSrps9he