Skip to content

Instantly share code, notes, and snippets.

@guoxingx
guoxingx / gerror.go
Created February 26, 2020 09:36
error with code and message
package gerror
import (
"fmt"
)
// Error with an code in int type
type Error struct {
code int
message string
@guoxingx
guoxingx / list_nethogs.py
Created May 20, 2019 12:35
analyse script for "nethogs -t > filename"
#! /usr/bin/env python
# analyse script for "nethogs -t > filename"
import sys
def process_line(line, sent, received):
"""
@params: line: string: line to process
@params: sent: int: threshold for sent
@guoxingx
guoxingx / ipfsdocker.py
Last active July 20, 2018 08:50
wrapped ipfs docker cmd
#!/usr/bin/env python
"""
usage:
ipfsdocker start
ipfsdocker stop
ipfsdocker -h
ipfsdocker add <file>
"""
@guoxingx
guoxingx / solcdocker.py
Created July 5, 2018 03:13
docker solc cmd
#!/usr/bin/env python
"""
chmod a+x solcdocker
mv solcdocker /usr/local/bin
usage:
solcdocker <path-to-sol-file>
output:
@guoxingx
guoxingx / memcheck.py
Created June 13, 2018 05:31
Get memory info
"""
basic memory check functions.
"""
import subprocess
def get_memory_info(remote_addr=None):
"""
All messages from /proc/meminfo
@guoxingx
guoxingx / grab_ropsten_ether.py
Created June 13, 2018 05:30
Script to request ether in testnet
#!/usr/bin/env python
import os
import enum
import time
import asyncio
import hashlib
import argparse
import requests
@guoxingx
guoxingx / Exercise-Equivalent-Binary-Trees.go
Created May 18, 2018 17:16
A Tour of Go - Exercise: Equivalent Binary Trees
package main
import (
"golang.org/x/tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@guoxingx
guoxingx / Exercise-Images.go
Created May 18, 2018 11:21
A Tour of Go - Exercise: Images
package main
import (
"golang.org/x/tour/pic"
"image"
"image/color"
)
type Image struct{}
@guoxingx
guoxingx / Exercise-rot13Reader.go
Created May 18, 2018 10:59
A Tour of Go - Exercise: rot13Reader
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@guoxingx
guoxingx / Exercise-Readers.go
Created May 18, 2018 10:12
A Tour of Go - Exercise: Readers
package main
import (
"golang.org/x/tour/reader"
)
type MyReader struct{}
// TODO: Add a Read([]byte) (int, error) method to MyReader.
func (reader MyReader) Read(b []byte) (int, error) {