npm init -y
npm i ethers
Set provider
let provider = new ethers.providers.JsonRpcProvider("https://bscrpc.com", 56) // bsc
// let provider = new ethers.providers.WebSocketProvider("wss://..........", 56) // bsc
// Copyright 2020 Kentaro Hibino. All rights reserved. | |
// Use of this source code is governed by a MIT license | |
// that can be found in the LICENSE file. | |
package asynq | |
import ( | |
"context" | |
"errors" | |
"fmt" |
import ( | |
"context" | |
"crypto/ecdsa" | |
"crypto/elliptic" | |
"encoding/json" | |
"github.com/ethereum/go-ethereum/common" | |
"github.com/ethereum/go-ethereum/core/types" | |
"github.com/ethereum/go-ethereum/ethclient" | |
"github.com/ethereum/go-ethereum/log" | |
"io/ioutil" |
npm init -y
npm i ethers
Set provider
let provider = new ethers.providers.JsonRpcProvider("https://bscrpc.com", 56) // bsc
// let provider = new ethers.providers.WebSocketProvider("wss://..........", 56) // bsc
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>WebAssembly Real-Time Face Detection</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<style> | |
body { | |
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; |
This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
We Gophers, love table-driven-tests, it makes our unittesting structured, and makes it easy to add different test cases with ease.
Let’s create our table driven test, for convenience, I chose to use t.Log
as the test function.
Notice that we don't have any assertion in this test, it is not needed to for the demonstration.
func TestTLog(t *testing.T) {
t.Parallel()
package main | |
import ( | |
"github.com/kardianos/service" | |
"log" | |
"flag" | |
) | |
type Service struct {} |
Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".
Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).
Let's dig in:
// fetch ace's language tools module: | |
var langTools = ace.require('ace/ext/language_tools'); | |
// data stub: | |
var sqlTables = [ | |
{ name: 'users', description: 'Users in the system' }, | |
{ name: 'userGroups', description: 'User groups to which users belong' }, | |
{ name: 'customers', description: 'Customer entries' }, | |
{ name: 'companies', description: 'Legal entities of customers' }, | |
{ name: 'loginLog', description: 'Log entries for user log-ins' }, |
package main | |
import ( | |
"fmt" | |
"net/http" | |
"sort" | |
"time" | |
) | |
// a struct to hold the result from each request including an index |