Wednesday, May 25, 2016

Android: WiFi ADB



It's great being able to debug code on a real live Android device. Typically, though, your device needs to be tethered to your host computer. Now ADB has a facility to connect wirelessly, so you can debug code on your device without a physical connection to it. To do this, you need to know the IP address of the device, and follow these steps:
  1. Connect the device to your computer via USB; make sure ADB can see it (ie, make sure it shows up in the command 'adb devices').
  2. Enter the command 'adb tcpip 5037'
  3. Enter the command 'adb connect <ip address>:5037'
You're now free to disconnect your device. Go ahead and disconnect the device, and you'll still see it in the response to 'adb devices', and you can use all the other adb commands as well (shell, push/pull, etc).

Here's a Ruby script that'll do all this for you:

wifiadb.rb
# get the IP address of the device
if ARGV.length == 0
port = 5037
print "PORT not specified: defaulting to 5037\n"
else
port = ARGV[0]
end
wlan0 = `adb shell netcfg | find /i "wlan0"`[/(\d{1,3}\.){3}\d{1,3}/]
printf "The device's IP address is " + wlan0 + "\n"
system("adb tcpip " + port.to_s)
system("adb connect " + wlan0 + ":" + port.to_s)


Now all you need to do is run wifiadb.rb. It'll figure out your device's IP address and run the necessary commands.

For more information:
Android Debug Bridge: https://developer.android.com/studio/command-line/adb.html
Ruby: https://www.ruby-lang.org/en/

Wednesday, February 27, 2013

Mothers PowerBall 4Lights Kit: A Review


The headlights lenses on my wife's car (2003 Toyota Camry) were looking pretty dull and gray.  It makes sense that clear headlights are better for safety and visibility, and clear headlights look better than dull headlights as well.  My mechanic offers a headlight restoration service, and I knew I could buy new lenses for about $50 each. I've seen headlight restoration kits for sale, but I would wonder "do they really work?" and not want to risk the twenty bucks or so to find out. I read a review of restoration kits on Consumer Reports, and it seemed that for the most part these kits will work well enough, in other words, they will to some extent make an improvement to headlight lenses.

I decided to go ahead and try out the Mothers' Powerball 4Lights Headlight Restoration Kit, which I bought for a little over $20 at our local Walmart.  Here's what I found.

The bottom line: take a look at the before and after pictures. I'm pretty happy with the outcome.

Before 4Lights
The kit I bought included liquid polish, a polishing cloth, the buffer bit for your power drill, and for use in extreme cases, sanding pads. Even though I thought my lenses were in fairly bad shape, I wound up not having to use the sanding pads.

I started by opening the hood of the car, so that polish wouldn't get splattered all over the hood of the car, and I taped off the area around the lenses. It was cool outside that day, so I happened to be wearing a jacket. You definitely want to use safety glasses too, because the polish will get splattered all over the place, especially as you first get the hang of running the drill.

After 4Lights
I basically followed the instructions: clean the lens, install the buffer bit on your drill, put a blob of polish on the it, and get to work. Try to keep the bit speed down to minimize splatter, and just go back and forth with the polisher over the lens, and add a little more polish every now and again. It took me about 20-30 minutes per lens. Let dry for a few minutes, and then polish them with the supplied cloth.

I like that everything I needed was included (except the drill, of course). I like that there is enough polish that I could do a second vehicle if I needed.

I'm happy with the Powerball 4Lights Restoration Kit. I think you will be to.

Tuesday, December 4, 2012

The Motorcycle Bug

This is what I did when I got bit by the motorcycle bug:

1.  I read a lot.  There are a bunch of good books at the local library.  I read a couple of "Motorcycle for Dummies"-type books, as well as a series I really liked called Proficient Motorcycling by David Hough (there are two books in that series.)

2.  I took the MSF class.  I found about rider education from www.msf-usa.org .  They've got a lot of good reading material there too.  I signed up for the course and I took the class at our local community college. There are several "types" of class, and I took the Beginner RiderCourse.  When you [successfully] complete the class, you get a card, which might be worth an insurance discount to you.  The class covers the types of situations you need to be aware of, and how to deal with them.


