Skip to content

Instantly share code, notes, and snippets.

@young001
young001 / gist:3826069
Created October 3, 2012 09:36
crawler for tianya.cn
# -*- coding:utf-8 -*-
from BeautifulSoup import BeautifulSoup,SoupStrainer
import urllib
import urllib2
import re
import time
import os
import json
import redis
@young001
young001 / gist:3834860
Created October 4, 2012 16:45
tianya crawler
# -*- coding:utf-8 -*-
from BeautifulSoup import BeautifulSoup,SoupStrainer
import urllib
import urllib2
import re
import time
import os
import json
import redis
from log_code import logger
@young001
young001 / gist:3835876
Created October 4, 2012 19:33
tianya3
# -*- coding:utf-8 -*-
from BeautifulSoup import BeautifulSoup,SoupStrainer
import urllib
import urllib2
import re
import time
import os
import random
import cookielib
import json
@young001
young001 / mysql error in ubuntu
Created October 20, 2012 14:14
mysql error in ubuntu
┌─(young001@young001-HP-Elite-7100-Microtower-PC:pts/8)────────────────(/run/mysqld)─┐
└─(22:12:%)── sudo dpkg --configure mysql-server-5.5 ──(六,10月20)─┘
[sudo] password for young001:
Setting up mysql-server-5.5 (5.5.24-0ubuntu0.12.04.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
mysql-server-5.5
@young001
young001 / gist:5449751
Created April 24, 2013 05:04
mutil threads
import requests
from threading import Thread
import Queue
import httpsqs
import os
#gevent_profiler.print_percentages(True)
#gevent_profiler.time_blocking(True)
#gevent_profiler.set_stats_output('my-stats.txt')
@young001
young001 / gist:5517224
Created May 4, 2013 11:30
tmux configuration
#
# author: Xu Xiaodong <xxdlhy@gmail.com>
# modified: 2012 Apr 16
#
#-- base --#
unbind C-b
set -g prefix C-q
set -g default-terminal "screen-256color"
#!/usr/bin/expect -f
# ./ssh.exp password 192.168.1.11 id
set name [lrange $argv 2 2]
set server [lrange $argv 1 1]
set pass [lrange $argv 0 0]
spawn ssh $name@$server
match_max 100000
expect "*?assword:*"
send -- "$pass\r"
4556 5092 0.7000
4556 4785 0.7500
4556 5397 0.7000
4556 5139 0.7500
4556 5937 0.8333
4556 6220 0.7000
4556 5139 0.7500
4556 6220 0.7063
4559 4563 0.7500
4559 4770 0.7500
4556 5092 0.7
4556 4785 0.75
4556 5397 0.7
4556 5139 0.75
4556 5937 0.833333333
4556 6220 0.7
4559 4563 0.75
4559 4770 0.75
4559 4837 0.75
4559 5640 0.75
data = file("test_train")
relevance_file = file("train_relevance","w")
def dwell_to_relevance(time):
if time < 50:
return 0
elif 50 <= time <=399:
return 1
else:
return 2