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 hash_file(file, block_size=65536): | |
| hasher = hashlib.md5() | |
| for buf in iter(partial(file.read, block_size), b''): | |
| hasher.update(buf) | |
| return hasher.hexdigest() | |
| def upload_to(instance, filename): | |
| """ |
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
| """ | |
| MIT License | |
| Copyright (c) 2018 Mitchel Cabuloy | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is |
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
| """ | |
| MIT License | |
| Copyright (c) 2018 Mitchel Cabuloy | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is |
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 django.test import TestCase | |
| from django.conf import settings | |
| from django.contrib.sessions.middleware import SessionMiddleware | |
| from graphql_jwt.testcases import JSONWebTokenClient | |
| class MYJSONWebTokenClient(JSONWebTokenClient): | |
| def execute(self, query, variables=None, **extra): | |
| extra.update(self._credentials) | |
| context = self.post("/", **extra) |
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 time | |
| from functools import wraps | |
| def timeit(method): | |
| @wraps(method) | |
| def timed(*args, **kw): | |
| ts = time.time() | |
| result = method(*args, **kw) | |
| te = time.time() |
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
| https://press.one/p/v?s=91071199849ea0254aef566bcecdcf9686b0128162ae0dc2dcb4b4ddaabbe4d21068cbf83a6874a14c1e4416bd12b42a8c77a9d5e5725b39388883f3260c1f9b1&h=caf41557e46af6293b0f2d028200e32158b472a0255b2f4eb45884b29d31b9ba&a=4cf4d161036bf303e7fe92ff38b43eaab73f15e8&f=P1&v=3 |
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
| """ | |
| fun fib(n) = | |
| if n=1 then 1 | |
| else if n=2 then 1 | |
| else fib(n-1) + fib(n-2) | |
| """ | |
| def fib_loop(n): | |
| a = 1 | |
| b = 2 |
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
| # Execice for tail recurse | |
| # Reverse the integr, strip 0 | |
| # if 0 is the first num | |
| # | |
| # e.g: 123450 --> 54321 | |
| def reverse(n): | |
| s=list(str(n)) | |
| length = len(s) |
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
| curlftpfs ftp://192.168.0.105:3721 /tmp/phone |
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
| # duration: api 耗时,按秒计 | |
| # duration_ms: api 耗时,按毫秒计 | |
| # level: api 耗时档次,分为 | |
| # LEVEL-A: x < 1 sec | |
| # LEVEL-B: 1 sec < x < 5 sec | |
| # LEVEL-C: 5 sec < x < 10 sec | |
| # LEVEL-D: x > 10 sec | |
| # method: http 请求方法 | |
| # status_code: 请求响应状态 | |
| # user_agent: HTTP_USER_AGENT |
NewerOlder