Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ include

# .pyc files
*.pyc

# Buffered files
*~

# Database
db.sqlite3

# Environment files
.env
51 changes: 45 additions & 6 deletions Code-ologists/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,48 @@
PyDSA Visualization Examples

**Team**: Code-ologists
<br>
**Team Members**: Kanika Murarka ( _@kanikaa1234 )
Anika Murarka (_@anikamurarka )
<br>
**Algorithm Implemented**: Bubble Sort


**Team Members**: Kanika Murarka [kanikaa1234](https://github.com/kanikaa1234)
Anika Murarka [anikamurarka](https://github.com/anikamurarka)

**Set up environment**

Create and activate virtual environment.
```bash
$ pip install -r requirements.txt
```

**Set-up environment variables**
After activating your virtual environment export the following variables:

```bash
export SECRET_KEY="alskj2mn34m@$%asd#45ASD"
export DATABASE_URL="sqlite:///db.sqlite3"
export DEBUG=True
```


**Algorithm Implemented**:

1. Bubble Sort implementation using `python` and `matplotlib`

```bash
$ cd Code-ologists
$ python bubble_sort.py
```

2. Visualization of Bubble Sort as a web app using `Django` and `JavaScript`

```bash
$ cd Code-ologists
$ ./startserver.sh
```

The server is up and running at [localhost:8000](http://0.0.0.0:8000)

Some features :-
+ Whenever you RELOAD the page, you will see distinct colors.
+ Every iteration is played as an animation.
+ Hover on the bars to see the number that is sorted.
+ You can make different sorting objects and visualize Bubble Sort on it.

Binary file modified Code-ologists/bubble_sort.py
Binary file not shown.
10 changes: 10 additions & 0 deletions Code-ologists/pydsa/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pydsa.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
Empty file.
115 changes: 115 additions & 0 deletions Code-ologists/pydsa/pydsa/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"""
Django settings for pydsa project.

Generated by 'django-admin startproject' using Django 1.8.2.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import environ


root = environ.Path(__file__) - 3 # three folder back (/a/b/c/ - 3 = /)
env = environ.Env(DEBUG=(bool, False),) # set default values and casting
environ.Env.read_env() # reading .env file

SITE_ROOT = root()
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env('DEBUG') # False if not in os.environ

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'sort',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'pydsa.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'pydsa.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
'default': env.db(),
'extra': env.db('SQLITE_URL', default='sqlite:////tmp/my-tmp-sqlite.db')
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'sort/static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'staticfiles'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
23 changes: 23 additions & 0 deletions Code-ologists/pydsa/pydsa/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""pydsa URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('sort.urls')),
]
16 changes: 16 additions & 0 deletions Code-ologists/pydsa/pydsa/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for pydsa project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pydsa.settings")

application = get_wsgi_application()
Empty file.
11 changes: 11 additions & 0 deletions Code-ologists/pydsa/sort/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib import admin
from sort.models import Sorting


# Register your models here.
class SortAdmin(admin.ModelAdmin):
fields = ['Name', 'List']
list_display = ('Name', 'List')


admin.site.register(Sorting, SortAdmin)
24 changes: 24 additions & 0 deletions Code-ologists/pydsa/sort/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-04-14 11:13
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Sorting',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('Name', models.CharField(max_length=50)),
('List', models.CharField(max_length=50)),
],
),
]
Empty file.
11 changes: 11 additions & 0 deletions Code-ologists/pydsa/sort/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.db import models

# Create your models here.


class Sorting(models.Model):
Name = models.CharField(max_length=50)
List = models.CharField(max_length=50)

def __str__(self):
return self.Name
Loading