Skip to content

Instantly share code, notes, and snippets.

🎯
Reading Unix Network Programming

Zhi Sun inhzus

🎯
Reading Unix Network Programming
Block or report user

Report or block inhzus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View polymorphism.go
import "fmt"
type Other struct {
c bool
x, y int
}
type Model interface{}
type A struct {
@inhzus
inhzus / channel.go
Created Jul 11, 2019
Passing channel over channel to do request & get response
View channel.go
package main
import "fmt"
var queue = make(chan int)
var c = make(chan chan error)
func request() {
for i := 0; i < 4; i++ {
queue <- i
View main.py
import argparse
from . import user_service, doc_service, repo_service
parser = argparse.ArgumentParser()
# ... set argument
args = parser.parse_args()
print(getattr(
globals()[f'{args.sub}_service'],
getattr(args, args.sub))
@inhzus
inhzus / edge_linking.m
Created Apr 30, 2019
Inner boundary tracing
View edge_linking.m
function output = my_edgelinking(image, row, col)
output = [row col;];
image(row, col) = 0;
dir = 7;
while (1)
[row, col, next_found, dir] = find_next_dir(row, col, dir, image);
if (~next_found)
break;
end
@inhzus
inhzus / edge_detection.m
Created Apr 30, 2019
Canny edge dection
View edge_detection.m
function output = my_edge(input_image)
mean_value = mean(mean(input_image));
[height, width] = size(input_image);
fft_mid_img = fftshift(fft2(input_image));
fft_ratio = 12;
a = round(height/fft_ratio):round((fft_ratio-1)*height/fft_ratio);
b = round(width/fft_ratio):round((fft_ratio-1)*width/fft_ratio);
% disp(a);
% disp(b);
fft_mid_img(round(height / 2), round(width / 2)) = 0;
@inhzus
inhzus / fp_growth.py
Created Apr 22, 2019
Frequent itemsets algorithm: FP-Growth
View fp_growth.py
# -*- coding: utf-8 -*-
# created by inhzus
import typing
from collections import Counter, defaultdict
from itertools import combinations
from pprint import pprint
T = typing.TypeVar('T')
@inhzus
inhzus / apriori.py
Created Apr 22, 2019
Frequent itemsets Algorithm: Apriori
View apriori.py
# -*- coding: utf-8 -*-
# created by inhzus
import typing
from collections import defaultdict
from itertools import combinations
from numbers import Number
from pprint import pprint
from bitarray import bitarray
@inhzus
inhzus / Histogram_equalization.m
Created Mar 13, 2019
Histogram equalization, RGB and HSV
View Histogram_equalization.m
function [output] = Histogram_equalization(input_image)
%first test the image is a RGB or gray image
hsv = true;
if numel(size(input_image)) == 3
%this is a RGB image
%here is just one method, if you have other ways to do the
%equalization, you can change the following code
if hsv
input_image = rgb2hsv(input_image);
h=input_image(:,:,1);
@inhzus
inhzus / Branch. cpp
Last active Feb 16, 2019
document tracker gist
View Branch. cpp
class Branch {
Date time;
unsigned index;
unsigned succ;
string comment;
}
View HanLPSeg2Sentence.java
public static void main(String[] args) {
Segment segment = HanLP.newSegment().enableAllNamedEntityRecognize(false).enableCustomDictionary(false);
List<List<Term>> result = segment.seg2sentence("信里说他们离青云山还有很远,老祖宗说不着急,走个两三年也没什么打紧,所以他们走走停停," +
"有时听说哪里有好看好玩的事物,也会专门绕路过去,停驻几天。又说路上什么都好,哪怕是荒郊野外," +
"老祖宗也能变出热腾腾的吃食,还有各种衣物,穿戴比家里都要好。他们还自己动手搭过木屋,在一颗很高很大的树上," +
"建起了一座小小的屋子,为此他还专门学会了爬树…总之是一切都好,让父母大人不用担心他,老祖宗有个百宝囊,里面什么都有," +
"连书都有很多,没事的时候,他们就跟着老祖宗读书练字,最后祝高堂安泰。", true);
for (List<Term> sentence : result) {
for (Term term : sentence) {
System.out.printf("%s ", term.word);
You can’t perform that action at this time.