Browser Tab Overload

Posted on

I’m addicted to browser tabs. Right now on my work computer I have 39 tabs open. I have a fairly large screen but with this many tabs open I can’t even see their titles anymore. I usually just forget about what’s there until some point in the future when I end up deleting a bunch of them just so I can see which tab my email’s on.

Computer With Multiple Tabs

Of course, every tab is important to me. Each one is a blog post I want to read or a tutorial I just don’t have time to go through yet. I’ve tried bookmarking pages instead but without something in front of me I usually just forget that I have things bookmarked. Of course I usually just forget that I have things tabbed too.

One thing that sort of works, sometimes, is to organize my bookmarks into logical folders and then show those folders on my bookmarks bar. But then my bookmarks bar gets too long and a lot of the folders get hidden and I end up forgetting about them anyway.

My work computer has a solid state hard drive, a 3.4 GHz i7 processor and 32 GB of ram. It has no problem holding 40+ tabs open in Chrome along with running five to ten other programs I regularly use. My problem is just being able to see what the tabs hold so I can read them later.

At home, however, I have a different problem. My home computer is a 7 year old laptop with a core 2 duo and only 3GB of ram running Windows 10. But I still have my tab addiction. Unfortunately, I’ve hooked my wife on tabs too. Now two of us want to bounce from site to site and keep everything we’ve seen open. Arrggghhh, there’s too much interesting stuff on the internet!

My home laptop slows to a crawl if I use Chrome with more than about four tabs open. And good luck having any other programs open at the same time. The best solution would probably be to just close tabs or at least bookmark them and hope to someday remember to look at the bookmarks. But no, I found a way to force my ancient computer to keep my tabs up without crashing.

I loaded the Chrome extension called The Great Suspender. It suspends (surprise, surprise) tabs that haven’t been focused for more than a set amount of time. When you click on a suspended tab it reloads and away you go. This way I can keep lots of tabs open without affecting my system’s performance.

Yes, it’s a band aid for a problem that should be fixed by bookmarking or something. Of course, now that I think about it, when I have a screen full of tabs open I usually forget to go back and look at them anyway. My parents used to tell me that if I couldn’t remember something, it probably wasn’t that important anyway. And if most of the things my tabs hold aren’t that important, maybe I shouldn’t keep them around in the first place.

I need to get out more.

Time to Start Thinking of Gardens

Posted on

It’s that time of year again. The time when I wait too long to plant my cool weather garden. I then wait too long to plant my warmer garden. All of that comes after I’ve already forgotten to amend the soil properly for the particular plants I want to grow. But hey, every year’s a new year. Even though I should have already sown my first round of carrots, radishes, lettuce and peas, I can still get them in a little late. And there’s always Fall and early Winter.

 

My biggest goal this year is to get a harvest of winter squash off the vine and onto my plate. Last year’s crop was absolutely decimated by squash bugs. I had amazing plants with beautiful leaves but I let the squash bugs get established. They destroyed everything. It’s hard to see vibrant plants start to put out fruit only to see everything killed by little vine-boring punks.

I’m determined that this year will be different. I plan on putting in fewer plants and defending them to the death against the insidious squash but. There are lots of great ideas in books and on the internet of ways to kill or deter them organically (the only way I grow food plants). One can try Castile soap sprays, diatomaceous earth, row covers, traps, companion plants, oils and others. I’m willing to try them all. The ultimate, of course, would be to design a garden defense system that uses computer vision and laser beams to blast bugs. I might need to put a little more thought into that one.

I love Kabocha, Acorn, Delicata and Spaghetti squash. I’d love them even more if they came from my garden rather than the store’s shelves. With a little care and attention, along with a healthy dose of bug violence, I might be able to make it happen this year. Now I just have to go put it all on the calendar so I don’t forget to actually do it.

Chrome Developer Tools

Posted on
As a JavaScript developer I need tools that help me figure out what’s going on between my code and the browser. Thankfully, most major browsers today provide developer tools that do just that.

 

Google Chrome Toolbox

 

With these tools you can see exactly how your code affects the browser. At runtime you can find errors in code you’ve written or how long your site takes to load. You can view or even rewrite your CSS rules to see what changes will look like before you ever even commit them to your source files.

 

