Tuesday, December 18, 2012

find and mv files in bash

I thought I would document this shell command for posterity's sake.  My bash skills are sketchy so I will need to look it up again.

I downloaded a few zip files this morning and needed to move them to a new directory.  Moving them to a new directory from the command line was trivial:


for i in $(find . -type f -newermt 2012-12-18); do cp $i /[NEW DIRECTORY PATH/; done;

Monday, December 10, 2012

You have already activated torquebox...

Working with TorqueBox this afternoon I got the following error just after creating a new application :

You have already activated torquebox-core 2.1.2, but your Gemfile requires torquebox-core 2.0.3.redhat.1. Using bundle exec may solve this.

A quick check inside my .rvm/gems/jruby-1.6.7.2@appname/ folder showed that I had two versions of torquebox installed :



I deleted the incorrect version, 2.1.1.  Everything was fine.

Tuesday, August 14, 2012

Fedora fonts and infinality.net

I use Fedora, and I really like Gnome 3.  Gnome-shell is extremely productive.  However, Fedora is not known for the beauty of its' fonts.

A colleague suggested that I install the infinality fonts from infinality.net
 .

Run :
sudo yum install fontconfig-infinality
sudo yum install freetype-infinality

Fedora looks great.

Be  careful though : it deleted a lot of my preferences.

Tuesday, July 3, 2012

rvm requirements

I recently upgraded to Fedora 17, Beefy Miracle.  The first time I used rvm to install a gem I got the following :

ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

I ran :

rvm notes

and

rvm requirements

And installed everything listed as a requirement for Fedora 17. That still didn't do the trick. I reinstalled 1.9.2 with :

rvm install 1.9.2

And finally :

sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel1.9.2

Finally!

The moral of the story is :
  • run rvm requirements 
  • check the error logs if there are any (the location is the last line of the output)

Wednesday, May 16, 2012

Fun with RVM

I typically work with jRuby.  I don't have "rvm use jruby" in my bash scripts,  but I might as well.

I wanted to install awestruct this morning.  I wanted to use C Ruby, or MRI.

The frst step for using awestruct is of course to install awestruct, gem install awestruct.

I got the following :

ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

  
I tried to install zlib with RVM :
rvm pkg install zlib

Unfortunately that didn't work:
/home/jeremy/.rvm/scripts/functions/pkg: line 52: cd: /home/jeremy/.rvm/src/zlib-1.2.6: No such file or directory
Configuring zlib in /home/jeremy/.rvm/src/zlib-1.2.6.
Error running ' ./configure --prefix="/home/jeremy/.rvm/usr"  ', please read /home/jeremy/.rvm/log/zlib/configure.log
Compiling zlib in /home/jeremy/.rvm/src/zlib-1.2.6.
Error running 'make ', please read /home/jeremy/.rvm/log/zlib/make.log

I tried the quick fix from the RVM site, https://rvm.io/packages/zlib/.
Reinstalled Ruby with :
rvm reinstall 1.9.2
rvm use 1.9.2
gem install awestruct

And back to work.

How to enable a datasource using the JBoss CLI

data-source enable --name=DATASOURCE-NAME

Thursday, March 8, 2012

How to shut down JBoss EAP6 / AS7 from the CLI

From the JBOSS_HOME/bin run the following :

./jboss-cli.sh --connect command=:shutdown

Thursday, March 1, 2012

Changing a symbolic link in Linux

Symbolic links are great.

I need to swap out local Maven repositories for the project I'm working on.  I created a symbolic link, "maven_repo" in my home directory that points the current local Maven repo.  When it came time to change the "maven_repo" link I realized that changing a symbolic link to a directory requires an extra command :

ln -sfn DESTINATION_DIRECTORY LINK_NAME

It wasn't so obvious from the man page.  This blog post saved me a ton of time.

Wednesday, February 22, 2012

Gnome Shell shortcuts

There is an excellent cheat sheet/post about Gnome Shell at (go figure) gnome.org, http://live.gnome.org/GnomeShell/CheatSheet

I'll repost a quick summary here :

  • System (Windows) key: Switch between overview and desktop
  • Alt+F1: Switch between overview and desktop
  • Alt+F2: Pop up command dialog
  • Alt+Tab: Pop up application switcher
  • Alt+Shift+Tab: Cycle in reverse direction in the application switcher
  • Alt+[key above Tab]: Switch between windows of the same application in Alt+Tab
  • Ctrl+Alt+Tab: Pop up accessibility switcher
  • Ctrl+Shift+Alt+R: Start and end screencast recording
  • Ctrl+Alt+Up/Down arrow: Switch between workspaces
  • Ctrl+Alt+Shift+Up/Down arrow: Move the current window to a different workspace
  • Ctrl+Enter: Launch a shell command in a new Terminal window

Tuesday, February 21, 2012

Fedora 16, gnome-shell and rvm

I recently upgraded to Fedora 16.  There's lots to like.  There are some things that are annoying.

I found a couple of new oddities this evening after installing rvm.

First, rvm requires gcc, and gcc has to be installed.  I sort of assumed that gcc would have already been around.  Anyway,

sudo yum install gcc

did the trick. Second, after
  • installing rvm
  • logging out
  • logging back in
  • installing Ruby 1.9.2
  • installing the latest JRuby
  • logging out
  • logging back in

I ran :

rvm use jruby

I got :

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

Huh?

There is of course an entry on the rvm site.  It's some gnome-terminal weirdness.  I was launching the terminal with Alt + F2.

Wednesday, February 8, 2012

RVM, jRuby, ActiveRecord::ConnectionNotEstablished, and PostgreSQL

I generated a new Rails 3 app with a PostgreSQL backend.  I was using the latest jRuby.

I started the server and got :

ActiveRecord::ConnectionNotEstablished

That was annoying.
I connected to the database from the command line and from another tool.
I ran rails console and got the following :

ArgumentError: syntax error on line 42, col 0: `'
                    load at org/yecht/ruby/YParser.java:152
                    load at /home/[USER NAME]/.rvm/rubies/jruby-1.6.5/lib/ruby/1.8/yaml.rb:134
  database_configuration at /home/[USER NAME]/.rvm/gems/jruby-1.6.5/gems/railties-3.2.1/lib/rails/application/configuration.rb:115


Taking a look at yaml.rb line 134 clued me in that I was using the wrong jRuby compatibility.

RVM to the rescue.  RVM is just pure goodness.  It really makes switching rubies a breeze.

The executive summary is that RVM makes it easy to run multiple versions of Ruby and/or Ruby gems.  To use jRuby :

rvm use jRuby

It even makes it easy to set jRuby's version compatibility.  RVM  allows you to specify hooks to run after its' methods.

jRuby 1.6.x has 1.8 and 1.9 Ruby compatibility.  To use 1.9 just add an "after_use" hook (this is detailed on the RVM site).

Tuesday, January 24, 2012

Gradle

A few years ago I read The Pragmatic Programmer.  The Pragmatic Programmer may not be the GoF book, but it's almost as valuable.

Andy Hunt and Dave Thomas recommend learning a new language every year. I started with Groovy.

Being a Java developer I thought Groovy would give me the most bang-for-the-buck. After all Groovy is part of the Java spec so there is no excuse not to learn it.

I think Groovy delivered. I used to think that Groovy was worth learning for XML parsing/writing alone. XMLSlurper and MarkupBuilder are by far the best things I've used for dealing with XML.

Gradle changed my mind. Gradle is a fantastic build tool. Maven solves some problems, but it is a whole set of problems itself. Gradle can run Ant tasks so you keep Ant's functionality. 

As for the one language per year thing I picked up Python next and got a Django app into production. I'm on Ruby now, but I'm behind schedule. I'll get to Scala soon...

No bundle plugin resource available to handle deployment for bundle type

The first time I tried deploying a bundle with a fresh server and JBoss Operations Network agent I got the following error :

java.lang.Exception:No bundle plugin resource available to handle deployment for bundle type [BundleType[id=10001,name=Ant Bundle]]. Ensure the bundle plugin is deployed and its resource is imported into inventory.

I restarted the agent and everything was fine.

If I can reproduce this its time to login to Bugzilla.  I thought I'd post here first in case anyone Googles the Exception though.

Happy coding