Skip to content

Instantly share code, notes, and snippets.

@FlorianBouron
FlorianBouron / multiple-deploy-keys-multiple-private-repos-github-ssh-config.md
Last active Nov 18, 2022
How to configure multiple deploy keys for different private github repositories on the same computer
View multiple-deploy-keys-multiple-private-repos-github-ssh-config.md

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 Apr 14, 2021
Drupal 8 - Programmatically translate strings via hook_update_N()
View add_translations.install
/**
* 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 Jan 29, 2018
[Drupal 8] Override id map with custom plugin for migrations
View id_map_custom.php
<?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 Dec 21, 2018
Drupal 8 Get allowed values of field
View gist:656c8eee367f44e4742192c7e56e39f8
$values = FieldConfig::loadByName('node', 'BUNDLE', 'FIELD')->getSetting('allowed_values');
@jonhattan
jonhattan / tmux.md
Last active Mar 9, 2018
tmux quickstart
View tmux.md

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 Dec 14, 2015 — forked from barneycarroll/application.controller.js
Can't access object values by dynamic key in Handlebars
View application.controller.js
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 Apr 5, 2022
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.
View example_ajax.php
<?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 Oct 28, 2015
Ember and XSS Safety
View ember-xss.md

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 Sep 29, 2015
Drush command to inspect cache config of blocks, views and panels
View sb_surgery.drush.inc
<?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 Dec 9, 2020
Extension patterns: events, tagged services, plugins
View extension-patterns.md

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".