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
| go_file: decl_package [imports] ([decl_type] [decl_func])* | |
| decl_package: "package" ident | |
| imports: "import" single_import | |
| | "import" multiple_imports | |
| single_import: ["("] ESCAPED_STRING [")"] | |
| multiple_imports: "(" ESCAPED_STRING+ ")" | |
| stmt: stmt_var | |
| | stmt_for | |
| | stmt_if |
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 socket | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.connect(("localhost", 50010)) | |
| msg_to_send = 'Hello world!' | |
| bytes_to_send = msg_to_send.encode('utf-8') | |
| print('Send to the server:', msg_to_send) | |
| s.send(bytes_to_send) |
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
| MAKE := make --no-print-directory | |
| DESCRIBE := $(shell git describe --match "v*" --always --tags) | |
| DESCRIBE_PARTS := $(subst -, ,$(DESCRIBE)) | |
| VERSION_TAG := $(word 1,$(DESCRIBE_PARTS)) | |
| COMMITS_SINCE_TAG := $(word 2,$(DESCRIBE_PARTS)) | |
| VERSION := $(subst v,,$(VERSION_TAG)) | |
| VERSION_PARTS := $(subst ., ,$(VERSION)) |
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
| select | |
| ProductID, | |
| sum(case | |
| when first_order_datetime is null then 0 | |
| else 1 | |
| end) | |
| from order_lines | |
| left join ( | |
| select | |
| min(Datetime) as first_order_datetime, |
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 functools import wraps | |
| def print_function_name(f): | |
| @wraps(f) | |
| def wrapper(*args, **kwargs): | |
| print('Call: {}'.format(f.__name__)) | |
| return f(*args, **kwargs) | |
| return wrapper | |
| @print_function_name |
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 datetime import datetime | |
| import functools | |
| def track_time(f): | |
| @functools.wraps(f) | |
| def wrapper(*args, **kwargs): | |
| start = datetime.now() | |
| result = f(*args, **kwargs) | |
| print('Run {}: {}'.format(f.__name__, datetime.now() - start)) | |
| return result |
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
| class Color: | |
| pass | |
| empty = Color() | |
| print(empty) | |
| #|<__main__.Color object at 0xf709fff0> |
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
| class Color: | |
| pass | |
| print(Color) | |
| #|<class '__main__.Color'> |
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
| class Color: | |
| def __init__(self, r, g, b): | |
| self.r = r | |
| self.g = g | |
| self.b = b | |
| def __add__(self, other): | |
| return Color( | |
| (self.r + other.r) // 2, | |
| (self.g + other.g) // 2, | |
| (self.b + other.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
| class Color: | |
| def __init__(color, r, g, b): | |
| color.r = r | |
| color.g = g | |
| color.b = b | |
| white = Color(255, 255, 255) | |
| print(white.r, white.g, white.b) | |
| #|255 255 255 |
NewerOlder