The class cost $235 (when I took it), and it was well worth it.  I had zero experience to speak of, and I want to learn things the right way.  It's a three day course: Friday evening, and all day Saturday and Sunday.  There are some videos to watch, book work, and discussion.  The fun part is riding.  They supply small (250cc range) motorcycles that you use to develop skills, and practice driving around the range (a parking lot).  You'll practice quick stops, swerves, etc.  You don't venture out into traffic. 

To take the class, you'll need gloves, a DOT-approved helmet, something long-sleeved, and over-the-ankle footwear. This particular class offered helmets to borrow, but in my group, everyone had his own gear. 

3.  I got my gear.  I bought riding gloves, a full head helmet, a riding jacket.  I wear all the gear all the time. My jacket is a Tourmaster Intake II. It is a mesh jacket, with a water/wind liner and a thermal liner.  During the summer, people ask "don't you get hot in that?"  No more so than a car without air conditioning.

4.  I ask questions.  There are a couple of riders at my office here, and they are a great resource; I've still got a lot to learn.  There are good on-line motorcycle rider communities, where you can continue learning. 

5.  I practice.  When I first got my bike, I had the previous owner drive it to my house.  The first couple of days all I did was drive it around the block a few times.  I learned that it's tough to start of from an incline, for example :-)  After I felt more comfortable I ventured out on the road.  I try to ride as much as I can.  The experts recommend you continue to take some time driving around a parking lot to get better at handling, continue practicing quick stops, swerves, etc.

6.  I got my full license.  My state requires a rider to have at minimum a Motorcycle Learner's Permit; the basic restriction of which is that one cannot ride after dark.  Here in SC, one can get a permit after passing a written test.  One of the findings from the Hurt Report is that having a full license reduces your chances of being in an accident.  I suppose it's because if you've shown that you can handle the bike good enough for the test, you can handle it good enough on the roads to keep out of trouble.  The riding test here consists of several maneuvers. I practiced for a couple of months, and then passed the riding test. In some states, successfully completing the MSF Intermediate RiderCourse allows you to waive the riding test at your local DMV. Of course, you'll have to check for yourself.


7.  Of course, I bought a motorcycle!  I bought a lightly-used 2006 Honda Shadow VLX. It's a 600-cc bike, and reviewed very well as a fine "beginner bike." What I like about it is that it's small enough for me to control, but large enough to put on the interstate without being blown all about.  It's a fantastic bike. 

Tuesday, October 30, 2012

Hacked about #schacked

I'm hacked about #schacked.

Last Friday, October 26, news broke that the South Carolina Department of Revenue was hacked, and a few million Social Security Numbers, and a few hundred thousand credit and debit card numbers, were exposed to hackers. The breach affects residents who filed tax returns going back for almost fifteen years. 15 YEARS!

There's a twitter hashtag, #schacked, for people wanting to follow the events.

I'm irritated about several things:

1. That it happened. Not only that it happened, but that it has been happening. Apparently, there have been numerous system breaches going on for months.

2. The bad guys had a 16-day head start. The state admits that it knew about the breach sixteen days before informing the public.

3. The costs to the state (ie, taxpayers) is "capped" at $12 million dollars. Presumably this does not include the additional cost due to the head start the bad guys had. The $12M divided by the 4.5M population works out to a little less than $3 per person, if that makes you feel any better.

4. SC's helpful suggestions. These include getting a free activation code for Experian's ProtectMyID alert. It took a day or two for me to get through to get the code. It was a laughably simple code, and there's not a clear reason why the code could not have been posted online, instead of forcing millions of people to call a toll-free number. And now to protect my information, I have to enter it into yet another system.

