Sunday, September 28, 2014

More Late Night Ruby Fun

Late Friday/Early Saturday morning, after the wife and kids found solace in sleep, I sat awake in a fevered pitch to patch my laptops and ruby install. I had to install the bash exploit patch, because security!

I also had to take a good stab at compiling the ruby TK library that comes with it.
No luck there though.

I had an adventure when I updated Ruby to Ruby 2.1.3. Basically, I deleted my whole ruby installation and recompiled from source. This left me with no ruby gems. Fortunately, because of my previous late night ruby thinking session, I had a list of gems. It's a slightly dated list, I'd installed the rubyXL gem a couple of night ago, but it is a good start.
I've automated gem installation before, using a simple script to install the gems from a list. I decided to create a couple of stand alone methods and a short script to 1. Create a list of gems currently installed on the system. 2. Install the list of gems (while determining if a gem has already been installed). 3. Determine if any gems in the list I have are missing without installing any new gems.

Objective 1 was easily accomplished. I took my one-liner from the other night and broke it down into a method using a "do... end" block.

I chose to do the method this way because I believe it makes the method more readable. Plus, the rest of the methods in the file are multiline by necessity and it echoes their format.


Objective 2 provided more of a challenge. The original script I wrote installed all the gems listed whether they were already installed or not. Sometimes one gem depends on another for installation, so it gets installed before a gem further up the list. You can still "install" the gem, even if it's already been installed as a dependency, but this adds to the time the script takes to execute. I decided that if I had already installed a gem, whether as a dependency or as part of a previous installation, then I didn't want to reinstall it.


That was a good enough place to stop for the night.
Some cautionary notes:
I'm doing this on Ubuntu 14.04, and you'll see a sudo in there. A unix purist might say that it would be better to su to the superuser and execute without the sudo. I got no problem with that. Understand what you are doing when you use sudo. I execute this script because I wrote it and I know what it says. Don' t do nothin' with sudo you don't understand. That's how things get borked fast.

Also, I don't check for the existence of the gemlist.txt file. I haven't needed that functionality so I haven't created it.

Last night when I got home from work, I watched a little tv while doing laundry,  and then remembered that I'd left my little script here hanging. I still needed a way to check and see if a gem was in the gemlist.txt file.


The hardest part about writing this script was figuring out how to get two arrays created and then subtracting them. For some reason split wasn't behaving as expected. I chalk it up to general tiredness.

At the bottom of this file, I stitched my methods together using an if else ladder.

Everything works!
I know that choice #2 isn't really doing what it says it does. If a gem is already installed on the system, but not in the gemlist file, then it's not on both lists, and it's not installed, nor is it placed in the gemlist file.

Also, I'm sure that there's a better way to do the menu. Perhaps using a hash or something.
One thing this file won't do is install gems that aren't in your install path. Currently I have one gem installed that's built from the gemspec in the gem itself.
One way around this would be to store the gemlist in a csv file or perhaps a spreadsheet, and carry the installation path in there.
Right now though, the file is useful.
I've saved it as a gist on github.

Maybe you can find it useful too!

Sunday, September 21, 2014

"Way to Commit Soldier!"

I'm not a soldier, but that is one of the funnier lines in Madagascar 3.



The pertinent quote begins about 35 seconds in, but this whole scene is what I would call "high comedy".

