This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The following code uses 735992 bytes = 735.99200 kilobytes | |
*/ | |
print memory_get_usage(FALSE); | |
$limit = 1; | |
for($i = 0; $i < $limit; $i++) { | |
$func = 'hello_' . $i; | |
$$func = function() { | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* For the sake of example, I assume that the caller only needs the date without any time information. | |
* If you also need the time, you will have to modify the following code a little. | |
* @param object $phpDate | |
* A DateTime PHP object | |
* @return int | |
* The number of days from 1899-12-30 (Delphi's starting point). This is also the correct value to be | |
* stored as a TDate type variable in Delphi. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Divides product weights into packages. | |
* | |
* @param array $weights | |
* An array of product weights. | |
* @param int $package_max_weight | |
* The maximum weight of a package. Set to 0 to not allow limit per weight. | |
* @param int $package_max_items | |
* The maximum number of items per package. Set to 0 to not allow limit per items. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_error_handler(function($errno, $errstr, $errfile, $errline, $errcontext) { | |
dpm($errcontext); | |
}); | |
$variables = db_query('SELECT name, value FROM {variable}')->fetchAllKeyed(); | |
foreach($variables as $name => $values) { | |
$value = unserialize($values); | |
} | |
restore_error_handler(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_field_attach_view_alter(). | |
* | |
* It fills the empty "alt" and "title" attributes of images with the label of | |
* the corresponding entity. | |
*/ | |
function mymodule_field_attach_view_alter(&$result, $context) { | |
if (!empty($context['entity_type']) && !empty($context['entity'])) { | |
$label = entity_label($context['entity_type'], $context['entity']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = Request Forms | |
core = 7.x | |
description = Creates the request forms of the website | |
dependencies[] = pathauto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The following script requires jQuery to exist in the website. | |
*/ | |
(function($) { | |
if (typeof(ga) == "undefined") { | |
console.log('No Google Analytics script found'); | |
} | |
else { | |
var UAs = ga.getAll(); | |
$.each(UAs, function(key, value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Class Euro2Text. | |
* | |
* Translates an amount in EUR to Greek text. Only the main sayEuro() method | |
* is public. Every other method is set to protected in order to allow | |
* developers to extend this class for their own purposes. | |
* | |
* Original Credit for the Greek version goes to Uberalles_gr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Turns a HEX color to a darker/lighter shade. | |
* | |
* @param string $colorstr | |
* The color as a HEX string with a # prefix. | |
* @param int $steps | |
* The number of steps to alter the color to. Both negavive and positive | |
* numbers are allowed. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_form_mailchimp_signup_subscribe_form_alter(). | |
*/ | |
function MODULE_form_mailchimp_signup_subscribe_form_alter(&$form, &$form_state) { | |
$form['#submit'][] = 'MODULE_mailchimp_signup_subscribe_form_redirect'; | |
} | |
/** | |
* Submit callback for mailchimp signup subscribe form. |
OlderNewer