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 cpp_tools
#pragma once
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include "dirent.h"
std::string replace_all(const std::string& str, const std::string& from, const std::string& to) {
std::string result_str = str;
size_t start_pos = 0;
@xylcbd
xylcbd / dl_optimizer.py
Created Mar 1, 2017
visualise optimizer for neural network
View dl_optimizer.py
#coding:utf-8
import numpy as np
import matplotlib.pyplot as plt
import math
def f(x):
return x[0] * x[0] + 50 * x[1] * x[1]
def g(x):
return np.array([2 * x[0], 100 * x[1]])
View algorithms_in_program.md

程序设计时的常用算法

排序

  • 冒泡排序
  • 快速排序
  • 直接插入排序
  • 希尔排序
  • 简单选择排序
  • 桶排序
  • 归并排序
View algorithms_in_machine_learning.md

机器学习中的常用算法

有监督算法

  • SVM
  • ANN/CNN/RNN(LSTM)
  • 朴素贝叶斯
  • 决策树
  • Logist
  • KNN
  • EM
@xylcbd
xylcbd / string_utils.cpp
Created Jun 21, 2016
c++ string about utils code
View string_utils.cpp
static std::string strip(const std::string& content)
{
if (content.empty())
{
return content;
}
std::string result = content;
while (true)
{
const wchar_t last_char = result[result.size() - 1];
View freetype_demo.cpp
#include <cstdio>
#include <cstring>
// FreeType headers
#include <ft2build.h>
#include FT_FREETYPE_H
// OpenCV headers
#include <opencv2/core/core.hpp>
View utf16 dump
#include <iostream>
#include <fstream>
static std::string convertUtf16ToLocal(const unsigned short data)
{
char dstData[3];
::wcstombs(dstData, (const wchar_t *)&data, 2);
dstData[2] = '\0';
return dstData;
}
static void dumpUtf16Charset()
View SIMD指令优化Tips
1,SIMD指令优化的是计算,对于内存复制之类的问题,限制在内存,使用SIMD指令优化很少;
2,SIMD指令也需要耗费时间,不要把若干移位和一两次乘法变成SIMD乘法,性能急剧下降;
@xylcbd
xylcbd / scope_exit_lambda.cpp
Last active Nov 27, 2015
scope exit lambda
View scope_exit_lambda.cpp
namespace cxxdetail
{
template <typename FuncType>
class InnerScopeExit
{
public:
InnerScopeExit(const FuncType _func) :func(_func){}
~InnerScopeExit(){ if (!dismissed){ func(); } }
private:
FuncType func;
@xylcbd
xylcbd / timeout_handler.cpp
Created Aug 31, 2015
c++11 timeout handler
View timeout_handler.cpp
template<typename CALLBACKTYPE,typename... ARGS>
class TimeoutHandler
{
public:
TimeoutHandler(const int _timeout/*ms*/,CALLBACKTYPE _callback, ARGS... _args)
{
std::thread([](TimeoutHandler* this_object,int _timeout, CALLBACKTYPE _callback, ARGS... _args)
{
std::this_thread::sleep_for(std::chrono::milliseconds(_timeout));
if (!this_object->exit_flag)
You can’t perform that action at this time.