Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
lol no

Cameron Tod cam8001

💭
lol no
  • Wellington, New Zealand
View GitHub Profile
@cam8001
cam8001 / adblock_hosts.sh
Created Aug 26, 2015
Block a curated selection of ad and malware servers via local host resolution.
View adblock_hosts.sh
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 Feb 17, 2014
Patch to add settings.local.php support. Note that this won't work as a patch atm, it's just for reference.
View settings.local.patch
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 Feb 17, 2014
Use .htaccess so that you request remote files from your production server.
View .htaccess
### 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/.*$
View gist:9375657
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']
@cam8001
cam8001 / drupal_scan_large_cache_objects.php
Last active Aug 29, 2015
drupal_scan_large_cache_objects.php
View drupal_scan_large_cache_objects.php
<?php
$user = '';
$pass = '';
$database = '';
$limit = 1000000;
$dsn = 'mysql:dbname=' . $database . ';unix_socket=/var/run/mysqld/mysqld.sock';
try {
View golocal.drush.inc
<?php
/**
* @file
* Custom Drush integration.
*/
/**
* Implements hook_drush_command().
*
* @return
@cam8001
cam8001 / ah_sync_backups.sh
Created May 30, 2014
Download all stored database dumps from Acquia cloud
View ah_sync_backups.sh
# 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 Aug 29, 2015
Example views datasource output
View reviews.xml
<?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 Sep 8, 2014
Sum a bundle in SFDC
View sum_bundle.js
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 Aug 29, 2015
Bookmarklet - Convert github issue to bash-safe git branch name
View bookmarklet.js
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());