Skip to content

Instantly share code, notes, and snippets.

View xylcbd's full-sized avatar
🎯
Focusing

xylcbd xylcbd

🎯
Focusing
View GitHub Profile
@xylcbd
xylcbd / giflib_to_opencv.cpp
Created August 17, 2017 08:47
load gif to opencv mat, using giflib & opencv
//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);
#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',
static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
static inline bool is_base64(unsigned char c) {
return (isalnum(c) || (c == '+') || (c == '/'));
}
#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 March 1, 2017 09:58
visualise optimizer for neural network
#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]])

程序设计时的常用算法

排序

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

机器学习中的常用算法

有监督算法

  • SVM
  • ANN/CNN/RNN(LSTM)
  • 朴素贝叶斯
  • 决策树
  • Logist
  • KNN
  • EM
@xylcbd
xylcbd / string_utils.cpp
Created June 21, 2016 07:41
c++ string about utils code
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];
@xylcbd
xylcbd / freetype_demo.cpp
Created June 14, 2016 08:51
freetype demo
#include <cstdio>
#include <cstring>
// FreeType headers
#include <ft2build.h>
#include FT_FREETYPE_H
// OpenCV headers
#include <opencv2/core/core.hpp>
#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()