Skip to content

Instantly share code, notes, and snippets.

View chaobin's full-sized avatar

Chaobin Tang (唐超斌) chaobin

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# -*- coding: utf-8 -*-
#!usr/bin/env python
# Excersise 5.7
"""
Let A be an array of size n ≥ 2 containing integers from 1 to n − 1, inclu- sive, with exactly one repeated. Describe a fast algorithm for finding the integer in A that is repeated.
"""
import random
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python
import time
def coroutine():
try:
print "Executing"
seconds = (yield)
time.sleep(seconds)
class NamedAndCachedAttributeType(type):
'''
In cases, where getting an attribute will
expose to the client code the detail of
the very attribute name, which could be changeable
over time.
This NamedAndCachedAttributeType is intended to
hide this detail by mapping the public attribute name
to the real name that is maintained internally by the class itself.
By doing so, the content provider(this class) and the client
#!/usr/bin/env python
def remove_a(values):
for value in values:
new_value = value.replace('a', '')
print 'remove a'
yield new_value
def remove_b(values):
for value in values:
#!/usr/bin/env python
# Added by <ctang@redhat.com>
import sys
import os
from multiprocessing import connection
ADDR = ('', 9997)
AUTH_KEY = '12345'