You can also dig into the browser itself and inspect its cookies, local storage and cache. And with web users quickly transitioning to mobile devices, developer tool device emulation can show what your site looks like on, and how it will interact with, phones and tablets.

 

Every year that passes gives us better developer tools from the major browser makers. We are fast coming to a point where any tool you choose will be just as good as another. But for one reason or another developers tend to find themselves gravitating towards a particular set of tools.

 

When I surf the web I like to use more privacy oriented browsers like, well, anything but Google’s Chrome. But when it comes to debugging and developing code, Chrome takes first place in my world. I like the default look of the Chrome tools UI (although Mozilla’s Dark theme is slightly more pleasant to look at if you’re into dark themes). I also find Firefox developer tools to be a little slow when emulating mobile devices while Chrome is snappier. Other tools in Chrome also appear more polished and have more functionality.

Some browser developer tools might have features that others don’t but that’s usually only true until the others release their next version. Good ideas tend to spread themselves around quickly.

 

There are lots of tools out there for JavaScript developers and web designers. But Chrome’s developer tools provide great runtime debugging, design assistance and performance insights. If you’re a web developer and are not using these tools and features to the fullest, it’s worth taking the time to dive deep.

A First Crack at HTML5/JavaScript Game Development

Posted on

For a while now I’ve been wanting to start writing JavaScript/HTML5 based games for the web.  I’ve always been drawn to simple games like the old Asteroids and Galaga where you have a ship and a bunch of bad stuff trying to destroy you. They’re easy to learn, play and waste your time with and yes, they give you that easy, addictive sense that you are actually accomplishing something worthwhile when you break your high score by one point.

One of the coolest modern versions of these old arcade classics is actually kind of useful. Ztype  is a simple shooter game along the lines of Galaga but you are shooting words and you have to type them in correctly or your ship doesn’t shoot. It’s an addictive game with great graphics and sounds.

ZTYPE

 

But I needed something simpler to get me started and familiar with the game engine I had chosen to start with – Phaser. I found an amazing tutorial on how to re-build Asteroids over on zekechan.net. It is surprisingly straightforward, provides full code to check yours against, is easy to follow but goes in depth enough to take you through developing an entire game.

Asteroids screenshot

 

However, by the time I was finished building the game, I was a little bored with the idea of a ship trying to destroy asteroids so I switched it up a bit to include a political theme appropriate for the current presidential race. You can check it out at http://ryanrandom.com/ted .

Ted Cruz vs Donald Trump

 

Keeping My House From Burning

Posted on

Late last year my family and I moved to a two story, 1970’s era house on 1 1/2 acres of land. Since then I’ve been thinking about retrofitting the house with Ethernet cable to most rooms. This is just one of many projects I have planned to update the house and add a few “smart home” features to make management of it and the property easier.

But before I can move on to the fun stuff (or the Ethernet cabling which I don’t consider much fun) there are a few projects that have to be finished out of necessity. I undertook one of them last weekend in the hopes of preventing the house from burning down. Let me explain.

A couple of months ago we finished up a project converting the garage into livable space. In the process of the renovation we discovered that the existing 30 amp dryer circuit was wired using aluminum wire. This wasn’t necessarily a bad thing since the wire was sized right but our building inspector wanted to see a four prong dryer outlet which meant running a new four wire cable.

So my electrician pulled the breaker and put in a new circuit. That problem was solved but now, all of a sudden, my irrigation pump wasn’t getting power. We started poking around and discovered that someone, years ago, had simply continued the dryer circuit from the laundry room, through the wall and out to the pump.

This was a major problem for two reasons:

1. The spliced-in wire going to the pump was only 12 gauge which is only big enough for a 20 amp circuit.
2. The splice combined copper and aluminum wires under the same screw.

The smaller gauge wire basically caused it to act as a giant fuse that, technically, could have burned up. Almost all of it was in conduit, however, so it probably wouldn’t have caused much damage. But it was still a problem.

The bigger issue to me was the mixing of copper and aluminum wire. That combination can lead to a chemical reaction called electrolysis which can cause oxidation, which increases the resistance of the wire dramatically leading to excessive heat build-up and potentially causing a fire.

 

None of this was of immediate concern since the circuit was dead and the dryer was on its own now. But I needed my irrigation pump back on so I could:

1. Keep my landscape from dying.
2. Put in an automatic irrigation system and potentially add wifi connectivity so I can turn my sprinklers on from Fiji – just in case I need to.

