Skip to content

Instantly share code, notes, and snippets.

View inhzus's full-sized avatar
🎯
Coding

Inhzus inhzus

🎯
Coding
  • Shopee
  • Beijing, China
View GitHub Profile
@inhzus
inhzus / string_split.cc
Created November 12, 2019 15:39
split string
void split(const std::string &s,
const std::string &delim,
const std::function<void(const std::string &)> &f) {
std::string::size_type m{}, n{};
while (true) {
n = s.find(delim, m);
f(s.substr(m, n - m));
if (n == std::string::npos) {
break;
}
import "fmt"
type Other struct {
c bool
x, y int
}
type Model interface{}
type A struct {
@inhzus
inhzus / channel.go
Created July 11, 2019 05:51
Passing channel over channel to do request & get response
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
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 April 30, 2019 03:28
Inner boundary tracing
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 April 30, 2019 03:25
Canny edge dection
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 April 22, 2019 12:42
Frequent itemsets algorithm: FP-Growth
# -*- 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 April 22, 2019 12:40
Frequent itemsets Algorithm: Apriori
# -*- 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 March 13, 2019 17:21
Histogram equalization, RGB and HSV
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 February 16, 2019 04:11
document tracker gist
class Branch {
Date time;
unsigned index;
unsigned succ;
string comment;
}