8 Jul 2011

"warning: regexp match /.../n against to UTF-8 string" when running Cucumber

You probably have updated your environment lately and now getting the error "warning: regexp match /.../n against to UTF-8 string" when running Cucumber.

This is an encoding problem in the rack gem. This problem has already been fixed in version 1.3.0 but some of us are not able to update due dependencies issues e.g. rails. A simple monkey-patch based on pull request can solve the issue.

Create the file "config/initializers/rack_hotfix.rb" with the following content:

16 Dec 2010

Disable VMware Fusion's vmnet-* daemons on Mac OS X

VMware Fusion initializes some daemons (vmnet-bridge, vmnet-dhcpd, vmnet-netifup, vmnet-natd) at startup. The number of processes depends on the number of network interfaces you have configured. This might slow down your system startup.

Why is it necessary for them to load at system startup rather than application startup?

You need administrator privileges to load kernel extensions (which really makes sense), and these really do need to be kernel extensions (running a virtual machine at acceptable speed requires low-level access), so rather than prompting users for this when they start Fusion (and remember, they might not even know/have the password), we have the kexts get loaded at boot time. Advanced users can certainly disable this and manually start the services when needed.

Source

Here is an example how it could look like:

I don't use VMware Fusion often and want the daemons only to start up if it's necessary. The script to initialize the daemons is located at /Library/Application Support/VMware Fusion/boot.sh and is invoked by the LaunchDaemon script which is located at /Library/LaunchDaemons/com.vmware.launchd.vmware.plist.

  1. deactivate the LaunchDaemon script: "sudo launchctl unload -w /Library/LaunchDaemons/com.vmware.launchd.vmware.plist"
  2. use an apple script to start the boot.sh-script and VMware Fusion:

Here is a short how-to to get the script runnning:

(download)

19 Jun 2010

RecordColumnNameDecorator - A Doctrine Compatibility Decorator

I mentioned that we’re migrate our application from pure SQL to an ORM-Layer. Many of the existing functions work with column names of the database tables. Sometimes these column names are used hard coded or directly linked to the view layer. The actual problem is that we used the opportunity of the migration to unify the denotation of our tables and column names via the doctrine alias functionality. At the end we had functions using the old syntax and models with a new stylish unified nomenclature.

Fortunately it’s all OOP :)

The functions need a way to get the data from a given “Array”, but with the real column names instead of the new field names. The Doctrine_Record implements the ArrayAccess-Interface, which solves the problem that Doctrine_Record object should behave like an Array. The compatibility issue is solved through a small decorator which is currently not more as a proof of concept. The decorator change the functionality of the implemented ArrayAccess-Interface so that will accept real column names.

/**
 * A Doctrine_Record uses field names instead of columns names
 *
 * The RecordColumnNameDecorator change the functionality how
 * you call data from a Doctrine_Record. You can use the original
 * column names instead of the field alias.
 *
 * @author     Enrico Stahn <stahn@rib.de>
 * @version    SVN: $Id$
 */
class RecordColumnNameDecorator extends Doctrine_Record
{
  protected $record;

  public function __construct(Doctrine_Record $record)
  {
    $this->record = $record;
  }

  public function offsetGet($key)
  {
    return $this->record[$this->record->getTable()->getFieldName($key)];
  }

  // ... Implement the rest of the interface
}

Example:

// old: ugly_tablename.ugly_column_name
// new: foo.bar
$a = new Foo();
$b = new RecordColumnNameDecorator($a);
echo $a->bar;
echo $b->ugly_column_name

easy-peasy :)

11 Jun 2010

PostgreSQL - Add primary key to an existing Table

The next months are full of hard work because we have to master a huge migration task. We migrate all SQL-Statements to an ORM Layer. The application is already a bit long in the tooth and has approximately 8000 queries. The database itself has some strange design issues and some of them are incompatible with the ORM layer. One of this issues is the lack of a primary key at some tables. In PostgreSQL we can solve this with the following steps:

  • Add a column with type integer to your table
  • Create a sequence
  • Update the column table with sequence values
  • Set the necessary column properties (e.g. default, not null, etc.

Example for table “foo” and column “id”:

ALTER TABLE "public"."foo"   ADD COLUMN "id" INTEGER;
CREATE SEQUENCE "public"."foo_id_seq";
UPDATE foo SET id = nextval('"public"."foo_id_seq"');
ALTER TABLE "public"."foo"
  ALTER COLUMN "id" SET DEFAULT nextval('"public"."foo_id_seq"');
ALTER TABLE "public"."foo"
  ALTER COLUMN "id" SET NOT NULL;
ALTER TABLE "public"."foo" ADD UNIQUE ("id");
ALTER TABLE "public"."foo" DROP CONSTRAINT "foo_id_key" RESTRICT;
ALTER TABLE "public"."foo" ADD PRIMARY KEY ("id");
1 Dec 2009

Comparison: Symfony vs Ruby on Rails

21 Jun 2009

Microsoft PowerToys ImageResizer for Vista

A real time-saver back in XP-times was the Image Resizer from Microsofts PowerToys. Unfortunately this tool doesn't work for Vista, but there are some alternatives out there.

I guess both working great, but I just tested the first one because this meets my requirements perfectly.

21 Apr 2006

Filter FTP traffic with tcpdump

This command filters any FTP traffic for ip 10.1.1.22.

tcpdump -i fxp1 -x 'ip host 10.1.1.22 and (port ftp or ftp-data)'
10 Sep 2005

Favicon online erstellen

Mit dem Favicon Service von chami.com können Favicons online einfach und schnell erstellt werden. Man lädt lediglich ein Bild hoch und erhält dann das fertige Favicon in einer ZIP-Datei zum Download. Die Suche nach einem Favicon Editor kann somit entfallen. Eine Liste mit Online-Favicon-Editoren:

9 Sep 2005

MAC in IP Adresse umwandeln

Irgendwo im Netzwerk steht ein CISCO ATA 186, welches ein SIP Image verpasst bekommen soll. Auf dem Gerät befindet sich lediglich die MAC-Adresse (00:07:...) des Netzwerkinterface, jedoch ohne dazugehörige IP-Adresse. Ein kleiner Trick soll helfen die IP-Adresse herauszufinden:

nmap -sP 10.0.1.0/24
arp | grep "00:07"

Der obige Code, pingt alle IP’s des Class C Netzwerks an, und durchsucht danach die arp-Tabelle nach der entsprechenden MAC-Adresse, und gibt diese inklusive der dazugehörigen IP-Adresse aus. Ihr könnt auch in der von {{nmap}} ausgegebenen Liste nach der MAC-Adresse suchen. Jedoch stehen dort die MAC- und IP-Adresse nicht in einer Zeile, was es unnötig macht, die Liste mit {{grep}} durchzugehen.

9 May 2005

mtop – MySQL Monitoring Tool

Was der Prozessliste sein top, ist dem Query sein mtop. Mittels [mtop][1] lassen sich die aktuell abzuarbeitenden Abfragen beobachten und eventuelle Engpässe z.B. durch schlechte Indizierung, schlechter Queryaufbau, zu große Tabellen, etc. analysieren. [1]: http://mtop.sourceforge.net/ “mtop/mkill – MySQL Monitoring Tools”