Skip to content

Instantly share code, notes, and snippets.

View comalex's full-sized avatar

Oleksii Stupak comalex

View GitHub Profile
<!-- Nmodes start -->
<script data-wpfc-render="true" defer src="https://bot1.nmodes.com/v1/widget?api_key=7YJEE6nrZbDRolKBvTwi4pF4"></script>
<!-- Nmodes end -->
@comalex
comalex / Dockerfile
Last active August 17, 2017 22:13
Set up MS SQL 2005 on MAC with virtual box and docker
FROM lbosqmsft/mssql-python-pyodbc
RUN apt-get install -y freetds-dev
RUN apt-get install -y tdsodbc
EXPOSE 80
ADD . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
@comalex
comalex / google_ping.py
Last active August 9, 2017 14:34
Ping google use all available ips on the current machine
"""
Eсть сервер с несколькими айпи на линукс. у сервера 4 айпи. надо написать скрипт на питон 3,
который устанавливает в 4х потоках (каждый поток использует отдельный айпи), соединение с гугл.ком
"""
"""
pip3 install -r requirements.txt
"""
import logging
@comalex
comalex / mock.md
Last active February 12, 2020 07:41
Mock python cheatsheet

Python unittest.mock Cheat Sheet

Basic usage

mock.Mock()
mock.MagicMock()

Asserts

assert_called_with: This method asserts that the last call was made with the given parameters

@comalex
comalex / PythonUnitTestCheatSheet.md
Last active July 16, 2017 14:03 — forked from mogproject/PythonUnitTestCheatSheet.md
Python unittest Cheat Sheet

Python unittest Cheat Sheet

Skeleton

@comalex
comalex / aiohttp_devtools_error.py
Created June 29, 2017 18:11
aiohttp_devtools error traceback
>>> manage.py
from aiohttp_devtools.cli import cli
cli()
>>>
Error:
python3.6 manage.py runserver
[21:01:48] pre-check enabled, checking app factory
[21:01:48] Starting dev server at http://localhost:8000 ●
@comalex
comalex / models.py
Created October 8, 2016 13:30
Django user
class CustomUserManager(BaseUserManager):
def _create_user(self, email, password,
is_staff, is_superuser, **extra_fields):
"""
Creates and saves a User with the given email and password.
"""
now = timezone.now()
if not email:
raise ValueError('The given email must be set')