Thankfully my irrigation pump only needed a 20 amp circuit so the 12 gauge wire could stay. I also wanted to reuse the existing aluminum wire since it wouldn’t cost anything to keep it and it was already run through the house. All I really needed to do was take care of the aluminum to copper problem. There is a special connector called Alumicon but my aluminum wiring was too big (8 gauge) for it.

I opted for tin-plated aluminum splicing blocks which are approved for both copper and aluminum wire. The copper wire goes in one side of the block and gets screwed down while the aluminum wire goes in the other side and gets secured. The two metals never touch! Wrapped with some rubber splicing tape they actually look pretty good.

Now I can water my grass, not worry about my house burning down (at least for one reason) and start thinking about my next, hopefully more fun, project. Not a bad weekend.

Please Update Old ESRI JavaScript API Samples

Posted on

I’m confused – why does ESRI insist on keeping JavaScript API samples written in a legacy (non-AMD) module require style? I can understand keeping the legacy code in the API reference since a lot of developers probably wrote a lot of code using it. But current sample code should reflect current programming styles. And yes, the samples I’m talking about are the current ones.

ESRI Javascript API screenshot

Somebody actually goes in and updates the CDN reference to the current JavaScript API. Would it be that difficult to convert the requires to an AMD wrapper and change a few module references? Just a thought.

Mapping The Dead

Posted on 1 Comment

Skull and Crossbones

I’ve seen a lot of interesting mapping applications in the news over the last year. One that’s caught my attention is cemetery mapping. I had never really thought about just how ideal a cemetery is to be mapped. Each plot has a distinct spatial location. They have measurable attributes like occupant, location, depth and width. They are often laid out like a grid or a table but sometimes (especially on older properties) they are spread out seemingly without much thought to being easily located again.

Locating a plot is obviously the most important attribute for cemetery mapping. Caretakers have to be able to determine where a body is located so they can avoid accidentally digging it up when placing another body. Relatives of the deceased want to know where their family members are too so they and those in the future can find them again.

One of the first articles I cam across last year was about the cemeteries in the City of Mackinac Island Michigan. The city’s cemetery committee (I bet those meetings are fun) recognized that its current data holdings (hand-drawn paper maps, incomplete lists of cemetery residents and the memories of senior committee members who are increasingly ending up in the cemetery themselves) were not adequate. So they started mapping out plots using GPS and building a database of names.

The City of Mackinac Island Cemetery Committee hopes to have a completed digital mapping system by next June, which will help the city clerk’s office keep track of plots and burials more efficiently. The map is one of many updates the city is considering relating to its cemeteries and burial policies.

It didn’t surprise me to find that some cities are using GIS technology to keep track of cemeteries. What did surprise me was the number of software packages that have been created for mapping and managing them. A quick search for cemetery mapping software reveals several pages of apps, services and companies with interesting names like Memorial Business systems, CemMapper and The Crypt Keeper.

Yet with all of these software solutions, none of the cemeteries that I was interested in searching had detailed mapping of their plots. Only one even had a website. Although the mapping technology is there, this kind of project doesn’t seem like one many cemeteries are willing to undertake.

Building a Stubborn Driver: An Ubuntu Adventure

Posted on

I was confused, frustrated and defeated. My back was on fire and I could barely feel my legs. If there had been a bed within range I would have crawled in, closed my eyes and tried to forget the last five hours I had sat trying to build Linux drivers for my son’s new USB wireless adapter. It didn’t work. Nothing was working!

Wireless Adapter
Now I’m no Linux expert but I can usually figure out how to make the OS do what I need it to do. In this case it should have been simple – just make and install the source files and maybe change some setting on another file. But things went wrong from the beginning.
It was Saturday and I anticipated getting the project done fairly quickly. I had actually tried to get the WiFi working the day before but I was trying to do it without a wired connection to help out. I had just installed Ubuntu 14.04.03 and I really didn’t think I would have any trouble.

The open source drivers that come with Ubuntu take care of most of the hardware I want to use. But this particular wireless adapter was a plug-in USB with a proprietary driver that had to be compiled by hand. The adapter came with one of those mini-cds. It had three folders with drivers for Linux, Windows and Macs.

