Wednesday, 15 April 2026

GitHub Copilot Agents

Review agent in vscode

  1. create a folder .github in your workspace
  2. Create a agents folder in .github
  3. Create Reviewer.agent.md file in agents
  4. Choose reviewer as agent in chat window

Reviewer.agent.md content

---
name: "Reviewer"
description: "Review code for quality and adherence to best practices."
tools:
  ["vscode/askQuestions", "vscode/vscodeAPI", "read", "agent", "search", "web"]
---

# Code Reviewer agent

You are an experienced senior developer conducting a thorough code review. Your role is to review the code for quality, best practices without making direct code changes.

When reviewing code, structure your feedback with clear headings and specific examples from the code being reviewed.

## Analysis Focus

- Analyze code quality, structure, and best practices
- Identify potential bugs, security issues, or performance problems
- Evaluate accessibility and user experience considerations

## Important Guidelines

- Ask clarifying questions about design decisions when appropriate
- Focus on explaining what should be changed and why
- DO NOT write or suggest specific code changes directly

Tuesday, 14 April 2026

MySQL docker container in a host machine which has MySQL server running

Map container to another host port other than 3306

version: '3'
services:

  mysql:
    container_name: docker_mysql_1
    ports:
      - 3307:3306/tcp
    privileged: true
    restart: on-failure
    image: mysql:8.4
    volumes:
      - mysql84:/var/lib/mysql
    network_mode: bridge
    environment:
      MYSQL_ROOT_PASSWORD: test1234
    command:
      - --innodb_file_per_table=0
      - --innodb_checksum_algorithm=INNODB
      - --binlog_checksum=NONE
      - --sql_mode=NO_ENGINE_SUBSTITUTION
      - --slow-query-log=1
      - --slow-query-log-file=/var/log/mysql/my-slow.log
      - --long_query_time=1
      - --log-queries-not-using-indexes
      - --restrict_fk_on_non_standard_key=0
    security_opt:
      - seccomp=unconfined

volumes:
  mysql84:

After container is up, connect to container Mysql Server

#when ask password, type: test1234
mysql -h 127.0.0.1 -P 3307 -u root -p 

#another way using container name
docker exec -it docker_mysql_1 mysql -uroot -p

To connect MySQL running on the host machine. Assume there is MySQL user tester

mysql -u tester -p

How to check who owns 3306 now

#On host:
ss -ltnp | grep 3306
# or
lsof -i :3306

Monday, 13 April 2026

GitHub Copilot

Check vscode version

  • Code => About Visual Studio Code (in Mac)
  • Help => About

Check which github account is logged in for vscode

Click accounts icon (icon like a person

See Github Copilot features enabled and usage for your account

Limitations for different plans

Plans for GitHub Copilot

GitHub Copilot in VS Code docs

Copilot in VS Code

Get Start With Github Copilot

vscode external browser

  • install Live Preview extension
  • go to command palette
  • Live Preview: show debug preview

Shortcuts

  • add inline chat. (crtl + i)

troubleshooting

Error: request failed. Solution: log into Github while using vscode

  1. in vscode account. sign out
  2. in browser, sign out github
  3. Open vscode and crtl + i
  4. following instruction to sign in again

Wednesday, 8 April 2026

How to check php package in alpine linux

Go to Alpine Linux

  • In Package name field, search php83, php84 or php85
  • In Branch field, choose v3.23, v3.23 etc

Friday, 6 March 2026

Add Openai gpt-5.3-codex model into my Openai web application

Here is My Openai Chat Github Repository

To add gpt-5.3-codex model

  • Update Dockerfile to use python:3.9 base image.
  • Update requirements.txt to use Django 4.2.0 and Python openai sdk 2.26.0
  • Use Python openai sdk response api to interact with Openai gpt-5.3-codex model

Wednesday, 4 March 2026

See affected AWS resources for upcoming events

  1. log into aws console
  2. go to AWS health Dashboard
  3. ckick Scheduled changes
  4. click Calendar
  5. choose date
  6. click Upcomming
  7. choose one of events to see affected resourses

Thursday, 15 January 2026

SFTP server

#log in
sftp leo@82.992.123.124

#after log in

# upload a file:
put test.txt

# download a file
get test.txt

# delete a file
rm test.txt

Directly copy file between the server and the local machine if can ssh to the server

# find server public ip: 100.31.47.111

# ssh to the server
ssh -i /Users/leo/path/noc.pem ec2-user@100.31.47.111

# copy file to server
scp -i /Users/leo/path/noc.pem /Users/leo/path/test.txt.gpg  ec2-user@100.31.47.111:/home/ec2-user/

# copy file from server to local
scp -i /Users/leo/path/noc.pem  ec2-user@100.31.47.111:/home/ec2-user/test.txt  /Users/leo/path/ 

Decrypt gpg file

# verify have the private key
gpg --list-secret-keys

# decrypt. when prompt, provide private key phrase
gpg --decrypt --output mytest.csv  mytest.csv.gpg

Monday, 12 January 2026

CORS

Error: Access to fetch at .... has been blocked by CORS

CORS stands for cross origin resource share. If use Javascript to fetch a endpoint and endpoin is not the same origin as the current page, may see the above error. Here origin is protocol + domain + port.

//host is https://examplea.com
<script>

 let endpoint = "https://exampleb.com/create-order";
 return fetch(endpoint, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(data)
    })
      .then(resp => {
        if (!resp.ok) throw new Error('Network response was not ok');
        return resp.json();
      });
