Skip to content

Instantly share code, notes, and snippets.

@10gic
10gic / unmarshal_interface.go
Last active September 3, 2023 13:23 — forked from tkrajina/unmarshal_interface.go
Unmarshal JSON to specific interface implementation
package main
import (
"encoding/json"
"reflect"
)
type Something interface{}
type Something1 struct {
@10gic
10gic / example.go
Created March 22, 2023 14:23 — forked from fxfactorial/example.go
ABI encode struct in golang
package main
import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
)
@10gic
10gic / addr_to_hash160.py
Created March 7, 2021 14:09
Converts p2pkh or p2wpkh address to hash160, i.e. ripemd(sha256(pubkey))
import sys
import binascii
import argparse
# base58 from https://github.com/keis/base58
BITCOIN_ALPHABET = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def b58decode_int(
v: bytes, alphabet: bytes = BITCOIN_ALPHABET
@10gic
10gic / telegram-bot-example.go
Created August 23, 2020 13:55
Telegram bot example
package main
import (
"log"
"time"
tb "gopkg.in/tucnak/telebot.v2"
)
func main() {
-- Following sql will fill 1000000 rows in table tb1
-- Example of generated data:
-- mysql> select * from tb1 limit 10;
-- +----+-------+-------+-----------------------+----------------------------------+
-- | id | score | name | email | hash |
-- +----+-------+-------+-----------------------+----------------------------------+
-- | 1 | 3 | Jack | ffb2@xxx.com | ba85d9424281f259f9cb2f40e63b5044 |
-- | 2 | 1 | Bob | 618ac14397918@xxx.com | 21205c231fa846d35b0e776c40bd3a02 |
-- | 3 | 3 | Jerry | 90ab@xxx.com | 72f0e82a16b28da2953026230940eac9 |
-- | 4 | 2 | Bob | 1450d4ff3@xxx.com | 59e131ee35fd619243ee2e68daa8f6c3 |
@10gic
10gic / SslUtil.java
Last active April 5, 2024 16:28 — forked from rohanag12/SslUtil.java
Create an SslSocketFactory using PEM encrypted certificate files
/**
* Utility class to read encrypted PEM files and generate a
* SSL Socket Factory based on the provided certificates.
*
* Note:
* Java use jks (Java KeyStore) format, but openssl usual use pem format.
* We can convert it by keytool (jdk build-in tool), or use BouncyCastle
* library to handle pem.
*
* The original code is by Sharon Asher (link below). I have modified