High Tech Sorcery

Author Archive


The easiest way to get ruby 1.9 debugging functionality on Ubuntu 12.04

by on Mar.07, 2013, under Development

I’ve come across a number of posts giving instructions on how to get debugging to work with ruby 1.9.x and they all seem to involve downloading gems and installing them. Here is what I did on my Ubuntu 12.04 workstations that was very easy though not trivial to figure out.

1
2
3
4
sudo gem install linecache19 --pre
sudo gem install ruby-debug-base19 --pre -- --with-ruby-include=/usr/include/ruby-1.9.1/ruby-1.9.3-p0/
sudo gem install ruby-debug-base19x --pre
sudo gem install ruby-debug-ide --pre
Leave a Comment more...

Building xen-4.2.1 packages on Ubuntu 12.04

by on Feb.07, 2013, under virtualization

First install build dependencies. This list may not be complete as some necessary libraries and tools may have already been installed on my test machines. This is what I used to get the packages to build successfully:

  • apt-get install build-essential python-dev gettext bin86 bcc iasl uuid-dev libncurses5-dev pkg-config libglib2.0-dev libyajl-dev git gcc-multilib texinfo fakeroot

Then download, unpack, configure, and build:

  • wget http://bits.xensource.com/oss-xen/release/4.2.1/xen-4.2.1.tar.gz
  • tar -zxf xen-4.2.1.tar.gz
  • cd xen-4.2.1
  • ./configure
  • make deb

Afterword you’ll be left with a shiny new package:

  • dist/xen-upstream-4.2.1.deb
4 Comments more...

Fixing “uninitialized constant” errors in rake tasks when using Rails threadsafe! mode

by on Jan.31, 2013, under Ruby On Rails

I ran into this problem where I was getting “uninitialized constant” errors when running rake tasks. These are tasks which had been working and I verified that the proper paths were set (eager_load_paths). When searching I saw information about config.threadsafe! being a problem so I disabled it and the problems vanished. However, I wanted to use config.threadsafe!, specifically for allow_concurrency. So, how to resolve this.

(continue reading…)

Leave a Comment more...

Decimal precision for geocoding coordinates

by on Jan.20, 2013, under Development

I did some research and found a lot of discrepancy among recommendations for the decimal precision when doing geocoding. Some say you only need 4 digits of precision and others suggest up to 15. In my own testing the best results seemed to be with 6-digits and SQL type of PRECISION(9,6) for latitude and longitude. This should provide a resolution of less than 12cm which should be sufficient for most purposes. The storage requirements should be 5 bytes in MySQL and 9 bytes in PostgreSQL.

Leave a Comment more...

gems for validating email and urls in rails

by on Jan.19, 2013, under Ruby On Rails

Validating URL Addresses

  • http_url_validation_improved (1.3.1) – uses Addressable::URI.parse, can check url connectivity
  • url_validation (1.0.0) – uses Addressable::URI.parse, can check url connectivity
  • url_validator (0.1.0) – uses Addressable::URI.parse
  • validate_url (0.2.0) – simple, Rails 3 only, uses URI.parse
  • validates_url_format_of (0.3.0) – Rails 2 and 3, uses regexp

Obviously people’s needs will differ but I think validate_url suites my needs best: it doesn’t add a dependency on Addressable and doesn’t use a regexp for validation. Mostly I’m looking to prevent user entry errors link failing to provide a schema. Whether the site exists is not something I need to check in a validation.

Validating Email Addresses

There are about 28 gems for doing email address validation. I’ve been using validates_email_format_of for quite some time with no complaints. It can validate mx records, works in Rails 2 and 3, and is highly configurable. Until I see a reason to switch I’ll keep using it.

Leave a Comment more...

strftime flags on Linux systems

by on Jan.10, 2013, under Development

If you want to get the numeric month from strftime your only only is %m which is zero padded. So January is “01″. But what if you don’t want zero padding? Turns out that’s non-trivial, unless you’re on a system that supports strftime flags. Then you can use “%-m” for no padding (“1″) and “%_m” for space padding (” 1″). These same flags work on all of the other formatters so you can use “%_d” for space padded day instead of having to remember to use “%e”. Not portable, but much more readable.

Leave a Comment more...


Installing Windows GPLPV Drivers in Xen

by on Jan.18, 2012, under virtualization

I’ve done this enough times to know it by heart but I remember when I tried to find documentation on this step I ran into countless inaccurate and outdated examples.  So here’s what I do to get the Windows GPL PV drivers installed under Xen.

  1. Download the drivers from meadowcourt.org.  As of 1/18/2012 the latest version is 0.11.0.308.  You’ll need to get the appropriate drivers for your OS.
  2. turn testsigning off on Windows
    1. bcedit
      • I like to check out the config first
    2. bcdedit /set {current} testsigning on
      • this turns testsigning on
    3. bcdedit
      • I usually run this again to make sure “testsigning Yes” appears
  3. restart windows. upon restart the system should indicate it is in “Test Mode”
  4. install the drivers msi file that was downloaded. I always choose “Typical” installation. I choose not to restart at this point.
  5. create new default boot option
    1. bcdedit /copy {current} /d “GPLPV
      • this will copy the current boot setup into a new one called GPLPV
      • pay attention to the id returned here
    2. bcdedit /default ID
      • replace ID with the id from the copy command
      • this sets the new menu to be the default
    3. bcdedit /set {default} loadoptions GPLPV
      • this makaes this option use GPLPV drivers
    4. bcdedit
      • double check everything
  6. restart windows
2 Comments :, , , , more...

Researching Redis on Rails

by on Jan.08, 2012, under Ruby On Rails

I’ve been researching how good a fit Redis might be for a project or 2.  One project needs a memory based key-value store generally without persistence, which would seem to suggest memcached.  However, there may be times where persistence across reboots may be desirable and Redis’ atomic operations and data types may also be useful.  Here’s some links I’ve been checking out:

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...