Learning Python

•February 12, 2015 • Leave a Comment

Books

Learn Python the Hard Way, 3rd Edition” is available online for free or you can buy the eBook.

Several Packt Publishing titles also come to mind:
Learning Python Design Patterns
Expert Python Programming
Python Tools for Visual Studio
Raspberry Pi Cookbook for Python Programmers
BeagleBone for Secret Agents
Python for Secret Agents
Python Programming for Arduino

I would suggest creating an account with them and signing up for their daily special.

Some people don’t like O’Reilly but I find their books are pretty good as well:
Head First Python

IDE

One thing Python lacks is a solid IDE but that’s changed now that Microsoft has made Visual Studio Community 2013 available for free. Couple this with the Packt title, “Python Tools for Visual Studio“, listed earlier and you have a viable platform.

Some people swear by IDLE; I like Google’s PyScripter myself.

There’s also a great stackoverflow article listing many of the IDEs available and their feature set.

Python 2.x vs 3.x

There’s a war of sorts going on in the Python community since the release of version 3.x which breaks some existing 2.x code. The general consensus is to steer people towards 3.x unless they have to support 2.x legacy code or require a plug-in that’s not supported in 3.x.

Globally disable OnSwipe on iPad

•August 18, 2011 • Leave a Comment

Yep, I stole this entry’s title from the support article in the WordPress support forums.

Please do all those iPad owners a favor and disable OnSwipe on your blog. It does nothing to enhance or beautify your blog. In fact, it does the opposite and removes your individualization thus making all WordPress blogs look (and bounce) the same (boring).

How to Compile a Simple OpenGL Program (Part I : Symantec C++ 7)

•May 22, 2010 • 1 Comment

The other day, I was searching through my collection of discs and was distracted by a shiny thing: Symantec C++ 7.

Symantec C++ 7 is a complete development environment for Windows 16-bit & 32-bit and runs under MS-DOS, Windows 3.1, Windows NT, & Windows 95. While looking through the contents of the disc, I spied an OpenGL samples folder with one specifically named Book which I believe to be a reference to The Book.

I’ve always been fascinated by computer graphics so I decided to see how this compiler, released in 1995, held up today and try out the samples. The software includes an installer but more importantly, a folder is included on the disc from which the compiler and IDE can be run directly making this task easy to accomplish.

I copied the SC folder (BIN, HELP, INCLUDE, LIB, SAMPLES, etc.) to the local hard drive and then wrote a command script to set the environment for it:

@echo off
title Symantec C++ 7
set SYMANTEC7=C:\Tools\Symantec7
set include=%SYMANTEC7%\Include
set lib=%SYMANTEC7%\Lib
path %SYMANTEC7%\bin;%SYMANTEC7%\redist32;%PATH%
echo ----------------------------------------------------------
echo SCW32 : Windows 32-bit front-end
echo ----------------------------------------------------------

I also placed a shortcut in the Start Menu to execute the command script with the following settings:

Shortcut Name: Symantec C++ 7

Target: %COMSPEC% /k C:\Users\Public\bin\Symantec7.cmd

Start In: C:\Tools\Symantec7\Samples\win32

Comment: Set environment for Symantec C++ 7 for Windows

Icon: %SystemDrive%\Tools\Symantec7\bin\SCW32.EXE,0

I started SCW32 (the 32-bit version of the IDE) and voila! I opened up one of the OpenGL projects, compiled, and executed it:

OpenGL Sample of an array of teapots with different material colors.

OpenGL sample of an array of teapots with different material colors.

Very cool. In looking at the project definition, I noticed it was a single C file. Knowing there were 69 68 individual projects, I wondered how I could simplify this so it would be easier to compile all the examples. Fortunately, in addition to the project files, which are proprietary to Symantec C++, there are makefile equivalents for each project. Unfortunately, the make utility included with Symantec can’t seem to build them (I’ll figure out why at some other point in time).

The easier solution for the time being was to figure out what information the compiler needed to compile each source file into an executable. Reading through the makefiles for the options and linkage and then experimenting lead me to this:

sc -mn -C -WA -S -3 -a8 -g TEAPOTS.C glaux.lib glu32.lib opengl32.lib gdi32.lib

