Archive

Archive for the ‘Uncategorized’ Category

Determine Ubuntu Filesystem Type

November 7th, 2009 No comments

Ever connected a hard disk to your computer without knowing how the partitions are formatted, or even what type of formatting? This surprisingly hard-to-find utility reveals all:

/usr/lib/klibc/bin/fstype /dev/sdb1

just replace sdb1 with your drive.

fstype prints something like this:

FSTYPE=jfs
FSSIZE=156225608

I have no idea why the hide this under /usr/lib/klibc/bin. Other applications in the klibc-utils package get mapped to more reasonable locations.

Categories: Uncategorized Tags:

Multiple Ruby with update-alternatives

October 3rd, 2009 4 comments

Here’s a useful piece from David Lee on the Rails Oceania Google Group:

If any of you are using Ubuntu this is a pretty nice way to manage multiple ruby interpreters.

It has the advantage of managing the manpages, ri, and irb as “slaves”, so they change when a new interpreter is selected.

here’s the code:

# become root
su

# make sure the packages are installed for 1.8 & 1.9 aptitude install -s  ~n^ruby1.[89]$ ~n^irb1.[89]$ ~n^ri1.[89]

# install ruby1.8 & friends with priority 500
# so this will be the default “auto” choice
update-alternatives –install /usr/bin/ruby ruby /usr/bin/ruby1.8 500
–slave   /usr/share/man/man1/ruby.1.gz ruby.1.gz
/usr/share/man/man1/ruby.1.8.gz
–slave   /usr/bin/ri ri /usr/bin/ri1.8
–slave   /usr/bin/irb irb /usr/bin/irb1.8

# install ruby1.9 & friends with priority 400
update-alternatives –install /usr/bin/ruby ruby /usr/bin/ruby1.9 400
–slave   /usr/share/man/man1/ruby.1.gz ruby.1.gz
/usr/share/man/man1/ruby.1.9.gz
–slave   /usr/bin/ri ri /usr/bin/ri1.9
–slave   /usr/bin/irb irb /usr/bin/irb1.9

# choose your interpreter
# changes symlinks for /usr/bin/ruby ,
# /usr/bin/irb, /usr/bin/ri and man (1) ruby
update-alternatives –config ruby

for those with additional interpreters in say /usr/local/bin, other Debian variants, or managing other tools, vary as required.

% man update-alternatives

hope wrapping didn’t mangle it too much, and that someone finds this useful

Link to original here.

Categories: Uncategorized Tags:

Rails Rake Tutorial

August 4th, 2009 No comments

Great Rails Rake tutorial from railsenvy.

More Rake stuff from railsenvy:

Now that you know enough to start writing useful rake tasks, I figured I should leave you with a few more resources. The best way to improve your programming is to read other people’s code, so a few of these are existing useful rake tasks people have written.

You’re all set! If you find any other good ones, feel free to post them in the comments.

Categories: Uncategorized Tags:

Remote Access to MySQL Server

July 31st, 2009 No comments

Do something like this:

mysql -u root mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’remotehost’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;

For more details see:
https://www.idevelopment.info/data/MySQL/DBA_tips/Security/SEC_1.shtml

Categories: Uncategorized Tags:

Running VMWare Workstation VM’s as a service

July 31st, 2009 5 comments

If you don’t have VMWare Workstation, you can use the free VMPlayer instead – just replace vmware.exe with vmplayer.exe.

From Jim Kenzig:

The June issue of Windows .Net magazine has a good article about how to
run VMware VM’s as a service which may interest some of you:
See

https://www.winnetmag.com/Windows/Article/ArticleID/42607/42607.html

VMware-At Your Service!
Run VMware Workstation VMs as services
Chris Wolf
Feature
InstantDoc #42607
Windows & .NET Magazine

If you’re a VMware enthusiast, you’ve probably on more than one occasion
wanted to log off from your computer while leaving your virtual machines
(VMs) running. Or, maybe you’ve wanted selected VMs to start as soon as
your system boots so that your host system can log on to a domain
controller (DC) running inside one of the host machine’s VMs. Sound too
good to be true? That’s what I thought. I assumed that logging off of my
computer and having my VMs remain running was an unattainable dream. But
I discovered that getting VMs to run as services is possible and very
easy to configure.

