Snippets Collections
import java.util.*;
public class CountDigits{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int[] resArr;
        System.out.println("Enter a number");
        int num=sc.nextInt();
        resArr=count(num);
        for(int i=0;i<resArr.length;i++){
            if(resArr[i]!=0){
                System.out.println(i+"-"+resArr[i]);
            }
        }
    }
    private static int[] count(int num){
        int[] arr=new int[10];
        while(num!=0){
            int digit=num%10;
            arr[digit]+=1;
            num/=10;
        }
        return arr;
    }
}
   public class Box{
    private double length;
    private double width;
    public Box(){
        System.out.println("box_default constructor");
        length=10;
        width=20;
    }
    public Box(double length,double width){
        System.out.println("box_parameterized constructor");
        this.length=length;
        this.width=width;
    }
    public String toString(){
        return "length:"+length+"\nwidth:"+width;
    }
   }

public class BoxColor extends Box{
    private String color;
    public Box color(){
        System.out.println("boxcolor-default constructor");
        color="brown";
    }
    public BoxColor(double length,double width,String color){
        super(length,width);
        this.color=color;
    }
}

public class BoxRating{
    private double rating;
public Box Rating(){}
    public BoxRating(double rating){this.rating=rating;}
    public BoxRating(double length,doublr width,String color,double rating)
    {
        super(length,width,color);
        this.rating=rating;
    }
    public String toString(){
        return super .toString()+"\n Rating"+rating;
    }
}

public class Main {
    public static void main(String[] args) {
        BoxRating b1=new BoxRating();
        System.out.println(b1);
        System.out.println();

        BoxRating b1=new BoxRating(5);
        System.out.println(b1);
        System.out.println();

        BoxRating b1=new BoxRating(20,30,"red",4.5);
        System.out.println(b1);
        System.out.println();
    }
}
public class Trycatch {
    public static void main(String[] args) {
        try{
            doSomething();
        }catch(Exception e){
            System.out.println(e);
        }
        
        
    }
    static void doSomething() throws Exception {
            throw new Exception("This is checked exception");
        }
}
import java.util.*;
public class IncSeq{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int[] arr;
        System.out.println("Enter array size");
        int n=sc.nextInt();
        arr=new int[n];
        System.out.println("Enter"+ n + "elements");
        for(int i=0;i<arr.length;i++){
            arr[i]=sc.nextInt();
        }
        int count=getcount(arr);
        System.out.println("Elements" +Arrays.toString(arr));
        System.out.println("No.of increasing sequences"+count);
    }

    private static int getcount(int[] arr){
        int count=0;
        for(int i=0;i<arr.length-1;){
            boolean flag=false;
            while(i<arr.length-1 && arr[i]<arr[i+1])
            {
                flag=true;
                i++;
            }
            if (flag)
                count++;
            else 
            i++;
        }
        return count;
        }
    }
import java.io.BufferedReader;
import java.io.FileReader;

public class Count {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("Data.txt"));
        int charCount =0;
        int wordCount=0;
        int lineCount=0;
        String line = null;
        while((line=br.readLine())!=null){
            lineCount++;
            wordCount+=line.split(" ").length;
            charCount+=line.length()+1;
        }
        System.out.println("Character: "+charCount);
        System.out.println("Word: "+wordCount);
        System.out.println("Line: "+lineCount);
    }
}
import java.util.*;
public class StringDemo{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    System.out.println("Arguments are "+Arrays.toString(args));
    System.out.println("Enter key: ");
    String key=sc.nextInt();
    for(int i=0;i<args.length;i++){
      if(key.equals(args[i])){
        System.out.println("Found");
      }
      break;
    }
  }
}
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Copy {
    public static void main(String[] args) {
        if (args.length != 2) {
            System.out.println("Usage: java Copy <sourceFilePath> <destinationFilePath>");
            return;
        }

        try (
            FileInputStream fis = new FileInputStream(args[0]);
            FileOutputStream fos = new FileOutputStream(args[1])
        ) {
            byte[] contents = new byte[fis.available()];
            fis.read(contents);
            fos.write(contents);
            System.out.println("Contents Copied");
        } catch (FileNotFoundException e) {
            System.out.println("File not found: " + e.getMessage());
        } catch (IOException e) {
            System.out.println("Error reading or writing the file: " + e.getMessage());
        }
    }
}
import java.util.Arrays;
import java.util.Scanner;
public class Custom {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[5];
        for(int i=0;i<5; ){
            System.out.println("Enter marks: "+(i+1));
            arr[i]=sc.nextInt();
        
            if(arr[i]<0 ||arr[i]>20){
                try{
                    throw new InvalidMarksException(arr[i]+" ");
                }catch(InvalidMarksException e){
                    System.out.println(e);
                }
            }
            else{i++;}
            System.out.println(Arrays.toString(arr));
        
        }
    }
}
  
  ////
  
  
