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 __future__ import print_function | |
| from functools import wraps | |
| class Fish(object): | |
| def __new__(cls, *args, **kwargs): | |
| o = super(Fish, cls).__new__(cls, *args, **kwargs) | |
| o.foo_cache = {} | |
| o.type = 'goldfish' |
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
| """ | |
| FIND MOST COMMON ELEMENT IN LIST | |
| - what is "most common" | |
| - restrictions | |
| - list properties | |
| - tests? | |
| """ | |
| def solution(items): |
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 test_solution(): | |
| assert solution([]) == None | |
| assert solution([1]) == 1 | |
| assert solution([1, 2]) == None | |
| assert solution([1, 2, 3]) == None | |
| assert solution([1, 2, 1]) == 1 | |
| assert solution([1, 2, 1, 2]) == None | |
| if __name__ == "__main__": |
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 solution(items): | |
| if not items: | |
| return | |
| best = None | |
| best_count = 0 | |
| current_count = 0 | |
| last = items[0] | |
| for current in items: |
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 solution(items): | |
| if not items: | |
| return | |
| count = 0 | |
| best = None | |
| for n in items: | |
| if count == 0: | |
| best = n |
Public Request Resoponse Headers
HTTP/1.1 200 OK
Status: 200 OK
Server: GitHub.com
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
ps -ef
telnet
stats
stats slabs
stats items
stats cachedump SLAB_ID NUM_HOW_MANY
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 __future__ import print_function | |
| import inspect | |
| def fn(): | |
| return inspect.stack()[1][3] | |
| class Example(object): |
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
| """ | |
| For non inlplace dict setdefault. | |
| """ | |
| base_dict = {'a': 'a-ORIG', 'b': 'b-ORIG', 'd': 'd-ORIG'} | |
| defaults = {'a': 'A', 'b': None, 'c': 0} | |
| overrides = defaults | |
| # Update by override. Like: | |
| # - base_dict.update(overrides) -> new dict BUT `dict.update` is inplace | |
| # - base_dict + overrides -> new dict BUT unsupported operand |