Skip to content

Instantly share code, notes, and snippets.

View alexfinnarn's full-sized avatar
🐙
Curious with tentacles

Alex Finnarn alexfinnarn

🐙
Curious with tentacles
View GitHub Profile
@alexfinnarn
alexfinnarn / db-slaves-02.php
Last active March 7, 2018 16:11
Linkchecker Original Code
<?php
// Remove all links from the links array already in the database and only
// add missing links to database.
$missing_links = _linkchecker_bean_links_missing($bean->bid, $links);
// Ignore slave database briefly.
variable_set('maximum_replication_lag', 300);
db_ignore_slave();
<?php
db_merge('linkchecker_bean')
->key(array(
'bid' => $bean->bid,
'lid' => $link->lid,
))
->fields(array(
'bid' => $bean->bid,
'lid' => $link->lid,
<?php
$txn = db_transaction();
try {
db_insert('linkchecker_bean')
->fields(array(
'bid' => $bean->bid,
'lid' => $link->lid,
))
->execute();
<?php
// Ignore slave database briefly.
variable_set('maximum_replication_lag', 300);
db_ignore_slave();
// Remove all links from the links array already in the database and only
// add missing links to database.
$missing_links = _linkchecker_bean_links_missing($bean->bid, $links);
@alexfinnarn
alexfinnarn / db-slaves-06.php
Created March 7, 2018 18:19
System module hook_init()
<?php
function system_init() {
$path = drupal_get_path('module', 'system');
// Add the CSS for this module. These aren't in system.info, because they
// need to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
drupal_add_css($path . '/system.base.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE));
if (path_is_admin(current_path())) {
drupal_add_css($path . '/system.admin.css', array('group' => CSS_SYSTEM));
}
@alexfinnarn
alexfinnarn / much-better-than-medium.sh
Last active May 6, 2018 15:26
Showing how much better Gists look than Medium code blocks.
# Run JS tests if merging PR into dev or has JS in it.
if [ "${TRAVIS_EVENT_TYPE}" == "push" ] || [ "${EXPRESS_COMMIT_HAS_JS}" ]; then
echo "Running Express JS tests..."
${ROOT_DIR}/drupal/profiles/express/tests/behat/bin/behat --stop-on-failure --strict --config ${ROOT_DIR}/drupal/profiles/express/tests/behat/behat.travis.yml --verbose --tags ${EXPRESS_JS_BEHAT_TAGS}
earlyexit
else
echo "Not Running Express JS tests..."
fi
@alexfinnarn
alexfinnarn / example.lando.yml
Created May 17, 2018 16:47
My Half-assed Lando Config File
name: express
recipe: drupal7
config:
webroot: web
xdebug: true
php: "7.1"
conf:
php: config/php/zzzzzz-express-custom.ini
#database: config/mysql/.my.cnf
services:
@alexfinnarn
alexfinnarn / code_syntax_highlighting_bundle.php
Last active August 8, 2018 20:54
WYSIWYG to CKEdtior hooks
<?php
/**
* Implements of hook_wysiwyg_plugin().
*/
function code_syntax_highlighting_bundle_wysiwyg_plugin($editor, $version) {
// Add the code button for the ckeditor.
if ($editor === 'ckeditor') {
return array(
'code_sc' => array(
@alexfinnarn
alexfinnarn / plugin.js
Last active August 8, 2018 21:56
need to add variables to pass into function
(function ($) {
CKEDITOR.plugins.add('code_sc', {
// more code...
})(jQuery);
@alexfinnarn
alexfinnarn / plugin.js
Created August 9, 2018 17:03
final plugin code
(function ($, Backdrop, CKEDITOR) {
"use strict";
CKEDITOR.plugins.add('csh', {
init: function (editor) {
editor.addCommand('csh_command', new CKEDITOR.dialogCommand('code_sc_generatorDialog'));
if (editor.ui.addButton) {
editor.ui.addButton('CSH', {