How to use OpenAI ChatGPT in PHP

Step 1: Create a developer account with OpenAI

Do note that you are required to enter your credit card info as the developer account is a paid version.

Step 2: Generate a secret API key

You will need a API key for development.

Step 3: Install the package

I’m using the OpenAI API Client in PHP from https://github.com/orhanerday/open-ai. Install the package via your composer/ubuntu:

Continue reading “How to use OpenAI ChatGPT in PHP”

SQL get most recent record from group if record is active

In this tutorial, we will be using SQL MAX, subqueries, LEFT JOIN, IN. We want to show the most recent record from all users if the most recent record is active.

Assumption:

  • The primary key for subscription table is integer id. It starts from 1 for the first record and auto-increment for the rest.
  • A subscription has a start and end date. It may or may not have a early termination date.
  • If the end date or termination date has passed, it means that the subscription is no longer active.
  • Active status means that the project has started and both end date and termination date are future dates.
  • Current date is 31 October 2019.

Continue reading “SQL get most recent record from group if record is active”

How to configure Sphinx search & fix issues


Configure your Sphinx


Create your first index

To begin, you need to install Sphinx in your development environment. Next, look for the configuration file called sphinx.conf that is in /usr/local/sphinx/etc/ directory and edit the template to match your database. See below for an example of the standard template for creating your first index. You will need a source and index. Continue reading “How to configure Sphinx search & fix issues”

Meal plan: It’s mind over body

This is my meal plan since December 2017 and I was very strict with it till July 2018. It is similar to intermittent fasting on non-exercise days. I lost 4 kg in the very first month by just following this diet without exercise and I lost another 4kg through exercising in the second month. I am still sticking to it but making adjustment along the way.

A change in your diet should be a lifestyle change. It becomes a habit when you do it consistently and got used to it. That way, you don’t feel that it is a chore.

Difficulty: 2.5/5  |  Effectiveness: 5/5

9am breakfast

A

Skipped or

B

2 hard-boiled eggs or

C

Meal replacement shake

Continue reading “Meal plan: It’s mind over body”