I do however, want to commit, especially when it comes to committing more code that is. For 13 of the last 14 days, I've made at least one commit to projects I'm working on under Github. I want better programming skills. I believe that the best way to become a better programmer is to read code every day, and write code every day. Sometimes, the code I write isn't very complicated. Saturday I restructured the way I had some test steps written in a code library that will serve as the math problem generation engine for an application I'm developing for my kids. It wasn't very complicated, didn't change the world, but my habits were shaped into a design where such a refactor becomes automatic in the next code library. Other projects I've been working on are an effort to track student reading habits that reports out to a spreadsheet, and a ruby gem that serves as a wrapper for the EBird API.
I'm practicing and learning several different things at once. In my own code libraries, I'm practicing how to develop using the  "Red, Green, Refactor" methodology of cucumber and RSpec. I'm also learning how to write tests that make sense for code libraries that already exist, and I'm learning how to upgrade a library with the latest implementation of that library's methods and objects.
In short, I'm having fun, lots of challenging fun. It's the sort of fun that leads to more and better opportunities for employment and personal development. Committing every day reminds me of what I love about programming, each solution to a program is a unique implementation of patterns, and I love those patterns. It's like the rotunda in Beethoven's works, not the same, but the same is there when he gets around to it. The Bible says in Ecclesiastes chapter 5:

  18 Behold, what I have seen to be good and fitting is to eat and drink and find enjoyment in all the toil with which one toils under the sun the few days of his life that God has given him, for this is his lot.  19 Everyone also to whom God has given wealth and possessions and power to enjoy them, and to accept his lot and rejoice in his toil—this is the gift of God.
 I hope your work helps you find enjoyment. I know what little bit of programming I do at work helps me enjoy my job. I know it encourages me to seek out further skill so I can advance and enjoy it even more. Committing code every day shows me the enjoyment of my toil, and I believe there's nothing better you can do than enjoy whatever it is you are doing.

Saturday, September 6, 2014

Some Quick Late Night Ruby Fun

I should be asleep, but I'm not. Instead I'm up hacking around with ruby, taking some online classes, and generally having a good time.
In an effort to train myself in one discipline, I'm taking some online classes for ruby/ruby on rails/webdevelopment.

The kids and wife have all gone to bed, so I went through a course level about the ActiveSupport library, and started playing around in IRB with what I had learned. Eventually I found myself exercising one of my favorite ruby "koans" : writing a list of the gems I have installed on my computer into a text file. In the past I wrote this as a script that I would execute shortly before system updates or new ruby builds, so I can quickly install the ruby gems I use.

One of the things I've always wanted to do is "get it on one line" of ruby code. I started by executing the following in irb:

`gem list`

The backticks around gem list tell the interpreter "Go to your native environment (bash in this case) and execute the command gem list". The result is  a list of gems, including all the current versions installed, listed like so:

"twitter (5.11.0, 5.10.0, 5.9.0)\ntzinfo (1.2.2, 1.2.1, 1.1.0)\nuglifier (2.5.3, 2.5.1, 2.5.0)\nwatchr (0.7)\nxpath (2.0.0)\nyajl-ruby (1.2.1)\nzip (2.0.2)\n"

That's cool, but I don't necessarily need to know the versions. So the next step was to remove the versions from gems. I needed a regex and gsub to do that.

`gem list`.gsub(/\s[(].*[)]/, "")

this means, "Give me a string where we substitute everything in between two sets of parentheses including the parentheses and the space in front of the opening parenthesis, with an empty string."
That gave me something that looked like:

"twitter\ntzinfo\nuglifier\nwatchr\nxpath\nyajl-ruby\nzip\n"

This gave me a single string of the list of gems installed. I then rediscovered how to open a file and properly write to the file. Several iterations of using File.open do blocks later, I decide to go ahead and use the script below to write the file all in one line:

File.open("gemlist.txt", "w") {|file| file.write `gem list`.gsub(/\s[(].*[)]/, "")}
Now when I use a text editor to view gemlist.txt I see this:

twitter
tzinfo
uglifier
watchr
xpath
yajl-ruby
zip

And more importantly, I can use ruby to parse the file, and reload the gems I need to reinstall next time I build ruby!

The end!

Saturday, August 23, 2014

Potentially Problematic Plants

True Story:
As a young confident college freshman, I made my first genuinely certifiably stupid mistake with plant identification. Pride was my downfall. I thought that since I'd studied nature from an early age, been a card carrying member of the Audubon Society since I was 9, that I was pretty well qualified to know what was what when it came to plants.

Yeah, not so much.

Turns out that the central Florida region  where I was going to college, sits on the border between subtropical and temperate climates. This means there is a staggering variety of plants. Plus, many times, plants themselves have a wide variety of appearances, for instance; check out all the different ways that "Virginia Snakeroot" can present itself in FL. I find it hard to believe that all of these plants are from the same species, but then again, don't we show the same sort of variety within the human species? Also you have look alike plants that are not related. Some more than others, especially when it comes to things like say, for instance, castor beans and marijuana.

