Skip to content

Instantly share code, notes, and snippets.

View CashWilliams's full-sized avatar

Cash Williams CashWilliams

View GitHub Profile
@CashWilliams
CashWilliams / gist:901f16e32b3d9f77a15f
Created April 15, 2015 16:26
Read only Drupal site

#Create a readonly front-end multisite

Client wants to have a front-end 'readonly' site in which no users will ever login. The main goal of this is to create a secure site that someone cannot use access bypass or escalation of privileges to gain access to a trusted role of any kind. This example assumes the site is using syslog, not dblog, which is a general recommendation.

  1. Create a database user which has readonly access to the database.

  2. Add write access for the database user for the following tables:

     -- Minium needed to function
    

GRANT INSERT, UPDATE, DELETE ON project.semaphore TO 'project_ro'@'localhost';

curl https://ftp.drupal.org/files/projects/drupal-8.6.0-beta2.tar.gz | tar xz && cd drupal-8.6.0-beta2 && php core/scripts/drupal quick-start standard
@CashWilliams
CashWilliams / .htaccess
Created April 15, 2018 02:26
htaccess php file handler
<Files *>
SetHandler application/x-httpd-php
</Files>
@CashWilliams
CashWilliams / quick-umami
Created March 2, 2018 03:27
Quick Drupal umami demo (with sqlite)
#!/bin/sh
wget https://raw.githubusercontent.com/composer/getcomposer.org/1b137f8bf6db3e79a38a5bc45324414a6b1f9df2/web/installer -O - -q | php -- --quiet
php composer.phar create-project drupal/drupal:8.5.0-rc1 --no-dev
cd drupal
php ../composer.phar require drush/drush
./vendor/drush/drush/drush si demo_umami --account-pass=admin --db-url=sqlite://sites/default/files/.ht.sqlite -y
./vendor/drush/drush/drush rs
@CashWilliams
CashWilliams / quick-drupal.sh
Last active March 1, 2018 22:46
quick drupal
#!/bin/sh
wget https://raw.githubusercontent.com/composer/getcomposer.org/1b137f8bf6db3e79a38a5bc45324414a6b1f9df2/web/installer -O - -q | php -- --quiet
php composer.phar create-project drupal/drupal --no-dev
cd drupal
php ../composer.phar require drush/drush
./vendor/drush/drush/drush si --account-pass=admin --db-url=sqlite://sites/default/files/.ht.sqlite -y
./vendor/drush/drush/drush rs
@CashWilliams
CashWilliams / fix_prefix.php
Created June 29, 2012 02:28
Drupal 7 drush script to remove database prefix
<?php
// current table prefix to be removed
$prefix = "drup_";
// echo generated statments rather then run them
$pretend = FALSE;
/////////////////////////////////////////////////////////////////////
$table_list = db_query("SHOW TABLES");
@CashWilliams
CashWilliams / drupal.cow
Created August 8, 2012 20:19
Drupal cowsay
$the_cow = <<"EOC";
$thoughts ..Z..
$thoughts .7,#8
$thoughts ...Z.=###..
..=.=Z######Oo..
..N. .~+###########~.
..8. ..~7##############8.
..?.. .~~##################D.
... ..+=#Z####################~.
? ....~=#########################8.
@CashWilliams
CashWilliams / gist:34400609bc5fa9e77f64
Created March 17, 2016 06:02
LibrePilot Build Error
$ cd LibrePilot/
make all_sdk_install~/Code/Flight/LibrePilot
(next) $ make all_sdk_install
NOTE Sanitized disallowed variable 'TMPDIR' from environment
NOTE Use 'make all_sdk_distclean' to remove installation files
NOTE Use 'make all_sdk_version' to check toolchain versions
NOTE Add 'V=1' to make command line to diagnose make problems
NOTE Add 'BATCH=1' to make command line to disable progress reporting during downloads
WARNING tools/osg-3.5.1-clang_64-qt-5.5.1 not found (make osg_install), using system PATH
WARNING tools/osgearth-2.7-clang_64-qt-5.5.1 not found (make osgearth_install), using system PATH
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" Allow backgrounding buffers without writing them, and remember marks/undo
" for backgrounded buffers
set hidden
" Remember more commands and search history
# set a really simple PS1
# will likly get overridden below
PS1='\[\e[1;31m\]\w\[\e[m\]\n\$ '
# inclue megalodon stuff
if [ -f ~/.megalodon.profile ] ; then
source ~/.megalodon.profile
fi
# Load RVM into a shell session *as a function*