Skip to content

Instantly share code, notes, and snippets.

@nullvariable
nullvariable / .lando.yml
Last active May 10, 2018
lando/wordpress blog post examples
View .lando.yml
services:
pma:
type: phpmyadmin
hosts:
- database
mailhog:
type: mailhog
hogfrom:
- appserver
portforward: true
View gist:cadd8d05fd3b9965713cddecc8678225
docker cp <dbfile.sql> <container>:/tmp/import.sql
docker exec -it <container> /bin/bash
mysql -u <user> -p <database name> < import.sql
@nullvariable
nullvariable / index.php
Created Jan 27, 2017
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
View index.php
<?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 / example.css
Last active Oct 20, 2019
Create an image cap for Bootstrap 4 that aligns on the left side of a card
View example.css
.card-img-left {
border-bottom-left-radius: calc(.25rem - 1px);
border-top-left-radius: calc(.25rem - 1px);
float: left;
padding-right: 1em;
margin-bottom: -1.25em;
}
@nullvariable
nullvariable / moduleName.test.php
Last active Apr 21, 2016
Mocking a Drupal 7 core function with namespaces
View moduleName.test.php
<?php
namespace Same\As\Class\Testing
{
function drupal_valid_token($token = NULL)
{
return ($token == "expected value);
}
class moduleNameTestSuite extendsDrupalWebTestCase
@nullvariable
nullvariable / settings.php
Last active Aug 29, 2015
screen options hack code
View settings.php
<?php
$screen = get_current_screen();
add_filter('manage_' . $screen->id . '_columns', 'my_true_false_option');
function my_true_false_option() {
return array("my_true_false_option" => __("My True/False Option", 'translation-context'));
}
?>
<table id="fake_column">
@nullvariable
nullvariable / pi-wifi
Created Aug 20, 2013
connect Raspberry Pi to Wifi
View pi-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 Jan 2, 2012
javascript print_r
View print_r.js
/**
* 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 Jan 17, 2011
views in a module code
View view as rows
// 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 Nov 17, 2010
example webform additional processing
View webformmail.php
<?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();
}