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 common | |
import ( | |
"bytes" | |
"encoding/json" | |
"encoding/xml" | |
"io" | |
"net/http" | |
gourl "net/url" | |
"strings" |
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
@app.task | |
def send_email(*args, **kwargs): | |
time.sleep(1000000) | |
return send_mail(*args, **kwargs) | |
class SendEmail: | |
def __call__(self, *args, **kwargs): | |
return self.run(*args, **kwargs) |
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 .multi_action_view import BaseAction | |
# Sample action | |
class CheckDateView(BaseAction): | |
def print_date(self, *args, **kwargs): | |
r = Response(data={'current_date': datetime.now()}, status=200) | |
return r |
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 django.db import models | |
class MentionModel(models.Model): | |
text_field_name = "text" | |
mention_handler = "handle_mention" | |
class Meta: | |
abstract = True |
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 sqlalchemy.orm import Session | |
class Manager: | |
def __init__(self, Model, database: Session): | |
self.db = database | |
self.Model = Model | |
self._query = {} # Instantiate a query, update it on get/filter call | |
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 pytest | |
@pytest.fixture | |
def password(): | |
return 'my-password-is-stronger-than-yours' | |
@pytest.fixture | |
def create_user(db, django_user_model, password): | |
def _user(**kwargs): |
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 celery.utils.log import get_logger | |
from django.conf import settings | |
logger = get_logger(__name__) | |
class TaskRunner: | |
def __init__(self, func_code, func, args=[], kwargs={}, task_kwargs={}): | |
self.func_code = func_code # This could be used to save to db | |
self.func = func |
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
class MultiModel: | |
test_scores = {} | |
train_scores = {} | |
models = {} | |
def __init__(self, n_models, typeof): | |
self.n_models = n_models | |
self.typeof = typeof | |
def load(self, X_train, X_test, y_train, y_test): |