Skip to content

Instantly share code, notes, and snippets.

View ResolveWang's full-sized avatar
🎯
Focusing

resolvewang ResolveWang

🎯
Focusing
View GitHub Profile
比如我们需要让test.py在后台挂着,而不出现命令行窗口,那么可以使用以下命令:
start /min python test.py
linux下面:
nohup python test.py &
使用-encoding参数指明编码方式:javac -encoding UTF-8 XX.java
t = threading.Timer(timeout,conn.cancel)
t.start()
cursor = conn.cursor()
cursor.execute(query)
res = cursor.fetchall()
t.cancel()
import org.apache.http.HttpHost;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.DnsResolver;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
os.getenv('java')
# or
os.environ.get('java')
from time import sleep, time
import sys, threading
class KThread(threading.Thread):
"""A subclass of threading.Thread, with a kill()
method.
@ResolveWang
ResolveWang / 利用反射获取简单对象的属性和值
Last active November 3, 2016 01:38
Java中利用反射来显示对象所有属性和值
package cn.resolvewang;
import com.sun.deploy.util.ArrayUtil;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
@ResolveWang
ResolveWang / 原始方式
Last active November 3, 2016 01:48
python日志demo
# 最原始的方式
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import logging
# create logger
logger = logging.getLogger('simple_example')
# Set default log level
@ResolveWang
ResolveWang / install_scrapy_in_centos_6_5.sh
Created November 26, 2016 04:36 — forked from Shellbye/install_scrapy_in_centos_6_5.sh
Install scrapy in CentOS 6.5 in virtualenv, and install mysql to store the data crawled. After the installation, the `spider` dir will contains all the downloaded files and the `spider_env` is the virtualenv dir
#!/usr/bin/env bash
mkdir spider
cd spider/
yum update -y
# install pip on centos6
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install -y python-pip
# install wget
yum install -y wget
def to_dict(ins):
table_columns = ins.__table__.c
l = [column.key for column in table_columns]
d = {}
for k, v in ins.__dict__.items():
if k in l:
d[k] = str(v) if v is not None else ''
return d