A crash course in Python

Sometimes, you just need to figure out what you can do with the tools that you have available to you.

The situation: I have to check the status of a site that is on a server that I don’t control, and take various alert actions depending on specified parameters.

The tools that I have: a Linux server that I can reasonably assume to be up and available more often than the site that I’m checking on.

The fun part about this is that normally I would write a little PowerShell script, (or VBScript if I could not guarantee the presence of PowerShell) or a C# app and run it off of a Windows server. But, I don’t have a Windows server. So, that means looking for other options:

  1. Bash scripting – looked into this, unfortunately what I need to do is a little to complicated for Bash.
  2. Python scripting – much more powerful, and a reasonably familiar syntax. Yes! Lets do this!

So with the help of Google and Stack Overflow, I took a day and took a crash course in Python. I was able to set everything up to check the website, email if it met certain parameters, SMS me using Twilio if it met other parameters, and call me if there was a critical failure. All in all, not bad for what amounts to a quick and dirty script.

I’ve learned that I like working with Python, especially considering how many libraries are available for it, and will definitely consider using it for my next project. Especially if it’s something that needs to work cross-platform.

Moving on up

After spending a month trapped in certification limbo, I am happy to announce that I’ve officially finished my Windows Server 2008 certifications, giving me my MCSA: Windows Server 2008 and my MCITP: Enterprise Administrator on Windows Server 2008 certifications. This means that I just have to write two more exams to get to the Windows 8/Windows Server 2012 level, and then decide if I want to pursue an MCSE.

MCSA_2013(rgb)_1481_1458MCITP_2013(rgb)_1085_1314

 

 

What was particularly fun about this set of exams was the time limit. I learned in early January that several exams that I needed to write were scheduled for retirement at the end of January. This meant that in order to get my credentials, I had to finish 5 exams in about 4 weeks. I did it by the skin of my teeth, with plenty of late nights and lots of studying.

I even learned something interesting about the Microsoft exam system. It seems that an exam’s retirement date is simply the last day that you can register to write it. You can still actually write it up to 8 weeks out (at least based on Prometric’s scheduling system), but there is no second shot if you fail. Going into this, I didn’t know that, so had to take a gamble that I would be able to write the last exam that I needed, the 70-643, which was scheduled to be retired on January 31. My options were to either write it in Kelowna on January 30, which in January is a dangerous drive from here, or to schedule it for February 4th and risk not being able to write it or get the credit.

I wasn’t willing to risk the Coquihalla in January, so I took the risk and wrote and passed the exam on February 4th. Of course, that wasn’t the end of it. It can take 7 to 10 days for Prometric to report the results to Microsoft and get the exam added to your transcript. So, I waited patiently, if anxiously, until February 20, and still had not received a response. Worried, I sent an email to the appropriate department, who, after checking into it, promised to fix the problem within 3-5 business days.

As of last night, everything has finally registered properly in the portal, so I can breathe a sigh of relief, proudly display my new credentials, and move onto the next challenge.

Adventures in Retrocomputing: Troubleshooting a GS-RAM Plus

One of the outstanding items on my IIGS checklist has a bigger RAM card, because while 4mb is nice, I want to be able to push this thing to its limits. Fortunately, I’ve recently come a bit closer to completing the checklist. I sourced a 6MB Applied Engineering GS-RAM Plus for about $100 – a very reasonable price for a card like that, especially considering that the seller said that the card was tested to be in good working condition.

So, I bought the card, got it home and tried it in my IIGS – no luck. A little bit of research suggested that a GS-RAM plus would not work correctly on a ROM 03 IIGS if it had the 1A version of the GAL instead of the 1B version. This one, of course, had the 1A version. So, I popped it out, pulled my ROM 01 IIGS out from under the desk and tried it on that one. No luck there either. Got the same “checkerboard” screen on both machines, which can apparently indicate RAM or CPU problems, improperly seated chips, or a bad add-in card. Since the machine was working both before I installed the new RAM card, and after I took it out, I figured that it must be the culprit. So, I took a closer look:

