Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Focusing

Fan Zhang zh-f

:shipit:
Focusing
View GitHub Profile
@zh-f
zh-f / testlink-xml-to-csv.py
Created Jul 9, 2022 — forked from koichirok/testlink-xml-to-csv.py
Small Python 2 script to convert exported TestLink test cases (test suite) to CSV.
View testlink-xml-to-csv.py
View brew-cn-source
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
@zh-f
zh-f / pip-ssl.sh
Created Sep 2, 2020
Fix "pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available"
View pip-ssl.sh
brew update && brew upgrade
brew uninstall --ignore-dependencies openssl;
brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
View update-docker.sh
$ yum list installed | grep docker
docker.x86_64 2:1.13.1-91.git07f3374.el7.centos
docker-client.x86_64 2:1.13.1-91.git07f3374.el7.centos
docker-common.x86_64 2:1.13.1-91.git07f3374.el7.centos
docker-compose.noarch 1.18.0-2.el7 @MJQ-CTyun-Yum-epel
python34-docker.noarch 2.6.1-1.el7 @MJQ-CTyun-Yum-epel
python34-docker-pycreds.noarch 0.2.1-1.el7 @MJQ-CTyun-Yum-epel
python34-dockerpty.noarch 0.4.1-9.el7 @MJQ-CTyun-Yum-epel
@zh-f
zh-f / exercise-images.go
Created Jun 11, 2020
Solution of Exercise: Images
View exercise-images.go
package main
import (
"golang.org/x/tour/pic"
"image"
"image/color"
)
type Image struct{
width, height int
@zh-f
zh-f / exercise-rot-reader.go
Created Jun 11, 2020
Solution of Exercise: rot13Reader
View exercise-rot-reader.go
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@zh-f
zh-f / exercise-reader.go
Created Jun 10, 2020
Solution of Exercise: Readers
View exercise-reader.go
package main
import "golang.org/x/tour/reader"
type MyReader struct{}
// TODO: Add a Read([]byte) (int, error) method to MyReader.
func (r *MyReader) Read (b []byte) (n int, err error){
b = b[:cap(b)]
@zh-f
zh-f / exercise-errors.go
Created Jun 10, 2020
Solution of Exercise: Errors
View exercise-errors.go
package main
import (
"fmt"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string{
return fmt.Sprintf("cannot Sqrt negative number: %v\n", float64(e))
@zh-f
zh-f / exercise-stringer.go
Created Jun 10, 2020
Solution of Exercise: Stringers
View exercise-stringer.go
package main
import "fmt"
type IPAddr [4]byte
// TODO: Add a "String() string" method to IPAddr.
func (ip IPAddr) String() string{
return fmt.Sprintf("%v.%v.%v.%v", ip[0], ip[1], ip[2], ip[3],)
}
@zh-f
zh-f / exercise-maps.go
Last active Jun 3, 2020
Exercise Maps Solution
View exercise-maps.go
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
counter := make(map[string]int)
for _, v := range strings.Fields(s) {