Skip to content

Instantly share code, notes, and snippets.

@FlorianBouron
FlorianBouron / multiple-deploy-keys-multiple-private-repos-github-ssh-config.md
Last active April 6, 2023 16:55
How to configure multiple deploy keys for different private github repositories on the same computer

This is probably a common issue for people who wants to deploy serveral repository on one VPS or VM.

This is not going to be rocket science.

The first step is to generate your first ssh key, for this type the following command line in your terminal: ssh-keygen -t rsa -b 4096 -C "your@email.com" When the command CLI is asking you if you want to use a passphrase you might want to press ENTER in order to don't have to type it everytime you will want to pull your repository.

Now copy the content of your public key and add it to Github in your first repository (Settings > Deploy keys). For example on debian it might be:

@Erikdekamps
Erikdekamps / add_translations.install
Last active June 6, 2023 07:40
Drupal 8 - Programmatically translate strings via hook_update_N()
/**
* Helper function for adding translations.
*
* @param array $strings
* The array with strings and their translations.
*/
function _my_module_add_translations(array $strings) {
// Get locale storage service.
$storage = \Drupal::service('locale.storage');
@steffenr
steffenr / id_map_custom.php
Created January 29, 2018 07:23
[Drupal 8] Override id map with custom plugin for migrations
<?php
/**
* Implements hook_migration_plugins_alter().
*/
function my_module_migration_plugins_alter(array &$migrations) {
foreach ($migrations as $id => $configuration) {
if (!empty($migrations[$id]['idMap'])) {
// Do not override existing values.
continue;
@vivianspencer
vivianspencer / gist:656c8eee367f44e4742192c7e56e39f8
Last active December 21, 2018 09:07
Drupal 8 Get allowed values of field
$values = FieldConfig::loadByName('node', 'BUNDLE', 'FIELD')->getSetting('allowed_values');
@jonhattan
jonhattan / tmux.md
Last active March 9, 2018 11:03
tmux quickstart

tmux quickstart

$ tmux

CTRL+B C -> create new pane

CTRL+B [num] -> go to a pane

CTRL+D -> finish bash session, closes the pane. Closing all panes will destroy the window and thus the tmux

@rwjblue
rwjblue / application.controller.js
Created December 14, 2015 18:07 — forked from barneycarroll/application.controller.js
Can't access object values by dynamic key in Handlebars
import Ember from 'ember';
export default Ember.Controller.extend({
numbers:['1','2','3','4'],
letters:['a','b','c','d']
});
@jonhattan
jonhattan / example_ajax.php
Last active November 17, 2023 15:28
Drupal 8 - detect if we're in an ajax request, and if building the form for the first time, or re-building within the input processing.
<?php
use Drupal\Core\Form\FormStateInterface;
function example_ajax_form_alter() {
$ajax_form_request = \Drupal::request()->query->has(FormBuilderInterface::AJAX_FORM_REQUEST);
if ($ajax_form_request) {
if (!$form_state->isProcessingInput()) {
\Drupal::logger('example')->notice('first pass');
}
@jamesarosen
jamesarosen / ember-xss.md
Created October 28, 2015 16:50
Ember and XSS Safety

TL;DR

In Ember, always use {{...}}, not {{{...}}}. Use Ember.String.htmlSafe as necessary in JavaScript (usually in a component) to mark markup as HTML-safe. Never pass user-entered content directly to Ember.String.htmlSafe.

Details

Ember has great XSS protection built in. The HTMLBars templating library will automatically run any interpolations through htmlEscape for you. So

@jonhattan
jonhattan / sb_surgery.drush.inc
Created September 29, 2015 18:46
Drush command to inspect cache config of blocks, views and panels
<?php
function sb_surgery_drush_command() {
$items = array();
$items['cache-status'] = array(
'description' => 'Show cache status for each block, view, panel or minipanel',
);
return $items;
}
@bojanz
bojanz / extension-patterns.md
Last active January 14, 2023 16:59
Extension patterns: events, tagged services, plugins

This documentation is destined for drupal.org. Created first as a gist to make initial comments easier. Rewrites and clarifications welcome. Code samples are simplified for clarity. Perhaps a bit too much?

When talking about extensibility, there are several distinct use cases:

  1. Reacting to an action that has already happened.

The reaction can be anything; outputting a message, sending an email, modifying a related object, etc. Examples:

  • "A node has been saved"
  • "A product has been added to the cart".