There I was, innocent, trusting, confident and eager to prove myself, on the way back to my apartment from a shopping trip in St Cloud, when I caught a glimpse of a plant out of the corner of my eye: was that weed?
Murrrrwana, Mary Jane,  Cush, Endo, the Wacky Tobacky.
Growing on the side of the road.
So I thought.
I pulled off the side on highway 192 and backed up. I must confess, I don't have much experience with Cannabis, never have used the stuff, never grown it, and I generally avoid people who do. Rule #1 in my life is "Don't invite The Man into your life", and one of the quickest ways to invite the man into your life is to smoke something The Man says "Don't smoke".
I called the Osceola county sheriff non emergency line and they sent someone right over. I waited on the embankment where the Florida Turnpike crosses over highway 192. The deputy arrived, and I said "I think this is weed"
She says to me "It's not, it's castor bean"
Well that was embarrassing. 
Since then I've learned the clear difference between weed and castor bean.
Any time I find myself wondering, "what is it?" I immediately remember this incident from my college years, and the lesson I learned, take time to know what you see.
Recently, in my own back yard, I had a bit of identification drama while preparing the yard for mowing. Two of my children know the Stinging Nettle plant from experience, and along the back fence a plant grows, and it has a very suspicious appearance.
Don't get me wrong, I'm a big fan of Urtica species, they are among the most useful and tasty plants to have around, I just wanted to make sure the kids knew what was what and where. I picked the grass and weeds from around the plant, being careful not to touch, then took a picture:
Note Stem hairs and on leave

top of the plant

over all plant structure.
The only picture I have of a local Urtica is very blurry, I didn't have the Canon to shoot it with so I used the potato camera on the phone. At the time, I had a kid who was crying because it stung her, so I just pointed, clicked, and then began first aid.

I decided that the best way to id this plant was to go ahead and let it sting me. After brushing against it, it was clear, no sting, no pain at all. What else could it be?
I picked the leaf and crushed it up, no noticable smell, but the closest thing I've seen that doesn't sting is lantana. I picked off a woody part of the plant, and aha! there's that lantana smell!
So it is lantana, probably planted by a mockingbird.

Sunday, June 22, 2014

On That Night

On the night He was betrayed, Jesus ate with His Disciples.
On the night He was betrayed, He washed their feet.
He talked to them.
He scared them.
After giving them the cup and the loaf, he spoke some more to them.
John says that he told them very specifically the reason why they had no reason for fear:
John 16:33 I have said these things to you, that in me you may have peace. In the world you will have tribulation. But take heart; I have overcome the world.
He didn't tell them He was going away to cause them fear, He told them because He went to prepare a place for them. He didn't tell them that they would scatter at His arrest because He wanted to shame them. He wanted them to understand, Jesus came to do God's will, and God's will would be done. In the world we certainly have trouble.
Sin traps us.
We forget who we are.
People let us down.
We walk through the world, and sometimes it seems we are unforgivable because of what we've seen or done.
Sometimes it seems like the world wins every time evil wins. 
Take heart. Jesus overcomes this world, and through this gathering together to partake of the meal He gave us, we remind ourselves that Jesus always overcomes the world.


Tuesday, June 3, 2014

Definately Spartan, but a Sprint?

Whelp,
managed to QRV on 20m for the June Spartan Sprint.
I can hardly believe it!

KG4GVL is QRV!


Working nights is a pain for a lot of reasons, there's stress of not being home when my kids are  home, the stress of not being available for social activities, no time for radio when everyone else is doing things like sprints, or nets. There's stuff during the day too, and I do QRV when I can, but there's not the Spartan Sprints, or NAQCC sprints. There's pluses too, like how I don't have to send my kids to daycare, and the pay is good, and the company I work for is a good company to work for, I'm just looking for the sweetspot where I can have my cake, and eat it too.

Enough bellyaching, let's talk SP!

I took a lot of gear for this operation, too much really, I wanted to use my St Louis Vertical, and when I got to work, I realized that I was missing the jumper that goes from my tuner to my radio. Fortunately, I brought a couple of end fed antennas, and since I wanted to try 20m (20 had been good to me during the WPX contest at night), I decided to put up the homebrew end fed for 20m.
Setup went well, and baring any production issues, I eagerly awaited an opportunity to clock out for "electric lunch".