Here’s an explanation of the command line options used for Symantec C++ 7:

-mn
Memory model = Win32s, Windows 95, Windows NT
-C
No inline function expansion
-WA
Windows Executable
-S
Always generate stack frame
-3
80386 code (4 : 80486; 5 : Pentium)
-a8
Alignment of struct members
-g
Generate debug info
glaux.lib glu32.lib opengl32.lib gdi32.lib
The libraries necessary for linking

Armed with this knowledge, there are a couple of ways to compile all the examples. The simplest method is to use a shell “for” loop:

for %c in (*.c) do sc -mn -C -WA -S -3 -a8 -g %c glaux.lib glu32.lib opengl32.lib gdi32.lib

Interestingly, this works fine in Windows XP and all the examples compile. But in Windows 7 (64-bit), as it loops through each source file, some examples will compile, others generate an “OPTLINK” exception, and then the compiler will finally hang. The exceptions and hanging seem to be arbitrary as they occur at different points in the loop. Yet, no problems are encountered if each command is executed manually.

An example of the OPTLINK exception.

An example of the OPTLINK exception.

The “for” loop could be speeded up by pre-compiling the headers beforehand with the -HX compiler option.

Another method would be to create a makefile to incorporate all the projects with dependencies to build all & clean all. I’ll leave this as an exercise to perform at a later time.

In the end, this was a fun exercise getting to know an old friend. I’m surprised at how well the compiler (SC) has held up through the years despite all the changes made Windows but even more so that the IDE (SCW32) functions so well. Even though the size of the buttons and dialogs point to a time where 800×600 was king, the interface was ahead of its time and maybe even better than Visual Studio in some ways.

My interest in OpenGL has also been rekindled, especially in regards to Android, although I consider my desires to be more experimental in nature. I’m not a graphics artist so I don’t believe I’ll be publishing anything serious. But it’s still fun to play with.

The next step is to compile these examples with Visual Studio but before doing so, I’m going to slight detour into some history which involves Teapot

I Was Never A Real Programmer* But…

•March 28, 2010 • Leave a Comment

What I miss is the experience I enjoyed when programming close to the metal. Whether it was learning from Peter Norton or Tom Swan how to write assembly code, reading Ray Duncan’s treatise on MS-DOS, working with the intricacies of UNIX, or delving into the guts of an Apple II, I was never that far from the core of the machine. [Okay, maybe a bit more isolated from the hardware with UNIX.]

Today, we deal with operating systems and shells that try to protect us from ourselves: Windows 7, Snow Leopard, KDE, Gnome.

Today, we deal with frameworks that sit on top of the operating system and further abstract us from the underlying hardware: Microsoft’s .NET Framework to Apple’s Cocoa.

Today, we deal with frameworks that sit on top of the web browser, from jQuery to Dojo to Flash to Silverlight just to name a few, to insulate us from the network underpinnings.

Today, we no longer have to create custom file formats to store records because we have databases to perform that work for us: Oracle 11g, Microsoft SQL Server 2008, MySQL. Or we can save our data as XML.

Don’t get me wrong. Most of these things make development so much easier.

I’m glad I no longer have to create the framework to implement the functionality of a user-interface. Does the computer have CGA, EGA, or VGA? What interrupt trips when the mouse is moved? How do I respond to it? Doing it once or twice was enough to give me the experience and understanding I needed.

I no longer have to develop code to write out and read custom file formats, translate data from big-endian to little-endian, or ensure my binary file is the right size. Better still, now I can more easily share my data with others and vice -versa.

Instead, I get to concentrate on the logic and relationships to actually solve the problem at hand. I don’t even have to know what operating system my application is running on; the application is “happy” as long it has connectivity to the database.

But I still miss those opportunities when I had to drill down and really learn what was going on behind those plastic keys I press. I may have crashed and burned occasionally, spectacularly even, but I always came away educated further and having fun with it all. And the experiences are something I’ll never forget.

[While writing this, I’m reminded of an illustration on the growth of GIS from niche to enterprise within an organization contained within Focus on GIS Component Software Featuring ESRI’s MapObjects written by Robert Hartman. Perhaps another related article?]