import java.util.*;
class InvalidMarksException extends Exception{
 InvalidMarksException(){
    super("marks are invalid");
 }   
 InvalidMarksException(String msg){
    super("marks are invalid"+msg);

 }
 public String tostring(){
    return super.getMessage();
 }
}
public class PlayThread extends Thread{
    String songname;
    public PlayThread(String tname,String songname){
        super(tname);
        this.songname=songname;
    }
    public void run(){
        System.out.println("In Thread-"+this.getName());
    for(int i=1;i<=10;i++){
        System.out.println("Playing"+songname);
    }
    System.out.println("Done Playing");
}
}




public class Download extends Thread {
    String songname;
    public Download(String dname,String songname){
        super(dname);
        this.songname=songname;
    }

    public void run(){
        System.out.println("In Thread-"+this.getName());
    for(int i=1;i<=10;i++){
        System.out.println("Downloading"+songname);
    }
    System.out.println("Downloaded");
}
}




public class Main {
    public static void main(String[] args) {
        System.out.println("In Main Thread");
        PlayThread t1=new PlayThread("Play-Thread", "song-1");
        Download t2=new Download("Downloading Thread", "song-1");
        t1.start();
        t2.start();
        System.out.println("DONE");
    }
}
import java.util.*;

public class MultipleExceptions {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        try{
            System.out.println("Enter marks separated by ,");
            String[] marks=sc.nextLine().split(",");
            int sum=findSum(marks);
          System.out.println("Sum: "+sum);
            System.out.println("Average marks:"+sum/marks.length);
        }
        catch(ArrayIndexOutOfBoundsException e){
            System.out.println(e);
        }catch(NumberFormatException e){
            System.out.println(e);
        }catch(Exception e){
            System.out.println(e);
        }finally{
            System.out.println("This is executed always");
        }
    }

    public static int findSum(String[] marks){
        int sum=0;
        //String[] marks;
        for(int i=0;i<marks.length;i++){
            sum+=Integer.parseInt(marks[i]);
        }
        return sum;
    }
}
public class ElectricityBill implements Runnable {
    private int units;
    private double bill;
    private double unitcost=2.10;
    public ElectricityBill (int units){
        this.units=units;
    }
    public void run(){
        String tname=Thread.currentThread().getName();
        System.out.println(tname +"Bill Calculation Started:");
        try{
           Thread.sleep(10);

        }
        catch(InterruptedException e){
            e.printStackTrace();
        }
        bill =units<=250?300:300+(units-250)*unitcost ;
        System.out.println("Bill Form:"+tname+" ,"+bill);
    }
    public double getBill(){
        return bill;
    }

    
}






public class MainBill {
    public static void main(String[] args) {

        ElectricityBill house1=new ElectricityBill(200);
        ElectricityBill house2=new ElectricityBill(500);
        ElectricityBill house3=new ElectricityBill(400);

        Thread t1=new Thread(house1,"house1");
        Thread t2=new Thread(house2,"house2");
        Thread t3=new Thread(house3,"house3");

        t1.start();
        t2.start();
        t3.start();

        try{
            t1.join();
            t2.join();
            t3.join();

        }catch(InterruptedException e){
            e.printStackTrace();
        }

        double TotalRevenue=house1.getBill()+house2.getBill()+house3.getBill();
        System.out.println("Total Revenue is :"+TotalRevenue);

    }
}
public class Inheritance {
    private String name;
    private int age;
    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name=name;

    }
    public int getAge(){
        return age;

    }
    public void setAge(int age){
        this.age=age;
    }
    public String tostring(){
    return "name:"+name+"\n age:"+age;
}

    
}


public class Student extends Inheritance{
    private int rollno;
    public int getrollno(){
        return rollno;
    }
    public void setRollNo(int rollno){
        this.rollno=rollno;

    }
    public String tostring(){
        return super.tostring()+"\n"+"roll number:"+rollno;
    }
}


public class Main{
    public static void main(String[] args){
        Student s1=new Student();
        System.out.println(s1+"\n");
        s1.setName("person1");
        s1.setAge(18);
        s1.setRollNo(101);
        System.out.println(s1);
    }
} 
public class PrintMessage {
    synchronized void print(String Msg){
        System.out.println("["+Msg+"]");
    }
}



