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 ._anvil_designer import Form1Template | |
from anvil import * | |
import anvil.tables as tables | |
import anvil.tables.query as q | |
from anvil.tables import app_tables | |
import plotly.graph_objects as go | |
txt_list = [] | |
class Form1(Form1Template): |
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 hamcrest import * | |
native = { | |
'runtime': { | |
'err': {'data validation': anything(), 'evaluation': anything()}, | |
}, | |
'schema': { | |
'sheet_names': {'err': {'missing': ['Loans']}}, | |
}, |
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
# palyginimui su https://www.facebook.com/photo.php?fbid=10158413583218323&set=p.10158413583218323&type=3 | |
def varza(grandine): | |
R = 0 | |
for varzu_eil in grandine: | |
atvirkstiniu_suma = sum(1/x for x in varzu_eil) | |
R += 1 / atvirkstiniu_suma | |
return R |
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_call(func): | |
"""generic decorator""" | |
import functools | |
import inspect | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
try: | |
args_repr = list(map(repr, args)) + [f"{key}={repr(val)}" for key, val in kwargs.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
class SupervisedCallable: | |
""" | |
calls function and logs: `args`, `kwargs`, `result` | |
can add `side_effect` - idea is similar to the one in Mock: | |
has more options: mapping/list/callable/value | |
`NO_SIDE_EFFECT` sentinel -- fallback to original `fun` -- so can "mix" side_effect with fallback | |
>>> mock_randint = SupervisedCallable(randint, side_effect=[0, 13, ZeroDivisionError, SupervisedCallable.NO_SIDE_EFFECT, 2]) | |
>>> for x in range(6): |
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
; nice formatting of https://www.vertica.com/blog/vertica-quick-tip-splitting-string-rows/ | |
=> SELECT * FROM test; | |
id | c2 | |
----+------- | |
1 | A|B|C | |
2 | D|E|F | |
(2 rows) | |
;;;;; |
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
#%% | |
data = ... | |
#%% | |
import numpy | |
import scipy | |
values = [] | |
for rand_state in range(1000): | |
mask = numpy.random.rand(len(data)) < 0.5 |
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
# based on found https://repl.it/repls/EnlightenedWetFacts | |
import reprlib | |
import traceback, sys | |
traceback.repr = reprlib.repr # make traceback use the reprlib repr because it dumps locals, including the ENTIRETY of __builtins__, which can get a little annoying. | |
i = 0 | |
def foo(): |
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
"""adapters/extensions to caldav lib for incremental (old-fashioned) sync https://github.com/python-caldav/caldav/issues/69 | |
does monkey-patching on import!! | |
mostly by guide http://sabre.io/dav/building-a-caldav-client/ | |
""" | |
from caldav.objects import * | |
from caldav.objects import _fix_tz | |
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 InjectUrlDataMixin: | |
"""Used for POST on nested router (so it can take infromation from URL instead of repeting in serializer). | |
overrides `get_serializer` | |
(ps.: does not make sense for PUT/PATCH -- as the instance is selected by url-kwargs) | |
""" | |
def get_serializer(self, *args, **kwargs): | |
# standart `get_serializer` logic | |
serializer_class = self.get_serializer_class() | |
kwargs['context'] = self.get_serializer_context() |
NewerOlder