* A tip of the hat to those Real Programmers out there.

ESRI Make A Map (βeta)

•November 21, 2009 • Leave a Comment

ESRI has made an interesting web application available that allows you to plug a map into your own page. After navigating to the “Make A Map” site,

  1. Type in a location (city or zip code)
  2. Select a predefined demographic layer
  3. Resize the map window as needed
  4. Post the “iframe” code into your page or link to the provided URL of your customized map

So, here’s my customized map🙂

My Preamble to the Song “Belleau Wood” by Garth Brooks

•November 19, 2009 • Leave a Comment

We’re taking a slight break from the techno stuff today…

I wrote this preamble as an introduction to the song “Belleau Wood” by Garth Brooks (Sevens – 1997) as many people have asked me about the background story:

“I’ve always been an avid book reader. And so it was that I was ten years old when I came across a true and surreal story.

“The year was 1914 and the major European powers were fighting the ‘Great War’ or the ‘War to End All Wars’ – what we know now as the ‘First World War’. What began in the early summer of that year was only expected to last for a few weeks or months at the most. Instead, it would drag on for four years with some of the bitterest and bloodiest fighting the world had ever seen.

“On that cold, Christmas Day of 1914, an informal truce was declared – there would be no fighting on this day. And something magical happened.

“Eighty-three years later, Garth Brooks released a song that resurrected the memory of that moment in history for me. And so I dedicate this to the memory of those in harm’s way – and to those who believe we can do better.”

I had a more descriptive narrative for the third paragraph written but removed it so as not to ruin any surprise the listener may experience when hearing the tune for the first time:

“On that cold, Christmas Day of 1914, an informal truce was declared – there would be no fighting on this day. And something magical happened. With a reprieve from the fighting, soldiers from both sides of the barbed wire laid down their arms and turned their backs on the war, gathering together in ‘No Man’s Land’ to sing Christmas Carols, toast each other, exchange photographs, and even play a few games of soccer.”

To this day I am still awestruck by the historic event  – and I am given hope.

If you’re interested in learning more about the “Christmas Truce” there’s a great article available at Wikipedia as well as a children’s book and several movies: Joyeux Noël (Fiction); The Christmas Truce (History Channel) .

ESRI User Conference 2009 Recap

•November 4, 2009 • Leave a Comment

For those who didn’t get to attend the San Diego User Conference in person this, ESRI spent some time putting on local presentations of the Plenary Session. My co-workers and I attended the one given in Bellevue today and came away quite impressed. T.J. Abbenhaus, Heather Glock, & Leah Saunders were outstanding in going over the highlights. The only thing missing were the freebies.

Quite a few things from ArcGIS 9.3.1 were reviewed although the refresher was nice. Besides the significant improvements to the ArcGIS Server rendering I think layer packages and ArcGIS Online (which Jack Dangermond described as “GeoFlickr”) are going to go over big. We’re going to have to start enhancing our FTP site by providing layer packages which include the symbology that so many users have asked for in the past. Also mentioned was an ESRI Business Solution named MapIt. This was developed by ESRI to take advantage of Microsoft platform & technology such as SQL Server 2008 spatial datatypes, SharePoint, Bing maps, Excel & Silverlight to implement GIS-enabled enterprise solutions. Very interesting.

Next up was ArcGIS 9.4 rumored to be available around the time of the 2010 User Conference. Many changes to the user interface will be introduced – most for the better as long as it doesn’t go “ribbon” on us. I especially liked the dockable windows (which don’t cause a screen refresh) and the addition of edit templates. The map book capability has been greatly improved. Other changes or additions include an open API to the file geodatabase, replication of SDE data (non-versioned and multiple schemas), a new mosaic imagery catalog, the inclusion of some features from Image Analyst (the ENVI rooftop demo was awesome), and the ability for non-licensed clients to view Maplex labels. An interesting Python script was also shown that allowed reconnecting the data sources for multiple map documents – very cool.

After that, there were introductions to and demos of the Map Templates followed by a short overview of the “Creating Effective Web Maps” seminar.

All in all, a fully worthwhile use of the day!