The syntax bellow match any route beginning with / api /
and followed by any word and a iso format date, like /api/category/1999-01-01/
location ^~ /api/(\w+)/(\d{4}-\d{2}-\d{2})/$ {
# Settings to Python CGI file
}
# 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)] |
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 |
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)) |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>React.js learn</title> | |
<style type="text/css"> | |
* { | |
margin: 0; | |
padding: 0; | |
} |
""" | |
13. wordcount | |
Este desafio é um programa que conta palavras de um arquivo qualquer de duas | |
formas diferentes. | |
A. Lista todas as palavras por ordem alfabética indicando suas ocorrências. | |
Ou seja... |
import time | |
import random | |
from concurrent.futures import ThreadPoolExecutor | |
import timeit | |
def fn(n): | |
print(n) | |
from threading import Thread, Event | |
from itertools import cycle | |
class Loading: | |
""" | |
Shows an animated loading message on screen while some long process is processing. | |
Args: | |
message(str): message |
import socket | |
from queue import Queue, Empty | |
from random import randint | |
from threading import Event, get_ident, Thread | |
class QueuedThreadProcess(Thread): | |
def __init__(self, queue, stop_event): | |
super().__init__() | |
self._queue = queue |