Skip to content

Instantly share code, notes, and snippets.

View cloudaice's full-sized avatar
:octocat:

项超 cloudaice

:octocat:
  • Bytedance
  • Hangzhou China
View GitHub Profile
@cloudaice
cloudaice / pagerank.py
Created October 17, 2012 03:09
pagerank算法
# Copyright (c) 2010 Pedro Matiello <pmatiello@gmail.com>
# Juarez Bochi <jbochi@gmail.com>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
@cloudaice
cloudaice / BinaryStream.py
Created October 19, 2012 13:33
读取java中的字节流数据
# -*-coding: utf-8 -*-
from struct import *
class BinaryStream:
def __init__(self,base_stream):
self.base_stream = base_stream
self.offset = 0
def readBytes(self,length):
string, = unpack_from(str(length) + 's',self.base_stream[self.offset:])
@cloudaice
cloudaice / fabfile.py
Created December 6, 2012 03:02
fabric file
from __future__ import with_statement
import os
from django.core import management
# We have to re-name this to avoid clashes with fabric.api.settings.
import ohbooklist.conf.local.settings as django_settings
management.setup_environ(django_settings)
from fabric.api import *
@cloudaice
cloudaice / redis-hash
Created January 6, 2013 06:11
python的redis的hash
import md5
class HashRing(object):
def __init__(self, nodes=None, replicas=3):
"""Manages a hash ring.
`nodes` is a list of objects that have a proper __str__ representation.
`replicas` indicates how many virtual points should be used pr. node,
replicas are required to improve the distribution.
@cloudaice
cloudaice / download_pic.py
Created January 18, 2013 07:55
download_picture
#-*-coding:utf-8-*-
from BeautifulSoup import BeautifulSoup
import requests
from PIL import Image
from StringIO import StringIO
r = requests.get('http://www.xiaomi.com')
assert(r.status_code == 200)
soup = BeautifulSoup(r.text)
urls = soup.findAll('img')
@cloudaice
cloudaice / BeautifulSoup.py
Created January 18, 2013 07:58
分析html用的python包
"""Beautiful Soup
Elixir and Tonic
"The Screen-Scraper's Friend"
http://www.crummy.com/software/BeautifulSoup/
Beautiful Soup parses a (possibly invalid) XML or HTML document into a
tree representation. It provides methods and Pythonic idioms that make
it easy to navigate, search, and modify the tree.
A well-formed XML/HTML document yields a well-formed data
@cloudaice
cloudaice / github-china.md
Last active December 17, 2015 04:49
Activity chinese github users

Github上活跃的中国开发者

import tornado.ioloop
import tornado.web
import tornado.escape
import tornado.options
import tornado.httputil
import jinja2
import pyjade.compiler
import coffeescript
import markdown
@cloudaice
cloudaice / readme.md
Last active December 17, 2015 11:49
update users file 2

Github Users

@cloudaice
cloudaice / location_map.json
Last active April 14, 2016 10:00
update file at utctime 2016-04-14 10:00:51.535982
{
"china,canton,guangzhou": "guangdong",
"shenzhen,guangdong,china": "guangdong",
"china,,\u82cf\u5dde": "jiangsu",
"peking,china": "beijing",
"pudong,district,,shanghai,,china": "shanghai",
"beijing,.china": "beijing",
"huadu,district,guangzhou,guangdong,china": "guangdong",
"beihang,university,,beijing,,china": "beijing",
"shanghai,china": "shanghai",