Tools for Service
VMware doesn’t natively support running its software as a service, but
configuring VMware Workstation 4.0 VMs to run as services is almost as
easy as tying your shoes. All you need to get started are two
tried-and-true Windows resource kit tools: instsrv.exe and srvany.exe.
Both tools are available as free downloads. Go to
https://www.microsoft.com/downloads, enter Windows 2003 Resource Kit
Tools in the Keywords field, and click Go. Then, click the Windows
Server 2003 Resource Kit Tools Download button at the Windows Server
2003 Resource Kit Tools Web page to download rktools.exe-which contains
the most recent versions of Instsrv and Srvany-and run the executable to
install the tools on your system.

Note that you can install the Windows 2003 resource kit tools on a
Windows 2003 or Windows XP system. If your host system runs Windows 2000
or Windows NT, you can acquire Instsrv and Srvany from the Win2K or NT
resource kit CD-ROMs or you can install the Windows 2003 resource kit
tools on an XP system and just copy Instsrv and Srvany from the XP
system to the %windir% folder on your Win2K or NT host system. The
Windows 2003 versions of Instsrv and Srvany run on the earlier OSs
without any problems.

Getting Started
Installing the resource kit tools updates the system path to include the
resource kit installation folder. Updating the path requires a reboot,
so be sure to reboot your system after installing the resource kit.
Alternatively, you can copy Instsrv and Srvany to a folder already in
the path, such as the folder C:windowssystem32.

With the resource kit files in place, your next task is to determine the
location of the VMware application’s vmware.exe file. I used the default
settings when installing VMware, so the path I needed was C:program
filesvmwarevmware workstationvmware.exe.

The last bit of information that you need before you configure the new
service is the path to the configuration file of the VM that you want to
turn into a service. This file is in the folder in which the VM was
created and has a .vmx extension. All my VMs are stored on my system’s E
drive, so the path to the .vmx file of the VM that I want to run as a
service is E:vmsw2k1w2k1.vmx. When you have the vmware.exe path and a
VM’s .vmx path information, you’re ready to create the service.

Creating the Service
First, decide on a name for the service. I prefer to preface the name of
the VM with VM_ to form the service name. For example, I would give my
VM named W2K1 the service name VM_W2K1. After you decide on the service
name, you can use the following syntax to set up the service:

instsrv <VM service name> <Srvany path>
So a sample command might be

instsrv VM_W2K1 c:windowssrvany.exe
Now you need to modify the service’s parameters by using a registry
editor and the Microsoft Management Console (MMC) Windows Services
snap-in. In the registry editor, navigate to the
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices<VM service name>
subkey. Right-click the VM service name, select New, then click Key.
Name the new subkey Parameters.

Right-click the Parameters subkey, select New, then click String Value.
Name the new value Application. Double-click the Application value and
enter the path to the vmware.exe file on your host system (put the
pathname in double quotation marks), followed by -x, followed by the
path to the VM’s .vmx file (put the pathname in double quotation marks).
For my configuration, I used the string value “C:program
filesvmwarevmware workstationvmware.exe” -x “e:vmsw2k1w2k1.vmx”.
Close the registry editor.

Open the Windows Services snap-in. Locate and right-click the newly
created VM service and select Properties. In the service’s Properties
dialog box, click the Log On tab. Ensure that Local System account is
selected, and select the Allow service to interact with desktop check
box, which Figure 1 shows. Click OK to close the service Properties
dialog box. You can now use the Windows Services snap-in to start your
VM service. By default, the service is configured as automatic, so the
VM will start when your system starts. Each VM that you configure to run
as a service will appear in its own window on the desktop. Because the
VM is running as a service, you’ll now be able to log off of your
system, and the VM will continue to run.

Tuning VMware
The configuration steps you’ve performed thus far will let any number of
VMs run as services without problems. However, you might find that some
built-in VMware features will get in the way. For example, when multiple
VMs attempt to start and share the same floppy drive, VMware displays a
message that the floppy drive will start as disconnected on all VMs
except for the one that was powered on first. You must click OK to
acknowledge the message before the VM boot processes will continue. To
prevent the need for manual intervention at boot time, you might want to
configure the settings of each VM on the host so that their floppy
drives don’t connect at power on.

To configure a VM’s floppy drive to start as disconnected, open the VM
in VMware, double-click the floppy drive icon, then clear the Connect at
Power On check box and click OK in the floppy drive’s Settings dialog
box. One other method for preventing the floppy drive from connecting at
power on is to open the VM’s .vmx configuration file in Notepad and set
the floppy0.startConnected parameter to “false”.