public class MessageSend {
    public static Runnable getSender(PrintMessage p,String Msg){
        return new Runnable() {
            private PrintMessage pMsg=p;
            private String Message=Msg;
            public void run(){
                pMsg.print(Message);
            }
        };
    }
}



public class MessageMain {
    public static void main(String[] args) {
        PrintMessage pMsg=new PrintMessage();
        String n1="CVR",n2="College",n3="Engineering";
        Runnable r1=MessageSend.getSender(pMsg,n1);
        Runnable r2=MessageSend.getSender(pMsg,n3);
        Runnable r3=MessageSend.getSender(pMsg,n2);

        new Thread(r1).start();
        new Thread(r2).start();
        new Thread(r3).start();
    }
}
import java.util.Scanner;

public class RootsType{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    float det;
    double root1,root2;

    System.out.println("enter the number a,b,c");
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    det = b*b-4*a*c;
    root1 = (- b + Math.sqrt(det))/2*a;
    root2 = (- b - Math.sqrt(det))/2*a;
    if(det==0)
    System.out.println("Roots are real and equal");

    else if(det>0)
    System.out.println("roots are real and distinct");
    else
    System.out.println("roots are imaginary");
    System.out.println("root1:"+root1);
    System.out.println("root2:"+root2);

    }

}
public class Queue{
    private boolean Vset=false;
    private int n;
    public synchronized void get() throws Exception{
        while(!Vset){
            wait();
        }
        System.out.println("Got:"+n);
        Vset=false;
        notify();
    }

    public synchronized void put(int n)throws Exception{
        while (Vset) {
            wait();
        }
        this.n=n;
        System.out.println("Put:"+n);
        Vset=true;
        notify();
    }
}


public class ThreadService {
    public static Runnable getProducer(Queue q){
        return new Runnable() {
            private Queue queue=q;
            int i=1;
            public void run(){
                while (true) {
                    try{
                        queue .put(i++);
                    }catch(Exception e){
                        e.printStackTrace();
                    }
                    
                }
            }
        };
    }
        public static Runnable getConsumer(Queue q){
            return new Runnable() {
                private Queue queue=q;
                public void run(){
                while (true) {
                    try{
                        queue.get();
                    }catch(Exception e){
                        e.printStackTrace();
                    }
                }
            }
            };
        }
    
}


public class ProducerConsumerDemo {
    public static void main(String[] args) {
        Queue q=new Queue();
        new Thread(ThreadService.getProducer(q)).start();
        new Thread(ThreadService.getConsumer(q)).start();
    }
}
public class Box {
    private double width;
    private double height;
    private static int boxCount = 0;
    public Box() {
        boxCount++;
    }
    public Box(double width, double height) {
        this.width = width;
        this.height = height;
        boxCount++;
    }
    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    // toString method to display box information
    @Override
    public String toString() {
        return "Box{" +
                ", width=" + width +
                ", height=" + height +
                '}';
    }
    public static int getBoxCount() {
        return boxCount;
    }
}
public class BoxDemo {
    public static void main(String[] args) {
        Box box1 = new Box();
      	Scanner sc=new Sacnner(System.in);
       	Box[] boxarr=new Box[5];
      	System.out.println("Number of boxes created: " + Box.getBoxCount());
        for(int i=0;i<boxarr.length;i++){
          System.out.println("Enter "+(i+1)+" height width);
          double n1=sc.nextInt();
          double n2=sc.nextInt();
          boxarr[1]=new Box(n1,n2);
        }
      System.out.println("Boxes in array are: ");
      for(Box box:boxarr){
        System.out.println(box);
      }
    }
}
#!/bin/sh

for i in {1979..1980}
do
    echo "output: $i"
    dir2=$((i+1))
    cp /from/$i/FILE:$i-08* /from/$dir2/
    mv  /from/$i/FILE:$i-09* /from/$dir2/
    
    
done
import java.util.*
  public class Product {
    private int productId;
    private String productName;
    private double productPrice;
    public Product() {}
    public Product(int productId, String productName, double productPrice) {
        this.productId = productId;
        this.productName = productName;
        this.productPrice = productPrice;
    }
	public Product() {
        productId = 001;
        productName = "PEN";
        productPrice = 30.32;
    }
    @Override
    public String toString() {
        return "Product{" +
                "productId=" + productId +
                ", productName='" + productName + '\'' +
                ", productPrice=" + productPrice +
                '}';
    }

    public static void main(String[] args) {
        Product product1 = new Product(1, "Laptop", 999.99);
        System.out.println(product1.toString());
    }
}
import java.util.*;

public class Grade {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter marks:");
        int marks = sc.nextInt();

