Skip to content

Instantly share code, notes, and snippets.

View plopesc's full-sized avatar

Pablo Lopez plopesc

  • Lullabot
  • Valladolid, Spain
View GitHub Profile
@plopesc
plopesc / headers.php
Last active August 29, 2015 14:16
Get Header from URL
<?php
/**
* To execute this: php headers.php http.//url_to_check.com header
*/
$strURL = isset($argv[1]) ? $argv[1] : NULL;
$headerFind = isset($argv[2]) ? $argv[2] : NULL;
$resCurl = curl_init();
// Set URL and other appropriate options.
@plopesc
plopesc / update_field_definition.php
Last active August 29, 2015 14:10
Update the column structure for a field type.
<?php
/**
* Converts the value column from integer to float.
*/
function mymodule_update_70XX() {
$spec = array(
'type' => 'float',
'not null' => FALSE,
); // DB Column definition.
@plopesc
plopesc / enable_revision.php
Last active August 29, 2015 14:06
enable entity_translation revision support for existing site (Non previous revisionable data)
<?php
/**
* Enables entity_translation revisions support.
*/
function my_module_update_70XX() {
$revisionable_entity_types = array();
$query = db_select('entity_translation', 'et')
->fields('et', array('entity_type'))
@plopesc
plopesc / remove_field.php
Last active August 29, 2015 14:05
Cleans all the data related to a field and uninstalls the module that provides that field
<?php
/**
* Removes my_field and uninstalls its module.
*/
function my_module_update_70XX(&$sandbox) {
// If this is the first pass through this update function then set some variables.
if (!isset($sandbox['total'])) {
$sandbox['field_name'] = 'my_field';
$sandbox['field'] = field_info_field($sandbox['field_name']);
$sandbox['module'] = array($sandbox['field']['module']);
@plopesc
plopesc / translate_variable.php
Last active August 29, 2015 14:04
Enables multilingual support for variables defined in a group.
<?php
/**
* Enables multilingual support for variables defined in a group.
*
* @param string $group
* The group of variables to load
*/
function enable_multilingual_variables($group) {
// Load all the variables defined by group.
@plopesc
plopesc / 0_reuse_code.js
Created May 9, 2014 15:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console