We have 2 bucket that can be filled with 13kg and 5kg respectively. Certainly, we have a lot of sand. We can use unlimited sand. How can we get 11kg of sand from a huge sand pile?
ต้นฉบับใน https://www.facebook.com/share/p/Q4d2xXo63Wuu1vMw/
จากที่ผู้เขียนเกิดความสงสัยว่า
ขอลดรูปคำถาม* เป็น
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| drop function get_fee_master; | |
| create or replace function get_fee_master (jsonrate jsonb) | |
| returns table (fm_start_range decimal, fm_end_range decimal, fm_rate decimal, fm_acc_prev_fee decimal) | |
| language plpgsql | |
| as $$ | |
| begin | |
| return query | |
| with rate_master as ( | |
| select | |
| coalesce(lag(amount) over (order by amount), 0) as start_range, |
สรุปในมุม pseudo code เป็น JavaScript snippet
let condLength = 3;
let winningConditions = Array.from(
Array(condLength).keys(),
(_, i) => i < condLength - 1 ? i + 1 : 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # "python.analysis.typeCheckingMode": "strict", | |
| from typing import Generic, TypeVar | |
| T = TypeVar('T') | |
| class MyClass(Generic[T]): | |
| def run(self, x: T) -> T: | |
| return x | |
| class ExtendedMyClass(MyClass[int]): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dataclasses import dataclass | |
| @dataclass | |
| class A: | |
| id: int | |
| def __eq__(self, other): | |
| return self.id == other.id | |
| @dataclass(eq=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def deep_flatten(data: dict, flatten_result: dict = {}, parent_key: str = ""): | |
| for key, value in data.items(): | |
| target_key = f"{parent_key}.{key}" if parent_key else key | |
| if isinstance(value, dict): | |
| deep_flatten(value, flatten_result, target_key) | |
| else: | |
| flatten_result[target_key] = value | |
| return flatten_result | |
| assert deep_flatten( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE OR REPLACE FUNCTION PDBADMIN.GET_TB(DJANGO_FULL_INSTANCE_NAME IN VARCHAR) RETURN VARCHAR | |
| IS | |
| /** | |
| * GET TABLE NAME LIMITED BY ORACLE 30 CHARACTER RULE | |
| * RELATED DJANGO CODE IS [HERE](https://github.com/django/django/blob/main/django/db/backends/utils.py#L283) | |
| * | |
| * PARAMETER | |
| * --------- | |
| * - DJANGO_FULL_INSTANCE_NAME [VARCHAR] IS DJANGO_APP_NAME PLUS '_' PLUS DJANGO_MODEL_NAME | |
| * FOR EXAMPLE, IF YOU WOULD LIKE TO GET THE TABLE NAME OF RequestForCompensationAppealItem |
-
install phpenv from it's instruction, including optional steps
-
install the related libraries, refer to this issue
-
normally, on macos, you cannot use plain install command, otherwise, you face the problem
configure: error: Please reinstall the [PACKAGE] distribution -
so, install target php version available from php-build list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create table abc ( | |
| a int primary key, | |
| b text | |
| ) ; | |
| begin transaction; -- begin transaction | |
| insert into abc (a, b) values (1, 'testing'); -- success | |
| insert into abc (a, b) values (1, 'testing2'); -- failed | |
| commit; -- rollback | |
| end; -- end transaction |
NewerOlder