Skip to main content

Posts

Showing posts from 2022

Drupal Setup with docker

Option 1:  docker pull mysql docker pull phpmyadmin docker pull drupal docker run -d --name MysqlClient -e MYSQL_ROOT_PASSWORD=drupal mysql Download the phpmyadmin image and Setup Container: docker run --name phpmyadmin -d --link MysqlClient:db -p 8083:80 phpmyadmin Download the Drupal image and Setup Container: docker run -d --name dweb2 --link MysqlClient -p 8082:80 -e MYSQL_USER:root -e MYSQL_PASSWORD:drupal drupal   We are using docker4 drupal and following below URL https://wodby.com/docs/1.0/stacks/drupal/local/ From Mount my codebase Download and unpack docker4drupal.tar.gz with hidden files in a new directory, also get the drupal code with in web directory composer create - project drupal / recommended - project my_site_name_dir It means with in new directory we have docker files and drupal files also has web folder for drupal. now run docker-compose up -d Now PROJECT_BASE_URL is mentioned in .env file open this url in the web with port, it will open the drupal page, ...

Python Learning OOPs Part -2

  class Dog : # Class Object Attribute species = 'mammal' def __init__ ( self , breed , name ): self . breed = breed self . name = name     Lets break down what we have above.The special method __init__() is called automatically right after the object has been created, similer to construct() in php self argument is necessary in python, php has default so no need to pass in php sam = Dog ( 'Lab' , 'Sam' ) //here creating the instance of the class, no need to pass new keyword in python   Inheritance: class Animal : def __init__ ( self ): print ( "Animal created" ) def whoAmI ( self ): print ( "Animal" ) class Dog ( Animal ): // Inherating the Animal Class def __init__ ( self ): Animal . __init__ ( self ) print ( "Dog created" )   Error Handling & Exception :     try : f = open ( 'testfile' , 'r...

ES6 JS Refresher React Learning

 JavaScript refresher let and const: in Normal js we mostly used the var keyword to store the variables. but let is the new advanced concept to hold the value , its introduced in es6. let name = 'raj';  is same as var name = 'raj'; const host = 'localhost'; // To declare the constant variables   Arrow Function: let hello = () => {   return "Hello World!"; }  hello();  Exports and Imports:                            Spread & Rest Operators: const numbersOne = [1, 2, 3]; const numbersTwo = [4, 5, 6]; const numbersCombined = [...numbersOne, ...numbersTwo];      Rest Operator :  The rest operator is used to put the rest of some specific user-supplied values into a JavaScript array. function sumUp(...num){ console.log(num);//[10,20,30] here i am getting the array }   sumUp(10,20,30);// Passing here as a numbers not array Conver list of values to ...

Python Learning Part -1

Indexing and slicing with strings :  string = 'abcdefghijk' string[STARTING_INDEX_POSITION:GO_UPTO_INDEX_POSITION]  string[2:] //output cdefghijk string[:3] //output abc note-> it says goes upto the index d but not include the index d string[3:6] // output def String Concatenation : name = 'Amar'  lname = 'Singh' fname = name + lname // output Amar Singh Lost of string inbuild functions are there you can check and explore them like name.split() // ['Amar','Singh'] // split the string based on the white space Print Formatting with String : Format A string with .format() Input : print('my name is {}'.format('Dharmendra')) output : my name is Dharmendra Lists in Python: lists are ordered sequences which holds variety of object types. they use [] and , to separate it list support index & slicing   like [1,2,3,4,5] mylist = [1,2,3,4,5] mylist[1:] //[2,3,4,5] has some inbuild functions like .pop, .sort etc Dictionaries in Python ...

How To install and Use Anaconda for Python

 Download the sh file of anaconda from the below site. https://www.anaconda.com/products/distribution exceute the downloaded sh file  ssh Anaconda3-2022.05-Linux-x86_64.sh  and follow the steps, When done reopen the terminal and type anaconda-navigator (base) dharmendra@TTNPL-dharmendrasingh : ~ $ anaconda-navigator

How to Use Drush with Docker

 First make sure Drupal setup is up and running with docker ,  Execute the command docker ps to verify all the running container, Then execute the PHP container with bash of the application by below command docker exec -it {php_container_id} bash composer require drush/drush vendor/bin/drush --version  It will open the php docker container bash interface,,,  make sure you are in the right folder path like, var/www/html Here you can execute the drush command directly like below... How to use SSH with Lando services: First check the services which we are using by cmd lando info And then we can use lando ssh appserver{service name}  

Memcache Basics

Key Features of Memcache. 1- It's open source. Memcache server is a big hash table it significantly reduces the database load it's perfect for a website which has High Database Load. its client-server application over TCP/UDP How to Install it on Linux, Sudo apt-get install Memcached Default Port is - 11211 To connect to the Memcache server you need to use the Telnet command on HOST & PORT cmd - $telnet HOST PORT For exp - $ telnet 127.0.0.1 11211 Memcache set command is used to set a new value to a new or existing key. Command:-  set kEY FLAGS EXPTIME BYTES (noreplay) Value - KEY - name of the key - FLAGS - Its 32-bit unassigned integer that the server stores with the data provided by the user, and returns along with the data during the fetch - EXPTIME - expiration time in seconds - BYTES - Length of data(in bytes) which need to store in Memcache - noreplay - this parameter informs not to send any replay  from the server during the set - VALUE - It is the data that we nee...

MongoDB Uses

  To use MongoDB with PHP, you need to use MongoDB PHP driver. Add  extension = php_mongo.dll in php.ini file $m = new MongoClient (); echo "Connection to database successfully" ; // select a database $db = $m -> mydb ; It will create the connection & also select the database. if Database is not available then it will create automatically. $collection = $db -> createCollection ( "mycol" ); It will create a new collection in the DB. $db = $m -> mydb ; echo "Database mydb selected" ; $collection = $db -> mycol ; echo "Collection selected succsessfully" ; $document = array ( "title" => "MongoDB" , "description" => "database" , "likes" => 100 , "url" => "http://www.tutorialspoint.com/mongodb/" , "by" => "tutorials point" ); $collectio...