Skip to content

Instantly share code, notes, and snippets.

View qbig's full-sized avatar

Liang qbig

  • @us3r-network
  • Singapore
View GitHub Profile
@qbig
qbig / ethereum_smart_contract_ecrecover.sol
Created September 16, 2018 14:47 — forked from dominiek/ethereum_smart_contract_ecrecover.sol
ethereum_smart_contract_ecrecover.sol
function getOriginAddress(bytes32 signedMessage, uint8 v, bytes32 r, bytes32 s) constant returns(address) {
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(prefix, signedMessage);
return ecrecover(prefixedHash, v, r, s);
}
@qbig
qbig / ethereum_web3_signing.js
Created September 16, 2018 14:47 — forked from dominiek/ethereum_web3_signing.js
Ethereum Web3 Signing
const message = web3.sha3('Hello World');
const signature = await web3.eth.sign(account, message);
const { v, r, s } = ethUtil.fromRpcSig(signature);
@danielsaul
danielsaul / store.go
Last active October 11, 2018 03:29
Go db store transaction
type Store struct {
q Querier
}
type DB interface {
Querier
Beginx() (*sqlx.Tx, error)
}
type Tx interface {
@asselstine
asselstine / config.yml
Created August 24, 2018 22:05
Run Truffle Tests on CircleCI 2.0
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
@qbig
qbig / golang-break.md
Created August 20, 2018 02:27
Golang Weird; break keyword

A "break" statement terminates execution of the innermost "for", "switch", or "select" statement within the same function.

Infinite Loop!!!!

package main

import (
	"fmt"
	"time"
)
@qbig
qbig / nil.md
Last active April 10, 2019 10:15
Golang nil

ultimate "zero" value

'nil' is surprising NOT a keyword, but a predeclared identifier

nil of different types means completely DIFFERENT thing!!! eg. nil pointer is different from nil interface !!!

things that could be nil.

map, slice, pointer, interface, channel, func "nil is predeclared identifier representing the zero value for a point, channel, func, interface, map or slice"

nil

  • pointer: points to nothing
@swalkinshaw
swalkinshaw / tutorial.md
Last active October 24, 2025 14:52
Designing a GraphQL API
@dominiek
dominiek / ethereum_web3_signing.js
Created February 16, 2018 02:51
Ethereum Web3 Signing
const message = web3.sha3('Hello World');
const signature = await web3.eth.sign(account, message);
const { v, r, s } = ethUtil.fromRpcSig(signature);
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/jinzhu/gorm"
@pseudomuto
pseudomuto / main_1.go
Last active October 12, 2024 14:49
Blog Code: Clean SQL Transactions in Golang
package main
import (
"database/sql"
"log"
)
func main() {
db, err := sql.Open("VENDOR_HERE", "YOUR_DSN_HERE")
handleError(err)