FINALLY! SOME UPDATES! This website is being reconstructed. Some content will go away soon. If you want to see my new stuff, visit my github: https://github.com/jrcharney/.

November 3, 2013

Installing Ruby the Right Way: Epilogue

As much as I like to write about how to do things on this blog, sometimes I don't explain how I did things exactly as I though I explained them, mainly because later on I found out that I was most likely wrong about some things or there were other factors I didn't anticipate at the time the were done.

For instance, when I was doing the RVM install, I was using tmux inside my bash shell. To which, either because I am using Lubuntu or this is part of Ubuntu/Gnome Terminal's set up, in bash the terminal you are using (which you can find out what terminal you are using by typing echo $TERM) the xterm terminal, but when you are using tmux, your terminal is screen. xterm and screen both use bash as their shell of choice by default. However, depending on your distro more than likely, xterm will strictly use ~/.profile to load bash shell preferences whereas screen continues to follow the more traditional rules that state that ~/.profile is read only if ~/.bash_profile does not exists for screen to read at the creation of a new terminal.

So it would seem pretty simple to append the following line to the end of ~/.bashrc, which is loaded when ~/.profile is read.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
We could have just echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> ~/.bashrc

Yeah, we could have, figcaption, but what a mess that was! By the way, if that line is in ~/.profile or ~/.bash_profile, comment it out.

At any rate, back at ~/.bash_profile, the following line should be at the beginning of the file.

source $HOME/.profile
It's fixed now, right?

Actually, no. While this is necessary to make sure that the settings many of us are used to using in bash (i.e. using colors when listing what file type and making sure that common alias commands are used) there is one issue that still stands out. If you have a directory called ~/bin to run programs local to your home directory, that path is tacked on at the beginning of $PATH and if you haven't figured out by now, RVM wants to be the first thing that is read otherwise when you run rvm , you will get that Path Warning about how it's not the first item in the $PATH string.

While I'm not completely certain that it has to be, whether or not you want to do this next part is up to you. At this point, I'm of the opinion that if RVM want's to be first, it's requests for preferential positioning should be denied. RVM's Ruby is used in xterm and screen now. That's what matters. You can use a different terminal emulator like urxvt (or as Ubuntu calls it UXTerm), and RVM's Ruby would be shown when executing which ruby. Besides, we just want to use RVM to handle the more important installations like Ruby, JRuby, and Rails. Everything else should be done using gem. Right now, I'd really like to get gems for Tk and OpenGL set up.

But like I said, if you still want to appease RVM, you can either remove ~/bin (which more than likely you don't want to; I wouldn't), or ignore RVM's "Me first!" messages.

Unless I encounter some problem that requires RVM's paths to be first explicitly, it will just have to deal with where it is.

One more thing, to get RVM's version of JRuby working by default use the following command.

rvm use jruby --default
Two great things that work great together!

October 29, 2013

Installing Ruby the Right Way

I upgraded to Ubuntu 13.10 (Saucey Salamander) yesterday and have been working on making some changes to how I use my computer. As much as my love-hate relationship of Ubuntu Unity continues, and as much as I've been moving towards using Lubuntu (Ubuntu that uses LXDE as the Desktop Environment), it is important to remember that when you use a distribution's software, they generally build it so that it works as stable as possible with the current distro. This means, instead of installing the latest version of a software from source where things can go wrong if you don't have something else that is installed, they give you the stable version which is older than any new version.

Such is the case when you are trying to install new software that you want to actually be new software, you have to chose between compiling from the lastest source which could still be a beta version or installing the stable binary from the distro.

For Ruby, the worse thing you can do is install Ruby on Ubuntu like this.

sudo apt-get install ruby
Just like everything else.

Assuming you haven't installed anything that is dependent on the Ubuntu version (which is still stuck at version 1.9.3), you can fix this foolish mistake by uninstalling their version of Ruby.

sudo apt-get remove ruby
No harm. No foul.

Having undone such a foolish mistake, you can now install Ruby the right way. (Note: I have reason to believe this "ruby" is a meta package. So even if you did remove it, it probably won't matter since RVM handle multiple ruby versions. Besides, there is quite a bit of other stuff that uses Ubuntu's Ruby.)

The Ruby download page list some third party tools for installing Ruby. The most popular of these third party tools is RVM, the Ruby Version Manager. RVM makes installing Ruby and Rails very easy.

curl -l https://get.rvm.io | bash -s stable --ruby
Easy!

Running this will execute RVM to install the various software and a few common Ruby Gems (.gem) packages needed to run the latest version of Ruby. However, it won't take effect in the current shell window that you are using until you run the following command.

