2014-04-15

Let me tell you about my internet service provider. Because of my location, my only options for "hightspeed" internet is HughesNet, a satellite based internet service provider. The price is high, the service is lackluster, the speed is low, and the monthly data cap is wretched. I have a 5 Gigabyte monthly allowance that can be used from 8AM til 2AM and another 5 Gigabyte allowance that can be used from 2AM - 8AM. Yea, most mobile phone data plans are just as good.

Oh yea, and that data allowance includes both download data and upload data.

As soon as my monthly allowance is consumed, my network is throttled down to dialup speed, which makes using the contemporary internet quite problematic.

Since I didn't want to have to endure that crap, I needed a way to decently keep track of my data usage. Unfortunately, all of the resources provided by HughesNet for tracking data usage are lousy and don't meet my needs as a user of their service. Fortunately HughesNet's modem provides some semi-accurate data that I can parse and display in a way of my choosing.

So with my trusty text editor in hand, I used a bit of Ruby to scrap data from the modem and make a rough projection to determine if the data usage rate so far this month will result in running out of data.

Enter the Ruby

#!/usr/bin/env ruby

#------------------------------------
# What is Your Data Cap in Gigabytes?
#-------------------------------------
data_cap_in_gigabytes 5

#we will need to open a url
require 'open-uri'

#convert a gigabyte number to bytes
def gigabyte_to_bytes(i)
  1000000000 #that is how they determine a Gig
end

#what is the total allowance in bytes?
ALLOWANCE gigabyte_to_bytes(data_cap_in_gigabytes)

#what is the URL we need to scrape?
URL "http://192.168.0.1/cgi-bin/index.cgi?Command=11"

#read the text from the URL
text open(URL).read()

####use some sloppy regex to get important data
#get the gigs remaining
match_data text.match(/(?<remaining>[0-9\.]*) GB<br>Remain </)
remaining_bytes gigabyte_to_bytesmatch_data['remaining'].to_f )

#get the sleepytime gigs remaining
match_data text.match(/(?<remaining>[0-9\.]*) GB<br>Remain</)
remaining_bonus_bytes gigabyte_to_bytesmatch_data['remaining'].to_f )

#find the date of the next reset
match_data text.match(/Resets in (?<days>[0-9]*) days, (?<hours>[0-9]*) hr and (?<min>[0-9]*) min/)
offset match_data['days'].to_i*86400 match_data['hours'].to_i*3600 match_data['min'].to_i*60
NOW Time.now()
next_reset_date NOW offset

#when was the reset date? A month before the next reset date
next_reset_date.year
next_reset_date.month
#what month was previous?
-=1
12 if == 0
next_reset_date.day
next_reset_date.hour
next_reset_date.min
reset_date Time.localymdhM)

#how much time has elapsed?
elapsed_time NOW reset_date

#how fast is the data being used?
used_data ALLOWANCE remaining_bytes
data_per_second used_data elapsed_time

#how many seconds will it take to use the remaining data?
seconds_to_use_remaining_data remaining_bytes data_per_second

#when will the shitty throttling occur?
throttle_date NOW+seconds_to_use_remaining_data
puts "---- Projected Throttling ----"
puts "Next Reset Date: #{next_reset_date}"
puts "Throttling Date: #{throttle_date}"

#what is the difference in seconds?
difference_in_seconds next_reset_date throttle_date
#is the throttle date before the next reset?
throttled next_reset_date throttle_date
seconds difference_in_seconds.abs
#convert the difference is seconds to days, hours, minutes, seconds
days = (seconds 86400).to_i
seconds -= days 86400
hours  = (seconds 3600).to_i
seconds -= hours 3600
minutes = (seconds 60).to_i
seconds -= minutes 60
#print the difference in d h m format
if throttled
  puts "Projected throttling in %d days, %d hours, %d Minutes" % [dayshoursminutes]
else
  puts "Throttling is not project at this time"
end
puts ""

For easier copy/paste the script is also available at http://hoof.jezra.net/snip/oj.

This script was written to use the less-than-decent html output of the t1100 HughesNet modem and may or may not work on other modems. Your mileage may vary.

Now quit reading, and go solve a problem that needs solving.

Comments
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
0 plus 2
Answer:
required
2014-04-11

Having recently been gifted an HTC desire HD for some code testing, I decided to switch from my atrocious Firefox Device and start using the Desire as my daily driver. Unfortunately, I found the physical buttons: volume up, volume down, and power, to be far too flush with the phone's case and I have little to no tactile way of knowing when I was pressing a button. Here is my simple fix.

The Problem

Although the volume up and down buttons are visibly different from the body of the phone, I tend to use those buttons the most when I am listening to music in my car and I don't want to have to look down to find the buttons.

Oh, is that a bottle of super glue?

The Simple Fix

Yes, indeed that was a bottle of super glue. As a fix, I places two very small drops of super glue on the volume buttons.

Once the drops had dried, It was (and still is) quite easy for me to determine where the buttons are simply by touching the device. Sweet, now I can keep my eyes on the road as I rock out.

Now quite reading, and go rock out.

Comments
2014-04-12 Alison Chaiken:
Here's my usual solution to that problem:

http://www.unitednuclear.com/index.php?main_page=product_info&cPath=28_45&products_id=384

If a bump is good, isn't a glow-in-the-dark bump better?
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
2 minus 0
Answer:
required
2014-02-26

Someone once said that I was 'addicted to noise', while I don't necessarily agree with the 'noise' part, I certainly like to listen to music... all the time. With that in mind, you can understand my desire to have a sweet sweet music player in my workshop, and now I have one (sort of). Say hello to Bonechop!

What's in a name?

Bonechop is a Beaglebone Black computer running Debian Linux and using MuttonChop for network controlled audio playing, and the whole system is put in an old AM Radio. Since the Beaglebone Black doesn't have audio out capabilities, I opted to use a hella cheapo USB audio card; and it works wonderfully.

Gather Some Supplies

Here we have:

  • a nice big late 50s or early 60s Montgomery Ward Airline AM radio gifted by a friend (thanks buddy!)
  • a screw driver
  • some awesome glue
  • white gorilla tape
  • the beaglebone (and a USB audio card)
  • a bunch of little wood screws
  • a 1" x 1" piece of poplar to use a stand offs

OK, the Poplar Didn't Work

aside from having a hell of a time just cutting the poplar into little pieces, every piece I tried to put a screw into would split before the computer was securely fastened. bummer.

Fortunately, there were some pine shims in the workshop that were left over from when my buddy framed in a door. Thanks buddy!

Here we have 3 small pieces of pine secured to the Beaglebone with little wood screws. I would have used 4 pieces, but the 4th hole is located near the micro-SD card slot and my blocky stand-off wouldn't fit properly. That's OK because 3 points make a plane.

A New Adhesive!

This is the first time I've used Weldbond, and I must say that I'm quite pleased with the results. After tipping the radio onto its side, the 3 stand-offs were glued to the body of the radio.

The next day, I took my coffee picture with the finished product.

How about a video?

As an entry to a contest by Adafruit Industries, I made a video of Bonechop playing some music.

This project is definitely not finished, but it is in a damn fine usable state. Now I need to go find some switches to wire into the GPIO.

Comments
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
7 minus 7
Answer:
required
subscribe
 
2014
2013
2012
2011
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008