View string_split.cc
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; | |
} |
View polymorphism.go
import "fmt" | |
type Other struct { | |
c bool | |
x, y int | |
} | |
type Model interface{} | |
type A struct { |
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)) |
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 |
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; |
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') |
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 |
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); |
View Branch. cpp
class Branch { | |
Date time; | |
unsigned index; | |
unsigned succ; | |
string comment; | |
} |
NewerOlder