5. The blame game. When the news of the breach broke, residents had to call a toll-free telephone number to get the code. For me, I got busy signals until Saturday afternoon, at which time I got a recording which provided the code. The code did not work for me until Monday. With potentially millions of people affected by this, one would naturally expect wait times and busy signals. But at today's press conference the governor implied it wasn't the millions of affected residents causing the busy signals, it was the relative handful of journalists trying to cover the story. Additionally, the governor says that the social security numbers were not encrypted because the "industry standard" is that those numbers aren't encrypted.

News
http://www2.wspa.com/news/2012/oct/30/26/experts-say-credit-monitoring-being-provded-sc-wil-ar-4836674/
http://www.dispatch.com/content/stories/national_world/2012/10/30/hack-has-s-c--folks-open-to-id-theft.html
http://www.postandcourier.com/article/20121030/PC16/121039950/haley-hacking-8220-absolutley-bizarre-8221-state-costs-for-monitoring-capped-at-12-million&source=RSS

Friday, October 12, 2012

Stellarium and the Barlow Lens

In Stargazing on a cloudy night I wrote about configuring Stellarium's Oculars plugin so that Stellarium can show you what you'll see through your very own telescope. With the Oculars plugin you describe your telescope as well as your eyepieces.

What about the Barlow lens?  Essentially, a Barlow lens is a device which increases the focal length of your telescope, thereby increasing the magnification of the image in the eyepiece. In other words, an eyepiece which gives you 50x without a Barlow will give you 100x with a 2x Barlow.

I have a 3x Barlow lens to go along with my scope: the Orion SkyScanner 100mm.  Its focal length is 400mm, so when using the 3x Barlow with an eyepiece, it's as if my focal length is 1200mm. To use Stellarium's Oculars plugin with this particular setup, I just added a second telescope with the same parameters as the original telescope, but with the longer focal length. So in my case, I now have two telescopes, the SkyScanner 100, and the SkyScanner w 3x. 

I went out on the evening of October 11, and drew a sketch of Albireo, using the Barlow with a 10mm eyepiece:



Here's a screenshot from Stellarium with the same setup:

It's pretty cool how Stellarium can show you what you'll see when looking through your own scope.  

Friday, August 24, 2012

Stargazing on a Cloudy Night


Over the last year or so I've become interested in backyard astronomy. Growing up in south Florida, I was always fascinated by the rocket launches out of Cape Canaveral.  I remember having one of those cheap "department store" refracting telescopes, but it wasn't worth using for anything more than looking at the moon.

So last year I started reading more about astronomy, and even wound up buying a nice budget-friendly telescope, the Orion SkyScanner 100mm. It's a right nice little scope, and something I enjoy doing is going out on a clear night and taking a look at what's out there. When I head out, I tell my wife I'm going to go listen to "the heavens declare the glory of God." (Psalm 19:1)

The scope comes with a version of "Starry Night," a software planetarium package. It appears to be well regarded, but I run Ubuntu Linux on the machines at home.  For a while I tried to get Starry Night to run under WINE, but to no avail.  So I went hunting for planetarium software which runs under Linux.  I found Stellarium which I think is a fantastic package. It is open-source, and available for Linux, Mac, and Windows. 

One of the neat things about planetarium software is that if it knows where you are, it can tell you what your night sky looks like. So go ahead and download Stellarium, and configure it for your particular location.  Take a look at a constellation or two, and then go outside to see if you can find them for real.

Stellarium includes a number of "plugins" which add to its functionality. I found that with the "Oculars" plugin, I can configure Stellarium to show the sky exactly as it appears through my telescope. I'm going to show you how to do that yourself; it's a fairly straightforward process.  But before you begin, you are going to need to collection a little information:

  • What's the aperture and focal length of your telescope?  Mine is 100mm, focal length 400mm
  • For each eyepiece, what is its focal length and apparent field of view (aFOV)?  I'm going to define two eyepieces, one 10mm eyepiece (aFOV=52) and one 20mm eyepiece (aFOV=52 as well).  You can find aFOV information by looking at the technical specifications for the eyepiece. You can find this at the manufacturer's website, or you can use one of the many online calculators.  For example under the Specs tab here you will see the focal length and apparent field of view for the 10mm eyepiece I have.

