Skip to content

Instantly share code, notes, and snippets.

View cam8001's full-sized avatar
💭
lol no

Cameron Tod cam8001

💭
lol no
  • Amazon Web Services
  • Wellington, New Zealand
  • 02:36 (UTC +12:00)
View GitHub Profile
@cam8001
cam8001 / adblock_hosts.sh
Created August 26, 2015 14:59
Block a curated selection of ad and malware servers via local host resolution.
wget -qO- "http://winhelp2002.mvps.org/hosts.txt" "http://someonewhocares.org/hosts/zero/hosts" "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&startdate[day]=&startdate[month]=&startdate[year]=&mimetype=plaintext&useip=0.0.0.0" | grep -w ^0.0.0.0 | sed $'s/\r$//' | sort -u >> /etc/hosts
@cam8001
cam8001 / settings.local.patch
Created February 17, 2014 12:48
Patch to add settings.local.php support. Note that this won't work as a patch atm, it's just for reference.
commit f1f7f92eff14a56fd3eec137b4d25f8eae8b139c
Author: Cameron Tod <cameron.tod@gmail.com>
Date: Mon Feb 17 12:32:35 2014 +0000
Added local settings include, to ease debugging of memory issue.
diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,5 @@
@cam8001
cam8001 / .htaccess
Created February 17, 2014 13:00
Use .htaccess so that you request remote files from your production server.
### Apache Rewrite
RewriteEngine on
# Force image styles that have local files that exist to be generated.
RewriteCond %{REQUEST_URI} ^/sites/([^\/]*)/files/styles/[^\/]*/public/((.*))$
RewriteCond %{DOCUMENT_ROOT}/sites/%1/files/%2 -f
RewriteRule ^(.*)$ $1 [QSA,L]
# Otherwise, send anything else that's in the files directory to the
# production server.
RewriteCond %{REQUEST_URI} ^/sites/[^\/]*/files/.*$
diff --git a/core/core.services.yml b/core/core.services.yml
index c158be4..8a853fc 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -110,7 +110,7 @@ services:
arguments: [default]
form_builder:
class: Drupal\Core\Form\FormBuilder
- arguments: ['@module_handler', '@keyvalue.expirable', '@event_dispatcher', '@url_generator', '@string_translation', '@?csrf_token', '@?http_kernel']
+ arguments: ['@module_handler', '@keyvalue.expirable', '@event_dispatcher', '@url_generator', '@string_translation', '@?csrf_token', '@?http_kernel', '@config.factory']
<?php
/**
* @file
* Custom Drush integration.
*/
/**
* Implements hook_drush_command().
*
* @return
@cam8001
cam8001 / drupal_scan_large_cache_objects.php
Last active August 29, 2015 14:01
drupal_scan_large_cache_objects.php
<?php
$user = '';
$pass = '';
$database = '';
$limit = 1000000;
$dsn = 'mysql:dbname=' . $database . ';unix_socket=/var/run/mysqld/mysqld.sock';
try {
@cam8001
cam8001 / ah_sync_backups.sh
Created May 30, 2014 08:16
Download all stored database dumps from Acquia cloud
# Download all database backups from Acquia Cloud.
drush @SITE.ENV ac-database-instance-backup-list SITE | grep id | head -1 | awk -F ":" '{print $2}' | xargs drush @SITE.ENV ac-database-instance-backup-download DBNAME > backup_file.sql.gz
@cam8001
cam8001 / reviews.xml
Last active August 29, 2015 14:04
Example views datasource output
<?xml version="1.0" encoding="utf-8"?>
<node>
<node>
<title>It was ok</title>
<Rating>5</Rating>
<Body>One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment
</Body>
<merchant_id>12345</merchant_id>
</node>
<node>
@cam8001
cam8001 / sum_bundle.js
Created September 8, 2014 19:50
Sum a bundle in SFDC
sum = 0;
// Get Bundle 2.
var bundle = jQuery('.editPage .pbBody').children('div')[1];
jQuery('td[id*=j_id292]', bundle).each(function(index, value){
line_item_cost = value.innerHTML;
line_item_cost = +line_item_cost.replace(/[^\d\.-]/g,'');
sum = sum + parseFloat(line_item_cost);
});
@cam8001
cam8001 / bookmarklet.js
Last active August 29, 2015 14:07
Bookmarklet - Convert github issue to bash-safe git branch name
javascript:window.prompt('Branch name - copy to clipboard :)', 'issues/' + document.getElementsByClassName('gh-header-number')[0].innerHTML.replace(/#/, '') + '/' + document.getElementsByClassName('js-issue-title')[0].innerHTML.replace(/ /g, '-').toLowerCase());