VMware hints might also interrupt a VM’s startup process. You can
prevent all hints from appearing for any particular VM by opening and
editing the VM’s .vmx file in Notepad. To disable all hints, add the line

hints.hideAll = “true”
to the file, as Figure 2 shows.

Take It to the Max
Now your VMs can run in ways you’ve never imagined. For example, you can
configure a VM to run as a DC that your host OS can log on to. When
you’ve attained the “unattainable dream” of running VMware as a service,
the possibilities are endless.

Resources
WEB SITES
VMware
https://vmware.com

Windows Server 2003 Resource Kit Tools
https://www.microsoft.com/downloads

Windows & .NET Magazine Network is a Division of Penton Media Inc.
Copyright © 2004 Penton Media, Inc., All rights reserved

Categories: Uncategorized Tags:

Windows XP Resource Issues

July 29th, 2009 No comments

While trying to find out why my XP laptop is so screwed up, I ran across these tips from Artem Russakovskii:

Process explorer (technet.microsoft.com/en-us/sysinternals/…) is the first tool I’d use — what’s consuming resources? And how much memory are we talking about here? Is there at least 1GB in each of these machines, or less? – nedm

I also use Extended Task Manager (extensoft.com/?p=free_task_manager) to keep a little better tabs on what’s going on than the built-in one.

Oh, and lastly, verifier.exe (support.microsoft.com/kb/244617) can help diagnose and troubleshoot driver issues.

Categories: Uncategorized Tags:

MS TrueType Fonts on CentOS 5

July 21st, 2009 No comments

Microsoft TrueType fonts are used by most websites so it’s often useful to install them under Linux. No doubt due to licensing restrictions, there is no RPM to install them directly under CentOS, but it’s not that complicated forllowing these instructions:

1. Install the software needed. You may need the DAG rpm repository to install cabextract – see my “Must-Have Repos” post for details.

sudo yum install rpm-build cabextract

2. Download the specs to build the RPM

wget https://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec

3. Build the RPM

rpmbuild -ba msttcorefonts-2.0-1.spec

4. Install the RPM

rpm -ivh /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm

To use the fonts with ImageMagick, I also needed to create a link to the font installation folder as follows:

ln -s /usr/share/fonts/msttcorefonts/ /usr/share/fonts/default/TrueType

Categories: Uncategorized Tags:

Patching RubyGems Quickstart

July 21st, 2009 No comments

Patching is a Ruby gem is really quite simple, once you know how.
Fetch the original gem. Gems are just tar files containing a couple of compressed (.gz) files. Unzip the data.tar.gz file. Make necessary changes then create the Rakefile required to build the gem. It should contain the contents of the gemspec, preceded by:

require ‘rake/gempackagetask’

and followed by:

Rake::GemPackageTask.new(spec).define

Then build the gem with:

rake gem

The new gem is created in the pkg subdirectory.

Categories: Uncategorized Tags:

RMagick with Ruby Enterprise on CentOS 5

July 21st, 2009 2 comments

This was a lot trickier than it should have been due to a new “feature” in REE whereby it reports its version on two lines like this:

[root@myserver rmagick]# ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux]
Ruby Enterprise Edition 20090610

Unfortunately the RMagick gem uses this to initialize a string constant, RUBY_VERSION_STRING used in rmmain.c. The constant is defined in “configure.ac”, which is used by autoconf to produce “configure”. While the autoconf file is present, it’s not used (fortunately since most people won’t have autoconf installed) so the “configure” file needs to be patched.

While rubygems are great when they work, patching them is another matter. First you need to wget the gem, which is a tar containing a couple of compressed files, data.tar.gz and metadata.gz. Extract the data.tar.gz using gtar, then change the RUBY_VERSION_STRING in “configure” from:

RUBY_VERSION_STRING=`$RUBY –version`

to:

RUBY_VERSION_STRING=`$RUBY –version | head -n 1`

Then rebuild the gem. To see how read my next post.

Or you can download my patched gem here.

Categories: Uncategorized Tags:

RMagick and ImageMagick on CentOS-5

July 21st, 2009 1 comment

I’ve run into this a couple of times: CentOS 5.x provides version ImageMagick-6.2.8.0–4.el5_1.1, more than a little out of date but good enough for most applications. The problem is that by default, RMagick insists on a newer release. Fortunately you can specifiy an older version of RMagick like this:

yum install ImageMagick
yum install ImageMagick-devel
gem install rmagick –v 1.15.13 ––no–rdoc ––no–ri

Categories: Uncategorized Tags: