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
// Get headers from input.
orgLevelHeaders = document.getElementById('org_level_headers').value.split(',');
// Cut the data headers from the levels.
// Length will be the number of columns needed to determine hierarchy.
const dataHeaders = results.meta.fields.splice(orgLevelHeaders.length);
let varString = 'finalData';
results.data.forEach(function (el, index) {
for (i = 0; i < orgLevelHeaders.length; i++) {
@alexfinnarn
alexfinnarn / Person.php
Created September 19, 2018 17:34
sample generated model
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
@alexfinnarn
alexfinnarn / schema.yaml
Last active September 19, 2018 17:29
fields taken from schema.org
types:
Thing:
parent: false
properties:
alternateName: ~
description: ~
identifier: ~
image: ~
name: ~
url: ~
@alexfinnarn
alexfinnarn / .travis.yml
Created August 23, 2018 22:43
new travis file for Backdrop testing template
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 / backdrop_test_users.php
Last active August 23, 2018 22:36
user role config info hook
<?php
/**
* Implements hook_config_info().
*/
function backdrop_test_users_config_info() {
$prefixes = array();
$prefixes['user.role.developer'] = array(
'name_key' => 'name',
'label_key' => 'label',
@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.');
@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 / .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 / 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 / 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.