Skip to content

Instantly share code, notes, and snippets.

View sidgwick's full-sized avatar
🏠
Working from home

Zhigang Song sidgwick

🏠
Working from home
  • Beijing, China
View GitHub Profile
@sidgwick
sidgwick / middleware.go
Created March 20, 2024 07:23
Golang Middleware example
package main
import (
"context"
"fmt"
)
type Middleware = func(ctx context.Context) (bool, error)
type MiddlewareBuilder = func(next Middleware) Middleware
@sidgwick
sidgwick / printable.ts
Created January 5, 2024 10:06
Javascript 判断不可打印字符
// Bit masks for each code point under U+0100, for fast lookup.
const pC = 1 << 0; // a control character.
const pP = 1 << 1; // a punctuation character.
const pN = 1 << 2; // a numeral.
const pS = 1 << 3; // a symbolic character.
const pZ = 1 << 4; // a spacing character.
const pLu = 1 << 5; // an upper-case letter.
const pLl = 1 << 6; // a lower-case letter.
const pp = 1 << 7; // a printable character according to Go's definition.
const pg = pp | pZ; // a graphical character according to the Unicode definition.

OP_CHECKSIG 详解

预备知识

  • scriptSig 即解锁脚本, 是交易输入里面, 用来证明自己所有权一个私钥签名
  • scriptPubKey 即锁定脚本, 即上一笔交易输出(本次交易的输入)里面用来锁定所有权的字节序列

WIKI

OP_CHECKSIG is Script opcode used to verify that the signature for a tx input is valid. OP_CHECKSIG expects two values to be on the stack. These are, in order of stack depth, the public key and the signature of the script. These two values are normally obtained by running the scriptSig script of the transaction input we are attempting to validate. The scriptSig script is deleted after it is run, but the stack is left as is. Then, the scriptPubKey script from the previous transaction output that is now being spent is run, generally concluding in an OP_CHECKSIG.

#!/bin/bash
hosts_url='https://raw.githubusercontent.com/googlehosts/hosts/master/hosts-files/hosts'
sed -e "/# Copyright/,$ d" -i /etc/hosts
curl -s $hosts_url >> /etc/hosts
(do ((i 1 (+ i 1)) (j 1 (+ j i)))
((> i 10) 'done)
(format t "square i is ~A~%" (* i i))
(format t "square j is ~A~%" (* j j)))
diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c
index 08be3fc..5ce8a29 100644
--- a/ext/dom/documenttype.c
+++ b/ext/dom/documenttype.c
@@ -205,7 +205,11 @@ int dom_documenttype_internal_subset_read(dom_object *obj, zval **retval TSRMLS_
if (buff != NULL) {
xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL);
xmlOutputBufferFlush(buff);
+#ifdef LIBXML2_NEW_BUFFER
+ ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff), xmlOutputBufferGetSize(buff), 1);