The windows and mac folders had exactly one file that you can click on to load the driver. I’ve used this adapter on a windows box and it works really well. All you have to do to get it working is double-click the executable and away you go. On Linux you have to build the driver from source code. So we’ve gone from one .exe file to about 450 files that you have to figure out how to put together and get to work. OK, but this is Linux. That’s what you expect from an open source OS.

But even building drivers shouldn’t be that difficult if you know basic Linux commands, how to traverse directories, edit files and use Make. Still, with such a large user and contributor base (for Ubuntu) you would think someone would have made the process for this driver a little clearer. Here are the build instructions that came with the adapter:

Build Instructions:  
====================

1> $tar -xvzf DPB_RT2870_Linux_STA_x.x.x.x.tgz
    go to "./DPB_RT2870_Linux_STA_x.x.x.x" directory.
    
2> In Makefile
	 set the "MODE = STA" in Makefile and chose the TARGET to Linux by set "TARGET = LINUX"
	 define the linux kernel source include file path LINUX_SRC
	 modify to meet your need.

3> In os/linux/config.mk 
	define the GCC and LD of the target machine
	define the compiler flags CFLAGS
	modify to meet your need.
	** Build for being controlled by NetworkManager or wpa_supplicant wext functions
	   Please set 'HAS_WPA_SUPPLICANT=y' and 'HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y'.
	   => #>cd wpa_supplicant-x.x
	   => #>./wpa_supplicant -Dwext -ira0 -c wpa_supplicant.conf -d
	** Build for being controlled by WpaSupplicant with Ralink Driver
	   Please set 'HAS_WPA_SUPPLICANT=y' and 'HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n'.
	   => #>cd wpa_supplicant-0.5.7
	   => #>./wpa_supplicant -Dralink -ira0 -c wpa_supplicant.conf -d

4> $make
	# compile driver source code
	# To fix "error: too few arguments to function ¡¥iwe_stream_add_event"
	  => $patch -i os/linux/sta_ioctl.c.patch os/linux/sta_ioctl.c

5> $cp RT2870STA.dat  /etc/Wireless/RT2870STA/RT2870STA.dat
    
6> load driver, go to "os/linux/" directory.
    #[kernel 2.4]
    #    $/sbin/insmod rt2870sta.o
    #    $/sbin/ifconfig ra0 inet YOUR_IP up
        
    #[kernel 2.6]
    #    $/sbin/insmod rt2870sta.ko
    #    $/sbin/ifconfig ra0 inet YOUR_IP up

7> unload driver    
    $/sbin/ifconfig ra0 down
	$/sbin/rmmod rt2870sta

I started by simply trying to make the driver according to the instructions above. But the process kept showing an error and acting like it couldn’t find certain files that should have either been included or created when the make command was run. So I went searching “How to compile RT2870STA driver”. There were a lot of sites giving basic instructions about how to build the driver and it seemed like it should work fine. What I didn’t notice were the dates of most of these articles. They were pre 2010.

I finally came across a newer post that explained this driver was built with an earlier Linux kernel in mind (2.x). In the 3.x kernel, some functions that are referenced by my driver source files were re-named! Then I finally did what I should have done from the very beginning: I got specific. I searched “How to compile RT2870STA on Linux 3.19 kernel”. This seemed like a god idea at the time. In fact, it yielded a great blog post that provided a patch that supposedly would fix the discrepancy in the driver files. But for the life of me, I couldn’t even get that to run.
It was at that point I became too frustrated and defeated to continue. My entire day had been wasted. My kids were complaining that they hadn’t seen me all day. My wife was giving me that concerned “Oh dear, he’s trying to do smart people things again” look. Even my dog seemed annoyed at me that I had spent more time typing “make install” than I had spent throwing her ball.

So I gave up and took a few days away from my little project and did some other tasks that were just slightly easier for me like taking out the garbage. Then, Saturday morning I thought why not give it one more try? So I searched “How to compile RT2870STA on Ubuntu 14.04.03”. It was like magic! The very first result was a post on ubuntuforums.org that explained everything in a few simple steps. It seems there were two functions that had been renamed in newer builds of Ubuntu. I had to edit a file in one of the driver folders and change the names of a couple functions. I then ran Make again and voila, my adapter was up and running.

