Sunday, January 26, 2014

Getting CrashPlan out of the Way

I love CrashPlan (http://www.code42.com/crashplan/), but: by default it backs up EVERYTHING in a user's home directory. This creates real performance issues on Windows even if CrashPlan attempts to go easy on you while you're working. Even in Linux it can be a problem as applications like Firefox and Netbeans create so many hidden directories and files under your home directory. And then there's DropBox that never really deletes your files unless you work very hard to make sure they are gone.

So, I have found the best strategy is to go in and completely de-select my home directory when configuring my CrashPlan backups, and then add ONLY the few things I really care to back up.

BIG GOTCHA IS THIS: be sure to check the box that says "Show Hidden Files" or you will still get too much activity as Windows creates all sorts of junk files in your home directory.

Ah, at last, I can get some work done without putting CrashPlan to sleep.

Saturday, January 25, 2014

Ruby Development/Debugging with Netbeans 7.4 in openSUSE 13.1

Ruby development is possible with the latest version of Netbeans with a plugin, and Netbeans is by far my favorite Ruby development IDE -- and it's free unlike some of the others I've tried in Linux and couldn't get working anyway. Here are some tips:
  1. Download the latest Netbeans from https://netbeans.org/downloads/ (I download the full blown version. It downloaded fast and as will be seen below, you can choose later not to install things you don't want)
  2. Downloaded was netbeans-7.4-linux.sh and run it as root. I chose to customize the install and install ONLY the Base IDE, Java SE, and "Features on Demand"
  3. Netbeans installs nicely, and the IDE is found in the SUSE start menu without any extra effort (and I add it to my favorites for convenience).
  4. Run Netbeans and make sure all is well. 
  5. Go to http://wiki.netbeans.org/RubySupport and find the link to the plugin which is currently http://plugins.netbeans.org/plugin/38549. Download it (a zip file).
  6. Unzip it where you like, in this example, it's unzipped in the following directory under the directory structure Netbeans creates in my home directory: /home/admvrm/.netbeans/7.4/my_plugins/ruby -- a directory I created.
  7. In Netbeans, Navigate to Tools->Plugins->Settings and click the "Add" button.
  8. Change the url from http:// to file:// and add your full path to the updates.xml file. In my case, the url becomes: file:///home/admvrm/.netbeans/7.4/my_plugins/ruby/archive/build/updates/updates.xml
  9. When done, click the "Available Plugins" tab, select "Ruby and Rails" and choose install. I chose to ignore all "unsigned" warnings about the files.
  10. I chose to start restart the IDE as soon as the install is finished.
Great. Now Netbeans understands Ruby and Rails and I can open my existing Ruby and Rails projects,. Next thing was to get the Ruby debugger working because it was failing. My first big clue came as I read http://stackoverflow.com/questions/4188963/rails-on-netbeans-uncaught-exception-no-such-file-to-load-script-server-or. This helped me understand that I needed to fix /usr/lib64/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/bin/rdebug-ide. After some experimentation I found that I had to shift past an extraneous argument, and that was all I had to do. So, I made the following change to rdebug-ide and now I can debug console Ruby applications with Netbeans 7.4. Yay! It comes in handy from time to time.

Changed:

Debugger::PROG_SCRIPT = ARGV.shift

to:

script = ARGV.shift
if script =~ /^_0/
  script = ARGV.shift
end
Debugger::PROG_SCRIPT = script

Monday, January 20, 2014

Getting CrashPlan Working in openSUSE 13.1

I have come to rely on CrashPlan for my external cloud based backups. But installation proved problematic on openSUSE 13.1 64 bit. Here's how I solved the issue:
  1. Got into Yast software management and installed "eclipse-swt." The CrashPlan UI will crash complaining of "Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM" which is a bit of a red herring. I install eclipse-swt and it went away.
  2. That solved, another error will occur. But I had to refer to http://support.code42.com/CrashPlan/Latest/Troubleshooting/CrashPlan_Client_Closes_In_Some_Linux_Installations and following its recommendation add "-Dorg.eclipse.swt.browser.DefaultType=mozilla" to the end of the GUI_JAVA_OPTS definition in the CrashPlan "run.conf" file.
At this point, the CrashPlan service had not started, so I started it manually by running (as root):

/etc/init.d/crashplan start

Not sure if I had to do this, but I also ran:

insserv /etc/init.d/crashplan

However it was only after reboot that the CrashPlan service finally appeared in the list of services when I looked at the "Services Manager" And then everything was as it should be. It started automatically and was up and running.

ONE OTHER CAVEAT: if you happen to run the CrashPlanDesktop as root first, when you run it as some other user you may find you cannot start up because you cannot write to log files. If that is the case, make sure that you remove or chmod the ui_* logs in /usr/local/crashplan/log or wherever you installed CrashPlan.

And one final tip: you might have to right click on the SUSE start menu and select "Edit Applications" and create your own link to the CrashPlanDesktop. And if you want icons, see /usr/local/crashplan/skin.

Saturday, January 18, 2014

OpenSUSE: Making Oracle Java THE System Java

OpenSUSE comes with a subpar version of Java and some applications refuse to run on it. Replacing OpenJDK with the standard Java from Oracle is not difficult IF you have these resources at your fingertips:

The following link is actually all you need, and it starts out by explaining why OpenSUSE does not come with the standard Java:

http://en.opensuse.org/SDB:Installing_Java

From the article, however, you should see the following key links:





Sunday, January 12, 2014

Using Paperclip to Upload and Display Images in a Rails 4 Application

I recently decided to add support for uploading images of "users" to my application. Table name was "users." It turned out to be pretty easy, but there were a couple of gotchas. And it seems that many of the notes online do not cover Rails 4 specifics.  Here are some notes. First of all, some key resources:

https://github.com/thoughtbot/paperclip/wiki/Installation

The Paperclip Quick Start Notes

Someone Else's Rails 4 Paperclip Notes

Here is my step-by-step for my Rails 4 Application:
  1. Added to my Gemfile the following and then run "bundle install": gem "paperclip", "~> 3.1"
  2. Added just one line to my model (user.rb), (I'm placing my preferred "missing" image in public/system/users/avatar, and note that I am using "avatar" as my base field name for the image). Also note that Rails 4 does not like the use of "attr_accessible" as shown in the official Quick Start (The Paperclip Quick Start Notes). Leave it out or you may get a message like "`attr_accessible` is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add `protected_attributes` to your Gemfile to use old one.". Therefore, I only added the following one line to my model -- note that I wanted three versions of my file in addition to the "original"
    • has_attached_file :avatar, :styles => { :larger => '400x400', :medium => "200x200>", :thumb => "100x100>" },:default_url => '/system/users/avatars/missing.jpg'
  3. Generate my database migration with the following command: rails generate paperclip user avatar
  4. Migrate the changes to my database: rake db:migrate
  5. And here is a very important step. Without it the database was not getting updated, but there was not indication of error. Added ":avatar" (or whatever you are calling your field) to the permitted parameters in my controller class (users_controller.rb in my base). So: params.require(:user).permit(:avatar, ...)
  6. I use <%= image_tag @user.avatar(:larger) %> in my form_for(@user,:multipart => true) do |f| block to display the image. Note also the addition of ":multipart => true" which is also key. Note that I am displaying the "larger" version of the file by specifying "(:larger)". Leave off any specification if you just want the original size to display.
  7. In that same block I use the following to upload the image: <%= f.file_field :avatar %>
  8. And finally I had to comment the following which appeared only in my config/environments/production.rb file as it was preventing the application from both finding the uploaded images and thus displaying them: config.serve_static_assets  = true