Posts

PHP.....Fundamental

 sorting as array of associative array.....using the value of perticular key: In ascending order: usort( $inventory , function ( $item1 , $item2 ) { return $item1 [ 'price' ] <=> $item2 [ 'price' ]; }); In descending order   usort( $inventory , function ( $item1 , $item2 ) { return $item2 [ 'price' ] <=> $item1 [ 'price' ]; });     Other solution : array_multisort(array_column( $inventory , 'price' ), SORT_DESC, $inventory ); If you want Case Insensitive Sort on strings, you can use SORT_NATURAL|SORT_FLAG_CASE array_multisort(array_column( $inventory , 'key_name' ), SORT_DESC, SORT_NATURAL|SORT_FLAG_CASE, $inventory );       count occurrences of values in an associative array in php $employees = array ( 1 => array ( 'name' => 'Jason Alipala' , 'employee_id' => 'G1001-05' , 'position' => 1 ), 2 => array ( ...

Node Basics

Image
                                                                 Event Loop Node                                      Single Thread , Event loop & Blocking code                                                                Basic wrap up           

General info - 6350958828e0b

Image
29-08-2025 OFC: #LSEM@raj2025     Add new column of id : ALTER TABLE spam_alter_email  ADD `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ; exporting large db with ternimal : mysqldump --max_allowed_packet=1024M -u root -p database > dumpfile.sql   /home/rajeshwar/Videos/Cluster_query/2023-10-06/Cluster_New_update     Gravtar logo : https://ui-avatars.com/api/?name=John+Doe&background=random  load data from file into database : LOAD DATA INFILE '/home/export_file.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '/n' IGNORE 1 ROWS; download large set of databse : mysqldump -h 127.0.0.1 -u root -p spam_alter > database-dump-alter.sql Note for all this : 1: we have to modify max_upload_file_size , memory_size in the php.ini file. 2:php.ini file lives under the composer folder and then php version folder.   plocation key : 2c0bc0ca84f049c9ac43848eb0189e30 URL : $ip = '8.8.8.8' 'https://ap...

Angular

Image
                           How an Angular App gets Loaded and   Started   To start an angular app , the app first executes the main.ts file  where it looks for the app.module and in the app module we have the bootstrap array that contains the AppComponent and the appComponent get executes with the html code it has.                                                   Creating a New Component To create a component :    1:     import Component from @anguler/core    2:     create the component imported as a method with @ in the beginning    3:     This component method takes an argument like : selector , template/templateUrl , style/styleUrl.    4: Finally export the c...

sitemap date format

  Date formating in sitemap.xml file for SEO:     The 'lastmod' element has to be of the format YYYY-MM-DD or YYYY-MM-DDThh:mmTZD so use: gmdate( 'Y-m-d' , strtotime($row[ 'modified' ][ 'value' ])) or gmdate( 'Y-m-d\TH:i:s+00:00' , strtotime($row[ 'modified' ][ 'value' ]))

Oop - php

                                                              OOP-PHP      1:config.php     store all the db related info uder this file as constant:      <?php define ( "DB_HOST" , "ecom.loc" ); define ( "DB_USER" , "root" ); define ( "DB_PASS" , "" ); define ( "DB_NAME" , "phptest" ); ? > 2: Database.php create a class with suitable name  and initialize the connection from the database with oop mysqli. and make a function for selecting the data from the database. <?php class Database { //database configuration variables public $host = DB_HOST ; public $user = DB_USER ; public $pass = DB_PASS ; public $dbname = DB_NAME ; //connection and error variables public ...