Categories
Tech Notes

How to setup Brave Adblock Whitelist

Brave Browser is based on Chrome and with a built-in ad blocker, which is great. After using it for a while, you stop noticing it, that’s the whole point of ad blocking. In the default home page, you get to see how many minutes you “saved”, which doesn’t look significant, but ever minute of you attention can be used for something else.

Back to the point of this post. You can easily unblock a site for ads by clicking on the top right. But for sites that use many subdomains and redirects, it is annoying to have to disable them individually. (Sites like Taobao, Tmall, etc, their whole system is very much based on such cross-site tracking which modern browsers try hard to block.)

There is a way to fix this. In the address bar, go to “brave://adblock/” then you will see the Ad Block settings page. And at the bottom of the page, you can enter custom filters using the Adblock Plus syntax. A quick example is to add the following lines to it, which will allow the following domains (including subdomains) to be added to the whitelist.

@@||taobao.com^
@@||tmall.com^
@@||alipay.com^

After you have added the lines, you can just close the page and it is automatically saved.

Categories
Uncategorized

5 minutes to Install Hyperledger Explorer with Fabric v2.0.0 on Ubuntu 18.04 DigitalOcean (Unofficial)

I am sharing this as an unofficial guide as Hyperledger Explorer hasn’t been officially confirmed as Fabric v2.0.0 ready. But it seems to work fine, so let’s play with it and give feedback to the project accordingly.

Hyperledger Explorer is a browser that can be used to view the activities on a block chain network. The following guide installs Hyperledger Explorer on a basic Ubuntu 18.04 DigitalOcean droplet and it is built upon the sample network of Hyperledger Fabric 2.0.0.

点击这里即可查看本文的中文版。

Depending on the speed of the network connection,you can just about run all the steps below perfectly and install it in 5 mins. Let’s start. (I recommend getting at least the $10 bucks a month Droplet from DigitalOcean, you will need the 2GB RAM to run it smoothly, use my link (Discount code for newbies, I get some free referral credits too) to sign up. Then run the following steps.

Check out my other articles on just running Hyperledger Fabric 2.0.0 and Hyperledger Composer. We aim to publish a full set of these guides on how to play around with Hyperledger technologies. Chinese version of these articles will be available via Jasmine Yang soon. Eugene Yong tested every line of code in this article.

For new droplets, set the locale (choose en_US.UTF-8 if in doubt) and do apt update/upgrade.

sudo dpkg-reconfigure locales
sudo apt-get update && sudo apt-get upgrade

There will be errors if you try to install Hyperledger Explorer as a root, therefore, for the rest of the set-up, you will be using the new user “dora” to do it. You will be prompted to set up a new password for the user which you will be using later. You will also need to give “dora” the sudo access by setting the permission. ( Eugene Yong picked the name.)

sudo adduser dora
sudo usermod -aG sudo dora
#Switch to the newly created user
su - dora

In order to run Hyperledger Explorer, you will need the following prerequisites:
– Nodejs version 8: 8.9.4 or greater _or_ version 10: 10.15.3 or greater
– PostgreSQL 9.5 and above
– jq

In order to set up Hyperledger Fabric 2.0.0, you will need the following:
– cURL
– Git
– Docker version 17.06.2-ce or greater.
– Docker Compose version 1.14.0 or greater.
– Go version 1.13.x is required.
– Nodejs version 8: 8.9.4 or greater _or_ version 10: 10.15.3 or greater
– npm version 5.6.0 or greater.
– Python

sudo apt-get install curl git docker.io docker-compose nodejs npm python
#Updating npm to 5.6.0
sudo npm install npm@5.6.0 -g
#Setting up docker configuration
sudo usermod -a -G docker $USER
sudo systemctl start docker
sudo systemctl enable docker
#Installing golang
wget https://dl.google.com/go/go1.13.6.linux-amd64.tar.gz
tar -xzvf go1.13.6.linux-amd64.tar.gz
sudo mv go/ /usr/local
#edit gopath in .bashrc
pico ~/.bashrc
#(add these 2 lines to end of file)
export GOPATH=/usr/local/go
export PATH=$PATH:$GOPATH/bin
#Install postgres & jq for Explorer
sudo apt-get install jq postgresql postgresql-contrib
service postgresql restart
#Log out and log back in as dora
exit
su - dora

After installing the dependencies, you can now set up Hyperledger Fabric 2.0.0.

curl -sSL https://bit.ly/2ysbOFE | bash -s 2.0.0
cd ~/fabric-samples/test-network
./network.sh up createChannel
./network.sh deployCC

You will see `========= Channel successfully joined ===========` when the first script is done. You will see a list of cars printed in your logs when the script is deployed.

Now, setup Explorer

cd
git clone https://github.com/hyperledger/blockchain-explorer.git
#Setup DB
cd blockchain-explorer/app/persistence/fabric/postgreSQL
chmod -R 775 db/
cd db
./createdb.sh

You can use the following command to ensure that your PostgreSQL up and running

pg_lsclusters

Setup the first-network.json path to point at the right folder. Use the sample below if you follow every steps in the guide so far.

Configure Hyperledger Explorer based on the setup of the fabric. In the first-network.json, change the fabric-path to where your fabric-samples folder is found. Also, change the adminPrivateKey of “Org1MSP” to the correct path.

ls ~/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/

Note down the filename and use it to set the right parh below.

cd ~/blockchain-explorer/app/platform/fabric/connection-profile
nano first-network.json

Now modify “/ca4d946a621c0f528af9a3a6d05083d16afa7763da38b7e6c8d48c346b1d3034_sk” to the correct path. Please check all 3 paths in the file.

{
"name": "first-network",
"version": "1.0.0",
"license": "Apache-2.0",
"client": {
"tlsEnable": true,
"adminUser": "admin",
"adminPassword": "adminpw",
"enableAuthentication": false,
"organization": "Org1",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org1.example.com": {}
},
"connection": {
"timeout": {
"peer": {
"endorser": "6000",
"eventHub": "6000",
"eventReg": "6000"
}
}
}
}
},
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"fullpath": true,
"adminPrivateKey": {
"path": "/home/dora/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk"
},
"signedCert": {
"path": "/home/dora/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/home/dora/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpcs://localhost:7051",
"eventUrl": "grpcs://localhost:7053",
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com"
}
}
}
}

