Skip to content

Instantly share code, notes, and snippets.

View jpoesen's full-sized avatar

Joeri Poesen jpoesen

View GitHub Profile
@davidjguru
davidjguru / Blocks.md
Created November 12, 2020 17:47 — 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

$block_manager = \Drupal::service('plugin.manager.block');
@lcube45
lcube45 / Blocks.md
Created January 13, 2020 15:36 — 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

$block_manager = \Drupal::service('plugin.manager.block');
@Felk
Felk / ffmpeg_example.py
Last active May 21, 2020 20:24
example of lightweight ffmpeg wrapper in python
pipeline = ffmpeg.Pipeline()
silence, = pipeline.input(Filter("aevalsrc", 0, 1, filter_options=[ # using anullsrc corrupts the audio
"0", "channel_layout=stereo", "sample_rate=44100"
]))
color, = pipeline.input(Filter("color", 0, 1, filter_options=[
"color=0x009999",
"duration=" + str(duration),
"rate=" + str(config.framerate),
"size=1920x1080",
]))
@lolandese
lolandese / Yaml2Array.php
Last active January 14, 2022 13:36
Convert a Drupal YAML configuration file to an array as a working PHP code snippet to write its values to the database. This is code to generate code. Short URL: https://git.io/fjjDu
<?php
/**
* @file
* Convert a YAML file to PHP code to write its values to the database.
*/
use Drupal\Component\Serialization\Yaml;
// Replace 'filter.format.full_html' with any other existing configuration
@paboden
paboden / D8_translation_language_direction_tweaks
Created May 13, 2019 19:31
D8 language tweaks for better output between interface and content language
/**
* Some simple modifications that can help when dealing with an admin/interface language
* and a content language that have different directions (dir: ltr or rtl)
*
* Snippet to get current language of content.
* \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)
*
* Snippet to get current language of interface. This should be set to the users admin preference.
* \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE)
*
@muralikg
muralikg / background.js
Last active June 8, 2023 09:19
puppeteer screen capture demo. Currently records 10 second video. Change the timeout in background.js with your own logic to stop the recording when necessary. Try with `node export.js`
/* global chrome, MediaRecorder, FileReader */
chrome.runtime.onConnect.addListener(port => {
let recorder = null
port.onMessage.addListener(msg => {
console.log(msg);
switch (msg.type) {
case 'REC_STOP':
console.log('Stopping recording')
if (!port.recorderPlaying || !recorder) {
@bdlangton
bdlangton / Blocks.md
Last active October 12, 2023 08:40
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

$block_manager = \Drupal::service('plugin.manager.block');
@cesarmiquel
cesarmiquel / drupal-8-cheatsheet.md
Last active May 24, 2024 06:01
Drupal 8/9/10 Cheatsheet

Drupal 8 Cheatsheet

[Update 2024] - This gist is almost useless compared to Drupal at your fingertips. Will create pull requests to update that if something is not already there.

Files, Images and Media

// Load file object
$file = File::load($fid);
@crittermike
crittermike / ExampleModuleController.php
Last active June 17, 2021 12:55
Example of overriding a route controller in Drupal 8
<?php
/**
* @file
* Contains \Drupal\example_module\Controller\ExampleModuleController.
*/
// THIS FILE BELONGS AT /example_module/src/Controller/ExampleModuleController.php
namespace Drupal\example_module\Controller;

aws-cli bash helper functions

The official AWS command line tools, have support for configuration profiles. See Configuring the AWS Command Line Interface - Named Profiles.

Managing multiple profiles with the AWS CLI itself is relatively straight forward, switching between them with --profile flag on the command line or the AWS_PROFILE environment variable.

These helpers extend that functionality for convenience with other tools in the ecosystem.

aws-profile