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
<?php
/**
* Implements hook_page_alter().
*/
function code_syntax_highlighting_bundle_page_alter() {
// Add the JS and CSS assets if the page is supposed to have code syntax highlighting.
$current_object = menu_get_object();
if (in_array($current_object->type, config_get('code_syntax_highlighting_bundle.settings','csh_enabled_node_types'), TRUE)) {
backdrop_add_css(backdrop_get_path('module', 'code_syntax_highlighting_bundle')
. '/libraries/highlightjs/styles/' . config_get('code_syntax_highlighting_bundle.settings','csh_theme') . '.css');
@alexfinnarn
alexfinnarn / composer.json
Created August 21, 2018 16:49
behat composer file
{
"require": {
"behat/mink-extension": "~2.3",
"behat/mink-goutte-driver": "~1.2",
"behat/mink-selenium2-driver": "~1.3"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"bin-dir": "bin/"
@alexfinnarn
alexfinnarn / behat.travis.yml
Created August 21, 2018 16:58
behat config file
default:
# Ignore certain tags so they don't have to be excluded on the commandline.
gherkin:
filters:
tags: "~@broken"
# Not sure if this is the best, but it sounds nice.
formatters:
pretty: true
suites:
my_suite:
@alexfinnarn
alexfinnarn / build-express.sh
Last active August 21, 2018 17:31
running some drush commands
# Install a site.
$HOME/.composer/vendor/bin/drush si --db-url=mysql://backdrop:backdrop@127.0.0.1/backdrop -y
# Boot up the server.
$HOME/.composer/vendor/bin/drush backdrop-runserver 127.0.0.1:8057 > /dev/null 2>&1
# Enable a module.
$HOME/.composer/vendor/bin/drush en ${MODULE_NAME} -y
# This function takes the output of the last command and exits if it failed.
earlyexit() {
CODE="$?"
if [ "${CODE}" != "0" ]; then
echo ---
echo Exiting on failure...
echo ---
exit 1
fi
echo Script succeeded.
@alexfinnarn
alexfinnarn / helper-functions.sh
Created August 21, 2018 17:37
earlyexit helper function
# This function takes the output of the last command and exits if it failed.
earlyexit() {
CODE="$?"
if [ "${CODE}" != "0" ]; then
echo ---
echo Exiting on failure...
echo ---
exit 1
fi
echo Script succeeded.
@alexfinnarn
alexfinnarn / run-simpletests.sh
Created August 21, 2018 17:39
running simpletests
#!/usr/bin/env bash
cd ${ROOT_DIR}/backdrop
# Enable Testing module.
$HOME/.composer/vendor/bin/drush en simpletest -y
# Run SimpleTests.
php ./core/scripts/run-tests.sh --url http://127.0.0.1:8057 --php ~/.phpenv/versions/$(phpenv version-name)/bin/php "${SIMPLETEST_CLASSES}"
earlyexit
@alexfinnarn
alexfinnarn / .travis.yml
Created August 21, 2018 17:52
example travis file
language: php
# We want to avoid sudo. This allow us to use Travis docker infrastructure, which means builds start faster and have more CPU available.
sudo: false
git:
depth: 1
php:
- '7.1'
@alexfinnarn
alexfinnarn / install.sh
Last active August 21, 2018 17:55
install codebase
# Clone down Backdrop.
cd $ROOT_DIR
echo "Cloning Backdrop repo..."
git clone --branch 1.x --depth 1 https://github.com/backdrop/backdrop.git ${ROOT_DIR}/backdrop
# ...bunch more stuff...
# Clone down and install contrib modules.
for i in $(echo ${ADD_CONTRIB_MODULES} | sed "s/ / /g")
do
@alexfinnarn
alexfinnarn / user_roles.php
Last active August 23, 2018 22:31
getting all roles
<?php
function user_roles($members_only = FALSE, $permission = NULL, $full_objects = FALSE) {
$user_roles = &backdrop_static(__FUNCTION__);
if (!isset($user_roles)) {
$user_roles = array();
// @todo: Consider a cache get here instead of reading from disk.
$names = config_get_names_with_prefix('user.role.');