Skip to content

Instantly share code, notes, and snippets.

View nkgokul's full-sized avatar

Gokul N K nkgokul

View GitHub Profile
Array.from(document.querySelectorAll('section a span')).filter(function(el){return el.textContent.indexOf("@") > -1}).reduce(function(ac,cv){return ac + cv.textContent + ", "});
@nkgokul
nkgokul / entity_details.php
Created July 22, 2019 06:58
Entity and Field Details
use Drupal\node\Entity\Node;
$entity = Node::load(1183);
$fields = array_keys($entity->getFieldDefinitions());
dpm($fields);
foreach($fields as $field_name) {
dpm("Field Name");
dpm($field_name);
dpm("--------------");
dpm("Field Value");
dpm($entity->get($field_name)->value);
@nkgokul
nkgokul / drupal_roles_with_a_permission
Created July 9, 2019 11:26
Drupal Get Roles that have a permission
$roles = \Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple();
//dpm($roles);
foreach($roles as $role){
if($role->hasPermission('use sourcex transition keep_in_pending_publishing')){
dpm($role->label());
}
}
@nkgokul
nkgokul / options-in-intersection-api.js
Last active May 7, 2019 14:35
Options In Intersection Api
var options = {
root: document.querySelector('null'),
rootMargin: '0% 0% 75% 0%',
threshold: 1.0
}
@nkgokul
nkgokul / Intersection_Observer_API.js
Last active May 7, 2019 14:36
Intersection Observer API Sample Code
chrome.extension.sendMessage({}, function (response) {
var readyStateCheckInterval = setInterval(function () {
if (document.readyState === "complete") {
clearInterval(readyStateCheckInterval);
var options = {
root: document.querySelector('null'),
rootMargin: '0% 0% 75% 0%',
threshold: 1.0
}
@nkgokul
nkgokul / .bashrc
Created March 5, 2019 20:20
Bash File to install on new servers
alias cd...="cd ../.."
alias cd....="cd ../../.."
alias cd.....="cd ../../../.."
alias chrome="open -a 'Google Chrome'"
alias emacs="emacs -nw"
@nkgokul
nkgokul / drupal8-composer
Last active February 1, 2021 06:41
Installing Drupal8 using composer
Create a new Drupal 9 project on existing DO node with all things installed.
composer create-project drupal-composer/drupal-project:8.x-dev content --stability dev --no-interaction
If you want to set up everything on a new DO server follow the below gist.
// For set up check
https://gist.github.com/nkgokul/fe117844d122033e8eb125bd7d1550c6
@nkgokul
nkgokul / niginx_zabbix.conf
Created January 29, 2019 06:28
Nginx Settings for Zabbix server
server {
root /usr/share/zabbix;
server_name my-monitoring.example.com;
location / {
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
@nkgokul
nkgokul / active-config.sh
Created January 28, 2019 07:05
Read Active configurations in a file.
grep -v '^#' zabbix_server.conf | grep -v '^$'
@nkgokul
nkgokul / generate_toc_medium
Created January 21, 2019 19:54
Generate TOC for published medium articles
getTOCHtml();
function getTOCHtml() {
let TOCHtml = ""
$$("h2,h3,h4,h5").forEach(function(ele){
TOCHtml += `<a href='#${ele.id}'>${ele.innerText}</a><br/>` ;
//console.log(ele.innerText);
})
//console.log(TOCHtml);
var parentElement = $('.postArticle-content');