Looking back I realize I’ve learned (and re-learned) a lot about working with Linux. I now have much better terminal skills. I understand driver compilation processes better and how they interact with the kernel. I also reinforced my belief that an Ethernet connection to the internet is always superior to wireless, although inconvenient.

Search Directory Trees with Python

Posted on

Here is a simple but powerful way to use Python to search and find all files with a specific extension within a given folder and all of its sub-folders using os.walk(). I use it a lot to find map documents with broken data sources, images that need to be organized or just to get a quick count of certain files in a directory.

import os

directorypath = raw_input("Enter a directory path: ")
extension = raw_input("enter an extension: .")

#Loop through all folders and subfolders in your target directory. 
for root, dirs, files in os.walk(directorypath):
    fileList = [os.path.join(root, f) for f in files if f.endswith(extension)]             
    for item in fileList:
        print item #or do something else with each file found.

 

When Django Met IIS

Posted on 2 Comments

The Problem:

The county I work for had a one page geography quiz with outdated questions and a poorly structured user interface. It was just an unstyled list of select dropdowns and a submit button. The answer page that was returned just listed each question with all the answer choices under them. One answer under each question was highlighted in yellow but it wasn’t made clear to the user whether this was the correct answer or just the answer they chose.

Old Mesa County Quiz AppTo compound things, the quiz was stuck in an enterprise CMS that gave it a really ugly url. I wanted to change that so it would look good and be really easy to understand. Thankfully I wasn’t restricted to any particular language or technology stack to build the new quiz.

The Solution:

A few years back I had played around with Django and thought it was a cool framework but I had never really applied it to any project. So I said to myself “why not?” and set out to build a new geography quiz app with Django. Over the next couple of days I put together the components of the new application:

  • A PostgreSQL database to store the questions and answers
  • Models to define the data in the database
  • Views to process and send the data and to route user answers to the answer page
  • Templates to render the data

Everything seemed to be going along smoothly although I wasn’t very happy with the way I wrote my views to handle the user submitted answers. The app basically builds a form on the fly (questions with radio button answers) then does a POST when the quiz taker clicks the submit button. The view then takes the POST data and turns it into a Python list. The rest of the view just slices and dices the list and uses offsets to pull out the matching questions and answers.

I know there are cleaner ways of doing this. Especially since the returned POST data is a querydict object which is basically just a Python dictionary. Manipulating key/value pairs seems neater. But the way I did it worked and I got it up and running fast. Maybe a project next time I’m bored will be to make the code cleaner and more maintainable.

Another Problem:

Remember earlier when I said that I asked myself “why not?” when considering using Django? Well, I was about to answer that question and the answer wasn’t pretty.

While I was developing my quiz app I used Django’s built-in server which is a lightweight “please don’t use in production” server. It worked great. Then I decided it was time to port the app to my production server and actually use it in the real world. At that point I remembered we use IIS on a Windows server.

IIS isn’t all bad, especially if you work in a place that uses .NET components heavily which I do. Unfortunately, Django was never really developed to run on IIS. Django was really designed to live in a Unix world and be served out with something like Apache. I remembered that from my prior experience with the platform – I just forgot.

Another Solution:

There are several tutorials on the web (most of them several years old) that discuss running Django under IIS but none of them were very straight-forward. The solution that seemed like the quickest route to a running app was to use Helicon’s Python Hosting Package (part of the Helicon Zoo repository available through the IIS Web Package Installer). The hosting package basically loads all of your dependencies and does all of the complicated work of getting IIS to run an antagonistic technology. You then load a Python Project module which builds everything for you including:

  • A virtual Python install specific to your app
  • A web config file with needed environment variables
  • Permissions and application pool settings

The only pain point I had with using Helicon’s solution was discovering it doesn’t work with Django 1.7. I had developed in 1.7 and then when I migrated into the Helicon environment everything broke. This really threw me for a loop for a while until I found a post suggesting using Django 1.6. This didn’t turn out to be a big deal as it didn’t affect my apps functionality. I just had to remove a couple of middleware classes from my settings file and I was good-to-go.

New Mesa County Quiz AppConclusion:

I love working with Django. If I wasn’t in a Windows environment I might be trying to use it throughout my office GIS site. But I can’t see trying to force uncommitted technologies into a relationship they don’t even seem to want. I guess Django is just going to be a hobby framework for me for now. Fortunately there are plenty of others out there just waiting to be learned and implemented.