Skip to content

Instantly share code, notes, and snippets.

View suresh-kumara-gist's full-sized avatar

Suresh kumara suresh-kumara-gist

View GitHub Profile
@suresh-kumara-gist
suresh-kumara-gist / Create custom table in drupal 8
Last active February 22, 2019 17:14
Create custom table in drupal 8
Creating custom table in drupal 8 is not recommended. Create entity types instead.
But if you want to Create custom table you can create either by implementing hook_schema or
else create schema file config/schema/your_custom_module_name.schema.yml in your module
(https://www.drupal.org/docs/8/api/configuration-api/configuration-schemametadata).
( https://drupal.stackexchange.com/questions/219580/best-practice-for-creating-table-in-custom-module )
1. Implementing hook_schema in .module file (Not recommended).
/**
import React from 'react';
import ReactDOM from 'react-dom';
class Contact extends React.Component {
constructor(props) {
super(props);
this.state = {
password: 'swordfish',
authorized: false
};
@suresh-kumara-gist
suresh-kumara-gist / log_notify-bck.sh
Created September 24, 2018 12:27
log_notify-bck.sh
#!/bin/bash -e
#flag = true; tail -n-1 -f /Applications/DevDesktop/apache/logs/error_log | while read line; do if [ $flag ]; then echo "$(tail -n3 /Applications/DevDesktop/apache/logs/error_log)" | terminal-notifier$
flag=true;
function trigger_notification(){
# if (( $flag == true )); then
echo "$(tail -n3 /Applications/DevDesktop/apache/logs/error_log)" | terminal-notifier -sound default;
tail -n100 /Applications/DevDesktop/apache/logs/error_log > /tmp/log.txt;
@suresh-kumara-gist
suresh-kumara-gist / log_notify-bck.sh
Created September 24, 2018 12:27
log_notify-bck.sh
#!/bin/bash -e
#flag = true; tail -n-1 -f /Applications/DevDesktop/apache/logs/error_log | while read line; do if [ $flag ]; then echo "$(tail -n3 /Applications/DevDesktop/apache/logs/error_log)" | terminal-notifier$
flag=true;
function trigger_notification(){
# if (( $flag == true )); then
echo "$(tail -n3 /Applications/DevDesktop/apache/logs/error_log)" | terminal-notifier -sound default;
tail -n100 /Applications/DevDesktop/apache/logs/error_log > /tmp/log.txt;
https://www.cloudways.com/blog/best-startup-books-for-new-entrepreneurs/
var bookstitle; jQuery("h2").each(function(index) {
bookstitle += " @BooksBag " + $(this).text() + " by " + $( this).next("p").next("p").clone() //clone the element
.children() //select all the children
.remove() //remove all the children
.end().text(); console.log(bookstitle);
});
<?php
require_once customization_module_file_path();
/**
* @return string test.module file path
*/
function customization_module_file_path() {
// The directory of the file
$customizationsmodulepath = __DIR__;
/**
// get all ids of checkbox
var someObj={};
someObj.fruitsGranted=[];
someObj.fruitsDenied=[];
jQuery(“.js-rid-admin”).each(function() {
var $this = jQuery(this);
if($this.is("checked")){
someObj.fruitsGranted.push($this.attr("id"));
use Drupal\Core\Language\LanguageInterface;
echo strcmp("/", "/");
$test = \Drupal::service("pathauto.alias_cleaner")->cleanString("1");
$langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
$source = "";
$alias = $test;
$test = \Drupal::service("pathauto.alias_uniquifier")->uniquify($alias, $source, $langcode) ;
use Drupal\Core\Language\LanguageInterface;
echo strcmp("/", "/");
@suresh-kumara-gist
suresh-kumara-gist / Rendarable array to html string
Created April 24, 2018 02:20
Rendarable array to html string
$entity = EntityTest::create();
$entity->field_datasheet->target_id = $this->file->id();
$entity->save();
$output = $this->renderTestEntity($entity->id());
$expected_link = Link::fromTextAndUrl($this->field_label, Url::fromUri(file_create_url($this->file->getFileUri())));
$expected_link = $expected_link->toRenderable();
$expected_link['#attributes'] = [
'target' => '_blank',
];
$expected_link = \Drupal::service('renderer')->renderRoot($expected_link);
$menu = \Drupal::entityTypeManager()
->getStorage('menu_link_content')
->loadByProperties([
'menu_name' => ['agile-central-menu'],
'link.uri' => [ "entity:node/960"]
]);
If ($menu ) {
$menu->delete();
}