m_45738_1As you can see, the chip right above the connector, on the left, has a hole in it. (This is the eBay seller’s original picture, so it must have happened in between the testing and the listing.) That, to me, looked like a likely culprit.

So, I contacted the eBay seller, asking their permission to try and fix the problem myself before returning the card (recycledgoods.com – they were an absolute pleasure to work with) and set out to find a replacement chip. Fortunately, just about every chip on that card is socketed (a nice feature of late 80’s technology), so it would be easy to replace.

The trick, of course, is finding the right one. The hole was right in the middle of the model number on the chip, rendering the middle two characters unreadable – so I had to find another source of information. The product manuals were of no help, being mostly concerned with how to install the card. So, the next best option was to find a picture of the card (which appears to have gone through a couple of revisions) in a high enough resolution that I could read the model number off the chip. I busted out a little Google-fu, and eventually found this image kindly uploaded by the folks over at ReactiveMicro:

GS-RAM Plus - 6 Meg Board ShrunkFortunately, it was a GS-RAM Plus of the correct vintage, and the picture was high enough resolution to make a positive identification of the chip (The full sized picture is huge! 6068px × 2028px and 10MB – it was easy to read the fine print on all of the chips).

Now that I had a model number, the next step was to find out what the chip actually did. Fortunately, it was an off the shelf part (made by Samsung) and Google makes finding datasheets easy. With the datasheet in hand, I was able to determine that it was designed to be used in “implementing buffer registers, I/O ports, bidirectional bus drivers, and working registers.” Or, in other words, it would not contain any custom program logic or configuration, so can be easily replaced.

Fortunately, these are still readily available, so I checked out a few chip suppliers. Unfortunately, they all wanted me to buy in quantity, so it was back to eBay. I tracked one down for $1.78 plus shipping and had it sent out. It got here a few weeks later, arriving last night, and I swapped it out, plugged the card into the IIGS, and everything booted up just as expected.

It’s always nice when the problem ultimately turns out to be simple, even if it takes a bit of Internet spelunking to figure out the details!

Building a Baby Monitor

For our son, we have a video baby monitor mounted over his crib so that we can keep an eye on him while he is sleeping. This way we can tell if he is tossing and turning, or if he is actually asleep. This is something that we have gotten very used to, and perhaps even spoiled by. When we are visiting his Grandparents, for example, and he is supposed to be napping in his playpen in the other room, he often doesn’t want to go down nicely. We can hear him if he cries, but if he is quiet, can’t tell if he is actually asleep. So, we wanted a video monitor that we can take with us when we travel.

His regular monitor is mounted to the wall, so we can’t easily take it with us, and a new monitor is fairly expensive – at least relative to how much we would expect to use it. So, I had to come up with another solution. Being a technical person, I have bins full of old, cast off and left-over parts, including about a half-dozen routers, and a couple IP cameras left over from an old project.

So, I pulled one of the routers, and one of the IP cameras – a TRENDnet TV-IP422W.

TV-IP422W_a1It’s a few years out of date, and only supports Wireless-G, and 640×480 video at 30 FPS, but the price is right. Not to mention, this camera has Pan/Tilt/Zoom, infrared night vision, a microphone, and an iPhone app – perfect for use as a baby monitor!

Unfortunately, while the camera does support ad-hoc wireless networking, it only supports WEP “security”. So, to make sure that we have a reasonably secure wireless network, I need to pack along the router as well. And, since I needed to use the router anyways, I figured that I would just connect the camera using the wired connection. It is significantly quicker, and I have always had trouble getting a decent frame rate from the camera over wireless. It also means that I can connect to the router using Wireless-N instead of Wireless-G.

So, after a bit of grief requiring me to set everything back to factory settings on all the devices, (That’s what happens when you use devices for various projects and just throw them back into the box without resetting them first), I plugged the camera into the router, configured a network with the necessary security settings, and connected up my old iPhone, which will be pressed into service as a monitor station when we travel.

It works great! just goes to show you what you can do when you have a few boxes of old parts lying around and can do a little bit of creative thinking.

