Sunday, June 26, 2011

one-liner to get useful info on OpenNebula VMs

I've been playing with OpenNebula. I've got a few dozen VMs which are being provided with context dynamically. It would be handy to list all the machines MAC and IP addresses, along with their names. For this purpose, I use the following one-liner:

 for ID in `sqlite3 /var/lib/one/one.db 'select oid from vm_pool where state = 3 order by name;'` ; do onevm show $ID | grep "NAME\|IP\|MAC" | grep -v VIRTUAL | grep -v ' : ' | sed 's/REQUIREMENTS=/  /'; done

 

Tuesday, May 3, 2011

koan error on Scientific Linux 6

I'm doing some virtualisation stuff, using cobbler and koan. On a new install of Scientific Linux 6 (as a proxy for RHEL6) I got the error:


...
  if ret == -1: raise libvirtError ('virConnectGetVersion() failed', conn=self)



it seems that the package: qemu-kvm was not installed. So, to fix:

yum install qemu-kvm

Thursday, March 10, 2011

resetting password for user in authlogic

I needed to quickly reset a user's password in an Rails application that used authlogic. I didn't have the nice 'request reminder' stuff set up, so I used the console instead:

././script/console production
...
>> forgetfulUser = User.find(:first, :conditions => {:login => 'richard'})
...
...
>> forgetfulUser.password = 'newPassw0rd'
>> forgetfulUser.password_confirmation = 'newPassw0rd'
>> forgetfulUser.save

and it was done.

Thursday, February 17, 2011

encoding files to watch on Samsung TV

I have access to a nice Samsung TV that supports media on USB drives.

It has a bunch of codecs including x264 and MP3. My Ubuntu has some codecs on it so I needed to encode my media files into a suitable format to play them.

I received the error:

Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

And finally arrived at the following:


ffmpeg -i ./test.flv -acodec libmp3lame -vcodec libx264 -vpre medium test.avi

You can find helpful details on encoding on the blog:
http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/
including a handy list of encoding quality vs speed presets.



Update

It may be worth running ffmpeg -i test.

If either of the streams are mp3 or h264 then you can save time by passing 'copy' as the -acodec or -vcodec respectivly.

Tuesday, January 11, 2011

Drupal pretty URLs on Ubuntu

Ubuntu helpfully provides Drupal in its repositories. This installed fine for me but during install.php (to configure drupal) pretty urls wouldn't work.

To fix this, I had to edit

/etc/drupal/6/htaccess

find the line at the bottom:

#  RewriteBase /drupal

remove the '#' and add a '6' onto the end to give:

RewriteBase /drupal6

Wednesday, December 29, 2010

getting workspace with gnome visal effects

I maintain linux-desktop-audit software. My Ubuntu machine recently allowed me to enable 'visual effects' to make nice looking transitions between workspaces.

However, this broke linux-desktop-audit. So, instead of listening to 'active_workspace_changed' the code should be listening to 'viewports_changed'. Once this event fires, to get the current workspace number I use the following code:

def viewport_change (self, screen):
        self.current_workspace = screen.get_active_workspace()
        v_x = self.current_workspace.get_viewport_x()
        v_y = self.current_workspace.get_viewport_y()
        v_w = screen.get_width()
        v_h = screen.get_height()
        v_r = self.current_workspace.get_width()
        v_c = self.current_workspace.get_height()
        total_cols = v_r/v_w
        total_rows = v_c/v_h
        desk_col = v_x/v_w
        desk_row = v_y/v_h
        ws_num = desk_col + (desk_row * total_cols)

Tuesday, November 23, 2010

NUnit-console-runner, FileLoadException, access is denied

I was using NUnit, and careless stuffed it into svn from my Linux box.
When I checked it out from svn onto my Windows environment I got this error when trying to run: ./nunit-console.exe:


Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'nunit-console-runner, Version=2.4.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. Access is denied.
File name: 'nunit-console-runner, Version=2.4.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at NUnit.ConsoleRunner.Class1.Main(String[] args)

I had created a problem for myself because various dll's didn't have 'execute' flag enabled.

To fix this in a brutal way, from the cmd.com, I used:

cacls nunit.core.dll /p /e Everyone:F