Posts

Directory ownership change and mode change - Linux

- sudo chown hasib:hasib html/ - sudo chmod +x html/ - sudo chmod -R 777 html/

CURL

*** Initialize a cURL session $ch = curl_init(); *** Set the URL that you want to GET by using the CURLOPT_URL option. curl_setopt($ch, CURLOPT_URL, $url); *** Set CURLOPT_RETURNTRANSFER so that the content is returned as a variable. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); *** Set CURLOPT_FOLLOWLOCATION to true to follow redirects. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); *** Timeout after 120 seconds curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 120); *** Start counting time for response from BL API. $time_start     = microtime(true); $requestTime    = Carbon::now()->format('Y-m-d H:i:s'); *** Execute the request. $response   = curl_exec($ch); *** End counting, and calculate time for response from BL API. $time_end       = microtime(true); $responseTime   = Carbon::now()->format('Y-m-d H:i:s'); $execution_time = ($time_end - $time_start)*1000; *** Return a string containing the ...

MySQL Query - IF CONDITION, DATE FORMAT, ADD DAY IN DATE, SUBTRACT DAY FROM DATE

1. IF CONDITION SELECT IF(condition,true,false) AS row_name; 2. ADD 10 DAYS IN DATE SELECT DATE_ADD("2019-10-01", INTERVAL 10 DAY) 3. SUBTRACT 10 DAYS FROM DATE SELECT DATE_SUB("2019-10-01", INTERVAL 10 DAY); 4. FORMAT DATE DATE_FORMAT(table.date, "%Y-%m-%d 23:59:59") PRACTICAL EXAMPLE IN A SELECT-INSERT QUERY :  INSERT INTO subscription_history( customer_id, sales_log_id, customer_name, plan_id, plan_name, plan_duration, transaction_price, subscription_plan_purchased_date, subscription_activation_date, subscription_end_date, status, created_by, updated_by, deleted_by, deleted_at, created_at, updated_at) SELECT  sales_log.customer_id, sales_log.id AS sales_log_id, customers.name AS customer_name, sales_log.plan_id, subscription_plans.plan_name, subscription_plans.plan_duration, subscription_plans.plan_price AS transaction_price, sales_log.sales_date AS subscription_plan_purchased_date, sales_log.sales_date AS subscription_acti...

When failed to start MariaDB database server (Solution - Again Installation)

In the tutorial you should install mariadb-server in place of mysql-server. sudo apt purge mysql* sudo apt purge mariadb* sudo apt autoremove sudo apt autoclean Check if still something in the system : dpkg -l | grep -e mysql -e mariadb  if the list is empty then install mariadb server : sudo apt install mariadb-server Now try to check status on stop and start the database : Status after install : sudo systemctl status mysql.service ● mariadb.service - MariaDB database server    Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)    Active: active (running) since Wed 2018-03-21 16:08:49 CET; 2min 1s ago  Main PID: 15699 (mysqld)    Status: "Taking your SQL requests now..."    CGroup: /system.slice/mariadb.service            └─15699 /usr/sbin/mysqld .../.. Check the PID : sudo more /var/run/mysqld/mysqld.pid  15699 Stop the database : su...

Create User for phpMyAdmin (MySQL)

1. sudo mysql -p -u root 2. CREATE USER 'pmauser'@'%' IDENTIFIED BY 'password_here'; 3. GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'%' WITH GRANT OPTION;

Document Ready

1. Javascript code execution on ready document  $('.discard-ticket').on("click", function (ev) { }) 2. Javascript code execution on executed document $(document.body).on('click','.discard-ticket',function(ev){ })

Rename a local and remote branch in git

If you have named a branch incorrectly AND pushed this to the remote repository follow these steps before any other developers get a chance to jump on you and give you shit for not correctly following naming conventions. 1. Rename your local branch. If you are on the branch you want to rename: > git branch -m new-name If you are on a different branch: > git branch -m old-name new-nam e 2. Delete the old-name remote branch and push the new-name local branch. > git push origin :old-name new-name 3. Reset the upstream branch for the new-name local branch. Switch to the branch and then: > git push origin -u new-name