Skip to content

Instantly share code, notes, and snippets.

Avatar

Harsh harshvb7

  • Cologne, Germany
View GitHub Profile
View gist:5746881951e0dce5fb18
class Category(models.Model):
name = models.CharField(max_length=200, default='')
slug = models.SlugField(max_length=100,default='',unique=True)
def __unicode__(self):
return self.name
class SubCategory(models.Model):
category = models.ForeignKey(Category)
View smallest_twins.py
import math
l = input('Enter lowest no.')
h = input('Enter higest no.')
def check_prime(n):
if n < 2:
return False
View get_company_list.html
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<script>
var company_field = jQuery('#acf-field-company_name');
var is_admin = jQuery('#post_author_override')[0];
if(is_admin != undefined){
company_field.select2({
@harshvb7
harshvb7 / leaflet.google.js
Created Dec 8, 2016
Google Layer with custom style for leaflet
View leaflet.google.js
/*
* L.TileLayer is used for standard xyz-numbered tile layers.
*/
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
View unittest sample
import unittest
class TestExample(unittest.TestCase):
def test_hello_world(self):
self.assertEqual("hello world", "hello world")
View req
pytest
pytest-django
pytest-cov
View gist:ae0219dc42e90693f8b786ecf1afb74a
from .settings import * # NOQA
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
}
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
View ini
[pytest]
DJANGO_SETTINGS_MODULE=project.test_settings
addopts = --nomigrations --cov=. --cov-report=html
View .coveragerc
[run]
omit =
*apps.py,
*migrations/*,
*settings*,
*tests/*,
*urls.py,
*wsgi/*,
manage.py