Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

hongbomin xylcbd

🎯
Focusing
Block or report user

Report or block xylcbd

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 show_image.py
#!/usr/local/bin/python
#coding: utf-8
import os
import sys
import fnmatch
import cv2
def files_in_dir(root, pattern):
all_files = []
View useful.sh.md

批量替换目录中所有文件的字符串

sed -i "s/zhangsan/lisi/g" `grep zhangsan -rl /modules`

-i 表示inplace edit,就地修改文件
-r 表示搜索子目录
-l 表示输出匹配的文件名
View profiling.cpp
#include <chrono>
#include <string>
#include <iostream>
struct profiler
{
std::string name;
std::chrono::high_resolution_clock::time_point p;
profiler(std::string const &n) :
name(n), p(std::chrono::high_resolution_clock::now()) { }
View quick_sort.cpp
static int split(std::vector<int>& data, const int beg, const int end)
{
if (beg >= end || end <= 0)
{
return -1;
}
int idx = beg;
const int base = data[end - 1];
for (int i = beg; i < end; i++)
{
View format_cout.cpp
static std::ostream& operator<<(std::ostream& os, const std::vector<int>& data)
{
for (size_t i = 0; i < data.size();i++)
{
os << data[i];
if (i < (int)data.size() - 1)
{
os << ", ";
}
}
View utf8_helper.cpp
std::string local_to_utf8(const std::string& src)
{
#if _WIN32
int len = MultiByteToWideChar(CP_ACP, 0, src.c_str(), -1, NULL, 0);
wchar_t* wszUTF16 = new wchar_t[len+1];
memset(wszUTF16, 0, len+1);
MultiByteToWideChar(CP_ACP, 0, src.c_str(), -1, wszUTF16, len);
len = WideCharToMultiByte(CP_UTF8, 0, wszUTF16, -1, NULL, 0, NULL, NULL);
char* szUTF8 = new char[len + 1];
memset(szUTF8, 0, len + 1);
@xylcbd
xylcbd / cr_ar.py
Last active Sep 29, 2017
calc cr & ar, for ocr benchmark.
View cr_ar.py
def custom_min(data):
assert len(data) >= 1
if len(data) <= 0:
return data,0
min_idx = 0
min_data = data[min_idx]
for i,item in enumerate(data):
if item < min_data:
min_data = item
min_idx = i
@xylcbd
xylcbd / giflib_to_opencv.cpp
Created Aug 17, 2017
load gif to opencv mat, using giflib & opencv
View giflib_to_opencv.cpp
//std headers
#include <fstream>
#include <iostream>
//lib headers
#include <gif_lib.h>
#define USING_NEW_GIF_LIB defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
cv::Mat imread_gif(const std::string& filename, const int flags)
{
std::ifstream stream(filename, std::ios::in | std::ios::binary);
View seq2seq_beam_search.py
#coding: utf-8
#demo of beam search for seq2seq model
import numpy as np
import random
vocab = {
0: 'a',
1: 'b',
2: 'c',
3: 'd',
View cpp_web_tools.cpp
static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
static inline bool is_base64(unsigned char c) {
return (isalnum(c) || (c == '+') || (c == '/'));
}
You can’t perform that action at this time.