Skip to content

Instantly share code, notes, and snippets.

View imomaliev's full-sized avatar
🐼

Sardorbek Imomaliev imomaliev

🐼
View GitHub Profile
@imomaliev
imomaliev / fields.py
Last active January 12, 2024 14:13 — forked from jpadilla/fields.py
CharacterSeparatedManyField - A Django REST framework field that separates a string with a given separator into a native list and reverts a list into a string separated with a given separator.
from rest_framework import serializers
from rest_framework.fields import empty
from rest_framework.utils import html
class CharacterSeparatedField(serializers.ListField):
"""
Character separated ListField.
Based on https://gist.github.com/jpadilla/8792723.
"""
Calculate second lowest cost silver plan (SLCSP) and produce result.csv.
"""
import csv
from collections import defaultdict
def get_slcsp_zipcodes():
"""Get all zipcodes for slcsp research."""
@imomaliev
imomaliev / social_auth_credentials.py
Last active July 18, 2021 17:52
google-api-python-client Credentails using social-auth
# github.com/python-social-auth/social-core/issues/125
from datetime import datetime
from requests import exceptions as requests_errors
from google.auth.exceptions import RefreshError
from google.oauth2.credentials import Credentials as GoogleCredentials
from googleapiclient import discovery
@imomaliev
imomaliev / django_multiforms_view.py
Last active May 28, 2018 04:19
Django multiple forms CBV
# coding: utf-8
from __future__ import unicode_literals, absolute_import
from django.http.response import HttpResponseForbidden, HttpResponseRedirect
from django.views.generic.base import TemplateResponseMixin, ContextMixin
from django.views.generic.edit import ProcessFormView
class MultiFormMixin(ContextMixin):
@imomaliev
imomaliev / PyCharm CE python console.py
Last active August 29, 2015 14:13
Pycharm python console, for ipython with preloaded models
import os
import sys
import django
print('Django %s' % django.get_version())
sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])
sys.path.extend(['/Applications/PyCharm CE.app/Contents/helpers'])
sys.path.extend(['/Applications/PyCharm CE.app/Contents/helpers/pycharm'])
if 'setup' in dir(django): django.setup()
PROJECT_ROOT = WORKING_DIR_AND_PYTHON_PATHS
import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)