Skip to content

Instantly share code, notes, and snippets.

View wynemo's full-sized avatar
🤣
快落的时光总那么少

Nemo.Zhang wynemo

🤣
快落的时光总那么少
View GitHub Profile
#coding:utf-8
import json
import sys
json_file_name = sys.argv[1]#'C:/Users/zdb/Downloads/shared-items-jas.json',
f1 = open(json_file_name,'r')
o1 = json.load(f1,'utf-8')
i = 1
dir1 = u'd:/'
for item in o1['items']:
name = u''
@wynemo
wynemo / .vimrc
Created January 20, 2012 09:07
my vim rc
set sw=4 ts=4 sta et sts=4 ai
set nu
set guifont=Inconsolata\ Medium\ 12
syntax on
colorscheme slate
nmap <F8> :TagbarToggle<CR>
@wynemo
wynemo / ping_ip_rang.sh
Created January 20, 2012 09:26
ping ip range
#!/bin/bash
checkalive (){
NODE=$1
ping -c 3 $NODE>/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "$NODE is alive"
else
echo "$NODE is not alive"
fi
@wynemo
wynemo / mk_dict.py
Created January 21, 2012 05:39
grasp word definition from google
#!/usr/bin/env python
#coding:utf-8
import re
import sys
import urllib2
std_headers = {
'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101028 Firefox/3.6.12',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-us,en;q=0.5',
@wynemo
wynemo / myfind.py
Created February 20, 2012 14:42
find text in file
#!/usr/bin/env python
#coding:utf-8
#use example:
# find|python /tmp/myfind.py sth
# on cygwin
# find|python "C:\Users\user1\findtext\myfind.py" sth
import re
@wynemo
wynemo / httplib_set_tunnel.py
Created March 21, 2012 16:55
httplib in python 2.7 set proxy
import httplib
c = httplib.HTTPSConnection('localhost',8118)
c.set_tunnel('twitter.com',443)
c.request('GET','/')
r1 = c.getresponse()
print r1.status,r1.reason
data1 = r1.read()
print len(data1)
@wynemo
wynemo / urllib2_auth.py
Created March 21, 2012 17:03
urllib2 basic auth
# quoted from http://www.wkoorts.com/wkblog/2008/10/27/python-proxy-client-connections-requiring-authentication-using-urllib2-proxyhandler/
# urllib2_proxy_handler.py
#
# Author: Wayne Koorts
# Date: 27/10/2008
#
# Example for using urllib2.urlopen() with a proxy server requiring authentication
import urllib2
@wynemo
wynemo / check_utf8.py
Created March 23, 2012 04:32
check file containing chinese,but not in utf-8 format
#coding:utf-8
suffix_list = ['.cpp','.c','.h','.hpp','.txt','.html','.htm','.xml','.py']
def FoundInvalidFile(input_folder):#str,list
def calc_bom(str1):
rt = ''
for i in range(0,3):
rt += '%02X'%(ord(str1[i]))
return rt
@wynemo
wynemo / sub_url.py
Created April 4, 2012 16:16
sub url in twitter text
def sub_url(self,str1):
import json
rv = str1
try:
o = json.loads(str1)
changed = 0
if isinstance(o,list):
for i,each in enumerate(o):
if each.has_key('text') and each.has_key('entities') and each['entities'].has_key('urls'):
text = each['text']
@wynemo
wynemo / fedora15.md
Created April 5, 2012 15:40
something about fedora 15

##f15 kde 桌面

###video music 加源 http://rpmfusion.org/Configuration yum -y install gstreamer-plugins-bad-free ffmpeg ffmpeg-devel lame 显卡安装失败

###install kernel 更新内核 : yum update kernel 大更新: yum update