原创 關於c++析構函數

測試了一下c++的析構函數: #include <iostream> #include<boost/thread.hpp> #include<fstream> #include<memory> using namespace std;

原创 用socket(asio)實現了smtp的幾個簡單的指令

測試主程序 #include <iostream> #include<boost/asio.hpp> #include"logging.h" #include"smtplib.h" using namespace std; using

原创 優先隊列實現

先上測試: #include<iostream> #include<vector> #include<queue> #include<random> #include<fstream> #include"max_heap.h" #inc

原创 python的__getattr__方法

#wrpme包裝類 class wrapme: def __init__(self,obj): self.__data = obj def get(self): return self._

原创 asio測試

測試了一下boost的異步io. 客戶端::向服務器發出多個請求,連接成功就打印一條消息。 服務器端:主線程調用async_accept,handler函數先調用一個async_accept以接收新的請求。然後就去幹自己的事了(sleep

原创 重新寫了一個簡單的日誌類

之前寫的了個日誌類,感覺寫得比較囉嗦,重新寫一個比較簡單的,功能跟之前差不多. <pre name="code" class="cpp">#ifndef LOGGING #define LOGGING #include<string>

原创 python的email模塊

在Python官網上看到這個例子 import smtplib from email.mime.text import MIMEText from email.mime.image import MIMEImage from emai

原创 JAVA遍歷目錄

/*java實現了遍歷文件和目錄,文件過濾器,廣度優先和深度優先兩個版本*/ package jav; import java.io.File; import java.io.FilenameFilter; import java.

原创 寫了個小爬蟲

from mysql import connector import hashlib from _codecs import encode class Quercy(object):     def __init__(self,my

原创 分治和自頂向下動態規劃算法

Given a string of numbers and operators, return all possible results from computing all the different possible ways to

原创 寫了個異步日誌

主要實現:簡單的異步日誌,工作線程只需把日誌消息寫入緩衝,不必阻塞與耗時的IO操作,由一個背景線程專門負責IO操作。 採用的數據結構,前端爲雙緩衝區,後端爲BlockingQueue,緩衝區的初始化和析構都由背景線程負責,兩塊緩衝交替使用

原创 python twisted試用

reactor模式總是由事件驅動方法,一個問題是:當一個方法被驅動,我應該調用哪個處理函數?另一個問題是:reactor模式總是被動的激活某個方法,然後被動的激活處理函數,那麼我們現在想主動調用某個方法,應該怎麼調用,時機在哪裏?這兩個問

原创 關於sigsetjmp和siglongjmp

在CSAPP上看到的例子: #include<iostream> #include<signal.h> #include <setjmp.h> #include<unistd.h> sigjmp_buf buf; void handl

原创 Basic Calculator II

Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative i

原创 二叉樹中序遍歷(迭代)

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. C