Skip to content

Instantly share code, notes, and snippets.

🙃
wat

Ionel Cristian Mărieș ionelmc

🙃
wat
Block or report user

Report or block ionelmc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:acbf546e00bab661f0b599475807db45
>>> delta = datetime.timedelta(days=200)
>>> tz = pytz.timezone('Europe/Bucharest')
>>> datetime_dt = datetime.datetime(2019, 1, 1, tzinfo=tz)
>>> print('datetime.datetime(2019, 1, 1, tzinfo=tz):', datetime_dt.isoformat())
datetime.datetime(2019, 1, 1, tzinfo=tz): 2019-01-01T00:00:00+01:44
>>> datetime_dt = tz.localize(datetime.datetime(2019, 1, 1))
>>> print('tz.localize(datetime.datetime(2019, 1, 1)):', datetime_dt.isoformat())
tz.localize(datetime.datetime(2019, 1, 1)): 2019-01-01T00:00:00+02:00
>>>
>>> print('datetime + delta:', (datetime_dt + delta).isoformat())
@ionelmc
ionelmc / conftest.py
Last active May 21, 2018
A more sophisticated celery fixture (logs + tree term)
View conftest.py
from __future__ import print_function
import subprocess
import sys
import time
import psutil
import pytest
@ionelmc
ionelmc / conftest.py
Created May 21, 2018
pytest-django support for subprocesses
View conftest.py
@pytest.fixture(scope='session')
def django_db_setup(request,
django_test_environment,
django_db_blocker,
django_db_use_migrations,
django_db_keepdb,
django_db_modify_db_settings):
import pytest_django.compat
def teardown_databases(db_cfg, verbosity, _teardown_databases=pytest_django.compat.teardown_databases):
View gist:58db6ad253e36e1e3a7f1983d78baf2b
{
"chrome": {
"default": "60.0",
"versions": {
"60.0": {
"image": "selenoid/chrome:60.0",
"port": "4444",
"path": "/"
}
}
View debugger.py
"""
Make sure you have a `socat readline unix-listen:/tmp/debugger` or `socat - unix-listen:/tmp/debugger` running in
a termial before using set_trace.
"""
def set_trace():
from pdb import Pdb
import os
import socket
@ionelmc
ionelmc / .gitignore
Last active Jun 16, 2019
Socat PPA (readline)
View aspectlib-perm-example.rst
Python 3.5.1 (default, Dec 18 2015, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
    def delete(self, *, stuff_id, user):
        user.objects.remove(stuff_id)
    def change(self, *, stuff_id, params, user):
        pass
View test_attr_checking.py
import pytest
class A(object):
def __init__(self, **kw):
for k, v in kw.items():
setattr(self, k, v)
class B(object):
@ionelmc
ionelmc / .gitignore
Last active Mar 17, 2019
A JSON parser benchmark. See README.rst for instructions.
View .gitignore
*.cbor
*.log
*.xml
*.yaml
*.json
*.msgpack
*.html
*.marshal
*.pickle
.tox
View gist:8b88543e31f0a57fe3cb
__new__(<class 'file'>, '.coveragerc') <<< aspectlib/__init__.py:255:advising_function_wrapper < aspectlib/debug.py:177:__call__ < 2.7/ConfigParser.py:302:read < coverage/config.py:27:read < coverage/config.py:214:from_file < coverage/control.py:133:__init__ < pytest_cov/embed.py:58:init < <string>:4:<module> < <string>:1:<module> < <string>:167:addpackage
__new__ => <closed file ?, mode '<uninitialized file>' at 0x00007f0a64e70720>
{__builtin__.file}.__init__('.coveragerc') <<< aspectlib/__init__.py:255:advising_function_wrapper < aspectlib/debug.py:177:__call__ < 2.7/ConfigParser.py:302:read < coverage/config.py:27:read < coverage/config.py:214:from_file < coverage/control.py:133:__init__ < pytest_cov/embed.py:58:init < <string>:4:<module> < <string>:1:<module> < <string>:167:addpackage
{__builtin__.file}.__init__ => None
{__builtin__.file}.readline() <<< aspectlib/__init__.py:255:advising_function_wrapper < aspectlib/debug.py:177:__c
You can’t perform that action at this time.