RSS Feed


Comments RSS

Using Python to create a Bible database program

The programming bug bit me this evening and I did something I have wanted to do for a really long time, write my own code to create a useable bible database.   So, I took an indexed bible text available in the public domain, wrote the code to parse it properly and then package the parsed bible into a Sqlite3 database file that can then be querried.  Basically, the heart of any bible search program.  I cannot believe how fast it runs!  That is a whole lot of text, but Python excells in the text processing domain.   The link is to an archive containing the bible text file that gets processed and the Python program.   When run, the database is created from scratch.

The code is Python 2.x style.   You may use this code in anyway you wish. NOTE: the following code is obsolete and has been removed.  Please see this blog post for the fully featured program!

The code has good examples of:
1)reading a text file, line by line
2)text parsing and regular expressions
3)error handling
4)Sqlite3 database handling

Steve Jobs passes away

Steve Jobs, the Thomas Edison of our day, has passed away.  He dreamed of bringing computing to the masses, and he succeeded.  But he did much, much more than that.  He brought to us a revolution.  From the Apple computer, to the Mac, to the IPod, and then the IPhone and IPad all the other the great gadgets he and his company created,  our lives have been more fun and more productive.   He founded the company, Apple, in a garage then stepped aside for a time to pursue other technical interests, such as the NeXT systems and OS.  But then he returned to Apple to rescue and revive a company that has lost its way.  Oh, but he did much more that just revive Apple.  He had the vision to embrace other technologies and put his unique touch to them.  He spearheaded the creation of wonderful personal entertainment and communications devices and then married those to computing technologies, advanced operating systems and Internet content delivery; which turned Apple into a computing, communications and internet Juggernaut.  Steve Jobs was an inventor, businessman and visionary.  Most of all, he was a great man who gave his all, and even the last of his health, in pursuit of his dreams which have enriched all our lives.

Steve Jobs, RIP

February 24, 1955 – October 5, 2011.

electronics experimentation

There are lots of ways to experiment with electronics.  One way is to use a programmable testbed system.  There are several available at various costs.  One that I am looking at that seems interesting is the Arduino UNO, which sells for about $30.   I was shown this one at work by our electronics engineer.   I may get one for myself to play with.  It looks like a very inexpensive way to experiment with programmable electronics.  Such system can be used for data output and display, data collection, motor control, ham radio applications, and much more.

The main website.

A hands on turtorial.

Another programmable testbed system that is quite popular is the Parallax Basic Stamp.

The Arduino UNO

The Night Sky

I have always been a person of the countryside. I grew up in small Texas towns, usually outside of town in the countryside. Currently, I have the pleasure of living on the eastern edge of the Greens Creek valley here in Erath County, TX. It affords me a wonderful horizon from the South West to the West. Lately, I have taken notice of what a good location I have for star gazing. Several times in the last few weeks I have had exceptionally clear skies and the Milky Way seemed to be exploding across the sky. I have even seen a couple nice shooting stars. Nothing like a beautiful night sky to open up the wonders of creation before you. The majesty of the Creator seems to be made manifest at such times. I have taken an interest in star gazing and am beginning to pursue it now. I guess it was probably inevitable and a lot of factors have contributed to that. First, living in such a good viewing area. Second, having a good friend who is the manager of the planetarium at Tarleton State University and also the tech at the university observatory. He takes students and members of the public out on star watching parties at the observatory. Finally, I have installed a very nice astronomy program on my Ubuntu laptop called Stellarium. While not highly complex, it is an entirely useful and elegant free program. It is a very good guide to the night sky which helps as I am a complete novice at this. I have decided for now to just work on naked-eye astronomy, no external optics. I want to learn the sky as man learned it for eons. I want to see what they saw and notice what they noticed. I want to understand how men have found their way by the stars from time immemorial. I want to learn the sky for the times and the seasons and to look up and see the constellations come into view as the procession of the stars passes overhead. The night sky, such a beautiful thing.

Science Day at TSU

