Skip to content

Instantly share code, notes, and snippets.

View harshvb7's full-sized avatar

Harsh harshvb7

  • Cologne, Germany
View GitHub Profile
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)
import math
l = input('Enter lowest no.')
h = input('Enter higest no.')
def check_prime(n):
if n < 2:
return False
<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 December 8, 2016 08:21
Google Layer with custom style for leaflet
/*
* L.TileLayer is used for standard xyz-numbered tile layers.
*/
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
import unittest
class TestExample(unittest.TestCase):
def test_hello_world(self):
self.assertEqual("hello world", "hello world")
def test_hello_world():
assert "hello_world" == "hello_world"
@harshvb7
harshvb7 / req
Created February 18, 2017 18:19
pytest
pytest-django
pytest-cov
from .settings import * # NOQA
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
}
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
@harshvb7
harshvb7 / ini
Created February 18, 2017 18:29
[pytest]
DJANGO_SETTINGS_MODULE=project.test_settings
addopts = --nomigrations --cov=. --cov-report=html
[run]
omit =
*apps.py,
*migrations/*,
*settings*,
*tests/*,
*urls.py,
*wsgi/*,
manage.py