source ~/.rvm/scripts/rvm
Easy...but Hey, shouldn't I have done all this with a sudo?

Good point, figcaption. As I was writing this, I made the mistake of not using sudo, but this may have been a good mistake for the purpose of say installing the latest version of Ruby, JRuby, or Rails for your website. Theoretically this could work. Rather than wait for the server admins to update this software, you can start using it right away. This is something I hope to make possible here so that next month I can swap out PHP for Ruby.

Another thing that caught my attention was this text while running the RVM install command.

 * WARNING: You have '~/.profile' file, you might want to load it,
     to do that add the following line to '/home/jrcharney/.bash_profile':

           source ~/.profile
Ugh! why is the text dark red?

This seems to be something that Ubuntu users need to do so they don't have to run that previous command I mentioned, which you'll have to run every time unless you do the following.

echo "source ~/.profile" >> ~/.bash_profile
Append a line to .bash_profile

Oh, but there is still a couple problems with doing this. You still need to run source ~/bash_profile unless you want to restart the machine and RVM likes to be the first thing listed in the PATH variable. Here's what happens when you run a rvm command using that previous figure.

~$ rvm list
Warning! PATH is not properly set up, '/home/jrcharney/.rvm/gems/ruby-2.0.0-p247/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.0.0-p247'.

rvm rubies

=* ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
#  * - default

"Me first!"

So what seems like a better plan? Doing the opposite. In fact, load the contents from ~/.bash_profile to then end of ~/.profile Also we will need to get rid of ~./bash_profile or else ~/.profile will not load.

~$ cat .bash_profile >> .profile
~$ rm .bash_profile
This is what Should have happened.

You may notice that when you open another shell, your still using the unedited path. I'm pretty sure that will change upon system restart. But If you're not interested in waiting for the machine to start over, you can always run source ~/.profile. When you do this, you will notice that the RVM paths is now paths are now prepended to the $PATH and instead of which ruby pointing to Ubuntu's Ruby at /usr/bin/ruby it points to RVM's Ruby at ~/.rvm/rubies/ruby-2.0.0-p247/bin/ruby. You'll notice the difference when you run ruby -v and see the version number is 2.0.0 instead of 1.9.3 or 1.8.7

From here on, if you want to install other major gems like JRuby or Rails, you can use RVM like this.

~$ rvm install jruby
You got Java in my Ruby!

Or you can see a list of installed .gems using gem list or rvm list. In fact, I recommend using gem for this task. Be sure to check that you use which gem to make sure that RVM's gem is used.

Speaking of Gems, the recommended method of installing anything else Ruby related should be with Gem. There is a whole website full of Ruby Gems to download, but the big three are Ruby, JRuby, and Ruby on Rails.

To demonstrate, let's install Ruby on Rails. This process is so easy.

gem install rails
That's it? Why can't everything else be this easy?

It takes a little while for it to start up. Probably because .gem installation isn't as verbose as installing from source. It also installs 27 gems in the process.

And that's it. I look forward to completing this task on this website in the near future.

September 28, 2013

Thunderstone

As of today, getlsxlsr has a new, better name: Thunderstone. A project page has been set up, and a link to the new Github page can be found here. I'll get the links for the project page set up by the end of this weekend.

September 27, 2013

Invasion of the Design Snatchers (or Why Imitating Apple is Worst than Being Apple)

A strolled through MicroCenter last night to see what laptops were available. I felt motivated to stop by because everybody at the interview brought their own computer with them, namely Apple MacBooks.

Years ago, I though owning a Mac would be the bees knees as it was an alternative to computers that had Windows on them. But being a full-time Linux user, and seeing how I had the freedom to make my own programs without the data-bloat tacked on by using GNU programs on Windows or the Walled Garden empire that Apple has built, my interest still lies with using a PC, only swap out Windows for Linux.

One of the most important parts of any computer is the keyboard. While buttons like "Print Screen/SysRq", "Scroll Lock", "Pause/Break", the 12 F-Keys and the ever important "Insert" key (which if word processing is your forte, Insert toggles "overwriting" to over-type other text, a function that is indispensable to Vim users as well), these buttons despite being dismissed as "legacy buttons" are no more less important that the Arrow Keys on any standard keyboard. Sadly, many of the recent computers on the market seem to have forgotten their important purpose.

While many folks argue that anyone using Vim should remap these keys for this issue, it quite insulting considering that remapping keys should be reserved for frequent macros. They shouldn't be used to make up for the commands other keys that used to be part of the keyboard used to have.

