Skip to content

Instantly share code, notes, and snippets.

View juampynr's full-sized avatar

Juampy NR juampynr

View GitHub Profile
@juampynr
juampynr / mymodule.module
Last active August 29, 2015 14:24
Load a field for a set of nids
<?php
/**
* Fetches a field for an array of nids of a given type.
*
* Usage example: $nodes = mymodule_field_load_multiple('page', 'field_image', array(1, 2, 3));
*
* @param string $content_type
* The node's content type machine name.
* @param string $field
" Extra bundles.
Bundle 'joonty/vdebug.git'
" Editor overrides.
set shiftwidth=2 " Use indents of 4 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=2 " An indentation every four columns
set softtabstop=2 " Let backspace delete indent
" associate *.install and *.module files with with php filetype
@juampynr
juampynr / cool.md
Created June 10, 2015 22:21
Supercool

👍 :bowtie::neckbeard:🌟💩👍💃👯🙇😺👀🐰🐥💐🌸🌷🍁:squirrel:💝🎉💰🎸🎺🎷🎨🎩🍺🍹🍷🍣🍰🍪🚤🚀🏁🗿

@juampynr
juampynr / README.md
Last active November 9, 2020 18:34
Make Drupal 7 not to redirect to the node display after saving it

Drupal 7's default behavior is to redirect the user to the full display of a node after it has been saved.

If you want to stay in the edit form after saving, add this snippet to a custom module adjusting the module namespace in the two functions.

For Drupal 8 or 9, have a look at the comment below by @zanvidmar.

Acknowledgements

@juampynr
juampynr / automatic.md
Created May 21, 2015 10:07
Patching workflows in Drupal projects

Patching

Patches are managed through the Drush patch command. Existing patches can be found at patches.make.

Usage examples

Apply patch URL to multifield module

$ cd docroot
$ drush pa multifield https://www.drupal.org/files/issues/multifield-features_integration-2102265-29.patch
Patch https://www.drupal.org/files/issues/multifield-features_integration-2102265-29.patch applied to                                      [ok]
@juampynr
juampynr / municipales.md
Last active August 29, 2015 14:18
Elecciones municipales españolas 2015 - Voto por correo
  1. Acudir a cualquier oficina de correos solicitando el impreso.
  2. Se reciben dos impresos y un sobre. Uno es para Correos y el otro es para el Censo Electoral. En el segundo podemos especificar a qué dirección queremos que se nos envíe la documentación para votar.
  3. La documentación llegará al domicilio no más tarde del 4 de mayo.
  4. El voto deberá enviarse no más tarde del 19 de mayo.

Información adicional del Ministerio de Exteriores.

@juampynr
juampynr / skip.js
Last active August 29, 2015 14:17
CasperJS skip third party requests
/**
* Skip third party resources from being requested.
*
* Usage: add this file to casper js at the --includes option.
* Edit the array of URLs to skip.
* You can find out which third party requests your pages are making
* by adding the option --log-level=debug to the casperjs command.
*/
casper.on('resource.requested', function(requestData, request) {
// List of URLs to skip. Entering part of a hostname or path is OK.
// CasperJS default settings.
$command_specific['casperjs'] = array(
'verbose' => TRUE,
'url' => 'http://local.mysite.com',
'test-root' => '../testing/tests',
'includes' => '../testing/users.js,../testing/common.js',
);
function drush_pm_compare($alias_a, $alias_b) {
$result_a = drush_invoke_process($alias_a, 'pm-list')
$result_b = drush_invoke_process($alias_b, 'pm-list')
// Compare both arrays and inform about differences
}
@juampynr
juampynr / gist:60d5134a2555a3eaeec4
Last active August 29, 2015 14:07
Check database table size
SELECT TABLE_NAME, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "mydatabase" ORDER BY round(((data_length + index_length) / 1024 / 1024),2) DESC
LIMIT 0,15;