Now let's begin
  1. Enable the plugin. In Stellarium, open the Configuration window and select the Plugins tab.  One of the plugins should be titled "Oculars."  Feel free to email a thank you note to its author, Timothy Reaves.  Down at Options, click "Load at startup," then click "Configure"
  2. Add your telescope.  Click the Telescopes tab. You will see a couple of predefined telescopes. Click the Add button. You'll see a new entry called "My Telescope."  Change its name to something you might prefer, and then enter its focal length and diameter.  For my telescope, the focal length is 400, and diameter is 100. My particular telescope is a reflector, so I need to click "Horizontal Flip" and "Vertical Flip" so the image Stellarium presents is like what I'll actually see.
  3. Add your eyepieces. Click the Eyepieces tab. Click the Add button. You'll see a new entry called "My Ocular." Change its name so something you'd prefer, like perhaps "Orion 10mm". Enter the parameters you found for the ocular, ie, the aFOV and focal length.
  4. Test.  Click on any particular target in the sky, then select Ocular View (Ctrl-O [O as in Ocular]).  Once in Ocular View, to select your particular telescope, click Alt-O, scroll to "Select telescope," and select the telescope you want to use. Do the same for the ocular. What you see in now should be pretty much like what you see with this particular telescope/eyepiece combination outside.  Stellarium will also show the view parameters in the upper left of the screen.

I use Stellarium configured for my telescope to help me plan star-hopping to various targets. I can "aim" Stellarium at my starting point, then switch to ocular mode, then along with a star atlas star-hop to my target location. Knowing what my waypoints will look like in Stellarium helps me know what they are going to look like through the telescope outside. And I can stargaze anytime I want, even on a cloudy night.

Monday, August 13, 2012

Adobe Flash Woes

My wife's computer recently started giving her grief. The browser had started to report that "the plugin could not be loaded" on Flash-using sites (ie, Facebook, and most of our 8-year-old daughter's play sites). It is a somewhat elderly machine (AMD Athlon XP 2600+), but it had been running Ubuntu 10.04 LTS (Lynx) nicely for quite some time. I've used Firefox for years, and that was the browser running on that machine too.

I had heard said that Adobe was no longer going to provide Flash for Linux (outside of Chrome), and so I thought I'd try two Flash alternatives: Lightspark and Gnash. The very nice Flash-Aid Firefox plugin made this attempt very straightfoward. However, although the plugins loaded and reported their version numbers to Adobe's test site (http://www.adobe.com/software/flash/about), Facebook said I needed to upgrade the plugin. So the latest Adobe plugin didn't work, and the alternatives worked, but they were too far back.

Let's try a new browser. I read that Google Chrome had "integrated" Flash support, so I thought I could just download and go. So I downloaded Chrome, but the flash plugin still would not run.

Sigh. I suppose it's time to upgrade the OS. I had gotten out of the habit of upgrading that particular machine because,

1. If it ain't broke don't fix it,
2. I had had a pretty messy upgrade experience once with that particular machine.
3. And now that I was several revs back, I'd have to step through each new version to get up-to-date.

So after each version upgrade, I'd try Firefox and Chrome (and Chromium too) to see whether Flash sites would load. 10.10 -- Nope. 11.04 -- Nope. 11.10 -- Nope.

I started to wonder whether I had some kind of incompatibility with my card (an old nVidia GeForce 5200 [I told you this machine was old]) and Flash. I saw references to weird behavior (like the Smurf effect), but none of the fixes for those issues addressed the problem I was having.

In one of the debian forums, there's a thread titled "New Bug: Google Chrome - Couldn't initliaze plug-in" The originator was describing something very similar to what I'm experiencing. The hero of that post asked whether his CPU supported SSE2 instructions. Sure enough

cat /proc/cpuinfo | grep flags 

 implied that my CPU doesn't. The poster also said he thought the 11.1.102.63 didn't have the problem which was affecting the latest version. I downloaded the archive, pulled out libflashplayer.so, and put it into /opt/google/chrome/plugins.

That solved the problem!