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 -*- | |
| from http import HTTPStatus | |
| from django.http import JsonResponse | |
| class JsonErrorMiddleware: | |
| def __init__(self, get_response): | |
| self.get_response = get_response |
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
| def _log(request, response): | |
| print(''' | |
| General | |
| Request URL: {} | |
| Request Method: {} | |
| Status Code: {} | |
| Remote Address: {} | |
| ------------------------------------ | |
| Request Headers | |
| Accept: {} |
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 python | |
| # -*- coding: utf-8 -*- | |
| # `pip install requests` | |
| from datetime import datetime, date | |
| from dateutil.rrule import rrule, DAILY | |
| from enum import Enum | |
| import json |
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
| /*************************************************** | |
| * | |
| * Linux Inter-process Communication Demo | |
| * | |
| ***************************************************/ | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <string.h> |
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 python | |
| # -*- coding: utf-8 -*- | |
| # @see https://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python | |
| from enum import Enum # for enum34, or the stdlib version | |
| # from aenum import Enum # for the aenum version | |
| Animal = Enum('Animal', 'ant bee cat dog') | |
| # Mapping from enum's value to itself |
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
| // Question 35 | |
| // Attempt 001 | |
| public class Solution { | |
| /* | |
| static class ListNode { | |
| int val; | |
| ListNode next; | |
| ListNode(int x) { |
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
| #include <iostream> | |
| #include <type_traits> | |
| #include <atomic> | |
| // Truncate larger integers into smaller ones | |
| template <typename TargetType, typename Integer, | |
| std::enable_if_t<std::conjunction_v<std::is_integral<Integer>, std::is_integral<TargetType>>, int> = 0> | |
| constexpr inline TargetType AutoTrunc(Integer value) | |
| { |
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 python | |
| # -*- coding: utf-8 -*- | |
| ''' | |
| Bulls and Cows | |
| ''' | |
| import random | |
| class Game: |
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 python | |
| # -*- coding: utf-8 -*- | |
| ''' | |
| Reference: | |
| - https://github.com/uupers/BiliSpider/wiki/ | |
| - https://github.com/Hansimov/bili-comment-analysis | |
| ''' |
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 python | |
| # -*- coding: utf-8 -*- | |
| import functools | |
| import inspect | |
| import os.path | |
| def checkcaller(caller: str = 'package'): | |
| # 限制函数作用域 |
OlderNewer