EDIT: Forgot to add, you need to get the TRENDNet SecurView Mobile application off iTunes to support these old cameras. The TRENDnet SecurView Pro app only supports the newer ones. Both apps are free though.

Pimping an HP MicroServer

A couple of weeks ago, I got a new toy to play with for the office – an HP ProLiant MicroServer Gen 8! Since then, I’ve been collecting parts and working on getting it ready. It will replace our existing file server, take over virtualization duties, and should be able to handle just about anything else that we throw at it.

c03760147HP released these last summer, in a variety of configurations, and they are perfect for home and small business use. I had looked at the Gen7 version of these previously, and while perfect as a small business server, the weak processor and max of 8 GB of RAM meant that it would not be a very good VM host. This version, however, supports 16GB of RAM, and has an upgradable processor.

I started with the base version of the server available from NewEgg, which has 2 GB of RAM, a Pentium G2020T 2.5GHz (Dual Core Processor), and no hard drives or optical drives. (In hindsight, I should have gone for the Celeron version and saved $70, considering what I wound up doing). A little weak to start with, but an excellent base to build on.

The original plan was to upgrade to 16GB of RAM and add four 3TB drives to to create a 12TB storage pool. The Pentium processor was capable of virtualization, if a little weak, as it only had 2 cores and no hyperthreading, but it would have to do.

So, that’s what I started off with. I added the four 3TB Seagate Red hard drives and went to install Windows Server 2012 R2 Essentials on the server. Unfortunately, I ran into a big problem: The automatic provisioning tool did not want to format the drive as GPT, so Windows couldn’t take advantage of the full 3TB. So, my only option was to install Windows manually. After some reflection and further research, I decided to do what many others had done with this server and picked up an SSD to run as my system drive.

This, of course, caused another problem. HP, in their infinite wisdom, decided to use a 9.5mm super slim optical drive bay instead of the more typical 12.7mm slim optical drive bay. This along with the use of a 4-pin, floppy-like power connector meant that dropping an adapter tray in there was right out. Fortunately, just under the optical drive bay, there was something that plugged into a standard molex connector that could be tapped into, and there was an open SATA port on the motherboard that I could use. This meant that I could use a splitter, a SATA cable, and a zap strap and secure the hard drive in like so:

2014-01-29 19.45.33With the new system drive installed, I pulled the other 4 out so that they would not interfere with the installation and installed Windows. Everything went smoothly, so I shut down the system and popped the other 4 drives back in. After that, the system wouldn’t boot.

It turns out that the MicroServer’s BIOS will not let you specify the boot order of the hard drives, so it will always attempt to boot off the drive in slot 1. Fortunately, however, it also has an internal MicroSD slot (and internal USB port), which is considered by the BIOS to be a USB drive for the purposes of booting. This means that the bootloader can be moved to a flash drive or MicroSD Card, and that set as the first boot option, to keep it off the storage drives. TheBiggerMan over on the HomeServerShow forums put together an excellent tutorial.

With the system booting again, and after disabling the RAID controller, I set up the 3TB drives as a storage pool with parity in Windows, giving me a 12 TB storage array. This left only one thing left to do: upgrade the processor. After purchasing the server, I did some additional reading and learned that the processor can be successfully upgraded to a Xeon E3-1230V2. This removes the limitation of a weak processor, replacing the Dual-Core (non-hyperthreading) 2.5GHz Pentium with a Quad-Core hyperthreading 3.3 GHz Xeon – much better for virtualization!

The processor install went smoothly, and, with that, the build was done, leaving us with a pimped out MicroServer with a 3.3 GHz Xeon Processor, 16GB of RAM, a 12 TB storage array that will survive the failure of one drive, and a 256GB Samsung SSD as a boot drive – a pretty nice upgrade when all is said and done! Right now, it’s sitting under my desk copying files off the old server – soon it will be ready to replace it.

Happy 30th Anniversary to the Macintosh and a new version of FeedSpider

Just a short post today. I plan to have some longer stuff about some work that I did repairing a SystemSaver IIGS and Pimping an HP Microserver up soon.

