Saturday, January 30, 2021

Top 20 Algorithms Every Programmer Should Know

 Searching

1. Linear Search

2. Binary Search

3. Breadth First Search (BFS)

4. Depth First Search (DFS)

Sorting

5. Merge Sort

6. Quick Sort

7. Insertion Sort 

8. Selection Sort 

9. Counting Sort 

10. Heap Sort

11. Topological Sort

12. Kahn’s Topological Sort

Arrays

13. KMP

14. Kadane’s 

15. Quickselect

16. Floyd’s Cycle Detection

17. Boyer–Moore Majority Vote

Basic Algo

18. Euclid’s

19. Union Find

20. Huffman Coding Compression

Monday, January 25, 2021

How to build an Angular 8 app from scratch in 11 easy steps


Step 1 — Installing Angular CLI 8


Step 2 — Creating your Angular 8 Project


Step 3 — Adding Angular HttpClient


Step 4 — Creating Components


Step 5 — Adding Routing


Step 6 — Building the UI with Angular Material Components


Step 7 — Mocking a REST API


Step 8 — Consuming the REST API with Angular HttpClient


Step 9 — Handling HTTP Errors


Step 10 — Adding Pagination


Step 11 — Building and Deploying your Angular Application to Firebase



Reff : https://www.freecodecamp.org/news/angular-8-tutorial-in-easy-steps/

Thursday, January 9, 2020

Codeigniter URL Routing, Suffix & Enable Query String

Wildcards:

We can use two types of wildcards, namely:
  1. :num –  Segment containing only numbers will be matched.
  2. :any – Segment containing only characters will be matched.

$route['(blog/:num)'] = 'tutorial/java/$1';
$route['(blog/:any)'] = 'tutorial/java';

Regular Expression
$route['blog/([a-zA-Z0-9]+)'] = 'tutorial/java';

Saturday, October 12, 2019

JQuery count number of divs with a certain class?


var numItems = $('.item').length;

Get all text field value located in a specific class


$(".test .text-field").each(function() {
    alert($(this).val());
});

Note : test and text-field is class of text field

Friday, June 7, 2019

Remove Menu From Wordpress Admin

add_action('admin_init', 'remove_menu_from_admin');

function remove_menu_from_admin()

    // Remove unnecessary menus
    $menus_to_stay = array(
        // Job Listing
        'edit.php?post_type=job_listing',
    );
    foreach ($GLOBALS['menu'] as $key => $value) {         
        if (!in_array($value[2], $menus_to_stay)) remove_menu_page($value[2]);
    }
}

Thursday, April 18, 2019

PHP Code to Remove Everything Except Number


$mobileNumber = "(111) 2568-5698";

preg_replace('/\D/', '', $mobileNumber);

OR,

preg_replace('/[^0-9]/', '', $mobileNumber);

Monday, April 1, 2019

Encrypt and Decrypt a PHP String

function decEnc($action, $string) {
$output = false;

$encrypt_method = "AES-256-CBC";
$secret_key = 'Secret key';
$secret_iv = 'Secret iv';

// hash
$key = hash('sha256', $secret_key);

// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
$iv = substr(hash('sha256', $secret_iv), 0, 16);

if( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
}
else if( $action == 'decrypt' ){
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}

return $output;
}

Encryption Example:
$string = "hanzala";
decEnc("encrypt", $string);

Decryption  Example:
$string = "eU15RFhTZGN5SWJzTGgrRSs4SW9zQT09";
decEnc("decrypt", $string)

Sunday, March 31, 2019

How to get the value of selected radio button in a group using jQuery

    $(document).ready(function(){
        $("input[type='button']").click(function(){
            var radioValue = $("input[name='gender']:checked").val();
            if(radioValue){
                alert("Your are a - " + radioValue);
            }
        });
       
    });