        if (marks >= 90 && marks < 100)
            System.out.println("Grade: S");
        else if (marks >= 80 && marks < 90)
            System.out.println("Grade: A");
        else
            System.out.println("Grade: B");
    }
}
public class Test{
    public static int maximum(int a, int b){
        return a>b?a:b;
    }
    public static int maximum(int a, int b,int c){
        return (a>b&a>c)?a:((b>c)?b:c);
    }
    public static int maximum(int[] arr){
        int max=Integer.MIN_VALUE;
		for(int elem:arr){
          if(elem>arr)
            max=elem
        }
      	return max;
    }
}
public class TestDemo{
    public static void main(String[] args){
        System.out.println(Test.maximum(100,200));
        System.out.println(Test.maximum(10.05f,200.77f,20.55f));
      	int[] test=new int[] (1,2,3,4,5);
        System.out.println(Test.maximum(test));
    }
}
import java.util.*;
public class IncreasingDemo{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n;
        n = sc.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        for(int i=0;i<n;i++){
            System.out.println(arr[i]);
        }
    }
}
import java.util.*;
public class Person{
  private set ID;
  private String names;
  public void setdata(int no,String str){
    ID=no;
    name=str;
  }
  public show(){
    System.out.println(ID+" "+name);
  }
  public class PersonDemo{
    public static void main(String[] args){
      Person p1=new Person();
      show(p1);
      p1=setdata(101,"Person1");
      show(p1);
    }
  }
}
import java.util.*;
public class GcdDemo{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter 2 marks: ");
    int n1=sc.nextInt();
    int n2=sc.nextInt();
    int res=gcd(n1,n2);
    System.out.println("GCD is: "+res);
  }
	private static int gcd(int a,int b){
      if(n2==0)
        return n1;
      return(gcd(n2,n1%n2))
    }
}
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -I PREROUTING -p tcp -d 192.168.1.0/24 --dport 2222 -j DNAT --to-destination 127.0.0.1:2222

sysctl -w net.ipv4.conf.eth0.route_localnet=1
<?php

use \Drupal\taxonomy\Entity\Term;

$vocabulariNew = ["ambit_laboral", "ambit_social", "ambit_educations"];
$path =  dirname(__FILE__) . '/data/all_terms.csv';

$newCsvData = [];
$rowFe = [];
$i = 0;

//delete todos los términos 
function _l($m, $level = 'INFO') {
  echo "$level | $m \n";
}

function _delete_terms($vid) {
  _l("Delete terms form vocabulari $vid");
  $tids = Drupal::entityQuery('taxonomy_term')
    ->accessCheck(FALSE)
    ->condition('vid', $vid)
    ->execute();

  if (empty($tids)) {
    return;
  }

  $term_storage = \Drupal::entityTypeManager()
    ->getStorage('taxonomy_term');
  $entities = $term_storage->loadMultiple($tids);

  $term_storage->delete($entities);
}

// foreach($vocabulariNew as $vid){
//   _delete_terms($vid);
// }

$csv_data = [];

$handle = fopen($path, "r");
if ($handle  !== FALSE) {

  while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $i++;
    if($i == 1){
      continue;
    }

    $csv_data[] = $row;
   

    }
    fclose($handle);


    foreach ($csv_data as $row) {

      $terms = \Drupal::entityTypeManager()
      ->getStorage('taxonomy_term')
      ->loadTree($row[0]);
      $term_name = $row[2];
      $term_exists = false;
      $term_id = null;

      foreach ($terms as $term) {
        if ($term->name == $term_name) {
          $term_exists = true;
          $term_id = $term->tid;
          break;
        }
      }

      if (!$term_exists) {
        $term = Term::create([
          'name' => $row[2],
          'vid' => $row[0],
          'language' => 'es',
        ]);
        $term->addTranslation("ca", [
                  'name' => $row[1]
                ]);
        $term->save();
       $term_id = $term->id();
       }


      if ($term_exists && $term_id) {
        $term = Term::load($term_id);
        if($term->hasTranslation('ca')){
          $translation = $term->getTranslation('ca');
          $translation->set('name', $row[1]);
          $translation->save();
        }else{

          $term->addTranslation("ca", [
            'name' => $row[1]
          ]);
          
        }
        
        $term->save();
      }


    }

  }
   $vocNew = \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')
        ->loadByProperties(['name' => $map[2]]);
      

      if (!empty($vocNew)) {
        $vocNew = reset($vocNew);
        $vocabulary_id = $vocNew->id();
      }
  $lang = \Drupal::service('language_manager')
      ->getCurrentLanguage()
      ->getId();

    $current_route_name = \Drupal::service('current_route_match')
      ->getRouteName();

    $filter_all_text = t('Todo');
    $filter_all_url = Url::fromRoute($current_route_name);
    $filter_all_url->setOptions([
      'attributes' => [
      'class' => [
        'btn-main-filter',
        ],
      ],
    ]);
