"Life is all about sharing. If we are good at something, pass it on." - Mary Berry

How to send an HTTP request without using curl?

2022-05-22

Problem

We are using JWT validation. For some reasons, when testing on staging, we got 401 error:

1[GIN] 2022/05/20 - 14:20:57 | 401 |    2.588128ms |       127.0.0.1 | POST     "/v1/endpoint"

Troubleshooting

After looking at the source code, we need to set the operation_debug to true to see what caused that error:

12022/05/20 08:31:26 KRAKEND ERROR: [ENDPOINT: /v1/endpoint][JWTValidator] Unable to validate the token: should have a JSON content type for JWKS endpoint

Read More...


Adele - Million years ago

2022-02-10

Vừa lên xe thì nghe được đoạn guitar hay quá, vội lấy điện thoại ra ghi âm lại (sợ về nhà không Gúc ra bài gì). 25 tuổi mà bạn ấy viết lời hay thật đấy!

Adele - Million Years Ago (Acoustic Cover by Emir Taha)

I only wanted to have fun
Learning to fly, learning to run
I let my heart decide the way
When I was young

Deep down, I must have always known
That this would be inevitable

Read More...


Mùi Tết

2022-02-06

Chung cake Bánh Chưng rán… nước lọc.

Sáng 29

Những năm chưa covid, về sớm. Lang thang chợ hoa để chọn một cây quất: gốc ba chạc, quả xanh, quả chín, một ít lá non trên ngọn và nhất định phải có một vài nụ hoa. Đến mùng một, mùng hai nở là vừa đẹp.

Có năm còn nhờ U đi chợ mua một ít hạt kê, về ngâm nước ấm rồi đem rải ở dưới gốc. Chúng nảy mầm, mọc cao khoảng 1, 2 cm nhìn như cỏ thật.

Read More...


Đau cổ

2022-01-20

https://www.upliftdesk.com/ergonomic-calculator/

Tôi ước có ai đó đã nói với mình những điều này ngay từ khi bắt đầu dùng máy tính. Nhưng thường là khi có dấu hiệu đau ở đâu đó thì mới đi tìm hiểu nguyên nhân.

  1. Màn hình phải để ngang tầm mắt.
    Nếu bạn dùng máy bàn ở cơ quan, đừng ngại kiếm mấy quyển sách để kê lên. Nếu bạn dùng laptop đừng tiếc xèng đầu tư một cái giá đỡ + bàn phím ngoài.

Read More...


Kat

2021-11-30

Kat


SICP Exercise 2.43: Eight queens: interchange the order of the nested mappings

2021-11-02

Exercise 2.43: Louis Reasoner is having a terrible time doing exercise 2.42. His queens procedure seems to work, but it runs extremely slowly. (Louis never does manage to wait long enough for it to solve even the 6× 6 case.) When Louis asks Eva Lu Ator for help, she points out that he has interchanged the order of the nested mappings in the flatmap, writing it as

Read More...


SICP Exercise 2.42: Eight queens puzzle

2021-10-29

Exercise 2.42: The “eight-queens puzzle” asks how to place eight queens on a chessboard so that no queen is in check from any other (i.e., no two queens are in the same row, column, or diagonal).

One way to solve the puzzle is to work across the board, placing a queen in each column. Once we have placed k - 1 queens, we must place the kth queen in a position where it does not check any of the queens already on the board.

Read More...


SICP Exercise 2.41: Triple sum

2021-10-18

Exercise 2.41: Write a procedure to find all ordered triples of distinct positive integers i, j, and k less than or equal to a given integer n that sum to a given integer s.

unique-triples can be written easily base on unique-pairs in 2.40:

1(define (unique-triples n)
2    (flatmap
3        (lambda (i)
4            (flatmap
5                (lambda (j)
6                    (map (lambda (k) (list i j k))
7                         (enumerate-interval 1 (- j 1))))
8                (enumerate-interval 1 (- i 1))))
9        (enumerate-interval 1 n)))

Read More...


SICP Exercise 2.35: Counting leaves of a tree

2021-10-14

Exercise 2.35: Redefine count-leaves from section 2.2.2 as an accumulation:

1(define (count-leaves t)
2    (accumulate <??> <??> (map <??> <??>)))

The count-leaves procedure from section 2.2.2:

1(define (count-leaves x)
2    (cond ((null? x) 0)
3          ((not (pair? x)) 1)
4          (else (+ (count-leaves (car x))
5                   (count-leaves (cdr x))))))

Read More...


SICP Exercise 2.27: Reversing nested lists

2021-10-12

Exercise 2.27: Modify your reverse procedure of exercise 2.18 to produce a deep-reverse procedure that takes a list as argument and returns as its value the list with its elements reversed and with all sublists deep-reversed as well. For example,

 1(define x (list (list 1 2) (list 3 4)))
 2
 3x
 4((1 2) (3 4))
 5
 6(reverse x)
 7((3 4) (1 2))
 8
 9(deep-reverse x)
10((4 3) (2 1))

First, look at my reverse procedure:

 1#lang racket/base
 2(require racket/trace)
 3
 4(define (reverse items)
 5    (iter items null))
 6
 7(define (iter remaining result)
 8    (trace iter)
 9    (if (null? remaining)
10        result
11        (iter (cdr remaining) (cons (car remaining) result))))
12
13(trace reverse)
14(reverse (list (list 1 2) (list 3 4)))

Read More...