Skip to content

Instantly share code, notes, and snippets.

View bfodeke's full-sized avatar

Bayo Fodeke bfodeke

  • Red Hat
  • United States
View GitHub Profile
@bfodeke
bfodeke / appScriptsCreateForm
Created June 2, 2023 16:37
AppsScript to create google form programmatically. You will still need to connect the form to an existing sheet or create a new spreadsheet
function createForm() {
// Create a new Form.
var form = FormApp.create('Issue Priority Assessment');
var questions = [
{
title: 'Issue Impact',
options: [
'No impact on production today',
'Partial impact on production today',
@bfodeke
bfodeke / bradvin.social.share.urls.txt
Created January 11, 2023 19:17 — forked from HoldOffHunger/bradvin.social.share.urls.txt
Social Share URL's (Summary)
https://www.facebook.com/sharer.php?u={url}
https://www.facebook.com/dialog/share?app_id={app_id}&display={page_type}&href={url}&redirect_uri={redirect_url}
https://reddit.com/submit?url={url}&title={title}
https://twitter.com/intent/tweet?url={url}&text={title}&via={user_id}&hashtags={hash_tags}
https://www.linkedin.com/sharing/share-offsite/?url={url}
https://api.whatsapp.com/send?phone={phone_number}&text={title}%20{url}
https://www.tumblr.com/widgets/share/tool?canonicalUrl={url}&title={title}&caption={text}&tags={hash_tags}
http://pinterest.com/pin/create/button/?url={url}
https://www.blogger.com/blog-this.g?u={url}&n={title}&t={text}
https://www.evernote.com/clip.action?url={url}&title={title}
@bfodeke
bfodeke / drupal_8_twig_cheatsheet.md
Created August 17, 2022 17:43 — forked from raphaellarrinaga/drupal_8_twig_cheatsheet.md
[Drupal 8 Twig cheatsheet] #tags: drupal8, twig, cheatsheet

Drupal 8 Twig cheatsheet

Please note I created that sheet as a personal side note/draft and not everything is fully tested. There could be errors or better things to do. So if you spot something wrong or something that can be improved, feel free to comment below and I will do the changes.

Getting Drupal 8 field values in Twig

Image path: {{ file_url(content.field_name['#items'].entity.uri.value) }}

@bfodeke
bfodeke / MySQL View Table Sizes
Created March 28, 2022 18:10
Query the database to view tables by size. Replace `[database_name]` with the name of your database
SELECT table_name AS 'Table', TABLE_ROWS as 'Num. of Rows', round(((data_length + index_length) / 1024 / 1024), 2) 'Size in MB'
FROM information_schema.TABLES where table_schema = '[database_name]'
ORDER BY (data_length + index_length) DESC
LIMIT 200;
@bfodeke
bfodeke / mediaquery.hook.js
Created July 6, 2021 15:49
React mediaquery hook
import { useState, useEffect } from 'react';
export function useMediaQuery(query) {
const [matches, setMatches] = useState(false);
useEffect(() => {
const media: MediaQueryList = window.matchMedia(query);
if (media.matches !== matches) {
setMatches(media.matches);
}
@bfodeke
bfodeke / Blocks.md
Last active July 14, 2021 16:05 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

Creating a block instance

@bfodeke
bfodeke / gist:7090e12425f04e104af1034366731138
Created December 17, 2020 20:24
D8/Twig: Get URL of embedded media entity reference
// https://createdbycocoon.com/knowledge/get-media-video-url-twig-drupal-8
Sometimes it may be useful to access the raw media file URL/URI value for a video file that has been uploaded via a Media field on an entity type.
In your Twig template, you may wish to display the raw URL of the file, rather than the embedded video or rendered entity as Drupal 8 natively provides.
It's really simple to access the raw URI. Simply use the following syntax in your Twig file (which will work for nodes, custom block templates, and paragraphs):
`{{ file_url(content.field_video[0]['#media'].field_media_video_file.entity.uri.value) }}`
@bfodeke
bfodeke / gist:270d15b206c420b22b83268255c2e2ba
Created October 20, 2020 21:29
Drupal 8: Uninstall module that has already been removed
// https://www.drupal8.ovh/en/tutoriels/372/remove-uninstall-deleted-module-drupal-registry
drush sql-query "DELETE FROM key_value WHERE collection='system.schema' AND name='module_name';"
@bfodeke
bfodeke / behat.local.yml
Created May 23, 2019 15:32
Behat: Local behat settings
#local configuration
default:
extensions:
Behat\MinkExtension:
base_url: http://localdev.dev
sessions:
default:
goutte:
guzzle_parameters:
verify: false #get around ssl cert on local environment
@bfodeke
bfodeke / gist:4fc790b6ea27e7a500bf6b37e6872933
Created May 23, 2019 15:26
Behat: Logging in to accounts via email or username using drush
/**
* @Given I log in as :name
*/
public function iLogInAs($name) {
$domain = $this->getMinkParameter('base_url');
// Pass base url to drush command.
$uli = $this->getDriver('drush')->drush('uli', array(
"'" . $name . "'",
"--browser=0",
"--uri=$domain",