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
| package main | |
| import ( | |
| "bytes" | |
| "flag" | |
| "fmt" | |
| "net" | |
| "sync" | |
| ) |
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
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| func main() { | |
| fmt.Println("start...", time.Now()) | |
| timeout := time.After(1 * time.Second) |
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
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| func main() { | |
| fmt.Println("start...", time.Now()) | |
| timeout := make(chan bool, 1) // 超时信号传输通道 |
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
| # -*- coding: utf-8 -*- | |
| class GildedRose(object): | |
| def __init__(self, items): | |
| self.items = items | |
| def update_quality(self): | |
| for item in self.items: | |
| refresher_factory(item).refresh() |
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
| #!/usr/bin/env python3 | |
| from collections import MutableSet | |
| from weakref import proxy | |
| class Node(object): | |
| __slots__ = ["prev", "next", "key", "__weakref__"] | |
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
| # Use an official Python runtime as a parent image | |
| # 使用官方的Python环境做为父镜像(parent) | |
| FROM python:2.7-slim | |
| # Set the working directory to /app | |
| # 设置容器内的当前工作目录为 /app | |
| WORKDIR /app | |
| # Copy the current directory contents into the container at /app | |
| # 复制当前文件夹内容到容器的 /app 目录下 |
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
| #!/usr/bin/env python3 | |
| # Problem No.1 | |
| def get_pairs_helper(alist, total): | |
| """获取列表中和为total的一组元素""" | |
| if not (alist and isinstance(alist, (list, tuple))): | |
| return | |
| alist.sort() | |
| prev, next_ = 0, len(alist) - 1 |
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
| #!/usr/bin/env python3 | |
| class SparseMatrix(object): | |
| """二维稀疏矩阵""" | |
| def __init__(self, row, col): | |
| self.m = row - 1 | |
| self.n = col - 1 | |
| self.seq = [] | |
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
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| from datetime import datetime | |
| from elasticsearch_dsl import ( | |
| DocType, Date, Nested, Boolean, | |
| analyzer, token_filter, InnerObjectWrapper, Keyword, Text, String | |
| ) | |
| # 中文分词器 |
NewerOlder