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
(ns core-logic.core | |
(:require [clojure.core.logic :as logic] | |
[clojure.core.logic.fd :as fd])) | |
;;; 출처: https://blog.taylorwood.io/2018/05/10/clojure-logic.html | |
(defn- productsumo | |
"Sigma (vars_i * denoms_i) = sum 을 만족하는가." | |
[vars denoms sum] | |
(logic/fresh [vhead vtail |
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
(ns core-logic.core | |
(:require [clojure.core.logic :as logic] | |
[clojure.core.logic.fd :as fd])) | |
;;; 현명한 딸 셋을 두 상인이 사과 90개를 가져와 | |
;;; 첫째에게 50개, 둘째에게 30개, 셋째에게 10개를 주며 | |
;;; 그것을 팔아오되 첫째가 만약 10개를 1원에 팔면 | |
;;; 둘째, 셋째도 똑같이 10개를 1원에 팔아야 한다는 조건을 걸었다. | |
;;; 하지만 팔아서 번 돈은 셋이 모두 같아야 한다. | |
;;; 어떻게 해야 조건대로 팔 수 있을까? |
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
git fsck --full --no-reflogs --unreachable --lost-found | cut -d ' ' -f 3 | xargs -n 1 git log -n 1 --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit |
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 jsonb_remove_keys( | |
jdata JSONB, | |
keys TEXT[] | |
) | |
RETURNS JSONB AS $$ | |
DECLARE | |
result JSONB; | |
len INT; | |
target TEXT; |
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
set timezone='Asia/Seoul'; | |
show timezone; | |
SELECT '2018-12-01 00:00:00'::timestamp at time zone 'GMT'; | |
SELECT (timestamp '2018-12-01 00:00:00') at time zone 'GMT'; | |
-- 2018-12-01 09:00:00+09 | |
SELECT '2018-12-01 00:00:00' at time zone 'GMT'; | |
SELECT (date '2018-12-01') at time zone 'GMT'; | |
SELECT '2018-12-01 00:00:00'::timestamp with time zone at time zone 'GMT'; |
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
// validation.cpp | |
/** Store block on disk. If dbp is non-nullptr, the file is known to already reside on disk */ | |
static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested, const CDiskBlockPos* dbp, bool* fNewBlock) | |
{ | |
// ... | |
// Header is valid/has work, merkle tree and segwit merkle tree are good...RELAY NOW | |
// (but if it does not build on our best tip, let the SendMessages loop relay it) | |
if (!IsInitialBlockDownload() && chainActive.Tip() == pindex->pprev) | |
GetMainSignals().NewPoWValidBlock(pindex, pblock); |
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
// txdb.cpp | |
static const char DB_BLOCK_INDEX = 'b'; | |
bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex) | |
{ | |
std::unique_ptr<CDBIterator> pcursor(NewIterator()); | |
// Start from key b000... | |
pcursor->Seek(std::make_pair(DB_BLOCK_INDEX, uint256())); |
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
/******************** | |
* Do part | |
********************/ | |
// undo.h | |
class CTxUndo | |
{ | |
public: | |
// undo information for all txins // COMMENT: spent coin by txins | |
std::vector<Coin> vprevout; |
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
// rest.cpp | |
// will be called with http request /rest/block/[BLOCK_HASH_VALUE] | |
static bool rest_block(HTTPRequest* req, const std::string& strURIPart, bool showTxDetails) | |
{ | |
// ... | |
uint256 hash; // will be parsed from `strURIPart` | |
CBlock block; | |
CBlockIndex* pblockindex = nullptr; |
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
// bitcoin core (0d7e0a328) serialize/deserialize. | |
// Stream s; | |
// CBlock block; | |
// s >> block; | |
// internal above code. | |
// Step1: operator overloading |