Skip to content

Instantly share code, notes, and snippets.

@druman
druman / rename_es_index.sh
Created October 6, 2021 18:07 — forked from mjameswh/rename_es_index.sh
Demonstration of how to rename an ElasticSearch index using the Index Clone API, introduced in ES 7.4. This is the cUrl based version. See here for details: https://stackoverflow.com/a/59397746/2887657 .
source_index=source_index
target_index=target_index
elastic_search_server=elasticsearch:9200
# Make sure the source index is actually open
curl -X POST "${elastic_search_server}/${source_index}/_open"
# Put the source index in read-only mode
curl -X PUT "${elastic_search_server}/${source_index}/_settings" \
@druman
druman / readme.md
Created March 21, 2021 16:35 — forked from oliveratgithub/readme.md
Configure the PHP CLI in macOS to use MAMP PHP binaries

Pre-requisites

Find MAMP's installed PHP version(s) you want to use the PHP CLI for:

$ ls -l /Applications/MAMP/bin/php/

Configure PHP CLI in macOS to use MAMP's PHP

  1. First, open your local user's .bash_profile in edit mode, in order to add aliases for accessing the PHP CLI locally
$ pico ~/.bash_profile
@druman
druman / mac-setup-redis.md
Created October 23, 2019 20:16 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@druman
druman / d8.php
Last active January 11, 2022 19:36
Drupal 8 tweaks
<?php
// thx drupal8.ovh
//// 1) How to get the current language in Drupal 8
//To get the lanuage code:
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
//To get the language name:
$language = \Drupal::languageManager()->getCurrentLanguage()->getName();
@druman
druman / example.module
Created February 28, 2018 13:13 — forked from caschbre/example.module
Example of accepting drupal commerce coupon via querystring
<?php
/**
* Notes: the project this was taken from attempted to limit a user to one coupon per order.
* Some of the logic was taken directly from commerce_coupon 2.x.
*/
/**
* Implements hook_init()
*/
@druman
druman / drupal8.php
Created February 24, 2018 11:42
Drupal 8
<?php
// Make sure we are not on the user login route.
if (\Drupal::routeMatch()->getRouteName() == 'user.login') {
return;
}
// Check if the current user is logged in.
if (\Drupal::currentUser()->isAnonymous()) {
return;
}
@druman
druman / CollectPhone.php
Last active February 16, 2018 13:01
Drupal 8 Form API
<?php
// /src/Form/CollectPhone.php
namespace Drupal\helloworld\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface; // work witd data
/**
@druman
druman / HelloWorldController.php
Last active April 13, 2022 19:52
Drupal 8 Add library JS
<?php
namespace Drupal\helloworld\Controller;
use Drupal\Core\Controller\ControllerBase;
class HelloWorldController extends ControllerBase {
public function helloWorld() {
@druman
druman / simplenews-block-form.tpl.php
Created February 9, 2018 13:22
Theming simplenews block
<div class="contact_form news-form">
<div class="container">
<div class="row">
<div class="col-sm-12 text-center">
<h2> <span class="icons-a"><img src="<?php print drupal_get_path('theme', 'bartik');?>/img/news-letter-icon.png" alt="icon"></span>
<?php print t("Newsletter");?></h2>
<p><?php print $heading;?> </p>
</div>
</div>
<div class="row contact_field">
@druman
druman / updateAlias.txt
Created January 12, 2018 13:39
Bulk update url alias for unchecked “Generate automatic URL alias” nodes
1) In DB run request:
UPDATE `pathauto_state` SET `pathauto`=1 WHERE `entity_type` = 'node'
2) Checked /admin/config/search/path/settings Create new alias, delete old
3) admin/config/search/path/update_bulk or /admin/content BULK update alias