This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>React.js learn</title> | |
<style type="text/css"> | |
* { | |
margin: 0; | |
padding: 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import binascii | |
# Bin to string | |
def tostring(b): | |
b = int(b, 2) | |
return binascii.unhexlify('%x' % b) | |
# String to bin | |
def tobin(s): | |
return bin(int(binascii.hexlify(s), 16)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from utils import promo | |
@promo | |
def fidelity_promo(order): | |
"""5% discount for customers with 1000 or more fidelity points""" | |
return order.total() * .05 if order.customer.fidelity >= 1000 else 0 | |
@promo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# strategy_best.py | |
# Strategy pattern -- function-based implementation | |
# selecting best promotion from static list of functions | |
""" | |
>>> joe = Customer('John Doe', 0) | |
>>> ann = Customer('Ann Smith', 1100) | |
>>> cart = [LineItem('banana', 4, .5), | |
... LineItem('apple', 10, 1.5), | |
... LineItem('watermellon', 5, 5.0)] |
NewerOlder