Skip to content

Instantly share code, notes, and snippets.

// 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"
@0fuz
0fuz / eth_bsc_wallet_template.go
Last active April 16, 2022 13:59
eth_bsc_wallet_template
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"
@0fuz
0fuz / bsc_ethers_wallet_template.md
Last active June 7, 2022 11:43
Template of using ETH wallet for transfering native and ERC20 funds. Same for EVM-compatible chains like BSC,FTM,MATIC.
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
@symisc
symisc / usage.html
Last active November 29, 2020 04:37
Usage example of the WebAssembly Real-Time face detector model - https://pixlab.io/downloads
<!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;
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active November 14, 2024 06:21
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

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).

@posener
posener / go-table-driven-tests-parallel.md
Last active October 29, 2024 13:01
Be Careful with Table Driven Tests and t.Parallel()

Be Careful with Table Driven Tests and t.Parallel()

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()
@KatelynHaworth
KatelynHaworth / main.go
Last active August 9, 2024 02:08
Example of run an interactive process on the current user from system service on windows (Golang)
package main
import (
"github.com/kardianos/service"
"log"
"flag"
)
type Service struct {}
@rushilgupta
rushilgupta / GoConcurrency.md
Last active July 11, 2024 12:52
Concurrency in golang and a mini Load-balancer

INTRO

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:

Goroutines

@yuvalherziger
yuvalherziger / CustomCompleter.js
Last active November 28, 2023 23:53
Sample Ace Editor custom completer
// 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' },
@montanaflynn
montanaflynn / pget.go
Last active October 21, 2023 06:12
Bounded Parallel Get Requests in Golang
package main
import (
"fmt"
"net/http"
"sort"
"time"
)
// a struct to hold the result from each request including an index