Skip to content

Instantly share code, notes, and snippets.

View zwfang's full-sized avatar
📝
Know that it is you who will get you where you want to go, no one else.

zwfang

📝
Know that it is you who will get you where you want to go, no one else.
  • Remote
View GitHub Profile
@zwfang
zwfang / auto_remote_local_git_branch.bash
Last active May 23, 2019 11:54
Auto clean useless git branch. How effectively remove git branch.
#!/usr/bin/env bash
#----------------------------------------------------------------------------------
# author: Andy
# feature: clean useless git-branch,
# but master, current branch, other branch you passed in command line
# usage: bash auto_remote_local_git_branch.bash branch branch branch is you don't want remove
#----------------------------------------------------------------------------------
echo -e "begin...\n"
@zwfang
zwfang / delete_git_submodule.md
Created January 30, 2019 09:07 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@zwfang
zwfang / narcissisticNumber.c
Created December 7, 2018 14:42
水仙花数
//
// main.c
// narcissisticNumber
//
// Created by fzw on 10/7/18.
// Copyright © 2018 n. All rights reserved.
//
#include <stdio.h>
@zwfang
zwfang / MergeTwoSortedArray.c
Created December 7, 2018 14:41
first c algorithm. help me open computer gate.
//
// main.c
// MergeTwoSortedArray
//
// Created by fzw on 9/26/18.
// Copyright © 2018 n. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
@zwfang
zwfang / addBinary.c
Created December 7, 2018 14:39
Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0.
//
// main.c
// addBinary
//
// Created by fzw on 10/7/18.
// Copyright © 2018 n. All rights reserved.
//
#include <stdio.h>
#include <string.h>
@zwfang
zwfang / rotateList.c
Created December 7, 2018 14:38
Given a linked list, rotate the list to the right by k places, where k is non-negative.
//
// main.c
// RotateList
//
// Created by fzw on 10/7/18.
// Copyright © 2018 n. All rights reserved.
//
#include <stdio.h>
@zwfang
zwfang / reverseNodeKGroup.c
Created December 7, 2018 14:37
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
//
// main.c
// reverse node in k group
//
// Created by fzw on 10/12/18.
// Copyright © 2018 n. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
@zwfang
zwfang / fib.go
Created December 7, 2018 14:25
fib
package main
import "fmt"
func fib() func() int64 {
var i int64
var j int64 = 1
return func() int64 {
i, j = j, i+j
return i
@zwfang
zwfang / hanio.py
Created December 7, 2018 14:25
hanio
#!/usr/bin/env python3
import sys
def move(n, x, y, z):
if n == 1:
print("%s --> %s" % (x, z))
else:
move(n-1, x, z, y)
print("%s --> %s" % (x, z))
@zwfang
zwfang / sort.md
Last active February 21, 2019 05:56
sort

一、冒泡排序

def bububle_sort(alist):
    """冒泡排序(稳定|n^2m)"""
    n = len(alist)
    for j in range(n-1):
        count = 0
        for i in range(0,n-1-j):