</script>

To solve the issue. For that end point of exampleb.com. the response needs to set headers such as

$response = $response->withHeader('Access-Control-Allow-Origin', "*");
        
return $response->withHeader('Access-Control-Allow-Headers', 'X-Requested-With,x-api-key, Content-Type, Accept, Origin, Authorization, X-Authorization-JWT, X-CSRF-Token')
	->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
    }

Wednesday, 7 January 2026

Javascript Class

Class in ECMAScript 5

function PersonType(name) {
    this.name = name;
}

PersonType.prototype.sayName = function() {
    console.log("your name:" + this.name);
}

let person = new PersonType("leo");
person.sayName();

Class in ECMAScript 6

class PersonType {
    constructor(name) {
        this.name = name;
    }
    sayName() {
        console.log("your name:" + this.name);
    }
}

let person = new PersonType("leo");
person.sayName();

Use class in web page

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="person.js"></script>
    <script>
        let p = new Person('leo');
        p.sayName();
    </script>
</head>
</html>

person.js

class Person {
    constructor(name) {
        this.name = name;
    }
    sayName() {
        console.log("your name:" + this.name);
    }
}

// export to global namespace so index.html can see it
window.Person = Person;

Javascript Promise

Create a promise and consume a promise

example one

let p = new Promise((resolve, reject) => {
    let n = Math.floor(Math.random() * 100);
    let good = n % 2 == 0 ? true : false;

    if (good) {
        setTimeout(resolve, 100, { "dd": 1212 });
    } else {
        setTimeout(reject, 200, "bad2");
    }
});

p.then((v) => console.log("suc", v))
    .catch((v) => console.log("failed:", v));

//this is identical as the above
p.then((v) => console.log("suc", v), (v) => console.log("failed:", v));

example two

import { readFile as _readFile } from 'fs';

let p = new Promise((resolve, reject) => {
  _readFile("./test.js", 'utf8', (err, data) => {
    if (err) {
      reject(err);
    } else {
      resolve(data);
    }
  })
});

p.then((data) => console.log("good", data))
  .catch((err) => console.log("err", err))

Use await to consume a function which return a promise

example one

function myCreate() {
    return new Promise((resolve, reject) => {
        let n = Math.floor(Math.random() * 100);
        let good = n % 2 == 0 ? true : false;

        if (good) {
            setTimeout(resolve, 100, { "dd": 1212 });
        } else {
            setTimeout(reject, 200, "bad2");
        }
    });
}

//Any exception thrown in the try block (or any rejected promise when using await) will jump to the catch.
try {
    const ans = await myCreate();
    console.log("ans", ans);
} catch (err) {
    console.log("err:", err);
}

use async function to consume the promise

function myCreate() {
    return new Promise((resolve, reject) => {
        let n = Math.floor(Math.random() * 100);
        let good = n % 2 == 0 ? true : false;

        if (good) {
            setTimeout(resolve, 100, { "dd": 1212 });
        } else {
            setTimeout(reject, 200, "bad2");
        }
    });
}

async function test() {
    try {
        const ans = await myCreate();
        console.log("ans", ans);
    } catch (err) {
        console.log("err:", err);
    }
}

test();

You still can use then to consume a promise returned by a function.

function myCreate() {
    return new Promise((resolve, reject) => {
        let n = Math.floor(Math.random() * 100);
        let good = n % 2 == 0 ? true : false;

        if (good) {
            setTimeout(resolve, 100, { "dd": 1212 });
        } else {
            setTimeout(reject, 200, "bad2");
        }
    });
}

myCreate().then((ans) => console.log("ans", ans), (err) => console.log("err:", err));

Tuesday, 6 January 2026

Install older version vscode

Install

  • go to vscode versions
  • Pick a one and download
  • For mac, unzip the file. Drag app file into Application folder

Prevent from upgrading automatically

  • – Open VS Code.
  • – Press ⌘, (Command-Comma) to open Settings.
  • – In the search box type “update”.
  • – Under Features → Updates find “Update: Mode” and set it to “none”.