Skip to content

Instantly share code, notes, and snippets.

View nullvariable's full-sized avatar
☣️

Doug Cone nullvariable

☣️
View GitHub Profile
@nullvariable
nullvariable / wp-cli.php
Last active February 27, 2019 17:56
use wp-cli as a proxy for typerocket galaxy commands
<?php
if ( defined( 'WP_CLI' ) && WP_CLI ) {
\WP_CLI::add_command( 'galaxy', function () {
$count = count( $_SERVER['argv'] );
for ( $i = 0; $i < $count; $i++ ) {
// strip any preceeding arguments so galaxy isn't confused.
$arg = array_shift( $_SERVER['argv'] );
if ( 'galaxy' == $arg ) {
array_unshift( $_SERVER['argv'], 'galaxy' );
break;
docker cp <dbfile.sql> <container>:/tmp/import.sql
docker exec -it <container> /bin/bash
mysql -u <user> -p <database name> < import.sql
@nullvariable
nullvariable / .lando.yml
Created May 10, 2018 20:04
lando/wordpress blog post
events:
post-db-import:
appserver: >
cd $LANDO_MOUNT
&& wp search-replace "//example.com" "//example.lndo.site" --all-tables
&& wp search-replace "//www.example.com" "//example.lndo.site" --all-tables
@nullvariable
nullvariable / .lando.yml
Last active May 10, 2018 19:41
lando/wordpress blog post examples
services:
pma:
type: phpmyadmin
hosts:
- database
mailhog:
type: mailhog
hogfrom:
- appserver
portforward: true
@nullvariable
nullvariable / index.php
Created January 27, 2017 15:35
set Craft to use local mailhog instance. Just drop in an existing plugin's init function, refresh and then remove (assumes you're using official Mailhog docker instance
<?php
$mailhog_name = getenv('MAILHOG_NAME');
$mailhog_port = getenv('MAILHOG_PORT');
if ($mailhog_name && $mailhog_port) {
$hostname = array_slice(explode('/', getenv('MAILHOG_NAME')), -1, 1)[0];
$port = array_slice(explode(':', getenv('MAILHOG_PORT')), -1, 1)[0];
$settings = craft()->systemSettings->getSettings('email');
$settings['protocol'] = 'smtp';
$settings['port'] = $port;
$settings['host'] = $hostname;
@nullvariable
nullvariable / moduleName.test.php
Last active April 21, 2016 15:02
Mocking a Drupal 7 core function with namespaces
<?php
namespace Same\As\Class\Testing
{
function drupal_valid_token($token = NULL)
{
return ($token == "expected value);
}
class moduleNameTestSuite extendsDrupalWebTestCase
@nullvariable
nullvariable / pi-wifi
Created August 20, 2013 15:43
connect Raspberry Pi to Wifi
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOURSSID"
psk="YOURPASSWORD"
# Protocol type can be: RSN (for WP2) and WPA (for WPA1)
@nullvariable
nullvariable / print_r.js
Created January 2, 2012 20:24
javascript print_r
/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
* The level - OPTIONAL
* Returns : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
* Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php
@nullvariable
nullvariable / view as rows
Created January 17, 2011 21:03
views in a module code
// get your view object
$view = views_get_view('map_point_xml_page');
$view->init_display();
$view->pre_execute();
// execute the view sql
$view->execute();
// this is where the data will go
$rows = array();
// get the results
@nullvariable
nullvariable / webformmail.php
Created November 17, 2010 15:20
example webform additional processing
<?php
//http://api.lullabot.com/drupal_mail
if (isset($form_state['values']['element']) {
drupal_mail('webform', $key, $to, $language, $params, $from, $send)
drupal_mail_send();
}