Today was the annual Science Day at TSU (Tarleton State UniversityStephenville, TX). The amateur radio club, Tarleton Area ARC, takes the opportunity to set up our emergency power solar array and operate a ham radio station outside as a demonstration of both solar energy and radio technology. This same day is the day that new students and parents tour the campus, so we have lots of foot traffic passing by us. It is a good opportunity to educate the public about the solar energy and stir up some interest in amateur radio. We had quite a few people stop by to visit and it was a very successful event I felt. We operated from my Elecraft K2 QRP radio to a half-wave dipole for the 20 meter band. Very good contacts were made to Indiana and Iowa via SSB and PSK31. The only difficulty for the day was with a laptop running Ubuntu 10.10, which I have blogged about here. Many thanks to Larry Barr, K5WLF, for providing the solar energy setup and being my operating partner on the air.

MRI, not fun…

Today I had a VERY unpleasant experience.  I have never considered myself claustrophobic, but after having a MRI today I am really beginning to think I might be.  That was a very tight space and the sounds the MRI machine makes are terrible.  I was getting the MRI for a back problem and laying flat on my back is one of the positions that hurt me worst, so of course I had to lay in there that way and be perfectly still.  The space was so tight that I could not move very much even if I wanted to.   I became quite anxious and my blood sugar plummeted.  Generally, just a bad experience.  That was only 25 minutes in that infernal machine!  I now understand what a trapped animal feels like.   Yet, I got a reminder when I turned on the TV how much I should actually consider myself blessed.   They are preparing to rescue the trapped miners in Chile via a capsule only 21 one inches in diameter through a hole they drilled from the surface down to the location of the miners.  It will take a whole hour just to pull each one out and after so many days trapped underground.  Those are truly courageous men and all the people involved in the rescue are just awesome.   My hat is off to them all.   I feel like such a dope for letting that experience with the MRI machine get to me…

Python – Accessing Oracle Databases

Still learning the Python programming language here. However, along the way, I have found a need to branch out with some add-on modules for specific tasks. One of these is a module for accessing Oracle Databases. The module is cx_Oracle. Performing a query to an Oracle database become this simple process:

import the cx_Oracle module

import cx_Oracle

make your connection to the Oracle database

connection = cx_Oracle.connect(“username”,”password”,”oracle_instance”)

create an instance of the cursor

cursor = connection.cursor()

Perform a query. This demonstrates a simple select query, how to pass some user input as an argument to it, and how to do something something with the result.

user_input = str.upper(str(input(“Please provide value to query>>”)))

cursor.execute(“select some_field from some_table where some_field like :arg_1”, arg_1 = user_input)

for some_field in cursor:


Python – a learning exercise

In the process of learning Python, I have given myself a programming exercise to do.  This is a standard thing I do whenever learning a new programming language and I have used this same exercise several times before.  It is a simple text based game that simply lets a user explore a maze of rooms.   If fully fleshed out, it would be a Zork or D&D type game.  It demonstrates some basic programming tasks such as reading data into an array from a file, getting and responding to user input, looping, control structures, system calls and function definitions.  I share it here as example code for others also learning Python and I welcome comments.   The code is for Python 3.x, but the comments explain how to easily convert it for use in Python 2.x.  It is far from perfect and is for learning purposes only – something to tinker with.  It is based on concepts from Creating Adventure Games on Your Computer by Tim Hartnell, which used the BASIC programming language.   You are welcome to take this code and use and modify for any purpose you like.  The current version of this code will always be at this location: mazegame-current .  In this directory you find the program and the data files it will ask for when the program is run.

My previous blog entry Learning Python provides resources for those wanting to learn Python, as does the Dev page from my main website.

Learning Python

I have picked up learning to program in Python again.   Looking to add it to my trophy case along with BASIC, x86 Assembler, IBM BAL, Pascal, Modula-2, Forth and C.   In the process I have found some great resources, aside from the official Python website to share. The first two sites are excellent on-line books about programming in Python. The last two sites teach programming skills generally using Python as the example programming language.

A Byte of Python
Dive Into Python
Learning to Program
How to Think Like a Computer Scientist

More resources can be found on my Web Development and Programming page.

Shave Secret – WOW!