First, a shoutout to Apple – happy 30th anniversary to the Macintosh. I’m composing this post on a Macbook Pro, and hope to continue using Macs for years to come (as long as they don’t turn into oversized iPads). If you haven’t heard about it already, don’t forget to pick up a copy of the 30th Anniversary Macintosh Icon font that Apple snuck into the 30th anniversary website as an easter egg (via OSXDaily).

Second, there’s a new version of FeedSpider available from the feed at http://feedspider.net/packages. This version adds support for AOL Reader, Feedly’s mixes API, and the Fresh and Archived feeds in TT-RSS. I’ve submitted it to the App Catalog, so it should hopefully be approved before too long.

Moving forward

While I enjoy retrocomputing and developing for dead recently resurrected operating systems, my day job has me working with technology that is significantly more cutting edge, and fun and interesting in it’s own way. While I’ve been working with the tech all the way through, I’ve been bad about keeping up with certifications. So, one of my resolutions for 2014 is to get my certs up to date, from the Windows Server 2003 MCSE and Windows Vista MCITP level to the Windows 8 MCSA and Windows Server 2012 MCSE level.

Fortunately, since I’m already in the system, I just need to study for and write the upgrade exams. It also means that I have to hit the intermediate steps as well. So, as a first step, I wrote and passed the Windows 7 upgrade exam last week, getting me my Windows 7 MCSA. Next up, Windows Server 2008, and a large textbook order from Amazon.

MCSA_2013(rgb)_1481

My company also applied for and received entrance into the Microsoft BizSpark program for startups, on the strength of another project that I am working on, so that’s another thing that I’m excited about and can reveal more about when it’s closer to ready.

BizSpark_Startup

One other thing – after much frustration with the lack of updates to the HP app catalog, I put together a Preware feed and a shiny new website for FeedSpider. So, the latest version (1.1.3) is available for download from feedspider.net. It adds the following features over the current version on the app catalog:

  • Support for BazQux Reader, Feedly, and Tiny Tiny RSS
  • A new JSON parser that won’t choke on certain feeds.
  • The usual set of bugfixes and optimizations.

Spoiled by modern technology – Multiple Monitors

Jeff Atwood over at Coding Horror has been writing about the value of multiple monitors for years, and I have to say that I completely and totally agree with him, especially after the last week. You’ve seen what my desk at work looks like. (Although I’m thinking of getting rid of the 4th monitor. It’s a bit too much). At my previous job, I talked the boss into a dual monitor setup, and was ultimately responsible for getting dual monitor setups for everybody in the office. It’s amazing what a difference it makes for productivity.

Personally, I love the 3 monitor setup. My typical development environment is set up as follows:

  1. Left monitor: Emulator/Debugger/Logging tools, etc.
  2. Middle Monitor: Code – either a collection of text files, or IDE. Depends on what I am working on.
  3. Right Monitor: Reference Materials – usually one or more Firefox windows with a couple of dozen tabs open between them.

This allows me to quickly glance between windows without requiring a mental context switch. This is especially useful when referring to code and logging/debugging info at the same time or to code and reference material – without having to keep switching windows and risk dropping all of the variables that I am juggling in my head.

Over the past week or so for Christmas break, I’ve been home, so I’ve been developing on the laptop. I finished adding support for Tiny Tiny RSS to FeedSpider! (Now if HP would just release the thing to the app catalog…) But, it meant that I was stuck using the laptop’s tiny 17” inch screen. (Yes, I know, it’s a big laptop. But it’s a drastic change from dual 23” monitors.) I tried using Spaces and that is almost as good – at least the best experience that you’re going to get on a single screen. For my environment, it is very useful to be able to tie apps to individual spaces and switch between them with a keystroke. But, you’re still stuck mentally context switching.

So, I’m spoiled. While the laptop works, I don’t think that I could ever go back to a single monitor setup permanently. I’m looking forward to getting back to the office and getting some development done on a real setup.

The Joy of Creation

