View ConfigExampleOverrides.php
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 | |
// This file will reside in modules/custom/YOURMODULE/src/Config | |
namespace Drupal\custom_event\Config; | |
use Drupal\Core\Cache\CacheableMetadata; | |
use Drupal\Core\Config\ConfigFactoryOverrideInterface; | |
use Drupal\Core\Config\StorageInterface; | |
/** | |
* Example configuration override. |
View Reduce-git-size.txt
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
# To see the 10 biggest files, run this from the root directory: | |
$ git verify-pack -v .git/objects/pack/pack-7b03cc896f31b2441f3a791ef760bd28495697e6.idx \ | |
| sort -k 3 -n \ | |
| tail -10 | |
# To see what each file is, run this: | |
$ git rev-list --objects --all | grep [first few chars of the sha1 from previous output] | |
# Rewrite all the commits: | |
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch "Folder Name/*"' -- --all |
View gist:4a67ddbee1347c288dc79c451eff6008
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
# use sudo apt-get update command to download package information from all configured sources. | |
# The sources often defined in the /etc/apt/sources. | |
sudo apt update | |
# upgrade google chrome to latest stable version | |
sudo apt --only-upgrade install google-chrome-stable | |
# check the google chrome version | |
google-chrome --version |
View git.txt
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
// Git global setup | |
git config --global user.name "your git username" | |
git config --global user.email "your git email address" | |
// Create a new repository | |
git clone <.git url> | |
cd project_folder | |
touch README.md | |
git add README.md | |
git commit -m "add README" |
View custom.js
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
$.ajax({ | |
url: '/myurl/ajax', | |
type: 'POST', | |
data : { | |
title: title, | |
type : type, | |
target: target, | |
view : view, | |
display:display | |
}, |
View myController.php
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 | |
use Drupal\Core\Render\Renderer; | |
use Drupal\Core\Ajax\AjaxResponse; | |
use Drupal\Core\Form\FormBuilder; | |
/** | |
* Drupal\Core\Block\BlockManager definition. | |
* | |
* @var \Drupal\Core\Block\BlockManager | |
*/ |
View myController.php
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 | |
use Drupal\Core\Ajax\AjaxResponse; | |
use Drupal\views\Views; | |
use Drupal\Core\Render\Renderer | |
/** | |
* Drupal\Core\Render\Renderer definition. | |
* | |
* @var \Drupal\Core\Render\Renderer |
View wget.php
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 | |
function __callURLinBackground($url) { | |
exec("wget -bqc ".$url." -P /var/www/html/", $output, $result_code); | |
echo $output; | |
echo $result_code; | |
echo '<pre>';print_r($output); | |
echo '<pre>';print_r($result_code); | |
echo 'Running in background'; | |
} | |
// call a URL in background |
View example.module
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 | |
/** | |
* Implements hook_views_query_alter(). | |
*/ | |
function mymodule_announcements_views_query_alter(Drupal\views\ViewExecutable $view, Drupal\views\Plugin\views\query\QueryPluginBase $query) { | |
// Alter annoucements views. | |
if (($view->id() == 'announcements')) { | |
if ($view->current_display == 'page_announcements' || $view->current_display == 'block_announcements') { | |
$current_user_id = \Drupal::currentUser()->id(); | |
$user_service = \Drupal::service('my_service.user'); |
View interfaces.php
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 | |
// Define the interface for a payment gateway | |
interface PaymentGateway { | |
public function processPayment(float $amount): bool; | |
} | |
// Define a class for a credit card payment gateway that implements the PaymentGateway interface | |
class CreditCardGateway implements PaymentGateway { | |
private string $apiKey; |
NewerOlder