This file contains 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 | |
""" | |
Very simple HTTP server in python for logging requests | |
Usage:: | |
./server.py [<port>] | |
""" | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
import logging | |
class S(BaseHTTPRequestHandler): |
This file contains 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 | |
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE | |
# Written by Nathan Hamiel (2010) | |
# Adapted to Python 3 by Ilya "I159" Pekenly (2019) | |
import json | |
import pprint | |
from http import server | |
from optparse import OptionParser |
This file contains 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 _get_shard_iterator(self, shard, stream_arn): | |
return self.client.get_shard_iterator( | |
StreamArn=stream_arn, | |
ShardId=shard["ShardId"], | |
ShardIteratorType="TRIM_HORIZON", | |
) | |
def _process_signals(self, shards, remaining_items, termination_moment): | |
for shard_iterator in shards: | |
while remaining_items and dt.datetime.utcnow() <= termination_moment: |
This file contains 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
"""Infrastructure level of the application. | |
No logic is implemented here, only data retrieved from requests | |
passed to a controllers level. This module is not for testing, | |
a framework is trusted since it is ouf of our responsibility. | |
""" | |
from my_application.controllers_level import implemented_use_cases | |
import chalice |
This file contains 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 abc | |
# Entities level | |
class Entity(metaclass=abc.ABCMeta): | |
@abc.abstractmethod | |
def _lower_level_meth(self): | |
raise NotImplementedError | |
@property | |
def entity_prop(self): |
This file contains 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
#Framework Code: | |
class TokenInterface(): | |
def getUserFromToken(self, token): | |
raise NotImplementedError | |
class FrameworkClass(TokenInterface): | |
def do_the_job(self, ...): | |
# some stuff | |
self.user = super().getUserFromToken(...) |
This file contains 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
# Framework internal | |
def MetaIoC(name, bases, namespace): | |
cls = type("IoC{}".format(name), tuple(), namespace) | |
return type(name, bases + (cls,), {}) | |
# Entities level | |
class Entity: | |
def _lower_level_meth(self): | |
raise NotImplementedError |
This file contains 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, timedelta | |
from time import sleep | |
class Delay: | |
def __init__(self, secs): | |
self._secs = secs | |
self.when = datetime.now() + timedelta(seconds=secs) | |
def __await__(self): |
This file contains 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
typedef struct _frame { | |
PyObject_VAR_HEAD | |
struct _frame *f_back; /* previous frame, or NULL */ | |
PyCodeObject *f_code; /* code segment */ | |
PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ | |
PyObject *f_globals; /* global symbol table (PyDictObject) */ | |
PyObject *f_locals; /* local symbol table (any mapping) */ | |
PyObject **f_valuestack; /* points after the last local */ | |
/* Next free slot in f_valuestack. Frame creation sets to f_valuestack. | |
Frame evaluation usually NULLs it, but a frame that yields sets it |
This file contains 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" | |
) | |
var IDENTITY = [2][2]int64{{1, 0}, {0, 1}} | |
var DEFAULT = [2][2]int64{{1, 1}, {1, 0}} | |
func dotProduct(a, b [2][2]int64) (res [2][2]int64) { |
NewerOlder