Nothing is quite as satisfying as finishing a project that you’ve been working on for some time, especially if its been sitting on your desk for a while – important but not urgent. For me, that has been adding Feedly integration to FeedSpider over the last week or so. That is now complete, and I am just waiting for the guys over at Feedly to push my new client id to production so that I can release the app. (As a bonus, I also added support for BazQux Reader. It only took about half an hour thanks to their very Google-like API.)

The biggest challenge was implementing OAuth support (detailed in my last post), but between a few false starts with AOL reader, which requires the same technology, and work piling up at my day job, I got it done. The rest of the project was merely tweaking the app to support Feedly’s API, which is Google-like, but just different enough to create it’s own challenges, especially on the platform that I’m working on. And now, that’s finished too.

While I can’t take credit for building the app from the ground up, (Darrin Holst did an excellent job of architecting it), I have done some significant tinkering under the hood, and am very proud of reworking the API and login/credential layers so that the app can properly and easily handle multiple providers with different requirements. This was aptly demonstrated by how easy is was to integrate BazQux Reader. I just had to drop in a new app API, and add the service to the service list. No other changes required.

One of the things that I love about programming is the feeling of having built something, even if it’s just a bunch of bits. It gives you a certain satisfaction and an energy that can’t be duplicated – make you feel like you can take on the world, and makes you feel ready to go energetically into the next project. That’s something that’s feels like its missing nowadays – and why I intend to keep programming and building computers and systems for many years to come.

Programming via clever hack

I picked up an HP Touchpad shortly after the firesale back in 2011, and have been using it as my daily driver ever since – I even picked up a Pre 3 a little later to replace my aging iPhone 4. Suffice it to say, I’m a big fan of the webOS operating system, even though it’s been a while since it was updated.

Of course, with no new hardware on the horizon, and no official updates coming down the pipe for these devices, (although LG is still working hard on developing Open webOS), developers have left for greener pastures, and apps and services have slowly stopped working. One of the main things that I use my devices for is consuming RSS feeds. Until it was shut down, I used Google reader, and one of the best Google Reader apps for webOS: Feeder. After it shut down, we were kind of in a bind, as many Google Reader alternatives sprang up, but no apps supported them, and the developer had left for greener pastures.

So, as a developer, what am I to do but roll my own? Fortunately, Feeder had been open sourced when the developer finished with it, so I forked it and have been working on “FeedSpider” ever since, adding support for The Old Reader and InoReader. But that’s not the clever hack. Both applications cloned the Google Reader API (mostly) and allowed support for simple authentication using ajax calls, so adding support was pretty easy.

Where the clever hack comes in is when dealing with Feedly. Feedly is the largest of the Google Reader successors, and just opened their API up to the public fairly recently. What makes this challenging is that Feedly uses OAuth for authentication, which webOS does not support very well. Fortunately, somebody else already came up with a clever hack for that, which, in short, captures the OAuth authorization code from the browser when it redirects to redirect uri and allows the app to use it. The library mostly works for Feedly, but not quite.

My contribution to the clever hacks list is two-fold. There is a bug in webOS on tablets that causes it not to pop up the keyboard when using a webview inside an app. (Works fine on phones, and I need to use this method to keep support for old devices) that I had to hack around by manually causing the keyboard to pop up then you go to the Twitter, WordPress and Google OAuth providers. I did that by watching for the urlChanged event and acting accordingly.

The more interesting part of the hack was that Feedly forces you to register your redirect URI with them, and will only let you use the one that you registered. Since I’m currently in sandbox mode, they gave me two options, http://localhost, or urn:ietf:wg:oauth:2.0:oob. Localhost won’t work on a webOS device. The browser will just time out. It never actually tries to do the redirect in a way such that I can catch it. The other one will try to do the redirect, but, it generates a “MIME type not supported error.” Here’s the fun bit – this raises a “Mojo.Event.webViewMimeNotSupported” event, which returns the URL that it is trying to redirect to. So, I catch the event, feed it to the filter and get the OAuth code, allowing me to log in, and we’re in business! (Yes this means that I am making good progress on Feedly support and hope to deliver it as a Christmas gift).

This is one of the fun parts for developing for poorly supported operating systems – there’s always a clever hack that will let you do what you want to do, even if the path is a little roundabout at times.