Skip to content

Instantly share code, notes, and snippets.

View BruceChen7's full-sized avatar
🎯
Focusing

insects BruceChen7

🎯
Focusing
View GitHub Profile
@BruceChen7
BruceChen7 / easy.md
Last active August 4, 2020 03:44
[#python#try#logging#dict#module#set#list] #python #try#logging#dict#set#list

资料来源

python3 import

项目组织

project/
    main.py
    sub1/
        __init__.py
        helper.py
@BruceChen7
BruceChen7 / exit_pattern.md
Last active November 27, 2020 06:34
[#channel#context]#golang#context
@BruceChen7
BruceChen7 / go_basic.md
Last active August 23, 2020 15:44
#golang#reflection#effective#slice#embedding
@BruceChen7
BruceChen7 / epoll模块的使用.md
Last active August 17, 2022 14:13
[#dict#epoll] #epoll #python #dict#namespace #docker
import select
import socket

if __name__ == "__main__":
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
    s.setblocking(False)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    s.bind(('', 4000))
@BruceChen7
BruceChen7 / extern_c.md
Last active February 15, 2019 13:30
[#extern]#extern #__cplusplus
// call c function in cpp files
//cExample.h
#ifndef C_EXAMPLE_H
#define C_EXAMPLE_H
int add(int x,int y);
#endif
//cExample.c
#include "cExample.h"
int add( int x, int y ) {
@BruceChen7
BruceChen7 / log_test.md
Last active October 21, 2021 09:56
[#golang#log#flag] #log#flag#string#timer
import log
log.SetFlags(log.Lshortfile)   // config.go:46 xxxxx
log.SetFlags(log.Ldate)     // 2017/11/12 xxxx
log.Println("hello world") // 日志级别
log.Fatal("hello world")   // 终止还行

golang flag的使用

@BruceChen7
BruceChen7 / init_test.md
Last active June 30, 2021 02:20
[#pakcage#golang] #golang#init#mod#package#concurrency

在golang中的每个模块可以,定义init函数,用来初始化该包内的全局变量,我们可以看看它的特点

package main
import "fmt"
func init() {
    fmt.Println("init 1")
}
func init() {
    fmt.Println("init 2")
@BruceChen7
BruceChen7 / jsoncpp.cc
Last active January 31, 2019 07:46
[#rapidjson#jsoncpp ]#cpp #json
#include <fstream>
#include <cassert>
#include "json/json.h"
// json文件的读取
int main() {
ifstream ifs;
// 打开数据文件
ifs.open("testjson.json");
assert(ifs.is_open());
@BruceChen7
BruceChen7 / glog.md
Last active June 7, 2018 12:12
[glog的使用] #cpp #glog

常见的使用方式

// http://www.yeolar.com/note/2014/12/20/glog/
#include <glog/logging.h>

int main(int argc, char* argv[]) {
  // Initialize Google's logging library.
  google::InitGoogleLogging(argv[0]);
@BruceChen7
BruceChen7 / algorithm.md
Last active June 7, 2019 13:13
[#STL使用] #cpp #STL

不改变元素的算法

不改变元素的算法既不改变元素的顺序,又不改变元素的值.这些算法操作forward迭代器和input迭代器,所以,这类算法适用于所有标准的容器。

常见的算法

  • for_each() 对容器中的某个元素执行某个操作。
  • count() 返回元素的个数
  • count_if() 返回某个标准的元素的个数
  • min_element() 返回最小的元素
  • max_element() 返回最大的元素