Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

Ruby on Rails - Success kinda!

Okay. I'm totally going to try this again, just to see if I can't figure it out.

Ruby on Rails - A ruby based framework for web stuff. Basically, I haven't a clue, but I'm going to at least try to get it running on Windows and make some rudimentary website things, just to see HOW easy it is once I get the basic syntax down.

For the steps outlined below, I'm basically following the tutorial from http://guides.rubyonrails.org/getting_started.html verbatim, save for a few edits I'm needing to make to get the libraries downloaded and installed properly (i.e., they never told me in that tutorial that we needed the Ruby DevKit installed, and the DevKit download page doesn't really say HOW to install it).

  1. Download and install Ruby. Current version is 2.0.0p247 from http://rubyinstaller.org/downloads/. I installed mine to C:\Ruby200.
  2. Ensure Ruby is accessible from anywhere in the command shell by typing "ruby -v". You should get the current version of Ruby. If not, you may need to edit your environment variable "PATH" to include C:\Ruby200\bin (edited, of course, to where you installed Ruby).
  3. Download and unzip ruby DevKit, again from RubyInstaller.org. For version 2.0.0 and up, use DevKit 4.7.2. MinGW64-32 or MinGW64-64 specifies whether you're on 32 or 64-bit. I unzipped the development kit to C:\Ruby_DevKit.
  4. Install Ruby DevKit:
    1. Open a command shell and navigate to the location where you unzipped the development kit (C:\Ruby_DevKit).
    2. Type "ruby dk.rb" init
    3. Type "ruby dk.rb" install
    4. You should get messages that the development kit overwrote a few ruby gems that may have been already installed (Updating convenience notice gem override for 'C:/Ruby200'), and an "installing /devkit.rb"
    5. Type "gem install rails". You should get a ton of secondary libraries (gems) downloaded along with the main rails gem and documentation for each which could take a good long while. Just be patient. You should get something like "20 gems installed" at the end of the sequence.
    6. Type "rails --version". I got the message "Rails 4.0.0"
    7. We now have the ruby libraries needed to build a Rails application. Create a new location for Rails (C:\Rails, perhaps), navigate into it from the command shell and type "rails new ". I did like the tutorial suggested and just tried "rails new blog" which created an entire app folder structure in the "blog" subfolder. This was after I received the success messages "Your bundle is complete!" after it had installed a bunch of ...whatevers to the blog folder.
    8. Now, I did notice, rails automatically installs its OWN webserver (WEBrick, not Apache or IIS), so this app is able to run straight from its own folder out of Rails. I believe there's a way to install it over top of Apache, and use the Apache server configurations to control its access, but that's for later. Right now I just want to get this thing working in the first place, and am willing to put up with WEBrick.
    9. So anyway, I'm now told to startup Rails by typing "rails server".
    10. Whoops! I got a bunch of sqlite errors. Looks like I need to set up database config and connections first. I also tried starting OUT of the blog application, in which case I was told I needed to be inside a Rails application folder before I could start the server.
    11. Well that was odd. Tried installing the sqlite3 gem, which did not fix anything. Turns out I needed some other version of Ruby that had all the headers included, which I apparently did not do by using the windows installer. I REALLY hate trying to compile gcc projects on Windows. Hopefully I can try to make it work with MySQL since I already have that installed with source files and it's a part of my path.
    12. Thus, I deleted the blog folder and re-created the app with "rails new blog -d mysql" which forces the new app to use MySQL instead of the default sqlite.
    13.  Got a bundler error that said I needed the mysql2 gem. Ran "gem install mysql2 '0.3.13'. This errored, so I tried "gem install mysql" which worked, but was not the right version.
    14. Finally after a bit of research, I got the mysql2 gem to work with the following
      1. "subst X: "C:\Program Files\MySQL\MySQL Server 5.6"
      2. "gem install mysql2 mysql2 --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib --with-mysql-include=X:\include" <== Note the double -- in there. Basically, this splits out the main command with a bunch of sub-switches....I think. Simply put, you HAVE to have the -- --with-mysql- in there. Otherwise it will fail with an "invalid switch" error.
    15. Trying "rails new blog -d mysql" once more.
    16. Success! I received the "Your bundle is complete" message.
    17. However, when starting up the server, I once again got errors (needed MySQL2 gem 0.3.13). Tried to install using "gem install mysql2 --version=0.3.13 -- stuff stuff stuff". That worked. However, when trying to start up the server, I was STILL getting a bunch of stupid errors about missing something inside the mysql2 0.3.13 gem.
    18. I managed to fix this error. Basically, I was able to copy libmysql.dll from the MySQL Server/lib folder into Ruby/bin. Rails is now started up clean with no errors whatsoever -  I actually see the line "=> Ctrl-C to shutdown server."
    19. Tried navigating to "localhost:3000" and got the error "Specified 'mysql' for database adapter, but the gem is not loaded. Add `gem 'mysql'` to your Gemfile." - My database.yml I think is using mysql instead of mysql2 for its handle. I will change it there.
    20. Sure enough. Changing the "adapter" field in config/database.yml from "mysql" to "mysql2" got rid of the error. However, now it's attempting to login to my MySQL root user without a password. Gotta enter that information (with a password that you will not see repeated here ;)).
    21. Entered the password into database.yml. However, the error did not disappear. I manged to figure it out. I have to restart Rails. Ctrl-C in the command shell and run "rails server" again. This time it worked. However, now the website saying that it cannot find the "blog_development" database. Apparently it's not smart enough to create it itself (yet), so I will have to look up new tutorials on how to do that later on.
    22. Check that. I just went into PHPMyAdmin and created a blank "blog_developement" database, not adding anything to it. A refresh on the page now shows the "welcome to rails" homepage! I'm in!
In any case! I've apparently gotten it to work, so I'll be changing the title of the blog post from "A failed attempt" to "Success kinda!!"

Geotag Hack for Garmin Nüvi/Panoramio Photos

How to manually geotag photos for the Garmin Nüvi 1490
Does NOT require the Garmin Connect software.


Recently (yesterday) I was nominated to read up on and figure out the Garmin Nüvi 1490 GPS unit for a friend of the family. Well, looking through the features, I found that photos can be loaded into the unit and displayed in various locations, such as the bootup screen, a simple slideshow, or even as a navigate-to-photo feature!

Now, I assumed that somehow the unit would read out Geotagging meta data from any old photo you might tag in something like Picasa and copy to the unit. But this is not so. Actually, Garmin has signed a contract of some sort with Panoramio, an online photo-sharing site specifically for photos of general public areas, usually landscapes, historical photos, or any other pictures based mainly on a location. By connecting the Nuvi to the computer, one can navigate to http://connect.garmin.com/photos, browse the map for specific Panoramio photo, which, if they have geotag information loaded, will show up on the map, and add it to a separate dock area, which, by using the Garmin Connect software, can be downloaded directly to the GPS unit.

All well and good, except that in the last month and a half, I've uploaded about 20+ photos to Panoramio and NONE of them are showing up on the Garmin Connect map, though they specifically said in the Panoramio forums that they would after some time. And to top it off, a photo that my dad posted about four years ago is also not appearing! Not very on top of this little feature, are we?

Besides that, all of the other threads on Panoramio boiled down to "downloading Panoramio photos to your computer is illegal" and NONE of them gave any helpful information.

So, I decided to do some research and figure out just exactly how the Garmin Connect tool synchronized with the photos feature. When I plugged the unit into the computer via USB, two new drives were mounted: the Garmin Nuvi drive, which is the image of the internal memory, and a Removable Disk, which was accessing the Micro-SD expansion port.

Navigating into the Garmin Nuvi drive (on my machine, I:), there are a number of files and folders:
.System
Garmin
GPX
help
JPEG
keyboards
Reports
Screenshot
Text
Vehicle
Voice
.Volume.icns
autorun.inf
nuvi_drive.ico
Navigating into the GPX folder, I find three files:
Current.gpx
Panoramio_20110810T103416.gpx
Position.gpx
From my previous research using our own GPS unit, the GPSMAP 60CSx, I know that GPX files are an XML-based file that can be opened in any text editor, and record specific gps coordinates along with names of the locations, timestamps and sources. Knowing that the Garmin stored everything in GPX made decoding it so much easier! With this knowledge, I was able to determine that GPX/Current.gpx is the database that stored saved searches, tracks and tagged photos downloaded from Panoramio, GPX/Panoramio_20110810T103416.gpx is the list of geotagged photos downloaded from Garmin Connect/Panoramio, and GPX/Position.gpx is probably the unit's current position.

Assuming that the Current.gpx file is updated regularly based on what the the unit is detecting, I decided to decode the Panoramio_20110810T103416.gpx file. And it worked! The conclusion I came to was the following: photos downloaded from GC/Panoramio are not tagged in the unit using JPEG metadata, and the unit can't detect JPG location metatags. Instead, Panoramio also sends location data alongside the photos that the unit downloads, and injects this information into the Panoramio_*.gpx file. THEN when the photos are opened in the viewer, the proper location-based tools are activated.

Here is a waypoint for a specific Panoramio photo:

<wpt lat="40.615972" lon="-105.171969">
<name>Northwest of Fort Collins</name>
<src>Panoramio <link href="Garmin/JPEG/Panoramio_11075531.jpg">
<type>image/jpeg </link>
<link href="http://www.panoramio.com/user/965071">
<text>WildernessShots.com</text>
<type>text/html</type>
</link>
<link href="http://www.panoramio.com/photo/11075531">
<type>text/html</type>
</link>
<sym>Scenic Area</sym>
<extensions>
<gpxx:WaypointExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
<gpxx:Categories>
<gpxx:Category>Photos</gpxx:Category>
</gpxx:Categories>
</gpxx:WaypointExtension>
</extensions>
</wpt>
With this information, I think it would be fairly self-explanatory to edit this file. I have yet to actually try it out, but when I figure it out, I'll get back with you!
------------
SUCCESS!!! I simply added a new <wpt> ... </wpt> section to the panoramio_20110810T103416.gpx file and when I rebooted the unit (unplugged it from the computer), the photo appeared in the list AND had the location tools in the lower corner, along with my username and all that!! WONDERFUL!

And just as I suspected, Current.gpx was also updated to reflect these changes, even though I didn't do a thing to them.

So all that needs to be done to add photos to your Garmin, and tag them without worrying about the Garmin Connect/Panoramio tool, simply copy the photos into one of the locations where pictures are kept on the unit. The tool downloads them to /Garmin/JPEG/, but I'm sure /JPEG/ will do just fine (/JPEG/ is where all the sample photos are kept).

Then edit the /GPX/Panoramio_<datecode>.gpx file and add a new waypoint using the <wpt> ... </wpt> tags as shown above. Or if you have a secondary program to save GPX files, I'm sure there is a way to just fix this up to save in this format. Also, the datecode in the filename is in the following format: yyyymmddThhmmss, so in my case, it was 20110810T103416. Just to keep up with the consistency, I also changed the filename to Panoramio_20110810T173100.gpx.

So in the end, here is the waypoint I manually and successfully added, along with the required XML and GPX definition tags:


<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="http://connect.garmin.com/">
<wpt lat="40.631839" lon="-105.143142">
<name>Sunrise Over the Neighborhood</name>
<src>Panoramio</src>
<link href="Garmin/JPEG/56784165.jpg">
<type>image/jpeg</type>
</link>
<link href="http://www.panoramio.com/user/5873911">
<text>Daniel P</text>
<type>text/html</type>
</link>
<link href="http://www.panoramio.com/photo/56784165">
<type>text/html</type>
</link>
<sym>Scenic Area</sym>
<extensions>
<gpxx:WaypointExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
<gpxx:Categories>
<gpxx:Category>Photos</gpxx:Category>
</gpxx:Categories>
</gpxx:WaypointExtension>
</extensions>
</wpt>
</gpx>
I'm sure if you wanted to add non-panoramio files, it would be just as easy. Just change/remove the few <link> tags to reflect something else and you'd be good to go!

Now to write a program to do this for me...


Free Websites Lost

Somewhat disappointing news: The "Summer Home" of PPSStudios (hosted on WebSamba) closed down on me, as WebSamba decided they couldn't keep free hosting alive. So I'm down to one free website, and they're high enough on the Google listing that I don't think I'll have any problems from them any time soon.


They've closed me off...but remember that my active coding that I decide to make public is going to http://ppsstudios.brinkster.net.


Of course, most of the stuff I develop, I keep on my own personal IIS (which is dynamic and I don't want to keep using No-IP for hosting a website, even though it works..kind of.

Brinkster

Alright yew people.  I've decided that my website is getting really boring.  You can see how boring here. The story writer is not being hit at all, hardly (probably because of the password protection).  If anyone has any ideas on what to add to it, shoot me (the webmaster) an email on http://ppsstudios.brinkster.net/sendMail.asp. I check it about once every three months, but I hope to fix that soon.



Anyhow, here's a note of pleading: don't send me any ideas on the elephant joke fanclub. I can't make database stuff work perfectly yet, nor do I have the time to try and figure it out. When I get it up and running better, I'll let ya'll know when you can send me requests for that. In the meantime, I'd say stick with feature requests revolving around html, asp, javascript and that sort of thing. Just databases are out.



I'll even accept requests for design changes if you so desire. A blue background with a simple table isn't my idea of a cool interface, although you must admit, it is CLEAN.