Now what?

So after 2.5 years of dedicating most of my free time to school and family, I now have time to look at what projects I’d like to explore.  Here’s my current list in no specific order:

  1. Create a ZoneMinder video alarm system for outside my home
    • Motion detection
    • Email alerts
  2. Create an Android tablet dashboard to show
    • Emails
    • Texts
    • Weather
    • Calendar alerts
    • News headlines
  3. Angular 2
  4. React
  5. Create an Android app to block calls
    • Not in my zip code &&
    • Not in my address book &&
    • Not in my outgoing call list &&
    • Not in my outgoing text list
  6. Work on my recipe collection to eventually publish a cook book
  7. Setup an educational instance of Linux for my 8 year old

Setting up a Django project with an ORM connected to an existing MySql instance

1.  Install Python:

I had to add the following to my %PATH% variable


2.  Install Django:  pip should have been installed with python so type

pip install Django==1.7.7

**Django comes with it’s own light-weight web-server, so there is no need to install one for development.

I’m going to follow for the following steps.

3. Create the project:  Run the following command in the directory you wish to use for development.  It will create the project.

$ startproject CourseOptimizer

4.  Install the C++ .0 python compiler at:

5.  Add the MySql libraries

pip install MySql-Python (I spent about an hour before I found out it's very difficult to get it to work on windows)

pip install PyMySQL

To use it, you must go to the django directory, exactly in this directory
and do a search and replace of MySQLdb with pymysql
in the two files "" and  "

6.  Connect to database:  In the file, change the DATABASES variable to:

 'default': {
 'ENGINE': 'django.db.backends.mysql',
 'USER': 'XXXX',
 'HOST': '',
 'PORT': '3306',

7. Scaffold the database schema for a Django site:

$ python migrate

8. Verify it runs:

$ python runserver

Go to

9. Create your first Models:

$ python startapp CourseCatalog

10. Map the legacy database to the of the CourseCatalog app:

$ python inspectdb > coursecatalog/

11. Open a python shell and verify the data has been mapped:

$ python shell
>>> from CourseCatalog.models import Course, Specialization, SpecializationCourse   # Import the model classes we just wrote.

# No questions are in the system yet.
>>> Course.objects.first().coursename
It should return the first row in the database's coursename

12. Create a view:

In the CourseCatalog/ file add the following and save:

from django.shortcuts import render
from django.http import HttpResponse

from CourseCatalog.models import Course

def index(request):
 course_list = Course.objects.all()[:5]
 output = ', '.join([p.coursename for p in course_list])
 return HttpResponse(output)

13. Map the view to a route

Create a file CourseCatalog/ file add the following and save:
from django.conf.urls import patterns, url

from CourseCatalog import views

urlpatterns = patterns('',
 url(r'^$', views.index, name='index'),
In the CourseOptimizer/ file add the following and save:
 url(r'^coursecatalog/', include('CourseCatalog.urls')),

14. Create a template directory and index.html template

The template structure is /App/templates/App/index.html, so in this instance, create /CourseCatalog/templates/CourseCatalog/index.html and add the following:
{% if course_list %}
 {% for course in course_list %}
 <li>{{ course.coursename }}</li>
 {% endfor %}
{% else %}
 <p>No courses are available.</p>
{% endif %}

15. Run the server and verify you get a list of courses

The template structure is /App/templates/App/index.html, so in this instance, create /CourseCatalog/templates/CourseCatalog/index.html and add the following:
$ python runserver
Browse to and see the courses

A simple static page web server using node js


I’m building a SPA using AngularJS, and Chrome doesn’t allow Angular to load the html partials because of cross origin request errors.  Firefox works, but I just prefer to develop using Chrome, so I needed to host the SPA somewhere.  IIS seemed like overkill, so I turned to Node which turned out to be very simple.

  1. Assuming you have node and NPM installed, install connect and serve-static with NPM
    $ npm install connect serve-static
  2. Create a server.js and place it in the same directory as the entry point of your SPA
    var connect = require('connect'); 
    var serveStatic = require('serve-static');
  3. Start the web server
    $ node server.js
  4. Browse to your SPA entry page:


That’s it!  I really love some things about Node, and the simplicity of setting up a web server is one of those things.

How to add polygon search capabilities to Apache SOLR


This is another post to document for myself how to add polygon search capabilities to solr since I do it very seldomly.


  1. >wget
  2. >sudo unzip -d jts-1.13
  3. >sudo cp lib/* /var/lib/tomcat6/webapps/solr/WEB-INF/lib
  4. Add the following field type to your solr schema:
    <fieldType name=”location_rpt” class=”solr.SpatialRecursivePrefixTreeFieldType”
  5. Add a field of type “location_rpt” to index the lat/lng data:
    <field name=”geo” type=”location_rpt” indexed=”true” stored=”true” multiValued=”true” />
  6. Restart Solr
  7. Index the data in solr
  8. Query to ensure you have the ability to search a polygon:*%3A*&fq=Geo:%22Intersects(POLYGON((-84.113824%2034.085196,-84.003009%2034.146633,-83.856827%2034.032769,-84.188127%2033.993178,-84.113824%2034.085196)))%22+&wt=json&indent=true

How to increase solr jvm heap memory


I’m really only documenting this for myself, so I know where to look when I need to do this again in 6 months, but maybe it will help someone else as well.

I was getting an exception:

java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap space

After digging around on StackOverflow for a while, I found several methods of increasing the default memory allocation of 128m.

The one that worked for me was changing the JAVA_OPTS value in the script and restarting tomcat.

Step 1.  Locate

> ps aux | grep catalina

Look for the catalina.home.  In my case it was "/usr/share/tomcat6". will be located in the bin subdirectory.

Step 2:  Edit the following lines to set the JVM heap size:

if [ -z "$LOGGING_MANAGER" ]; then
   JAVA_OPTS ="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms256m -Xmx512m"

Arduino Garage Door Opener Part 3

So, I’m finally back healthy enough to be coding in my free time, and I have made tremendous progress on the garage door opener.  Here is how it currently works:

I’m using magnetic reed switches to sense the state of the doors, then send it over to the controller via rf (315 mhz).

When the garage door installers put the garage door opener in, they were nice enough to use Cat5 cable, and only used 2 pairs per safety sensor.  That means I can use the other pairs to connect the reed switches without running additional wires.  After I’m done, the door sensors will not even be noticeable!

Now to the arduino code…

I opted to use a 2 character code to represent the state of both doors.

  • 00 represents both doors being open.
  • 11 represents both doors closed.
  • 10 represents door 1 being closed.
  • 01 represents door 2 being closed.

I have updated the code on GitHub:

There are 2 arduino projects (an opener and a sensor), and a phonegap mobile app.

The opener receives the rf signal indicating the status, and in turn, serves a json result to web requests indicating the status of the doors.  It also listens for web requests to open and close the doors.

The sensor sends the 2 digit code indicating the door status.

The phonegap app requests the door status every 10 seconds, and provides 2 buttons to open and close each door.