Global Cache` Ruby Utility

Posted: August 26, 2013 by admin in Blog
Tags: , , ,

I’ve written a locator utility for Global Cache` gateway adapters. This utility will scan your network and report the first available Global Cache` unit that it can locate. The report includes IP Address, Model Name, Firmware Version, and Configuration URL. Here is a sample of the output:

C:\Users\Ryan\gcfinder>ruby gcfinder.rb
IP Address: 192.168.1.137
Configuration URL: http://192.168.1.137
Model: iTachWF2IR
Mac Address: 000C1E02C17A
Firmware Version: 710-1001-05

The code is on GitHub at https://github.com/RPMinihan/GCFinder

You can find out more about Global Cache` network adapters at http://www.globalcache.com/

Enjoy!

GPS Fix for Android Phones

Posted: April 30, 2012 by admin in Blog

I use the GPS features on my Android (Samsung Galaxy SII) very frequently. I’ve noticed from time to time on various Android phones that it will take a long time to acquire a location fix. Sometimes it even times out while trying. As I currently use my phone as a speedometer on my motorcycle, the GPS is pretty important to me.

I recently discovered a free app called GPSFix for android.

Here is the vendors description:

Must have GPS application for your Android Phone.

GpsFix helps to decrease the time required to obtain a position fix.
It keeps GPS/AGPS receiver turned on until location is fixed.
It is useful when your navigation app says “waiting for location” too often.

It helps to work with Google Maps, RMaps, OsmAnd, Sygic, Yandex Maps and others navigation software.

Fix for uploading small files to tmp using Ruby

Posted: February 22, 2012 by farmer in Blog

Turns out there is a quirk in the Ruby CGI library. Came across it while making a file uploader for a client.

What was supposed to be an optimization in Ruby, actually makes it difficult to save files less than 20kb to the file system.  Ruby just holds the entire file in memory and never writes it to tmp.

The work-around was to check for IOString write it directly to a file.

 

Here’s the code:

if myfile.is_a? Tempfile
   if File.exists?(filepath)
      then mv(filepath, Archive + filename )
   end
   elsif myfile.is_a? StringIO File.open(Archive + filename, "wb")
   { |disk_file| disk_file << myfile.read }
end

IOStrings are funny animals.  They let you treat memory like a file.