This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import urllib | |
import time | |
class Mythread(threading.Thread): | |
'''Download pictures.''' | |
def __init__(self, url): | |
threading.Thread.__init__(self) | |
self.url = url | |
print 'init thread.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import urllib | |
import Queue | |
import time | |
class Mythread(threading.Thread): | |
'''Download pictures.''' | |
def __init__(self, queue): | |
threading.Thread.__init__(self) | |
self.queue = queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import threadpool | |
starttime = time.time() | |
def job(args): | |
print args[0] | |
print args[1] | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
void qsort_last(int s[], int start_index, int end_index); //select the last element as the pivot | |
void qsort_first(int s[], int start_index, int end_index); //select the first element as the pivot | |
void qsort_mid(int s[], int start_index, int end_index); //select the middle element as the pivot | |
void qsort_rand(int s[], int start_index, int end_index); //select a random index's value as the pivot | |
void qsort_mot(int s[], int start_index, int end_index); //median of three partitioning + insertion sort | |
void qsort_clrs(int s[], int start_index, int end_index); //select the last element as the pivot, CLRS version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "MyString.h" | |
MyString::MyString(void) : capacity(INITIAL_CAPACITY), size(0) | |
{ | |
s_ptr = new char[INITIAL_CAPACITY]; | |
*s_ptr = '\0'; | |
} | |
MyString::~MyString(void) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
1. Construct the url with num_iid, eg: http://a.m.tmall.com/i15110720150.htm, 15110720150 is the num_iid. | |
2. Get the html text. | |
3. Parse the img urls and insert the num_iid and img urls into sqlite. | |
''' | |
import requests | |
from pyquery import PyQuery as pq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import requests | |
from pyquery import PyQuery as pq | |
import yaml | |
from hashlib import md5 | |
from datetime import datetime | |
import smtplib | |
from email.mime.text import MIMEText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test_jsoup.test_jsoup; | |
import org.jsoup.Jsoup; | |
import org.jsoup.nodes.Document; | |
import org.jsoup.nodes.Element; | |
import org.jsoup.select.Elements; | |
public class App | |
{ | |
public static void main( String[] args ) throws Exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <vector> | |
#include <sstream> | |
using std::vector; | |
using std::string; | |
using std::stringstream; | |
vector<string> &split(const string &s, char delim, vector<string> &result) { | |
stringstream ss(s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
import sys | |
def read_input(file): | |
''' | |
read input tf mapper-reducer file | |
class:Queries\tword_1:val_1,word_2:val_2,..... | |
''' | |
for line in file: |
OlderNewer