Skip to content

Instantly share code, notes, and snippets.

@opi
opi / skype_on_debian_stretch.md
Last active July 1, 2021 21:56
Install Skype on Debian Stretch

Install Skype on Debian Stretch

Install the GPG key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1F3045A5DF7587C3

Ensure apt is set up to work with https sources:

sudo apt-get install apt-transport-https
@opi
opi / backdrop_import_user.php
Created March 1, 2018 21:45
Backdrop import user from csv
<?php
function MYMODULE_import() {
// Path relative to document root
$csv_filepath = backdrop_get_path('module', 'MYMODULE');
$csv_filepath .= '/user_list.csv';
if ($handle = fopen($csv_filepath, 'r') ) {
// Read from CSV
@opi
opi / backdrop_drush.md
Last active February 5, 2018 15:44
Backdrop Drush
@opi
opi / drupal8_sharing_code.md
Last active December 7, 2017 08:27
Drupal8 : The safe sequence for sharing code and configuration

The safe sequence for sharing code and configuration

  1. Export configuration: drush cex
  2. Commit your code: git add && git commit
  3. Merge upstream: git pull
  4. Update dependencies: composer install
  5. Run database updates: drush updb
  6. Import configuration: drush cim
  7. Push your code: git push
@opi
opi / drupal8_views_exposed_form_theme_suggestions.php
Created November 28, 2017 11:13
Drupal8 - Custom views exposed form suggestions
<?php
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function MYTHEME_theme_suggestions_views_exposed_form_alter(array &$suggestions, array $vars) {
// form[#id] pattern is views-exposed-form-VIEWNAME-DISPLAY
// We need to remove the 'views-exposed-form-' part
// and to replace underscores with dashes
$suggestions[] = 'views_exposed_form__' . str_replace(
@opi
opi / mailhog.md
Last active January 27, 2023 23:19
Install and configure MailHog (for Drupal) with a nice systemd unit and apache reverse proxy

MailHog (for Drupal) on Debian Stretch

MailHog is a nice mail testing tool for developers.

Website: https://github.com/mailhog/MailHog

Installation

Download the latest release on your local machine

@opi
opi / extra_field_token.php
Created November 10, 2017 13:27
Add a sub token for a node field
<?php
/**
* Implements hook_token_info_alter()
*/
function MODULE_token_info_alter(&$data) {
// Modify description of node tokens for our site.
$data['tokens']['node-field_myfield']['foo'] = [
'name' => "Foo",
'description' => "Process field_myfield value"
@opi
opi / drupal_multiple_field_add_to_top.php
Last active May 11, 2017 14:17
Drupal multiple field : Add new item on top of the list
<?php
// Insert new item on top of the list.
// Display file input first for better UI (https://lut.im/0AkZwIQOUa/dtzEPerqgp3hQ3hk.png)
// In a .module
/**
pub 4096R/C061B01D 2013-06-20
Empreinte de la clef = A975 C4B7 A021 5442 0D36 0E92 246F 5501 C061 B01D
uid [email protected] <[email protected]>
sub 4096R/9D9BDFDF 2013-06-20
#!/usr/bin/env python3
import urllib.request
import urllib.error
# Free mobile credentials
free_user = "XXX"
free_pass = "XXX"
# Website to ping
sites = [