Skip to content

Instantly share code, notes, and snippets.

View muxuezi's full-sized avatar
⛹️‍♂️
basketball

Todd Tao muxuezi

⛹️‍♂️
basketball
View GitHub Profile
@muxuezi
muxuezi / sudoku9.prolog
Last active August 29, 2015 14:01
7Weeks7languages--prolog
%-- Thanks Ben Nadel for his blog http://www.bennadel.com/blog/2074-seven-languages-in-seven-weeks-prolog-day-3.htm
%-- I am the 9x9 solution.
%-- Empty boards are valid.
valid( [] ).
%-- The sets are valid if each set contains unique values.
valid([Head|Tail]) :-
fd_all_different(Head),
valid(Tail).
@muxuezi
muxuezi / cleanpyc.py
Created May 23, 2014 02:06
clean pyc files
"""
delete all .pyc bytecode files in a directory tree: use the
command line arg as root if given, else current working dir
"""
import os, sys
rootdir = os.getcwd() if len(sys.argv) < 2 else sys.argv[1]
findonly = False if len(sys.argv) < 3 else int(sys.argv[2])
found = removed = 0
@muxuezi
muxuezi / C_right_left_rule.c
Created May 26, 2014 07:48
The "right-left" rule is a completely regular rule for deciphering C declarations. It can also be useful in creating them.
/*The "right-left" rule is a completely regular rule for deciphering C
declarations. It can also be useful in creating them.
First, symbols. Read
* as "pointer to" - always on the left side
[] as "array of" - always on the right side
() as "function returning" - always on the right side
as you encounter them in the declaration.
@muxuezi
muxuezi / alldoulist.py
Created May 26, 2014 09:08
doulist with thread and queue
# -*- coding: utf-8 -*-
import urllib2
import thread
import Queue
import time
from bs4 import BeautifulSoup
def findlen(item):
url = 'http://dongxi.douban.com/doulists/%s/?start=0' % (item)
@muxuezi
muxuezi / makeSwiftSoup.py
Last active October 30, 2016 04:13
Web crawler of Swift iOS&OSX
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------
# Name: The-Swift-Programming-Language
# Purpose: Web crawler of Swift, Python is slow-------
#
# Author: muxuezi@gmail.com
#
# Created: 10/27/2014
# Copyright: (c) muxuezi 2014
# Licence: <All licence>
import asyncio
import aiohttp
import bs4
import tqdm
@asyncio.coroutine
def get(*args, **kwargs):
response = yield from aiohttp.request('GET', *args, **kwargs)
return (yield from response.read_and_close(decode=True))
@muxuezi
muxuezi / duokanbook.py
Last active August 29, 2015 14:06
crawl [duokan](http://www.duokan.com/list/1-1) books index by aiohttp
import asyncio
import aiohttp
import bs4
import tqdm
import re
allBook = [] #init allbook index
@asyncio.coroutine
# coding: utf-8
import logging
import threading
from queue import Queue
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(message)s')
ch = logging.StreamHandler()
@muxuezi
muxuezi / PythonLogo.ipynb
Created May 13, 2017 09:31 — forked from jakevdp/PythonLogo.ipynb
Creating the Python Logo in Matplotlib
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple