Skip to content

Instantly share code, notes, and snippets.

@SolemnJoker
SolemnJoker / defer.h
Last active November 7, 2020 06:42
[c++ unit] #c++
class ExecuteOnExit{
public:
ExecuteOnExit() = default;
// movable
ExecuteOnExit(ExecuteOnExit&& ) = default;
ExecuteOnExit& operator=(ExecuteOnExit&& ) = default;
// non copyable
ExecuteOnExit(const ExecuteOnExit& e) = delete;
@SolemnJoker
SolemnJoker / utils.h
Last active November 7, 2020 06:51
[get files list ] 获取文件列表 #c++ #file
inline
std::vector<std::string> getFilesList(std::string dirpath){
DIR *dir = opendir(dirpath.c_str());
if (dir == NULL)
{
std::cout << "opendir error" << std::endl;
}
std::vector<std::string> all_path;
struct dirent *entry;
@SolemnJoker
SolemnJoker / csv.cpp
Last active November 7, 2020 06:51
[read csv by cpp] c++读取csv文件 #c++ #csv
#include "csv.h"
inline
std::vector<std::string> split_csv_line(const std::string& str) {
char seperator = ',';
std::vector<std::string> results;
std::string::size_type start = str.find_first_not_of(' ');
std::string::size_type sep = str.find(seperator);
while (sep != std::string::npos) {
@SolemnJoker
SolemnJoker / add_boost.txt
Last active November 7, 2020 06:50
[cmake] #CMakelist #cmake
find_package(Boost REQUIRED COMPONENTS regex filesystem) #要使用的boost库
if(NOT Boost_FOUND)
message("Not found Boost")
endif()
include_directories(${Boost_INCLUDE_DIRS})
@SolemnJoker
SolemnJoker / rbtree.c
Last active November 7, 2020 06:52
[rbtree] c++红黑树 #c++ #算法
#include <stdio.h>
#include <stdlib.h>
#include "rbtree.h"
#define rb_parent(r) ((r)->parent)
#define rb_color(r) ((r)->color)
#define rb_is_red(r) ((r)->color==RED)
#define rb_is_black(r) ((r)->color==BLACK)
@SolemnJoker
SolemnJoker / list_dir.py
Last active May 11, 2021 09:07
[python unit] #python
import os
rootdir = "./input_files"
paths = os.listdir(rootdir)
for path in paths:
path = os.path.join(rootdir,path)
if os.path.isfile(path):
#...
@SolemnJoker
SolemnJoker / Makefile
Last active November 7, 2020 06:49
[makefile 记录] #makefile
CC := g++
C_FLAGS := -std=c++14 -Wall -Wextra
BIN := .
SRC := .
INCLUDE := include
LIB := lib
LIBRARIES :=
@SolemnJoker
SolemnJoker / alpine-localtime
Last active November 7, 2020 06:48
[dockerfile] #dockerfile #docker
Run sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk update &&\
apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& apk del tzdata

例:

docker inspect -f {{.LogPath}} container_name;

@SolemnJoker
SolemnJoker / 6_privileges.sql
Last active November 17, 2020 02:46
[mysql privileges] #mysql
use mysql;
select host, user from user;
grant all on uic.* to root@'%' identified by '123456' with grant option;
grant all on falcon_portal.* to root@'%' identified by '123456' with grant option;
grant all on dashboard.* to root@'%' identified by '123456' with grant option;
grant all on graph.* to root@'%' identified by '123456' with grant option;
grant all on alarms.* to root@'%' identified by '123456' with grant option;
flush privileges;