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 / 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 / prog-create-drupal-commerce-order.php
Created November 17, 2017 13:30 — forked from wluisi/prog-create-drupal-commerce-order.php
Programmatically Create Drupal Commerce Order
<?php
/**
* Creates an order for the given user containing the product with the given id.
* This example may be extended easily to create an order containing several
* products, a shipping and so far.
*
* Returns a commerce order that's now saved in the database with the status
* "processing and can be finished by an administrator in the UI.
* Throws an exception, if something is wrong.
@druman
druman / dc_emw.php
Created August 1, 2016 13:22 — forked from BBGuy/dc_emw.php
Working with Drupal commerce entities using entity_metadata_wrapper. Just a bunch of exampled copied from the web or added by me. will keep adding over time.
<?php
// order.
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
// Order id.
$order_id = order_wrapper->order_id->value();
// User detils.
@druman
druman / gist:14b1ce50091f4859f8c467748a749288
Created May 13, 2016 08:06
DRUPAL bootstrap dropdown override
/*
* Bootstrap override
* make dropdown menus do dropdown on hover,
* and allow parent link to be clickable
*/
// place this in your styles
ul.nav li.dropdown:hover > ul.dropdown-menu{
display: block !important;
}
@druman
druman / Drupa7 Output URL large image
Created March 10, 2016 06:45 — forked from iledcom/Drupa7 Output URL large image
Drupa7 Output URL large image
<?php
foreach ($node->field_product['und'] as $key => $product_array) {
if ( !empty($product_array) ) {
$product = commerce_product_load($product_array['product_id']);
$largeimg = image_style_url('large', $product->field_image['und'][0]['uri']);
echo $largeimg;
}
}
?>
$product_array = array();
foreach ($vars['field_product'] as $product) {
$product_array[] = $product['product_id'];
}
$products = commerce_product_load_multiple(
$product_array,
array("status"=>1)
);
// testing...
echo "<pre>";
@druman
druman / demo.module
Created February 4, 2016 08:28 — forked from pascalduez/demo.module
Drupal 7 — Basic Ajax form submit (Ajax framework)
<?php
/**
* @file
* Demo module, Basic Ajax form submit (Ajax framework).
*/
/**
* Implements hook_menu().
*/