Skip to content

Instantly share code, notes, and snippets.

View zh-f's full-sized avatar
:shipit:
Focusing

Fan Zhang zh-f

:shipit:
Focusing
View GitHub Profile

Set rz and sz on Mac

There are a mess of troubles in sending and receiving files from my macbook to dev server, since I had no permission to excute command scp on dev server. Here is a lightweight, quick, and convenience tools which related with ssh, called lrzsz. lrzsz is a unix communication package providing the XMODEM, YMODEM, ZMODEM file transefer protocol which usually has been already installed in most of servers.

Prerequisites

  • iTerm2 is necessary. [Here][] is the official website.
@zh-f
zh-f / rm_mysql.md
Created February 13, 2019 06:35 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

@zh-f
zh-f / Retry.java
Created April 25, 2019 08:11 — forked from dtodt/Retry.java
Retrofit2@2.5.0 - Retry Adapter Factory - Call & CompletableFuture
package com.company.retrofit2.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
@zh-f
zh-f / exercise-slices.go
Last active June 3, 2020 03:17
Exercise Solution: Slices
package main
import (
"golang.org/x/tour/pic"
"fmt"
)
func Pic(dx, dy int) [][]uint8 {
fmt.Println(dx, dy)
@zh-f
zh-f / exercise-maps.go
Last active June 3, 2020 09:07
Exercise Maps Solution
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) {
@zh-f
zh-f / exercise-stringer.go
Created June 10, 2020 02:01
Solution of Exercise: Stringers
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-errors.go
Created June 10, 2020 02:25
Solution of Exercise: Errors
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-reader.go
Created June 10, 2020 03:29
Solution of Exercise: Readers
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-rot-reader.go
Created June 11, 2020 01:28
Solution of Exercise: rot13Reader
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@zh-f
zh-f / exercise-images.go
Created June 11, 2020 01:56
Solution of Exercise: Images
package main
import (
"golang.org/x/tour/pic"
"image"
"image/color"
)
type Image struct{
width, height int