There is a script found in the blockchain-explorer folder that does this for you. You can also use the ./main.sh script to remove the dependencies (./main.sh clean) or run test for the explorer setup (./main.sh test).

cd blockchain-explorer
./main.sh install
./start.sh

Your Hyperledger Explorer should be properly set up and you can access it at http://<Your-IP-Address>:8080. If it prompts you to log in, use admin:adminpw.

You can check blockchain-explorer/logs/console/console-date.log to see if Hyperledger Explorer is running properly.

Reminder: Check out my other articles on just running Hyperledger Fabric 2.0.0 and Hyperledger Composer. We aim to publish a full set of these guides on how to play around with Hyperledger technologies. Chinese version of these articles will be available via Jasmine Yang soon. Eugene Yong tested every line of code in this article.

点击这里即可查看本文的中文版。

Categories
Lists

List of Mac apps

Just a list of apps I use on my mac, you might find them useful too.

  • Brave Browser – Just like Chrome, but no ads and you get rewarded if you choose to view ads.
  • KeePassXC – To store my passwords which are not in the built-in keychain. No, I don’t trust SaaS to store my passwords.
  • qBittorrent – Bittorrent client, supports RSS which I use with showRSS to watch daily shows regularly.
  • Resilio Sync – I use this to having my own P2P storage for important files which I don’t want to upload to OneDrive. I use Syncthing on servers because it doesn’t have iOS client.
  • Magnet – Just a quick way to organise windows on my Mac.
  • DEVONthink – Instead of Evernote, I use this to store web clippings. I use built in iCloud Notes for typing notes.
  • DEVONagent – For slow/deep searches. Rather than just relying on first few results from Google, I use this to run wider searches. Good for working out related topics too.
  • VS Code – Still trying to move to VSC, but I am actually still using BBEdit as my main text editor because I am so used to the Grep search.
  • Synergy – software KVM (keyboard, video, mouse) to share my keyboard and mouse across a few computers on my desk. I prefer multi-computers to just multi-screens.
  • WeChat, Whatsapp, Telegram, Mattermost, iMessage, Skype, Zoom, Webex, etc. I am not picky with chat software, I just use it by needs. It’s hard to avoid needing VPN if you want end-to-end encrypted chats. Also, I use this Wechat Extension on Mac, it’s good for auto-replies and running multiple accounts at the same time.
  • TeamViewer – Remote access.
  • Apple Remote Desktop for managing a network of Mac computers
  • Day One – Good Journal app on Mac and iOS, but getting a bit expensive now, I paid for it long ago, I don’t pay for SaaS version.
  • The Unarchiver – Zip utility. Can handle Chinese filenames properly.
  • VLC – still my favourite media player.
  • Cryptomator – Use any free cloud storage to store whole folder encrypted. Cross platform. Use it with multi-cloud, Baidu, Netease, Google, iCloud, OneDrive, etc. Another way is to use Cryptomator with Resilio Sync to have your own encrypted P2P storage. DON’T LOSE YOUR PASSWORD.

Categories
Uncategorized

New blog. Using WordPress again.

Unlike most developers, I don’t hate PHP. Not that I don’t want to move on to something newer, but my new site is hosted on Cyberpanel, which has WordPress installer built in. It’s simple. Just a few clicks and I am up and running. When they have Ghost installer as part of Cyberpanel, I might move again then.

According to W3Techs, WordPress powers 35% of all the websites on the Internet. That’s quite impressive. And it has certainly improved a lot over the years. Auto updates, annual themes, ecosystem to extend it well beyond standard CMS needs, etc, etc.

I am not a writer as such. I just want this site to be an extended version of my tweets. I try hard not to write anything too edgy and stay focused on tech and business (not even economics which are often too political).