1- sites/default/development.services.yml

parameters:
    session.storage.options: { gc_probability: 1, gc_divisor: 100, gc_maxlifetime: 200000, cookie_lifetime: 2000000 }
    twig.config: { debug: true, auto_reload: true, cache: false }
    renderer.config: { required_cache_contexts: ['languages:language_interface', theme, user.permissions], auto_placeholder_conditions: { max-age: 0, contexts: [session, user], tags: {  } } }
    http.response.debug_cacheability_headers: true
    factory.keyvalue: {  }
    factory.keyvalue.expirable: {  }
    filter_protocols: [http, https, ftp, news, nntp, tel, telnet, mailto, irc, ssh, sftp, webcal, rtsp]
    cors.config: { enabled: false, allowedHeaders: {  }, allowedMethods: {  }, allowedOrigins: ['*'], exposedHeaders: false, maxAge: false, supportsCredentials: false }
services:
    cache.backend.null:
        class: Drupal\Core\Cache\NullBackendFactory

2- en sites/default/setting.local.php
/**
 * Enable local development services.
 */
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
3- 

sites/default/setting.php
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {  include $app_root . '/' . $site_path . '/settings.local.php';
}
hook_preprocess_menu ($variables){
  $$menuItems = &$variables['items'];
  foreach ($menuItems as $idx => &$item) {


   $idx = explode(":",$idx);
   $i = \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadByProperties(['uuid' => $idx]);
   $i= reset($i);
   $idParent = $i->getParentId();
   $idParent = explode(":",$idParent);
   $parent = \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadByProperties(['uuid' => $idParent]);
   $parent= reset($parent);
 
  
   $j = MenuLinkContent::load($parent->id());
 
  
  $highlited = $j->field_highlighted_id->value;
  
  }
// este ejemplo se envia la misma pagina
    $url = Url::fromRoute('<front>');
    return Link::fromTextAndUrl($minisite->label(), $url)->toRenderable();
// file modules/custom/mymodule/mymodule.module



/**
 * Implements hook_form_alter().
 */
function henka_training_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'user_login_form') {
     $form['#submit'][] = 'redirect_submit_handler';
  }
}

/**
* Custom submit handler for login form.
*/
function redirect_submit_handler($form, FormStateInterface $form_state) {
   $url = Url::fromUri('internal:/formacion'); 
  // or $url = Url::fromRoute('view.VIEW_MACHINE_NAME.PAGE_MACHINENAME');
  //example  $url = Url::fromRoute('view.henka_training.page_training');
   $form_state->setRedirectUrl($url);
}
<?php

// module custom /src/Plugin/views/filter/CustomFilter.php
// ejemplo en smsjd_druplal
<?php

namespace Drupal\sm_utils\Plugin\views\filter;

use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\filter\InOperator;
use Drupal\views\ViewExecutable;


/**
 * Filters by current tags.
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("som360_node_revelance_filter")
 */
class CurrentNodeRevelanceFilter extends InOperator {

