This file contains 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 | |
//Create a variable for start time | |
$time_start = microtime(true); | |
//Create a variable for end time | |
$time_end = microtime(true); | |
// total execution time. | |
$execution_time = ($time_end - $time_start) / 60; |
This file contains 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 script is created purely based the video I saw on youtube about | |
* Personal finance on how to save money with small savings. | |
* | |
* If you invest 2 INR a day,In a year you can save around 133590 INR. | |
* | |
* The calculation goes like if on the 1st of january you save 2 rupees | |
* 2nd january you have to save 2*2 = 4 and 3 day 2*3 = 6 and likewise. | |
* | |
* You can not ideally transac this small amount to the bank, so I created |
This file contains 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
// With Jquery. | |
$('.year-select').once('current-year').on('change', function () { | |
var month = $('.month-select'); | |
var currentYear = (new Date()).getFullYear().toString(); | |
var selectedYear = jQuery('.year-select option:selected').val(); | |
if (currentYear === selectedYear) { | |
var currentMonth = (new Date()).getMonth(); |
This file contains 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 | |
// Add these lines at the end of your code. | |
echo PHP_EOL; | |
echo "Memory Usage :" . memory_get_usage(); | |
echo PHP_EOL; | |
echo "Real Memory Usage :" . memory_get_usage(true); | |
echo PHP_EOL; | |
echo "Real Peak Memory Usage :" . memory_get_peak_usage(true); | |
echo PHP_EOL; |
This file contains 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 | |
$base = \Drupal::service('custom_decorator_base.base'); | |
print $base->helper(); |
This file contains 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 | |
namespace Drupal\custom_decorator_base; | |
use Symfony\Component\HttpFoundation\RequestStack; | |
/** | |
* Class OriginalService | |
*/ | |
class OriginalService implements CustomDecoratorInterface { |
This file contains 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 | |
/** | |
* Replace drupal core token service with our own. | |
*/ | |
class TokenServiceProvider extends ServiceProviderBase { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function alter(ContainerBuilder $container) { |
This file contains 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
services: | |
custom_decorator_override.base: | |
class: Drupal\custom_decorator_override\OriginalServiceOverride | |
decorates: custom_decorator_base.base | |
decoration_priority: 9 | |
public: false | |
arguments: ['@custom_decorator_override.base.inner', '@request_stack'] |
This file contains 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
services: | |
custom_decorator_base.base: | |
class: Drupal\custom_decorator_base\OriginalService | |
arguments: ['@request_stack'] |
This file contains 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
example: | |
css: | |
theme: | |
css/example.css: {} | |
js: | |
js/example.js: {} |