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
@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-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 / 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 / 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

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.
#!/usr/bin/python
# largely taken from python examples
# http://docs.python.org/library/email-examples.html
import os
import sys
from email import encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
@zh-f
zh-f / linux-http-tcp.md
Created June 26, 2018 01:04 — forked from v5tech/linux-http-tcp.md
linux下查看http 并发和 tcp连接数

linux查看httpd进程数

ps -ef | grep httpd | wc -l

查看Apache的并发请求数及其TCP连接状态

netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
@zh-f
zh-f / squash-commits.sh
Created May 21, 2018 06:34 — forked from jbub/squash-commits.sh
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
@zh-f
zh-f / segurity_group_rules.sh
Created May 15, 2018 03:02 — forked from jriguera/segurity_group_rules.sh
Neutron cmd to add security group rules
# Add Neutron security groups for ping and ssh
neutron security-group-rule-create \
--protocol icmp \
--direction ingress \
--remote-ip-prefix 0.0.0.0/0 \
default
neutron security-group-rule-create \
--protocol tcp \

OS

Linux

$ vim ~/.config/pip/pip.conf
or $ vim ~/.pip/pip.conf

Windows

%APPDATA%\pip\pip.ini