  /**
   * {@inheritdoc}
   */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);
    $this->valueTitle = $this->t('Current Tags');
    $this->definition['options callback'] = [$this, 'generateOptions'];
  }

  /**
   * {@inheritdoc}
   */
  public function operators() {
    return [
      '=' => [
        'title' => $this->t('Is equal to'),
        'short' => $this->t('='),
        'method' => 'opFilterNodeRevelance',
        'values' => 1,
      ],
      '!=' => [
        'title' => $this->t('Is not equal to'),
        'short' => $this->t('!='),
        'method' => 'opFilterNodeRevelance',
        'values' => 1,
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function query() {
    // Override the query
    // So that no filtering takes place if the user doesn't select any options.
    if (!empty($this->value)) {
      parent::query();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function validate() {
    // Skip validation
    // If no options have been chosen so we can use it as a non-filter.
    if (!empty($this->value)) {
      parent::validate();
    }
  }

  /**
   * Helper function that generates the options.
   *
   * @return string[]
   */
  public function generateOptions() {
    return [
      'current_tag' => t('Current tags'),
    ];
  }

  /**
   * Add SQL condition to filter by.
   */
  protected function opFilterNodeRevelance() {
    if (empty($this->value)) {
      return;
    }

    $this->ensureMyTable();
    $mid = 1854;
   // $field =  'node__field_ref_minisites.field_ref_minisites_target_id';
    $field = 'node_field_data.nid';
   
    $this->query->addWhereExpression($this->options['group'], "$field $this->operator $mid");
  }


}

//en sm_utils.module


/**
 * Implements hook_views_data_alter()
 *
 * Register a new filter to be used in views in this project.
 * Logic is defined in src/views/filter/CurrentNodeRevelanceFilter.php
 */
function sm_utils_views_data_alter(&$data) {

   
  $data['node_field_data']['node_revelance_filter'] = [
    'label' => t('Custom tags filter'),
    'title' => t('Current tags'),
    'group' => t('Custom Filters'),
    'filter' => [
      'title' => t('Current tags'),
      'help' => t('Filters nodes that belong to current tags'),
      'field' => 'smsjdnode_field_data',
      'id' => 'som360_node_revelance_filter',
    ],
  ];

}
// en config/schema.yml

views.filter.som360_node_revelance_filter:
  type: views.filter.in_operator
  label: 'Current tags'
git init --initial-branch=main
git remote add origin git@gitlab.com:omada-dev/irjsg-150.git
git add .
git commit -m "Initial commit"
git push --set-upstream origin main
<?php


# vendor/bin/drush php-script web/modules/custom/henka_utils/scripts/create_user.php

use Drupal\user\Entity\User;



$path = dirname(__FILE__) . '/users.csv';


$i = 0;

$handle = fopen($path, "r");
if ($handle !== FALSE) {
  while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $i++;
    if ($i == 1) {
      continue;
    }

    $user = User::create([
      'mail' => $row[0],
      'field_name' => $row[1],
      'field_surname' => $row[2],
    ]); 
    $user->activate();
    $user->addRole('teacher');
    $user->save();
  }
  fclose($handle);
}
Listen 10151
<VirtualHost *:10151>
  DocumentRoot /var/www/intercat-drupal8/web
  <Directory /var/www/intercat-drupal8/web>
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>
 $url = Url::fromUri('//' . $minisite_url);  for fix the invalid URL shema
\Drupal::request()->getScheme()  ======> return http://
\Drupal::request()->getSchemeAndHttpHost()  ======> return http://localhost/es 
<?php 
//if you want show in every li of menu diferent onformation of node sigue instruction(2) 
// in theme 
function themName_preprocess_menu(&$variables){
  $node = Node::load(2311);
  $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
  $teaser_view = $view_builder->view($node, 'teaser');
  $variables['teaser'] = \Drupal::service('renderer')->renderRoot($teaser_view);

  //instruction(2)
    $ar = [];
  $i = 0 ;
  $ids = \Drupal::entityQuery('node')
         ->condition('status', 1)
         ->condition('type', 'blog')
         ->range(0, 30) 
         ->execute();

  foreach ($ids as $key => $value) {
    $ar[] = $value;
  }

  $menuItems = &$variables['items'];

  foreach ($menuItems as $idx => &$item) {
    $node = Node::load($ar[rand(0,30)]);
    if(empty($node)){
     continue;
    }
    $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
    $teaser_view = $view_builder->view($node, 'teaser');
    $item['#node']= \Drupal::service('renderer')->renderRoot($teaser_view);
    // in twig corespon print foreach($item in $items){  <li> {{ $item['#node }}  </li> }
  }
  
}

// in twig menu.html.twig

//{{ teaser }}
$file = File::create([
  'uri' => $data['image']['url'],
]);
  $file->save();
$media = Media::create([
  'bundle' => 'image', 
  'field_origin_id' => $data['image']['id'],
  'field_fecha' => time(),
  'field_media_image' => [
    'target_id' => $file->id(),
    'title' => $data['image']['title']['es'],
    'alt' => $data['image']['alt']['es'],
  ],
  ]);
  $media->save();
$node->field_ref_image = $media;
$node->save();
example sitges web//modules/custom/sff_warnings
https://befused.com/drupal/ultimate-cron/
ejemplo en smsjd_drupal omg_ga_reporting.module
ejemplo sitges sff_warning module
1- install ultimate_cron -> activate
2- in custom module /file.module 
  crear 
   function custom_module_cron() {
    \Drupal::logger('custom_utility')->notice('Cron ran');
  }
3- Hit the Discover jobs button and the job you created above will appear on the list.
4- copy configuration localhost:10162/es/admin/config/development/configuration/single/export

  trabajo del cron and nombre que has creado in module 
  pega en imprendincible  que el file en config llamma ultimate_cron.job.unnombrequeqieres.yml  
  config/utility_cron.job.nombre.yml like this 
   langcode: ca
status: true
dependencies:
  module:
    - sff_warnings
title: 'Publish and Unpublish warnings based on dates'
id: sff_warnings_publish_warnings_cron
weight: 0
module: sff_warnings
callback: sff_warnings_publish_warnings_cron
scheduler:
  id: simple
launcher:
  id: serial
logger:
  id: database
in module elimina el function
crear otra del nombre callback like sff_warnings_publish_warnings_cron and put you logica
importa configuracion con comando druash
drush config-import --source=modules/custom/custom_utility/config --partial -y
<?php

namespace Drupal\irsjg_home\Plugin\DsField;

use Drupal\ds\Plugin\DsField\DsFieldBase;
use \Drupal\views\Views;


// ejemplo irsjg_hom/src/Plugin/videosMasReciente.php
/**
 * Provides a custom DsField to display home header as field
 *
 * @DsField(
 *   id = "irsjg_home_video_field",
 *   title = @Translation("IRSJG Home | Video más reciente"),
 *   entity_type = "node",
 *   provider = "irsjg_home",
 *   ui_limit = {"home|full"}
 * )
 */

class HomeMasReciente extends DsFieldBase {

  /**
   * {@inheritdoc}
   */
  public function build() {

    $view = Views::getView('irsjg_homepage_slicks');
    if (!is_object($view)) {
      return;
    }
   
    $view->setDisplay('block_home_video_slider');
    $view->preExecute();
    $view->execute();
    $view->element['#attached']['library'][] = 'irsjg_home/video_slider';
    $content = $view->buildRenderable('block_home_video_slider');  

    return $content;
    
  }

}
    $view = Views::getView('irsjg_homepage_slicks');

    if (!is_object($view)) {
      return;
    }
   
    $view->setDisplay('block_home_video_slider');
    $view->preExecute();
    $view->execute();
    $view->element['#attached']['library'][] = 'irsjg_home/video_slider';
  
   $rendered = $view->render();
   $output = \Drupal::service('renderer')->render($rendered);

   return [
     ['#markup' => $output]
   ];
 // orrrrrrrrrrr


    $view = Views::getView('irsjg_homepage_slicks');

    if (!is_object($view)) {
      return;
    }
   
    $view->setDisplay('block_home_video_slider');
    $view->preExecute();
    $view->execute();
    $view->element['#attached']['library'][] = 'irsjg_home/video_slider';
    $content = $view->buildRenderable('block_home_video_slider');  
 
    return $content;
// irsjg->home module DS fiedl HomeHeaderField
 $build = \Drupal::entityTypeManager()->getViewBuilder('media');
$a = $build->view($url, 'token');
$output = \Drupal::service('renderer')->render($a);     
$video['uri'] = $output;
$node = \Drupal::entityTypeManager()->getStorage('user')->load($e->id());
$users[] = \Drupal::service('entity_type.manager')->getViewBuilder('user')->view($node, 'contact_equip');


// render web from
 $webform = \Drupal::entityTypeManager()->getStorage('webform')->load('contacto_profesional');
   $view_builder = \Drupal::service('entity_type.manager')->getViewBuilder('webform');
A recent gaming trend and user preference for playing fantasy sports games. As a result, fancy sports game companies have benefited from gaining more profit and attracting more business in the game market. A real-life best-example app is Dream11. This is the first company in India to showcase this unique trend of fancy sports games for Indians and succeed in the Indian market, apart from other parts of the world, with their branding. As well, you can build your desired business by using our Dream11 clone app to kickstart your business journey with affordable market pricing compared to others. Not only that, we offer Dream11 clone scripts, Dream11 clone app development, and a website with more user-centric customization depending upon their client needs. Utilize this perfect opportunity to build your own fantasy sports mobile app for your business.
class D
{
    public static void main(String[] args){
        try
        {
            m1();
        }
        catch(Exception m)
        {
            System.out.println("exception handeld ");
        }
    }
    public static void m1()
    {
        m2();
    }
    public static void m2()
    {
        System.out.println(10/0);
       
    }
}
class InvalidAgeException extends Exception
{
    InvalidAgeException(String msg)
    {
        System.out.println(msg);
    }
}
class test
{
    public static void vote(int age) throws InvalidAgeException
    {
        if(age<18)
        {
            throw new InvalidAgeException("not eligible for voting");
        }
        else
        {
            System.out.println("Eligible for voting ");
        }
    }
    public static void main(String[] args){
    
    try
    {
        vote(12);
    }
    catch(Exception d)
    {
        System.out.println(d);
    }
    }
}
while True:
    try:
        marks = float(input('Enter your marks to calculate your grade: \n'))
    except ValueError:
        print('Invalid input, try again')
        continue
    if marks > 100:
        print('your input must not be greater than 100')
    else:
        break

if 85 <= marks <= 100:
    print('You have grade A')
elif 65 <= marks < 85:
    print('You have grade B')
elif 41 <= marks < 65:
    print('You have grade C')
elif 0 <= marks < 41:
    print('You failed')
else:
    print('Invalid Marks')
Here's a guide on how to start developing poker software, outlining key steps and code structure:

1. Define the Scope of Your Project:

    Game Variants: Choose which poker variants you'll include (e.g., Texas Hold'em, Omaha, 5-Card Draw).
    Features: Decide on essential features like player accounts, gameplay, betting, tournaments, chat, and multi-platform compatibility.
    Target Platforms: Determine if you're developing for web, desktop, mobile, or a combination.

2. Choose Your Programming Language and Development Environment:

    Common Languages: Python, Java, C++, C#, and JavaScript are popular choices for game development.
    Development Environments: Select an IDE (Integrated Development Environment) like Visual Studio Code, PyCharm, or Eclipse for efficient coding.

3. Structure Your Code:

    Classes: Create classes for representing cards, decks, hands, players, game tables, and the game logic itself.
    Functions: Write functions to handle shuffling, dealing, betting, evaluating hands, and managing game flow.

4. Implement Core Functionalities:

    Card Deck: Create a class to represent a deck of cards, with methods for shuffling and dealing cards.
    Player Hand: Implement a class to hold a player's hand, with methods for evaluating hand strength.
    Game Logic: Write the core game logic, including betting rounds, hand comparisons, and pot management.

5. Design the User Interface (UI):

    Visual Design: Create visually appealing UI elements using graphics libraries or frameworks.
    User Interaction: Implement intuitive controls for players to interact with the game.

6. Test Thoroughly:

    Unit Testing: Test individual code units to ensure they function as intended.
    Integration Testing: Verify that different parts of the code work together seamlessly.
    User Testing: Gather feedback from real users to identify bugs and areas for improvement.

7. Deploy and Maintain:

    Deployment: Make your poker software available to users on your chosen platforms.
    Maintenance: Address any bugs or issues, and update the software with new features or improvements over time.
star

Thu Jan 18 2024 18:17:41 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:17:11 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:16:45 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:16:27 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:16:00 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:15:28 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:15:22 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:15:05 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:14:35 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:14:11 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:13:42 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:13:19 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:12:55 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:12:28 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:12:02 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:05:34 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 18:00:53 GMT+0000 (Coordinated Universal Time)

@diptish #bash

star

Thu Jan 18 2024 17:44:16 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 17:35:17 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 17:29:32 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 17:15:35 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 17:15:15 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 17:08:27 GMT+0000 (Coordinated Universal Time)

@login

star

Thu Jan 18 2024 17:06:45 GMT+0000 (Coordinated Universal Time) https://askubuntu.com/questions/444729/redirect-port-80-to-8080-and-make-it-work-on-local-machine

@p0ir0t

star

Thu Jan 18 2024 17:06:17 GMT+0000 (Coordinated Universal Time) https://unix.stackexchange.com/questions/111433/iptables-redirect-outside-requests-to-127-0-0-1

@p0ir0t #bash

star

Thu Jan 18 2024 16:22:30 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 16:20:04 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 16:17:06 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 15:40:35 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 15:38:07 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 15:32:38 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 15:28:25 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 14:17:27 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 14:16:10 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 14:15:27 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 14:12:08 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 14:06:23 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 14:02:34 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 13:55:05 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 13:44:45 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 13:42:02 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 13:38:59 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 13:36:31 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 13:35:11 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 13:33:27 GMT+0000 (Coordinated Universal Time)

@saida

star

Thu Jan 18 2024 13:17:32 GMT+0000 (Coordinated Universal Time) https://appticz.com/dream11-clone-app

@aditi_sharma_ #dream11 #dream11clone #dream11cloneapp #dream11cloneapp

star

Thu Jan 18 2024 13:08:49 GMT+0000 (Coordinated Universal Time)

@E23CSEU1151 #java

star

Thu Jan 18 2024 11:24:30 GMT+0000 (Coordinated Universal Time)

@E23CSEU1151 #java

star

Thu Jan 18 2024 11:01:45 GMT+0000 (Coordinated Universal Time)

@mwebrania #python

star

Thu Jan 18 2024 10:06:32 GMT+0000 (Coordinated Universal Time) https://www.orioninfosolutions.com/poker-game-development.php

@dckumawatorion #poker #software #php #html #css #design

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension