Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am gapple on github.
  • I am gapple (https://keybase.io/gapple) on keybase.
  • I have a public key ASBjZLWUCOtm6zRy7sMCukL0qOzna528FUkTfE8xFiovcgo

To claim this, I am signing this object:

@gapple
gapple / .htaccess
Created July 16, 2017 06:50
htaccess gzip/brotli-bomb
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_headers.c>
RewriteCond %{HTTP:Accept-encoding} br
RewriteCond %{REQUEST_FILENAME} wp-login.php
RewriteRule ^(.*)$ bomb-32G.brotli [QSA]
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME} wp-login.php
@gapple
gapple / .htaccess
Created July 16, 2017 06:47
htaccess gzip-bomb
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_headers.c>
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME} wp-login.php
RewriteRule ^(.*)$ bomb-10G.gzip [QSA]
# Set content type, and prevent mod_deflate double compression.
RewriteRule bomb-[\d]+G\.gzip$ - [T=text/html,E=no-gzip:1]
@gapple
gapple / index.php
Last active June 4, 2016 00:21
Drupal multilingual multi-site in a sub-path
<?php
// Trick Drupal into thinking it's being run from a sub-folder.
// @see conf_path()
if (preg_match('<^/([\w]+-subpath)>', $_SERVER['REQUEST_URI'], $url_subpath_match)) {
$_SERVER['SCRIPT_NAME'] = '/' . $url_subpath_match[1] ./' . $_SERVER['SCRIPT_NAME'];
}
else if (preg_match('<^/(sites/subsite/files/styles)>', $_SERVER['REQUEST_URI'])) {
// Direct image style requests to the subsite
$_SERVER['SCRIPT_NAME'] = '/en-subpath' . $_SERVER['SCRIPT_NAME'];
@gapple
gapple / duplicate-ids.js
Created January 16, 2015 20:23
Show HTML elements with duplicated IDs in the console
// @see http://stackoverflow.com/a/509965/120080
(function ($) {
$('[id]').each(function () {
var ids = $('[id="'+this.id+'"]');
if(ids.length>1 && ids[0]==this) {
console.warn('Multiple IDs #'+this.id);
console.group();
ids.each(function () {
console.info(this);
});
@gapple
gapple / file_sync.drush.inc
Last active December 18, 2017 21:20
Drush command to sync files directories between aliases https://gapple.github.io/drush-plugins/
<?php
/**
* @file
* Provide a file-sync command to sync files directories between environments.
*/
/**
* Implements hook_drush_command().
*/
@gapple
gapple / update_rerun.drush.inc
Last active December 18, 2017 21:20
Run a single module update hook via Drush https://gapple.github.io/drush-plugins/
<?php
function update_rerun_drush_command() {
$commands = array();
$commands['update_rerun'] = array(
'description' => 'Rerun an update hook for a module',
'aliases' => array('urr'),
'arguments' => array(
'module' => 'Module',
@gapple
gapple / .gitconfig
Last active December 18, 2017 21:38
Git user configuration
[url "ssh://git@github.com/"]
insteadOf = gh:
[url "ssh://git@gist.github.com/"]
insteadOf = gist:
[url "git@bitbucket.org:"]
insteadOf = bb:
[url "gapple@git.drupal.org:project/"]
insteadOf = drupal:
[core]
@gapple
gapple / create-site-cert
Created January 15, 2014 21:51
Create SSL certificates signed by local root certificate. Place in /user/local/etc/apache/ssl with the root and site certs and run from that folder
#! /bin/bash
# Create a private key and certificate, signed by the local root certificate
# http://datacenteroverlords.com/2012/03/01/creating-your-own-ssl-certificate-authority/
if [ -z $1 ]
then
echo "key name is required as an argument"
exit 1
fi
@gapple
gapple / my_model.php
Created December 5, 2012 18:38
CakePHP 1.3 model ordering
<?php
class MyModel extends AppModel {
public function __construct($id = false, $table = null, $ds = null) {
parent::__construct($id, $table, $ds);
$this->order = array(
$this->alias . '.weight ASC',
$this->alias . '.name ASC',
);