Ok, do not usually do this and certainly am not being paid to do it, but it is very seldom that a product I try on a whim that works out so well. I have always HATED shaving. Even the very best lubricated shaving gels did not prevent me getting pretty bad razor rash. I would not shave very often because of it, usually just once a week for church or otherwise on special occasions (like my wife insisting!). I was in Wal-Mart about two months ago and noticed a product called Shave Secret shaving oil. It is a little bottle and the product is a blend of oils. I bought it on a whim out of desperation for something that would work better than shaving cream or shaving gel. It works fantastically well! With it, I can shave daily and not be one constant case of razor rash and it leaves the skin refreshed, moisturized, and well conditioned. It can be found on-line at Oh, and it is a TEXAS product made by USA King’s Crossing, LLC.. Cuero, Texas.

A Romantic Dinner

It is my wife’s birthday today.  We are out of town in Houston and vacationing, away from the kids who are vacationing separately.  It is wonderful to finally be at that point in life where that is possible!  It has allowed for a nice romantic dinner tonight at Perry’s Steakhouse, a great fine dining experience.   We had an excellent dinner and I did what I wish I had done twenty years ago, get down on one knee in public and make a proper proposal.  Of course, we are already married, but I did next best thing.  I asked her if she had it to do all over again, would she still marry me?  I also asked her if she would renew our wedding vows with me later this summer when our 2oth wedding anniversary comes around.  I received a joyful affirmative on both counts!  My advice to any married couple, take the time to do the simple, romantic things.  Go out to dinner.  Tell each other often you love them.  Do not forget how to go out on a date.  Take time for each other, because a limited amount of time is all you have together.

a neat trick via Ghostscript

I have found a neat trick.  Not original, found it here:

PostScript and PDF

  • To concatenate PostScript or PDF files into a single PDF file:

    gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
    -sOutputFile=<outfile> <infile> <infile> …

  • To concatenate PostScript or PDF files into a single PostScript file:

    gs -q -dNOPAUSE -dBATCH -sDEVICE=pswrite \
    -sOutputFile=<outfile> <infile> <infile> …

  • This trick used in combination with the fact that in Ubuntu you can print not only to a printer, but also to either a postscript or PDF file directly, means that if a book is presented in html on the web, say with each chapter being an individual HTML page, you can easily print each of these to a file and then use the trick to concatenate the ps or pdf files together to reassemble the entire book.  For instance, I am doing that with this book that is online:

    I do not know how many other books that I have run across on the web that were HTML like this and I wanted to reassemble them for a good print out.  This is a way to do it.

    By the way, “gs” is the command line program for Ghostscript, which should be already installed on your Ubuntu system by default.  If you install Ghostscript on a Window system, the same trick should work there too so long as you print the HTML to a PDF printer driver.  Ghostscript can be downloaded from here:

    Oh, yes, this is also cool…:

    A beautiful day!

    What a beautiful day!   My wife and I went on a date today to Clark Gardens Botanical Park.   The gardens are located outside of Mineral Wells, TX which is about an hour from where we live.   We packed some fixings for sandwiches and a nice Muscat Canelli wine from Sister Creek Vineyards, one of our favorite wines.   The flowers were gorgeous and very fragrant.  The gardens exhibit a large variety of plant life, particularly flowers such as roses, iris, poppies, etc.  There is also a local contingent geese, guinea flow, swans, ducks, and peacocks.   As a bonus, if you are a fan of model trains, there is a brilliant set of G-scale model trains running in a section of the garden.  I highly recommend anyone take some time to visit this wonderful place.  Pack a lunch, take a loved one, and enjoy a great day out in the outdoors and the beauty of nature!

    Happy New Year, 2010!

    Happy New Year, 2010! Here is wishing the best and blessings to everyone for the new year. 2009 was a year of challenges for me, but who grows without challenges? No regrets, but I do hope to do better in the new year. My aims are to reclaim my health, get back to living in a less haphazard way, and to devote more time to my family. Things I really enjoyed about 2009 were that I took on a new job at work, that I had more travel and vacation time with my wife, my activities with TAARC, I became politically active in a formal way, and that I discovered the SDF community. Here is to 2010. Cheers!