Skip to main content

Posts

Google Sign-in using OAuth with PHP CodeIgniter 3 & JQuery

Pre-requisites: Setup project info in Google API Console . If you dont have any projects, add a new one. Make sure your OAuth Consent Screen have been configured correctly. If not, then now is the right time.  Choose user type 'External' and click Create. Fill up your project's details. Make sure to use your real project name. You will need to insert a link for your application's terms of service & privacy policy. Fortunately, you can just use google drive links for these files. Unless you know what you're doing, only select these scope. Add test users.  Review your changes and go back to the dashboard. Click Create credentials > OAuth client ID. Select Web application to create a new client ID. Add your server URLs in Authorized JavaScript origins or it wont work. In my case, adding localhost does nothing and I needed to test my project on the server with working URL instead. Go back to the Credentials menu. Click copy client id on the OAuth 2.0 Client IDs ...

Browse Reddit with Microsoft Visual Studio Code (VSCode)

Ever feel bored at work and thinking that it would be nice to scroll Reddit without your coworkers noticing? There's a fix to that problem.   Install Reddit Viewer . It does literally what it's name suggests. View Reddit. But there is a catch. After all, nothing comes trouble free, you have to work for it.  Upon opening the command that starts the extension, you will be greeted by a warm and welcoming error. A great scare to an intern and a mild annoyance for a programmer. Just like any other bugs you can find in real life, just try to step around it and hopefully wont fly towards you.  To make it work, just open the extension page. Then click the settings icon besides the uninstall button and click the extension settings. Next, you can either scrolls towards the 'Reddit Viewer: Home Trending' setting like a pleb or you can gloriously search it with the search bar. Untick the checkbox. And now you can open the extension without getting any errors. As of writing this blo...

HMVC vs HAVC vs MVC

  HMVC vs HAVC vs MVC MVC lama2 boleh jadi serabut sbb semua module dalam 1 folder sesuai projeck kecil - sederhana contoh: controller Programs Members model program_model member_model view program list form member list form HMVC lawa sikit, satu folder module yg dalam dia ada folder controller, view, model sesuai projek sederhana - besar contoh: modules program model program_model controller Programs view list form member model member_model controller Members view list form HAVC basically HMVC, tapi M tukar A sbb asset instead of model. takde model. segala benda resouce dia letak dalam asset, tak kira model   ke apa unique dkt trongate contoh: modules program asset images js css program_model controller Programs view list form

PHP Short Code

ternary vs coalescing null operator checks for null values example: echo isset($item_name) ? $item_name : NULL; echo $item_name ?? NULL; ternary vs elvis operator (ternary shorthand) checks for truthy values example: echo !empty($item_name) ? $item_name : NULL; echo $item_name ?: NULL; using ternary vs (coalescing null operator & elvis operator) example: echo isset($item_name) && !empty($item_name) ? $item_name : ‘default’; echo $item_name ?? $item_name ?: ‘default’; spaceship operator used to compare 2 values and returns either -1,0,1. mostly used to compare dates example: var_dump(1 <=> 2); // returns int(-1) var_dump(1 <=> 1); // returns int(0) var_dump(2 <=> 1); // returns int(1)

Test Guideline

  Test Guideline understand the requirement fahamkan title, desc & requirement task take note access utk user test lebih dari 1 organisasi try masuk sanitised live account utk test listkan main point utk di test create a test plan take note possible scenario try buat flow dari awal ikut flow yg legit cari page lain yg mungkin affected, contoh: satu view mungkin diguna untuk beberapa function perform testing functional testing - test function & mencapai goal atau tak non functional testing - ux, performance, security, usability test result focus on one test, takut lupa. then proceed with next one Conclusion: Test sehabis baik, try untuk cari bug sebelum sampai ke tester/production. 

Other useful things I sometime use but always forgot

  🐘 Useful PHP functions One line year array // will get the past 3 year including current year. eg: 2021,2022,2023 for ($i=-2; $i <= 0 ; $i++) $data['year'][date('Y')+$i] = date('Y')+$i; Unset attribute in array of array object $body_list[$count] = array(             'attr' => array(                 '1' => 'one',                 '2' => 'two',             ),             'data' => (object) array(                 '3' => 'three',                 '4' => 'four',             )         ); unset($body_list[$count]['data’]->{‘3’}); // will remove attribute ‘three’ Merge/combine array with duplicate keys while preserving the values // use this inside loops where + won...