joelin109 / blog

0 stars 0 forks source link

Server: Tools that I will install in Mac #4

Closed joelin109 closed 2 years ago

joelin109 commented 7 years ago

What I need install

Tool How to install Version
Utils
Homebrew http://brew.sh/ brew --version
Git brew upgrade git , brew install git git --version
cURL https://curl.haxx.se/ curl -V
brew install curl
Postman install from Extensions of Chrome
CMake https://cmake.org/
vim .bash_profile export PATH=$PATH:/Applications/CMake.app/Contents/bin
---
Server
Golang https://golang.org/dl/ 1.17 or later go version
vim .bash_profile export GOROOT=/usr/local/go export GOPATH=/Volumes/Mac-TBD/Server/Golang/external export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
NodeJS https://nodejs.org/en/ 14.0 or later node -v
Python3 https://www.python.org/downloads/ python3 -V
pip3 Python3 including pip3 pip3 -V
pip3 install -U -pip upgrade
npm npm view [package] version , npm uninstall -g [package] npm -v
WebStorm IDE For Golang & NodeJS ---
PyCharm IDE For Python ---
---
Mobile
CocoaPods sudo gem install cocoapods pod --version
Fastlane --- ---
iFunbox --- ---
---
SQL
MySQL http://www.mysql.com/downloads/
PostgreSQL http://postgresapp.com/ ---
Redis https://redis.io/ redis-server -v
---
Others
Slack App Store
Astrill - vpn ---
CleanMyMac3 ---
---

joelin109 commented 2 years ago

Tools that should install in Mac

1. Homebrew

osx的软件管理工具, z.B. NPM for NodeJS (http://brew.sh/)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

brew --version

brew install 安装软件包 brew uninstall 卸载软件包 brew search 查询软件包 brew update 更新brew brew home 用浏览器打开brew的官方网站 brew info 显示软件信息 brew deps 显示包依赖

brew list 或brew ls 列出已安装的软件包 (/opt/homebrew/Cellar)

2. wget

brew install wget
joelin109 commented 2 years ago

4. Redis

brew install redis

redis-server -v

127.0.0.1:6379> AUTH PASSWORD 127.0.0.1:6379> CONFIG SET requirepass "myredispassword" 127.0.0.1:6379> AUTH myredispassword

or

opt/homebrew/etc/redis.conf

uncomment line # requirepass foobared, then restart server now password is foobared


- start/stop Redis server

brew services start redis brew services stop redis brew services restart redis

redis-cli 127.0.0.1:6379> exit


- JavaScript Code

PSUBSCRIBE可以监听键的过期事件. 使用命令监听事件(psubscribe keyevnet@0:expired)

const redis = require('redis'); const client = redis.createClient({host: 127.0.0.1, port: 6379, db: 2}); const subClient = redis.createClient({host: 127.0.0.1, port: 6379, db: 2}); subClient.psubscribe('keyevent@2:expired');

client.set(key, value, 'EX', 60 60 24); client.get(key); client.del(key); client.expire(key, expire_time);

subClient.on("pmessage", function(pattern, channel, expiredKey){ console.log(channel + ': key [' + expiredKey + '] has expired'); });


- Python Code

import redis from embo import app

pool = redis.ConnectionPool( host=app.config["REDIS_HOST"], port=app.config["REDIS_PORT"], db=app.config["REDIS_DATABASE"], password=app.config["REDIS_PASSWORD"], decode_responses=True ) Redis = redis.StrictRedis(connection_pool=pool)

def zadd_compatible(name, *args): if not Redis.exists(name): return try: Redis.zadd(name, dict(zip(args[1::2], args[::2]))) except: Redis.delete(name)


-  Redis的消息发布(publish)/ 订阅(subscribe)

SUBSCRIBE channel [channel …] / 订阅给定的一个或多个频道的信息 PSUBSCRIBE pattern [pattern …] / 订阅一个或多个符合给定模式的频道 PUBSUB subcommand [argument [argument …] / 查看订阅与发布系统状态 PUBLISH channel message / 将消息发送到指定的频道

joelin109 commented 2 years ago

编辑 PATH

˜ %  `vim .bash_profile`
˜ %  `i`    进行编辑
˜ %  `esc`  结束编辑;
˜ %   `:`
˜ %   `wq`  存储离开
˜ %   `q`   离开