This is generally the reaction I get from Mac users when criticizing their computer.

But I am not alone with my criticism of the new keyboard layout which has now spread to Windows users who are using Windows 8. I'm not alone with my criticism of imitation instead of innovation either. The PC industry is starting to take on the technology the mac books use including keys that won't work like they should. This layout is called the Island Keyboard or Chiclet Keyboard which to this day has a history of miscommunicating data with their host device because the membrane layers are still in contact. It's basically the same technology as a TV Remote, to which what happens when you hold down a button on a TV Remote? It keeps doing the same command until you release the button. This technology is great for video game consoles, but bad if you are typing a letter and suddenlyyyyyyyyyyyyyyyyyyyyyyyy that happens.

PC makers may deny it all they want but attempting to imitate Apple hurts them more than it does Apple. When I go to MicroCenter, I expect to shop for a diverse array of products just as I would I were going to a Car Dealership. I don't want to go there and see a Ford Malibu, or a Chevy Viper, or a Dodge Mustang. Manufactures make different designs to appeal to different people. They all just can't make the same designs, accuse each other of infringement, sue the heck out of each other because someone used a type 10pt on their keyboard stickers and someone used a font size 8pt italic of the same font when the problem is much bigger than who used what fonts on the keyboard stickers.

Regardless, everybody else needs to stop trying to be Apple. They should just be themselves. I'm talking no "brushed metal" look. No Island Keyboards. No scrunching up the up and down arrow keys like a MacBook. No depreciation of important functions. Just be themselves.

I just hope I can find something on eBay before they're flooded with computers that have keyboards I can't use for actually typing.

September 25, 2013

Making Rubies

Oh, Ruby, why did I not start programming with you sooner? Over the past couple of weeks, I've picked up on Ruby faster than any programming language since I started programming ever. Maybe it is because it is built on a lot of stuff I already know from previous programming languages. Maybe it's because it's the most stress free language I've ever used. (No drama like C, C++, Java, PHP, Perl, or Python.) And aside from my understanding of blocks still be rusty, and still not exploring Procs yet, working with Ruby has been the most joy I've ever had programming since fiddling around with JavaScript about a decade ago.

Ruby
Ooooh, shiny.

I think once I get getlsxlsr rewritten, I'll dive into Rails and see what that is like. Heck, I might just take this website offline for a couple of week just to rewrite everything in Rails.

One of the things I did over the past couple of weeks was attempt to draw UML diagrams of the Ruby Core Documentation drawing the relationships between Ruby Classes and Modules and the Files the belong to ([1.8MB]), and the hierarchy of Ruby Classes and Modules by relationship ([1.7MB]). These files a quite big, and as much as I tried to whittle down their size with a little bit of Imagemagick, try to be gentle with my bandwidth when downloading them.

The other thing I did was re-create a personal script I've been using for my dad's roofing business to calculate the distance from his office to reported storm reports files with the local National Weather Service office. This script was called getlsxlsr.sh and it used a lot of Sed and Awk, but it wasn't Object-Oriented.

By the time I finally got the major bugs out of the Ruby version (which was a few minutes ago, which is like 1 AM!), I finally had something good, that I could present. It's kinda late, so any project page I have planned will have to wait until later. The direction field still has issues as New Baden should be I think south or southeast of where the office is.

It's still a work in progress, but it's one I'm satisfied with sharing.

The program requires Ruby 1.9.3 on up, since the included modules are loaded using require_relative. So here's a wide screenshot of what it would look like.

So what this program does is it takes the Local Storm Reports (LSRs) from a local National Weather Service office (the default is the St. Louis (LSX) office) website, takes the data from the LSR pages that are still up (which have a tendency to be remove after about a week or so), reformats the data into a table row with optional color formatting. It doesn't sound that exciting or impressive given this drought we've had. But when the storms are rolling through and the reports are flooding in, this program looks amazing.

The application of this program is to help find areas where local storm damage occurred. What I hope to use it for eventually is to construct a path or timeline of events. Graphically if possible using PostScript and Google Maps to draw a map of the damage area.

I was hoping to show off my getfips program, but I've run out of time to present it. Maybe later. It's still got some kinks to bang out. This program could be used to dig up zip code information and probably generate canvasing areas for door-to-door sales and political campaigns. More than likely the information for the latter may exist, but the patterns used for campaigning can also be used for sales if no personal data is included.

That's it! I'm done for the night! There's bound to be more goodies later this week.

UPDATE! This project is now on GitHub! I'm still trying to figure out how to use GitHub, but I think I've figure it out well enough to uploat files on it.

Tags

Under Construction