blog's People
blog's Issues
nodejs 多进程
nodejs 多进程demo
function createWorker() {
return new Promise(function (resolve, reject) {
const worker = new Worker("./four_workers.js", {
workerData: { thread_count: THREAD_COUNT },
});
worker.on("message", (data) => {
resolve(data);
});
worker.on("error", (msg) => {
reject(`An error ocurred: ${msg}`);
});
});
}
参考 https://www.digitalocean.com/community/tutorials/how-to-use-multithreading-in-node-js
postgres-service.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
namespace: dev
labels:
app: postgres
spec:
serviceName: postgres-service
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:14
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: xxx // 当前 uid
ports:
- containerPort: 5432
env:
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_PASSWORD
value: "postgres"
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: ostgres-volume
volumes:
- name: postgres-volume
hostPath:
path: /Users/wei/Desktop/project/k8s/postgres/db
type: DirectoryOrCreate
---
kind: Service
apiVersion: v1
metadata:
name: postgres-service
namespace: dev
spec:
type: NodePort
selector:
app: postgres
ports:
- port: 5432
targetPort: 5432
name: postgres
# Lens 协议解析三 Publication
Lens 协议解析三 Publication
Publication
Publication包括Post, Comment, Mirror,说白了就是放内容的地方
对应类型
/**
* @notice A struct containing the parameters required for the `post()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param collectModule The collect module to set for this new publication.
* @param collectModuleInitData The data to pass to the collect module's initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct PostData {
uint256 profileId; // 上一篇生成的profileId
string contentURI; // content
address collectModule; // collectModule
bytes collectModuleInitData; // collectModuleInitData
address referenceModule; // referenceModule
bytes referenceModuleInitData; // // referenceModule
}
/**
* @notice A struct containing the parameters required for the `comment()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param profileIdPointed The profile token ID to point the comment to.
* @param pubIdPointed The publication ID to point the comment to.
* @param referenceModuleData The data passed to the reference module.
* @param collectModule The collect module to set for this new publication.
* @param collectModuleInitData The data to pass to the collect module's initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct CommentData {
uint256 profileId;
string contentURI;
uint256 profileIdPointed;
uint256 pubIdPointed;
bytes referenceModuleData;
address collectModule;
bytes collectModuleInitData;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `mirror()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param profileIdPointed The profile token ID to point the mirror to.
* @param pubIdPointed The publication ID to point the mirror to.
* @param referenceModuleData The data passed to the reference module.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct MirrorData {
uint256 profileId;
uint256 profileIdPointed;
uint256 pubIdPointed;
bytes referenceModuleData;
address referenceModule;
bytes referenceModuleInitData;
}
Post
/**
* @notice Creates a post publication mapped to the given profile.
*
* @dev To avoid a stack too deep error, reference parameters are passed in memory rather than calldata.
*
* @param profileId The profile ID to associate this publication to.
* @param contentURI The URI to set for this publication.
* @param collectModule The collect module to set for this publication.
* @param collectModuleInitData The data to pass to the collect module for publication initialization.
* @param referenceModule The reference module to set for this publication, if any.
* @param referenceModuleInitData The data to pass to the reference module for publication initialization.
* @param pubId The publication ID to associate with this publication.
* @param _pubByIdByProfile The storage reference to the mapping of publications by publication ID by profile ID.
* @param _collectModuleWhitelisted The storage reference to the mapping of whitelist status by collect module address.
* @param _referenceModuleWhitelisted The storage reference to the mapping of whitelist status by reference module address.
*/
function createPost(
uint256 profileId,
string memory contentURI,
address collectModule,
bytes memory collectModuleInitData,
address referenceModule,
bytes memory referenceModuleInitData,
uint256 pubId,
mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
storage _pubByIdByProfile,
mapping(address => bool) storage _collectModuleWhitelisted,
mapping(address => bool) storage _referenceModuleWhitelisted
) external {
_pubByIdByProfile[profileId][pubId].contentURI = contentURI;
// Collect module initialization
bytes memory collectModuleReturnData = _initPubCollectModule(
profileId,
pubId,
collectModule,
collectModuleInitData,
_pubByIdByProfile,
_collectModuleWhitelisted
);
// Reference module initialization
bytes memory referenceModuleReturnData = _initPubReferenceModule(
profileId,
pubId,
referenceModule,
referenceModuleInitData,
_pubByIdByProfile,
_referenceModuleWhitelisted
);
emit Events.PostCreated(
profileId,
pubId,
contentURI,
collectModule,
collectModuleReturnData,
referenceModule,
referenceModuleReturnData,
block.timestamp
);
}
Comment
/**
* @notice Creates a comment publication mapped to the given profile.
*
* @dev This function is unique in that it requires many variables, so, unlike the other publishing functions,
* we need to pass the full CommentData struct in memory to avoid a stack too deep error.
*
* @param vars The CommentData struct to use to create the comment.
* @param pubId The publication ID to associate with this publication.
* @param _profileById The storage reference to the mapping of profile structs by IDs.
* @param _pubByIdByProfile The storage reference to the mapping of publications by publication ID by profile ID.
* @param _collectModuleWhitelisted The storage reference to the mapping of whitelist status by collect module address.
* @param _referenceModuleWhitelisted The storage reference to the mapping of whitelist status by reference module address.
*/
function createComment(
DataTypes.CommentData memory vars,
uint256 pubId,
mapping(uint256 => DataTypes.ProfileStruct) storage _profileById,
mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
storage _pubByIdByProfile,
mapping(address => bool) storage _collectModuleWhitelisted,
mapping(address => bool) storage _referenceModuleWhitelisted
) external {
// Validate existence of the pointed publication
uint256 pubCount = _profileById[vars.profileIdPointed].pubCount;
if (pubCount < vars.pubIdPointed || vars.pubIdPointed == 0)
revert Errors.PublicationDoesNotExist();
// Ensure the pointed publication is not the comment being created
if (vars.profileId == vars.profileIdPointed && vars.pubIdPointed == pubId)
revert Errors.CannotCommentOnSelf();
_pubByIdByProfile[vars.profileId][pubId].contentURI = vars.contentURI;
_pubByIdByProfile[vars.profileId][pubId].profileIdPointed = vars.profileIdPointed;
_pubByIdByProfile[vars.profileId][pubId].pubIdPointed = vars.pubIdPointed;
// Collect Module Initialization
bytes memory collectModuleReturnData = _initPubCollectModule(
vars.profileId,
pubId,
vars.collectModule,
vars.collectModuleInitData,
_pubByIdByProfile,
_collectModuleWhitelisted
);
// Reference module initialization
bytes memory referenceModuleReturnData = _initPubReferenceModule(
vars.profileId,
pubId,
vars.referenceModule,
vars.referenceModuleInitData,
_pubByIdByProfile,
_referenceModuleWhitelisted
);
// Reference module validation
address refModule = _pubByIdByProfile[vars.profileIdPointed][vars.pubIdPointed]
.referenceModule;
if (refModule != address(0)) {
IReferenceModule(refModule).processComment(
vars.profileId,
vars.profileIdPointed,
vars.pubIdPointed,
vars.referenceModuleData
);
}
// Prevents a stack too deep error
_emitCommentCreated(vars, pubId, collectModuleReturnData, referenceModuleReturnData);
}
Mirror
/**
* @notice Creates a mirror publication mapped to the given profile.
*
* @param vars The MirrorData struct to use to create the mirror.
* @param pubId The publication ID to associate with this publication.
* @param _pubByIdByProfile The storage reference to the mapping of publications by publication ID by profile ID.
* @param _referenceModuleWhitelisted The storage reference to the mapping of whitelist status by reference module address.
*/
function createMirror(
DataTypes.MirrorData memory vars,
uint256 pubId,
mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
storage _pubByIdByProfile,
mapping(address => bool) storage _referenceModuleWhitelisted
) external {
(uint256 rootProfileIdPointed, uint256 rootPubIdPointed, ) = Helpers.getPointedIfMirror(
vars.profileIdPointed,
vars.pubIdPointed,
_pubByIdByProfile
);
_pubByIdByProfile[vars.profileId][pubId].profileIdPointed = rootProfileIdPointed;
_pubByIdByProfile[vars.profileId][pubId].pubIdPointed = rootPubIdPointed;
// Reference module initialization
bytes memory referenceModuleReturnData = _initPubReferenceModule(
vars.profileId,
pubId,
vars.referenceModule,
vars.referenceModuleInitData,
_pubByIdByProfile,
_referenceModuleWhitelisted
);
// Reference module validation
address refModule = _pubByIdByProfile[rootProfileIdPointed][rootPubIdPointed]
.referenceModule;
if (refModule != address(0)) {
IReferenceModule(refModule).processMirror(
vars.profileId,
rootProfileIdPointed,
rootPubIdPointed,
vars.referenceModuleData
);
}
emit Events.MirrorCreated(
vars.profileId,
pubId,
rootProfileIdPointed,
rootPubIdPointed,
vars.referenceModuleData,
vars.referenceModule,
referenceModuleReturnData,
block.timestamp
);
}
注意
- pubId自增
- Mirror只是转发,是没有contentUrl
postgresql OVER() Partition By Order By
Partition By :分组但不聚合
Order By :排序
INSERT INTO "public"."a_test" ("a", "b") VALUES ('1', '1');
INSERT INTO "public"."a_test" ("a", "b") VALUES ('2', '1');
INSERT INTO "public"."a_test" ("a", "b") VALUES ('3', '1');
INSERT INTO "public"."a_test" ("a", "b") VALUES ('4', '4');
INSERT INTO "public"."a_test" ("a", "b") VALUES ('3', '3');
INSERT INTO "public"."a_test" ("a", "b") VALUES ('5', '5');
INSERT INTO "public"."a_test" ("a", "b") VALUES ('2', '2');
INSERT INTO "public"."a_test" ("a", "b") VALUES ('3', '2');
SELECT a,b ,count(1) OVER(partition by a ORDER BY a) as count ,
"row_number"() OVER(PARTITION by a ORDER BY a) as rownum from a_test
count(1) OVER(PARTITION BY a ORDER BY a) AS count,是按a进行分组且组内按a进行升序,统计组内记录的条数。
row_number() OVER(PARTITION BY a ORDER BY a) AS rownum,是按a进行分组且组内按a进行升序,返回组内行编号。
mongo-service.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
namespace: dev
labels:
app: mongo
spec:
serviceName: mongo-service
replicas: 1
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: mongo:latest
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: xx // current id
ports:
- containerPort: 27017
volumeMounts:
- name: dir-volume
mountPath: /data/db
volumes:
- name: dir-volume
hostPath:
path: xxx
type: DirectoryOrCreate
---
kind: Service
apiVersion: v1
metadata:
name: mongo-service
namespace: dev
spec:
type: NodePort
selector:
app: mongo
ports:
- port: 27017
targetPort: 27017
name: mongo
web3 login use metamask
frontend
sign
web3.eth.personal.sign("Hello world", "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!")
.then(console.log);
> "0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"
backend
ecRecover
web3.eth.personal.ecRecover("Hello world", "0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400").then(console.log);
> "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe"
scala 版本切换
# show all scala versions
brew search scala
# install specific version, maybe scala 2.11
brew install [email protected]
# unlink current scala version
brew unlink scala
# link new scala version
brew link [email protected] --force
# check result
scala -version
HiveServer2
启动
$HIVE_HOME/bin/hiveserver2
OR
$HIVE_HOME/bin/hive --service hiveserver2
./bin/schematool -initSchema -dbType mysql
参考
HiveServer2
ConfigurationProperties
issue
issue1
....
java.lang.NoClassDefFoundError: org/apache/tez/dag/api/TezConfiguration
...
修改hive-site.xml
<property>
<name>hive.execution.engine</name>
<value>mr</value>
</property>
重启依然报错,等会60000ms自动重启成功
issue2
User: xxx is not allowed to impersonate wei (state=08S01,code=0
<property>
<name>hive.server2.enable.doAs</name>
<value>false</value>
<description>
Setting this property to true will have HiveServer2 execute
Hive operations as the user making the calls to it.
</description>
</property>
Eth Sign && verifySign
// sign.go
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"log"
"github.com/ethereum/go-ethereum/crypto"
)
func main() {
dataHash := sha256.Sum256([]byte("ethereum"))
// 准备私钥
pkeyb, err := hex.DecodeString("289c2857d4598e37fb9647507e47a309d6133539bf21a8b9cb6df88fd5232032")
if err != nil {
log.Fatalln(err)
}
// 基于secp256k1的私钥
pkey, err := crypto.ToECDSA(pkeyb)
if err != nil {
log.Fatalln(err)
}
// 签名
sig, err := crypto.Sign(dataHash[:], pkey)
if err != nil {
log.Fatal(err)
}
fmt.Println("sig length:", len(sig))
fmt.Println("sig hex:", hex.EncodeToString(sig))
}
verifySign
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"log"
"github.com/ethereum/go-ethereum/crypto"
)
func main() {
decodeHex := func(s string) []byte {
b, err := hex.DecodeString(s)
if err != nil {
log.Fatal(err)
}
return b
}
dataHash := sha256.Sum256([]byte("ethereum"))
sig := decodeHex(
"7912f50819764de81ab7791ab3d62f8dabe84c2fdb2f17d76465d28f8a968f7355fbb6cd8dfc7545b6258d4b032753b2074232b07f3911822b37f024cd10116600")
pubkey := decodeHex(
"037db227d7094ce215c3a0f57e1bcc732551fe351f94249471934567e0f5dc1bf7")
ok := crypto.VerifySignature(pubkey, dataHash[:], sig[:len(sig)-1])
fmt.Println("verify pass?", ok)
}
kyuubi 安装
kyuubi 搭建
下载
- kyuubi
- jdk
- spark || flink
配置
kyuubi-defaults.conf
#
kyuubi.authentication NONE
kyuubi.frontend.bind.host localhost
kyuubi.frontend.bind.port 10009
#
# Details in https://kyuubi.apache.org/docs/latest/deployment/settings.html
kyuubi.engine.type SPARK_SQL
kyuubi-env.sh
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.15.jdk/Contents/Home
export SPARK_HOME=.../spark-3.3.0-bin-hadoop3
export FLINK_HOME=.../flink-1.14.3
启动
bin/kyuubi run // 前台
bin/kyuubi start // 后台
测试
bin/beeline -u 'jdbc:hive2://localhost:10009/'
select timestamp '2018-11-17';
显示
+----------------------------------+
| TIMESTAMP '2018-11-17 00:00:00' |
+----------------------------------+
| 2018-11-17 00:00:00.0 |
+----------------------------------+
1 row selected (2.308 seconds)
参考
clickhouse.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app: clickhouse
name: clickhouse
namespace: dev
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: clickhouse
template:
metadata:
labels:
app: clickhouse
spec:
containers:
- image: clickhouse/clickhouse-server
imagePullPolicy: IfNotPresent
name: clickhouse
securityContext:
runAsUser: 501
ports:
- containerPort: 8123
protocol: TCP
# resources:
# limits:
# cpu: 1048m
# memory: 2Gi
# requests:
# cpu: 1048m
# memory: 2Gi
volumeMounts:
- mountPath: /var/lib/clickhouse
name: clickhouse-volume
volumes:
- name: clickhouse-volume
hostPath:
path: ~/clickhouse/db
type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
name: clickhouse
namespace: dev
spec:
ports:
- port: 8123
protocol: TCP
targetPort: 8123
selector:
app: clickhouse
type: NodePort
mysql-service.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
namespace: dev
labels:
app: mysql
spec:
serviceName: mysql-service
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:latest
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: xxx // 当前 uid ,
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "root"
---
kind: Service
apiVersion: v1
metadata:
name: mysql-service
namespace: dev
spec:
type: NodePort
selector:
app: mysql
ports:
- port: 3306
targetPort: 3306
name: mysql
Lens 协议解析一
Lens 协议解析一
概念
lens 就是定义了一套Web3 social graph的协议,其中包含了Profile,Publication,Collect,Follow等概念
下载
git clone https://github.com/aave/lens-protocol.git
编译
npm i
npm run compile
本地部署
npx hardhat node
npm run full-deploy-local
结果就是把一堆部署的合约代码写入到addresses.json 文件
后面再详细介绍Profile,Publication,Collect,Follow等概念
# Lens 协议解析四 Follow
Lens 协议解析四 Follow
Follow
follow就是一个地址关注profile,并收到一个nft
源码解析
/**
* @notice Follows the given profiles, executing the necessary logic and module calls before minting the follow
* NFT(s) to the follower.
*
* @param follower The address executing the follow.
* @param profileIds The array of profile token IDs to follow.
* @param followModuleDatas The array of follow module data parameters to pass to each profile's follow module.
* @param _profileById A pointer to the storage mapping of profile structs by profile ID.
* @param _profileIdByHandleHash A pointer to the storage mapping of profile IDs by handle hash.
*
* @return uint256[] An array of integers representing the minted follow NFTs token IDs.
*/
function follow(
address follower,
uint256[] calldata profileIds,
bytes[] calldata followModuleDatas,
mapping(uint256 => DataTypes.ProfileStruct) storage _profileById,
mapping(bytes32 => uint256) storage _profileIdByHandleHash
) external returns (uint256[] memory) {
if (profileIds.length != followModuleDatas.length) revert Errors.ArrayMismatch();
uint256[] memory tokenIds = new uint256[](profileIds.length);
for (uint256 i = 0; i < profileIds.length; ) {
string memory handle = _profileById[profileIds[i]].handle;
if (_profileIdByHandleHash[keccak256(bytes(handle))] != profileIds[i])
revert Errors.TokenDoesNotExist();
address followModule = _profileById[profileIds[i]].followModule;
address followNFT = _profileById[profileIds[i]].followNFT;
if (followNFT == address(0)) {
followNFT = _deployFollowNFT(profileIds[i]);
_profileById[profileIds[i]].followNFT = followNFT;
}
tokenIds[i] = IFollowNFT(followNFT).mint(follower);
if (followModule != address(0)) {
IFollowModule(followModule).processFollow(
follower,
profileIds[i],
followModuleDatas[i]
);
}
unchecked {
++i;
}
}
emit Events.Followed(follower, profileIds, followModuleDatas, block.timestamp);
return tokenIds;
}
Spark Thriftserver
Spark Thriftserver
启动
./sbin/start-thriftserver.sh
测试
bin/beeline -u 'jdbc:hive2://localhost:10000/'
> show tables;
> CREATE TABLE events (eventId STRING,eventType STRING,data STRING )
> insert into events1 values(1,2,3);
> select * from events;
docker-compose.yml
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ports:
- 22181:2181
kafka:
image: confluentinc/cp-kafka:latest
depends_on:
- zookeeper
ports:
- 29092:29092
- 9092:9092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
kafka_ui:
image: provectuslabs/kafka-ui:latest
depends_on:
- kafka
ports:
- 8090:8080
environment:
KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper:2181
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
prometheus.yml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: prometheus
namespace: dev
labels:
app: prometheus
spec:
serviceName: prometheus-service
replicas: 1
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus:latest
imagePullPolicy: IfNotPresent
# securityContext:
# runAsUser: 501
ports:
- containerPort: 9090
volumeMounts:
- name: config-volume
mountPath: /etc/prometheus
volumes:
- name: config-volume
configMap:
name: prometheus-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: dev
data:
prometheus.yml: |
global:
scrape_interval: 15s
scrape_timeout: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: web
static_configs:
- targets: ["192.168.106.1:9000"]
# kubectl apply -f pro_cm.yaml
---
kind: Service
apiVersion: v1
metadata:
name: prometheus-service
namespace: dev
spec:
type: NodePort
selector:
app: prometheus
ports:
- port: 9090
targetPort: 9090
name: prometheus
# Lens 协议解析二 Profile
Lens 协议解析二 Profile
Profile
Profile是lens协议中重要的一个,所有的操作都会涉及到Profile。
核心代码
// PublishingLogic.sol
/**
* @notice A struct containing the parameters required for the `createProfile()` function.
*
* @param to The address receiving the profile.
* @param handle The handle to set for the profile, must be unique and non-empty.
* @param imageURI The URI to set for the profile image.
* @param followModule The follow module to use, can be the zero address.
* @param followModuleInitData The follow module initialization data, if any.
* @param followNFTURI The URI to use for the follow NFT.
*/
struct CreateProfileData {
address to; // profile 对应的地址
string handle; // 唯一不能为空,不知道干嘛
string imageURI; // profile image
address followModule; // 自定义followModule 的地址 ,关注的时候会运行 initializeFollowModule,见下面_initFollowModule
bytes followModuleInitData; // 初始化参数
string followNFTURI; // follow的时候 会mint nft NFTURI ,见tokenURI
}
// PublishingLogic.sol
function _initFollowModule(
uint256 profileId,
address followModule,
bytes memory followModuleInitData,
mapping(address => bool) storage _followModuleWhitelisted
) private returns (bytes memory) {
if (!_followModuleWhitelisted[followModule]) revert Errors.FollowModuleNotWhitelisted();
return IFollowModule(followModule).initializeFollowModule(profileId, followModuleInitData);
}
// CollectNFT.sol
function tokenURI(uint256 tokenId) public view override returns (string memory) {
if (!_exists(tokenId)) revert Errors.TokenDoesNotExist();
return ILensHub(HUB).getContentURI(_profileId, _pubId);
}
注意
- CreateProfileData返回的profileId是自增的
function createProfile(DataTypes.CreateProfileData calldata vars)
external
override
whenNotPaused
returns (uint256)
{
if (!_profileCreatorWhitelisted[msg.sender]) revert Errors.ProfileCreatorNotWhitelisted();
unchecked {
uint256 profileId = ++_profileCounter;
_mint(vars.to, profileId);
PublishingLogic.createProfile(
vars,
profileId,
_profileIdByHandleHash,
_profileById,
_followModuleWhitelisted
);
return profileId;
}
}
- 自定义module需要实现对应的方法,会在不同的地方自动调用
1. InitializeFollowModule() which is called when a profile sets this module as its follow module.
2. ProcessFollow() which is called when a user attempts to follow a given profile with this module set as its follow module.
3. FollowModuleTransferHook() which is called when a FollowNFT associated with a profile that has this module set as its follow module is transferred (we won't be needing to do anything here) and...
4. ValidateFollow() which is called to validate whether a follow is still valid (Note: this is implemented by the FollowValidatorFollowModuleBase contract, so we don't have to worry about it!)
Bun - Hello Wold
Bun现代的 JavaScript 运行时
安装
curl https://bun.sh/install | bash
启动
export default {
// ⚠️ 3001 端口如果被占用的话,程序执行会出错,并且没有一个明确的错误提示。
port: 3001,
fetch(request) {
return new Response("Hello World Bun");
},
};
bun run app.js
打开浏览器 localhost:3001
console-service.yaml
kafak ui
apiVersion: apps/v1
kind: Deployment
metadata:
name: console
namespace: dev
labels:
app: console
spec:
replicas: 1
selector:
matchLabels:
app: console
template:
metadata:
labels:
app: console
spec:
containers:
- name: console
image: docker.redpanda.com/vectorized/console:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
env:
- name: KAFKA_BROKERS
value: "192.168.106.1:9092"
---
kind: Service
apiVersion: v1
metadata:
name: console-service
namespace: dev
spec:
type: NodePort
selector:
app: console
ports:
- port: 8080
targetPort: 8080
# nodePort: 6379
name: console
mac docker 宿主 IP
docker --version
Docker for Mac v 17.12 以上版本
docker.for.mac.host.internal
Docker for Mac v 17.06 to v 17.11
docker.for.mac.localhost
grafana-service.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: grafana
namespace: dev
labels:
app: grafana
spec:
serviceName: grafana-service
replicas: 1
selector:
matchLabels:
app: grafana
template:
metadata:
labels:
app: grafana
spec:
containers:
- name: prometheus
image: grafana/grafana:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3000
env:
- name: GF_SECURITY_ADMIN_USER
value: "admin"
- name: GF_SECURITY_ADMIN_PASSWORD
value: "admin"
---
kind: Service
apiVersion: v1
metadata:
name: grafana-service
namespace: dev
spec:
type: NodePort
selector:
app: grafana
ports:
- port: 3000
targetPort: 3000
name: grafana
redis-service.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis
namespace: dev
labels:
app: redis
spec:
serviceName: redis-service
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:latest
imagePullPolicy: IfNotPresent
command: ["redis-server"]
ports:
- containerPort: 6379
---
kind: Service
apiVersion: v1
metadata:
name: redis-service
namespace: dev
spec:
type: NodePort
selector:
app: redis
ports:
- port: 6379
targetPort: 6379
# nodePort: 6379
name: redis
mac hadoop install
https://kontext.tech/article/547/install-hadoop-330-on-mac
bin/hdfs namenode -format
sbin/start-yarn.sh
sbin/stop-yarn.sh
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.