Skip to content

Instantly share code, notes, and snippets.

View msankhala's full-sized avatar
🎯
Focusing

mahesh sankhala msankhala

🎯
Focusing
View GitHub Profile
@msankhala
msankhala / Drupal8HorizontalTabs.php
Created December 14, 2023 12:50 — forked from leymannx/Drupal8HorizontalTabs.php
How to create horizontal tabs programmatically in Drupal 8, requires Field Group module
<?php
// How to create horizontal tabs programmatically in Drupal 8, requires Field Group module
$form = array();
$form['my_field'] = array(
'#type' => 'horizontal_tabs',
'#tree' => TRUE,
'#prefix' => '<div id="unique-wrapper">',
'#suffix' => '</div>',
);
$items = array(
@msankhala
msankhala / NearestEventFilter.php
Last active May 24, 2023 17:08
Drupal 9 Views custom filter plugin to filter content based on users zipcode
<?php
namespace Drupal\mymodule\Plugin\views\filter;
use Drupal\views\Plugin\views\filter\FilterPluginBase;
use Drupal\Core\Form\FormStateInterface;
use Geocoder\Formatter\StringFormatter;
use Drupal\user\Entity\User;
/**
@msankhala
msankhala / tmux-restore-lost-sessions.md
Created April 10, 2023 12:50
How to restore tmux lost sessions

How to restore tmux lost sessions

Tmux is a terminal multiplexer that allows users to create multiple sessions, panes, and windows within a single terminal window. It is an excellent tool for developers and system administrators who often work with multiple terminal sessions at once. However, sometimes users may face a situation where their tmux session gets lost due to system restart, terminal crash, or any other reason. In this blog post, we will discuss how to restore a lost tmux session.

There are various plugins available for tmux, including tmux-resurrect and tmux-continuum. These plugins allow users to save and restore their tmux sessions, making it easy to recover from a lost session. However, sometimes these plugins may not work correctly, and users may still lose their tmux session. In such cases, users can follow the steps mentioned below to restore their lost tmux session.

Step 1: Check for session files

The first step is to check if the session files created by tmux-resurrect are present

@msankhala
msankhala / DeleteFeeds.php
Created November 25, 2022 12:49
Drupal 9 batch api example using BatchBuilder
<?php
namespace Drupal\miax_content\Command;
use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drush\Commands\DrushCommands;
use Drupal\miax_content\Services\DeleteFeedsBatchService;
@msankhala
msankhala / useScript-react-hooo.js
Created February 2, 2022 00:48
React hook useScript
// hooks/useScript.js
import { useEffect } from 'react';
const useScript = url => {
useEffect(() => {
const script = document.createElement('script');
script.src = url;
script.async = true;
@msankhala
msankhala / prototype-design-pattern.js
Created December 19, 2021 08:16
Prototype design pattern javascript
const atv = {
make: 'Honda',
model: 'Rincon 650',
year: 2018,
mud: () => {
console.log('Mudding');
}
};
const secondATV = Object.create(atv);
@msankhala
msankhala / builder-design-pattern-js.js
Created December 19, 2021 08:15
Builder design pattern javascript
class Car {
constructor(make, model, year, isForSale = true, isInStock = false) {
this.make = make;
this.model = model;
this.year = year;
this.isForSale = isForSale;
this.isInStock = isInStock;
}
toString() {
@msankhala
msankhala / factory-design-pattern.js
Last active December 19, 2021 08:16
Factor pattern js pattern
import Motorvehicle from './Motorvehicle';
import Aircraft from './Aircraf';
import Railvehicle from './Railvehicle';
const VehicleFactory = (type, make, model, year) => {
if (type === car) {
return new Motorvehicle('car', make, model, year);
} else if (type === airplane) {
return new Aircraft('airplane', make, model, year);
} else if (type === helicopter) {
// The 4 Creational Design Patterns In Node.js
// https://daily.dev/blog/the-4-creational-design-patterns-in-node-js-you-should-know
// The Singletone Pattern
class DatabaseConnection {
constructor() {
this.databaseConnection = 'dummytext';
}
@msankhala
msankhala / CustomSerializer.php
Created June 25, 2021 11:50 — forked from BERRAMOU/CustomSerializer.php
Drupal 8 : Custom serializer example to render result as array instead of objects.
<?php
namespace Drupal\MY_MODULE\Plugin\views\style;
use Drupal\rest\Plugin\views\style\Serializer;
/**
* The style plugin for serialized output formats.
*
* @ingroup views_style_plugins
*