Close to 21:30 local time (01:30 UTC) I realized that production issues would prevent me from taking a full lunch, but that I needed a break, so I took 10 minutes to go outside for an "electric coffee break". I turned the SW-20 on, spun the dial, and best guessed where 14.060 is. I've got it pretty well pegged on this radio, and it wasn't long before I heard one VERY STRONG signal on 14MHz. It was W3KC, in MD running 5w! The end fed was mostly oriented on a slant, with the bottom end in the North West, and the top end in the South East. The far end was bent over a tree branch, so I don't know how I managed it, other than the antenna was mostly straight, ran to a fairly decent height, and had about a 30 degree pitch or so.
That was the only contact I managed. I did hear some TX station, WA5??? but couldn't grab him, QRN is fierce in the work parking lot.
I went back inside happy to make one QSO.
73,
GB Hoyt

Sunday, May 25, 2014

7276


Yep,
More numbers.
Ham radio club members are obsessed with trading numbers with each other. Every club has numbers it seems, even some of the ones of who don't have dues or officers!
0
here's some of mine:
QRPARCI (the first number I ever got) 10774
Flying Pigs: 2359
SKCC: 6161
4SQRP: 473
SOUTHCARS: 10360
QRP-L Zombie: 1059

and most recently:

the NAQCC : 7276, the number featured as the title of this blog.

On Wednesday night, May 21 (22 May 0200 UTC) I decided to get a lil QRV in an effort to practice my rapid radio deployment skills.
Here's a short video I made when I got to work:




I moved the vehicle once the parking lot cleared out some, and stretched my antenna up and across the parking lot. It was about 6 inches higher than my upstretched hand at the middle. 10-15 feet at the highest. Not exactly the best placement, but I know from experience that this height will get me a good match on 40m, so a tuner isn't necessary.  There's a decent number of QRP operators between FL and GA so I figured someone would hear me if I could hear them.

When I'm at work, I don't really have much time to operate. I get a 15 minute break and a 30 minute lunch break. During my 15min break, I worked like mad to get the antenna fully deployed, and then started calling CQ just to see if I could get a reverse beacon spot, and figure out where in the band I was transmitting. Lo and behold, after the second round of calling CQ, I get a station come back to me! It was Jim, W3GYM, just down the road in "The Villages" FL. We had a short QSO, then I had to head back inside to work.

I copied Jim! W3GYM.




About forty five minutes after my QSO with Jim, things at the work front slowed down enough so that I felt comfortable clocking out and taking a "lunch break". The action began when I plugged the radio in, and tuned up and down the band.

Knowing where you are with "The Killer Watt Radio" is an exercise is best-guestimation. I know that at the bottom of the tuning range, I'm around 7005 KHz, and the top, 7070KHz. I had plans on building a freq mite, still might, but not sure if I want to do that, or just do something with a digital display. I go back and forth. Probably should do a freq mite. When Dave retired the Small Wonder Labs business, he gave the design to the 4SQRP club and they gave me a number, so I should support them.

I tuned up the band, trying to guess where 7030 was, and then down the band, trying to guess the same. Finally, a lound "CQ NA" came on the air, and I worked K4BAI. He's not a stranger in my log, and it is always a pleasure to work him. I tuned around a little more, and heard some more CQ's, but QSB and QRN fought to keep me from catching the whole call. Finally, I copied N5GW, and added DX to the log. Hey, when your antenna is between 8 and 15 feet off the ground, outside of your home call area is DX! I tried to call CQ NA on a clear frequency between these two FB OP, but no luck, only two contacts for me. I took the antenna down and packed up my station when I clocked out to go home that night.

key on my leg, gettin' 'er done!

The important thing about this little excursion was not that I scored well, or that I have a new antenna to share about, or even that I now have all kinds of nice numbers to trade with other people. Happily I got on the air, and made some contacts. Didn't need to make many, just needed to have one.
Mission accomplished.
Now to find another club I can join who will give me a number that I can trade...