Skip to content

Instantly share code, notes, and snippets.

View maxwillzq's full-sized avatar

John maxwillzq

  • Google
View GitHub Profile
# -*- coding: utf-8 -*-
string = u"page=/web/mini_f21/site/index.jsp,0.0,\
pagetitle=博世家电-户外全能™系列洗衣机,\
pagetag=,pagedomain=minisite.bosch-home.cn,|page=/virtual/主页,122.0,\
pagetitle=博世家电-户外全能™系列洗衣机,pagetag=,\
pagedomain=minisite.bosch-home.cn,|page=/web/mini_f21/site/index.jsp,36.0,\
pagetitle=博世家电-户外全能™系列洗衣机,\
pagetag=,pagedomain=minisite.bosch-home.cn,\
|page=/virtual/主页,62.0,pagetitle=博世家电-户外全能™系列洗衣机,\
@maxwillzq
maxwillzq / 0_reuse_code.js
Created October 13, 2013 00:33
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import random
def knuthshuffle(a):
N = len(a)
for i in range(N):
r = random.randint(0,i+1)
temp = a[i]
a[i] = a[r]
a[r] = temp
if __name__ == "__main__":
import copy
from copy import deepcopy
def isSorted(a):
for i in range(1,len(a)):
if(a[i]<a[i-1]):
return False
return True
def insertionSort(a):
def binarySearch(a,key):
lo =0
hi = len(a)
while(lo<hi):
mid = lo + (hi-lo)/2
if(key < a[mid]):
hi = mid-1
elif(key >a[mid]):
class WeightedQuickUnionUF(object):
def __init__(self,N):
self.__id = []
self.sz = []
for i in range(N):
self.__id.append(i)
self.sz.append(1)
def root(self,i):
while(i!=self.__id[i]):
class QuickUnionUF(object):
def __init__(self,N):
self.__id = []
for i in range(N):
self.__id.append(i)
def root(self,i):
while(i!=self.__id[i]):
self.__id[i] = self.__id[self.__id[i]]
i = self.__id[i]
class QuickFindUF(object):
def __init__(self,N):
self.__id = []
for i in range(N):
self.__id.append(i)
def connected(self,p,q):
return self.__id[p] == self.__id[q]
@maxwillzq
maxwillzq / Python overview code sample.py
Created January 13, 2013 06:27
Day 0 Overview of python
#code sample
# from wiki.python.org/moin/SimplePrograms
# "1 line: Output"
print "hello,world"
# 2 lines: input,assignment
name= raw_input('What is your name?\n')
print 'Hi %s.' % name
#descriptor example
class RevealAccess(object):
def __init__(self,initval=None,name='var'):
self.val = initval
self.name = name
def __get__(self,obj,objtype):
print "Retrieving",self.name
return self.val