Skip to content

Instantly share code, notes, and snippets.

View shelane's full-sized avatar

Shelane French shelane

View GitHub Profile
@shelane
shelane / .gitignore
Last active November 6, 2018 19:40 — forked from octocat/.gitignore
Some common .gitignore configurations
# git config --global core.excludesfile ~/.gitignore_global
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
@shelane
shelane / gist:653f0de69f9dca4eeb440bfe86e3cf55
Created March 13, 2019 22:14
DRUPAL bootstrap dropdown override
/*
* Bootstrap override
* make dropdown menus do dropdown on hover,
* and allow parent link to be clickable
*/
// place this in your styles
ul.nav li.dropdown:hover > ul.dropdown-menu{
display: block !important;
}
@shelane
shelane / git_create_orphan.sh
Created April 30, 2020 02:58 — forked from seanbuscay/git_create_orphan.sh
Create an orphan branch in a repo.
cd repository
git checkout --orphan orphan_name
git rm -rf .
rm '.gitignore'
echo "#Title of Readme" > README.md
git add README.md
git commit -a -m "Initial Commit"
git push origin orphan_name
@shelane
shelane / ask.sh
Created July 21, 2020 03:34
Bash General-Purpose Yes/No Prompt Function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# https://djm.me/ask
local prompt default reply
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
@shelane
shelane / drupal8-links.php
Created October 9, 2020 23:47 — forked from colorfield/drupal8-links.php
Drupal 8 links, or where is my l() function
@shelane
shelane / MyService.php
Created October 10, 2020 03:53 — forked from JeffTomlinson/MyService.php
Drupal 8 Configuration Dependency Injection
<?php
namespace Drupal\my_module\Services;
use Drupal\Core\Config\ConfigFactory;
/**
* Class MyService.
*
* @package Drupal\my_module\Services
@shelane
shelane / placeholders.php
Created November 15, 2020 05:18
t function variables
Including a link:
$link = Link::fromTextAndUrl($this->t('Bootstrap Documentation'), Url::fromUri('https://getbootstrap.com/docs/3.4/css/#grid-example-mixed-complete', ['attributes' => ['target' => '_blank']]))->toString();
'#description' => $this->t('When this option is selected, clearfix divs will be used to "clear" the columns as needed per device size (see %bootstrap_docs). Please note this option applies only when "Single row" is selected for the "Number of columns per view row" option.',
['%bootstrap_docs' => $link]),
The most common placeholder is probably @variable. This placeholder runs static::placeholderEscape() on the text before replacing it.
You may also use %variable, which runs placeholderEscape() on the text similar to @ placeholders. Using this placeholder will also create <em> tags around the placeholder values.
<?php
/**
* @file
* Token related hook implementations.
*/
use Drupal\Core\Render\BubbleableMetadata;
/**
@shelane
shelane / nodemaker_term_create.php
Created March 2, 2021 19:52 — forked from himerus/nodemaker_term_create.php
Create a taxonomy term programmatically in Drupal 8.
<?php
/**
* @file
* Contains various helper functions.
*/
use Drupal\taxonomy\Entity\Term;
/**
@shelane
shelane / D9 example code
Created May 10, 2021 22:29
Basic code examples for Drupal 9
<?php
// Load a Node
use Drupal\node\Entity\Node;
$node = Node::load($nid);
// Load Multiple Nodes
use Drupal\node\Entity\Node;
$nodes = Node::loadMultiple($nids);