Skip to content

Instantly share code, notes, and snippets.

@a3dho3yn
a3dho3yn / abstract_model_test_case.py
Last active March 26, 2024 12:17
Utility class to test Django abstract/mixin models
from django.db import connection
from django.db.models.base import ModelBase
from django.test import TestCase
class AbstractModelTestCase(TestCase):
"""Utility class to test abstract/mixin models
Abstract models doesn't allow you to make instances and Django will not create tables for them.
This utility class creates a temporary subclass for the abstract models, and creates the table for it.
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
class TestCase extends BaseTestCase
{
use CreatesApplication;
protected $headers = ['accept' => 'application/json'];
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
class TestCase extends BaseTestCase
{
use CreatesApplication;
protected $headers = ['accept' => 'application/json'];
<?php
namespace Tests\Feature;
use Tests\TestCase;
class DataProviderTest extends TestCase
{
/**
* @dataProvider additionProvider
@a3dho3yn
a3dho3yn / 0_README.md
Last active August 5, 2019 21:11
How to use PHPUnit's @dataProvider in extended TestCase

PHPUnit @dataProvider simply doesn't work!

If you are using subclasses of PHPUnit's TestCase, you should call parent::__construct in order to benefit @dataProviders. But the tricky part is that TestCase::_construct receives some arguments. So, you should define them in your inherited class and pass them to the parent::__construct.

read more

@a3dho3yn
a3dho3yn / persian-nlp.md
Last active September 14, 2020 11:00
نمایه ابزارهای پردازش زبان فارسی
  • پیکره‌گان: انواع پیکره‌ها (داده‌های متنی و غیرمتنی زبانی) را به عنوان مجموعۀ داده‌های زبانی می‌شناسیم. پایگاه پیکره‌گان با هدف ایجاد شرایط مناسب برای اشتراک‌گذاری مجموعه داده‌های زبانی و دسترسی آسان پژوهشگران به این مجموعه داده‌ها ایجاد شده است.

  • متن‌کاوی: مجموعه کم نظیر از سرویس‌ها، ابزارها و خدمات سفارشی متن‌ کاوی برای پژوهشگران و سازمان‌ها

  • فارس‌نت:

@a3dho3yn
a3dho3yn / main.cs
Last active July 17, 2018 06:51
ServiceStack.Text Deserializer Issue
using System;
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
using System.Collections.Generic;
public class Request
{
public bool? IsOk {get; set;}
}
@a3dho3yn
a3dho3yn / mongodb_c#_cheatsheet.md
Last active December 9, 2024 06:58
MongoDB C# Driver Cheat Sheet

MongoDB C# Driver Cheat Sheet

(C) 2015 by Derek Hunziker, (C) 2017 by AppsOn

As of releasing MongoDB 3.4 and C# Driver v2.4, original cheatsheet by Derek is outdated. In addition, it has some deficiencies like connecting to MongoDB, creating indexes, etc. This updated version works fine with C# Driver v2.4.7 and MongoDB v3.4.

Setup

Define Document Models

Note: Defined models and collections will be used in entire cheatsheet.