Skip to content

Instantly share code, notes, and snippets.

View purushotamrai's full-sized avatar
👨‍💻
git bisect good

Purushotam Rai purushotamrai

👨‍💻
git bisect good
View GitHub Profile
@purushotamrai
purushotamrai / DrupalCallback.php
Created April 25, 2020 21:15
Implementing Custom Pagination without Drupal Entity Query - Drupal 8
<?php
namespace Drupal\custom_module\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Pager\PagerManagerInterface;
class ListNonDrupalItems extends ControllerBase {
@purushotamrai
purushotamrai / foldable_bt.js
Last active April 16, 2020 20:02
Check for foldable binary tree
// https://www.geeksforgeeks.org/foldable-binary-trees/
class BinaryTree {
static root = 1;
bt_array = [];
setRoot(data) {
this.bt_array[BinaryTree.root] = data;
}
// Memcached Server URL and other settings.
$settings['memcache']['servers'] = ['localhost:11211' => 'default'];
$settings['memcache']['bins'] = ['default' => 'default'];
$settings['memcache']['key_prefix'] = 'pk';
// Memcache cache backend related configs for all caches.
$settings['cache']['default'] = 'cache.backend.memcache';
// Or some specific cache tables.
$settings['cache']['bins']['render'] = 'cache.backend.memcache';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.memcache';
@purushotamrai
purushotamrai / step 1.3 - Enable Module
Created February 14, 2019 17:40
Getting Started with ReactJS and Drupal - Step 1
vendor/bin/drush en -y admin_toolbar admin_toolbar_tools jsonapi
composer require drupal/jsonapi
composer require drupal/admin_toolbar
@purushotamrai
purushotamrai / Composer create-project
Created February 14, 2019 17:38
Getting Started with ReactJS and Drupal - Step 1
composer create-project drupal-composer/drupal-project:8.x-dev travel_destinations --stability dev --no-interaction
@purushotamrai
purushotamrai / App.js
Last active February 14, 2019 17:30
Getting Started with ReactJS and Drupal - Step 3 - App.js
ReactDOM.render(<App />, document.getElementById('root'));
@purushotamrai
purushotamrai / Create React App
Created February 14, 2019 17:28
Getting Started with ReactJS and Drupal - Step 3
npx create-react-app react_app
cd react_app
npm start
@purushotamrai
purushotamrai / services.yml
Created February 14, 2019 17:12
Getting Started with ReactJS and Drupal - Step 4.2 - Drupal services CORS
cors.config:
 enabled: true
 # Specify allowed headers, like 'x-allowed-header'.
 allowedHeaders: ['*']
 # Specify allowed request methods, specify ['*'] to allow all possible ones.
 allowedMethods: ['*']
 # Configure requests allowed from specific origins.
 allowedOrigins: ['*']
 # Sets the Access-Control-Expose-Headers header.
 exposedHeaders: true
@purushotamrai
purushotamrai / DestinationItem.js
Created February 14, 2019 17:11
Getting Started with ReactJS and Drupal - Step 4.2 - DestinationItem.js
import React from 'react';
export default class DestinationItem extends React.Component {
render() {
return (
<div>
<h2>{this.props.attributes.title}</h2>
<div dangerouslySetInnerHTML={{__html: this.props.attributes.body.value}} />
</div>