Skip to content

Instantly share code, notes, and snippets.

View cydu's full-sized avatar

cydu cydu

View GitHub Profile
@cydu
cydu / merge_multi_html_to_pdf.py
Last active August 29, 2015 14:09
Merge a class of geeksforgeeks.com posts into one html, then convert into PDF
import sys
import requests
from xhtml2pdf import pisa
from bs4 import BeautifulSoup
def convertHtmlToPdf(sourceHtml, outputFilename):
print "generate pdf to " + outputFilename
resultFile = open(outputFilename, "w+b")
pisaStatus = pisa.CreatePDF(
DOWNLOAD_HANDLERS = {
'http': 'myspider.socks5_http.Socks5DownloadHandler',
'https': 'myspider.socks5_http.Socks5DownloadHandler'
}
@cydu
cydu / gist:5045568
Last active December 14, 2015 06:49
thread-safe blocking queue
class ThreadQueue {
private:
ThreadQueue& operator=(ThreadQueue&);
list<int> data;
pthread_mutex lock;
pthread_mutex empty_lock;
public:
ThreadQueue() {
pthread_mutex_init(&lock,NULL);