Tuesday, 18 July 2023

Create SSL/TSL Certificate in AWS ACM

cname name and cname value

cname allows to point a hostname to any other hostname. hostname1 maps to hostname2. Here hostname1 is called cname name and hostname2 is called cname value. cname name can not be root domain name. something.mydom.com works, but mydom.com can not be used to be cname name.

Can use dig command to find cname /cname value pair.

dig checkout.mytest.com

Request a certification in AWS ACM

  1. request a public certification. Also choose DNS validation
    • If record is in AWS route 53, AWS will do validation automatically and issued the certificate
    • If record is not in AWS route 53, grab the cname name and cname value provided by the certificate. Create a cname record in your domain registra, and AWS will verify it and issue the certificate

Add certificate to ELB

The default Limit for Certificates per Application Load Balancers is 25

  • Select the load balancer.
  • On the Listeners and rules tab, choose the text in the Protocol:Port (443) column to open the detail page for the listener.
  • On the Certificates tab, choose Add certificate.
  • Within the ACM and IAM certificates table, select the certificates to add and choose Include as pending below
  • Choose Add pending certificates.

Delete a certificate

  1. Got to ACM to find that certificate. Check if it is in use. If it is in use, write down which elbs are using it.
  2. If in use, go to elb. click cetificates, and check that certificate. Then click remove.
  3. After it is removed from all associated elbs, go back to ACM. Choose the certificate, and click delete

Monday, 17 July 2023

API Access-Control-Allow header


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

Friday, 7 July 2023

MySQL Query

rank

# see leetcode 2173 https://leetcode.com/problems/longest-winning-streak/description/
select
    player_id,
    result,
    RANK () OVER (
        PARTITION BY player_id,
        result
        ORDER BY
            match_day
    ) as my_rank
from
    Matches
order by
    match_day

generate sequence


# 1 to 100
WITH RECURSIVE seq AS (
    SELECT 1 AS value UNION ALL SELECT value + 1 FROM seq WHERE value < 100
    )

create help tables


with platforms as (
select 'Android' as platform
union
select 'IOS' as platform
union
select 'Web' as platform
),

 activities as (
  select 'Reading' as experiment_name
  union
  select 'Sports' as experiment_name
  union
  select 'Programming' as experiment_name
)

More Queries

#day function converts timestamp to day. 2023-10-11 23:33:33 to 11

select day(created), partner_fid, count(*) from cpa_conversion where created>="2024-9-1" group by day(created), partner_fid;