Skip to content

Instantly share code, notes, and snippets.

View Wizmann's full-sized avatar
⚙️
不好好学习,只能。。。

Wizmann Wizmann

⚙️
不好好学习,只能。。。
View GitHub Profile
@Wizmann
Wizmann / renren.py
Created February 25, 2013 14:08
人人网发状态机
#coding=utf-8
import urllib
import urllib2
import cookielib
import httplib
import json
import re
import time
import datetime
import os
@Wizmann
Wizmann / lashou_parser_gevent.py
Created March 2, 2013 15:26
Python XML Parser with gevent
# coding=utf-8
import sys
import xml.etree.cElementTree as cElementTree
from pyquery import PyQuery
import time
import gevent
from gevent.queue import Queue, Empty
reload(sys)
sys.setdefaultencoding('utf-8')
@Wizmann
Wizmann / lashou_parser_single.py
Created March 2, 2013 15:50
Python XML Parser with single thread
# coding=utf-8
import sys
import xml.etree.cElementTree as cElementTree
from pyquery import PyQuery
import time
reload(sys)
sys.setdefaultencoding('utf-8')
start_time = time.time()
@Wizmann
Wizmann / lashou_parser_multiprocessing.py
Created March 2, 2013 15:53
Python XML Parser with multiprocessing
# coding=utf-8
import sys
import xml.etree.cElementTree as cElementTree
from pyquery import PyQuery
import multiprocessing as mp
import time
reload(sys)
sys.setdefaultencoding('utf-8')
@Wizmann
Wizmann / kde.py
Created March 10, 2013 15:10
KDE with ``numpy``, ``scipy`` und ``matplotlib``
#coding=utf-8
import sys,re,os
import numpy as np
from scipy import stats
import matplotlib.pylab as plt
def draw_kde(grade):
gkde = stats.kde.gaussian_kde(grade)
ind = np.arange(0.,100.,0.01)
plt.plot(ind, gkde(ind), label='Gods\' Grade', color="g")
@Wizmann
Wizmann / Bottle.scala
Created March 15, 2013 16:01
瓶子问题
//瓶子问题
import scala.annotation.tailrec
object Bottle
{
val N_Bottle = 3
def main(args : Array[String])
{
val n = readLine toInt
@tailrec
def solve(full : Int, empty : Int = 0, drinked : Int = 0) : Int =
@Wizmann
Wizmann / MergeSort.scala
Created March 15, 2013 16:02
归并排序
//归并排序
object MergeSort
{
def main(args:Array[String]) {
val a = readLine split(" ") map(_ toInt) toList
val b = readLine split(" ") map(_ toInt) toList
def merge_sort(a : List[Int], b: List[Int]): List[Int] = {
a match {
case Nil => b
case _ => b match
@Wizmann
Wizmann / Palindrome.scala
Created March 15, 2013 16:03
最长回文串
//最长回文串
//有O(n)的Manacher算法,不过好难写。。。
import scala.math;
object Palindrome
{
def main(args : Array[String])
{
def isPalindrome(x : String): Boolean =
{
x equals x.reverse
@Wizmann
Wizmann / ball.scala
Last active December 15, 2015 11:29
小球乱跑的Scala动画
import scala.swing._
import scala.swing.event._
import scala.actors.Actor._
import scala.actors._
import javax.swing.{UIManager,JComponent}
import javax.swing.KeyStroke.getKeyStroke
import java.awt.{Graphics2D,Graphics,Color,Rectangle}
object ball extends SimpleSwingApplication
{
@Wizmann
Wizmann / py_set.py
Created April 4, 2013 03:28
无聊乱跪
#coding=utf-8
if __name__ == '__main__':
with open("input.txt") as data:
a, b = map(set,zip(*[line.split() for line in data]))
print 'a,b两集合里都包含的元素'
for item in a.union(b):
print item
print '-'*20