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
  • 21:48 (UTC +12:00)
View GitHub Profile
@cam8001
cam8001 / response_time.sh
Created December 2, 2014 12:20
response_time.sh
#!/bin/bash
CURL="/usr/bin/curl"
GAWK="/usr/bin/gawk"
URL="$1"
result=`$CURL -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} $URL`
echo "Host: $URL"
echo "Time_Connect Time_startTransfer Time_total
$(echo $result | $GAWK -F: '{ print $1" "$2" "$3}')
" | column -t
@cam8001
cam8001 / keybase.md
Created December 18, 2014 15:08
keybase.md

Keybase proof

I hereby claim:

  • I am cam8001 on github.
  • I am cam8001 (https://keybase.io/cam8001) on keybase.
  • I have a public key whose fingerprint is EC6C CBC2 D6C3 4977 BA4A 52A6 D1E6 98A6 1B4C B576

To claim this, I am signing this object:

@cam8001
cam8001 / acapi.drush.help.json
Created December 19, 2014 12:00
Acquia Cloud API drush commands help
{
"acapi": {
"title": "Acquia commands",
"summary": "Acquia Cloud commands.",
"commands": {
"ac-api-login": {
"description": "Store Acquia Cloud API credentials and configuration information.",
"arguments": [],
"options": {
"email": {
@cam8001
cam8001 / dice.sh
Last active August 29, 2015 14:11 — forked from saltednut/dice.sh
#!/usr/bin/env bash
# Usage: dice makefile docroot dbuser dbpass dbname sitename install-profile
drupal_install_clean_env() {
if [[ -r $2 ]]; then
sudo rm -r $2
cd ~/
fi
if [[ -r $1 ]]; then
drush make --working-copy --concurrency=5 $1 $2
@cam8001
cam8001 / ldap.authsource.php
Created June 25, 2015 21:19
Example simplesamlphp IdP config
<?php
$config = array(
// Example of a LDAP authentication source.
'example-ldap' => array(
'ldap:LDAP',
// Give the user an option to save their username for future login attempts
// And when enabled, what should the default be, to save the username or not
//'remember.username.enabled' => FALSE,
//'remember.username.checked' => FALSE,
@cam8001
cam8001 / acquia.inc
Last active August 29, 2015 14:27 — forked from typhonius/acquia.inc
An include file for the Acquia Cloud to be placed at the docroot/sites/acquia.inc location. May be optionally called from the site's settings.php with further details found on the Acquia Knowledgebase article.
<?php
/**
* @file
* Utilities for use in protecting an environment via basic auth or IP whitelist.
*/
function ac_protect_this_site() {
global $conf;
@cam8001
cam8001 / gist:1700086
Created January 29, 2012 18:45
Building a drupal query
$arg = "%".drupal_get_path_alias($_GET['q'])."%";
echo $arg;
$query = db_select('url_alias', 't');
$query->fields('t');
$query->condition('t.alias', '$arg', 'LIKE');
$query->range(0, 1);
$result = $query->execute();
while ($record = $result->fetchAssoc()) {
print_r($record);
@cam8001
cam8001 / php_closing_tags.sh
Created September 12, 2012 11:19
Find mismatched closing tags in php files
#!/bin/bash
# Find extra ?> tags in a PHP source tree.
# Much thanks to chx (drupal4hu.com) who gave me the regex!
ack '<\?php.*\?>(.(?!<\?php))+\?>' .
@cam8001
cam8001 / remove_conf_vars.sh
Created October 10, 2012 17:12
Removing conf vars from site.conf.php (or whatever)
# Only works for vars that are expressed on one line, grep -A1 or a multilne pcregrep
# might be useful if you have longer var definitions.
# Check extant definitions
egrep "[$]conf\['related_videos_return'\]" --include site.conf.php .
# Blast em (note bsd/osx sed syntax, the first "" is not needed on gnu grep)
find . -type f -name site.conf.php -exec sed -i "" "/[$]conf\['related_videos_return'\]/d" {} \;
# Check them again, they are gone!
egrep "[$]conf\['related_videos_return'\]" --include site.conf.php .
@cam8001
cam8001 / gist:3956062
Created October 25, 2012 23:14
backtrace of _drupal_log_error notice
<?php
array(
0 =>
array (
'file' => '/Users/cam8001/Sites/drupal/core/includes/bootstrap.inc',
'line' => 2220,
'function' => '_drupal_log_error',
'args' =>
array (