61 cards

Ubuntu Tomcat too many open files

If you encounter an too many open files exception you usually edit /etc/security/limits.conf and increase the value. But on Ubuntu (10.04 LTS at least) this is ignored!

A workaround is to edit /etc/init.d/tomca6 directly and set the limits directly.

ulimit -Hn 16384
ulimit -Sn 16384

Usually this error occurs if you run a resource intensive app like alfresco share.

Rails, ActiveAdmin and CanCan

Building an admin interface for your rails application using activeadmin goes quick and easy. Some more work is required if you want to integrate with CanCan.

The available docs are quite good but I always forget howto setup the active admin controllers properly. Therefore here is the code that should be added to your active admin resources:

controller do
  load_and_authorize_resource :except => :index

  def scoped_collection

FreeBSD py-cairo and error python headers not found

If you run into an error while trying to compile the py-cairo port complaining it can't find the python headers, you need to rebuild your python port with pth support disabled.

Mounting ISO images under FreeBSD

To mount an iso image under FreeBSD just follow these steps.

Create a loop-back device with mdconfig

# mdconfig -a -t vnode -f PATH_TO_YOUR_ISO/ISOFILE.iso

Mount the create vnode to a folder (Replace /dev/mdX with your device node!).

# mount -t cd9660 /dev/mdX /cdrom

The md device is automatically created by mdconfig and the name is printed after the command has been executed e.g. md0 or md1.
After you have unmounted the directory you can destroy the md-device with the following command:

# mdconfig -d -u X…

Installing wine under FreeBSD 8 amd64

To get wine (which is a 32 bit application) running on a 64 bit FreeBSD installation you have 2 options:

  1. Get the wine-fbsd64 packages from mediafire.
  2. Build it manually.

In my case the second option was necessary because my system was running pkgng and there are no pkgng packages for FreeBSD 8 available.
Before you start be sure to have enough disk space for the /compat/i386 directory. You'll need around 2 gb.

At first we create the necessary directory structure…

Debugging SugarCRM using Krumo

Using the krumo library debugging sugarcrm becomes a lot easier.

  1. Download the latest version.
  2. Unzip it into custom/include/krumo.
  3. Edit krumo.ini and adjust the url setting for the css. It should be somewhat like http://YOUR_HOST/SUGAR_PATH/custom/include/krumo.
  4. Include krumo in your code and use it (see below).

To use krumo in your code you have to include class.krumo.php like this php require_once('custom/include/class.krumo.php');

Then in your detail or edit view for example you could us…

Reset SugarCRM admin password via sql

If you are not able to get access to a sugarcrm installation you can reset the admin password directly via the sql interface.

First you need to find the active admin account in the database table users. It has the column is_admin set to 1 and the column status set to active. The code below should return a list of all active admin users.

SELECT user_name FROM users WHERE is_admin = '1' AND status = 'Active';

The password is simply a md5 hash, therefore you can set it to any value you like via:

UPDATE users SET user_hash = MD...

Delete remote git tags

Actually you should never do that!

But just in case the following commands will work it out.

% git tag -d TAGNAME
% git push origin :refs/tags/TAGNAME

Rails 3, ruby-debug gem and build error on bundle install under freebsd

Since some time it seems to be somewhat impossible to install the ruby-debug gem into your rails app. The error message will most likely look similar to this one:

Building native extensions.  This could take a while...
ERROR:  Error installing ruby-debug-base19-0.11.26.gem:
    ERROR: Failed to build gem native extension.
    /usr/local/bin/ruby19 extconf.rb
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
*** extconf.rb failed ***
Could no...

Quick application crash debugging on FreeBSD or "strace is a Linux tool"

When using Linux it is often helpful to use the following command if an application crashes:

% strace application

You'll get a list of system calls and some helpful information that'll help you often to pin down the reason for the crash.

If you're using FreeBSD you should use the truss command:

% truss application

It provides the same information as strace.

Drupal organic groups extras add content links

If you're using Drupal 7 and Organic Groups (2.x) you probably have the OG extras module enabled.

The documentation to enable the "create content" links for your organic group nodes is sparse. Therefore a short howto:

  1. Enable all needed modules
  2. Enable the module entityreference prepopulate!
  3. Go to "Structure" -> "Content types" and select your group content type, not your group type…

Rails, FactoryGirl and has_and_belongs_to_many

When testing has_and_belongs_to_many models using rspec and factory girl you should setup your factory the following way:

FactoryGirl.define do
  factory :foo do
    name "Foo" 
  factory :bar do
    name "Bar"
    foos { |a| [a.association(:foo)] }

This is slightly more verbose than association(:foos, :factory => :foo) but it works without getting errors. ;-)

Beware of setting innodb_log_file_size too high on mysql!

If you run MySQL you probably use the innodb storage engine because it provides a number of advantages over myisam.

The official documentation recommends giving 50-80% of your ram to innodb_buffer_pool_size which can easily go above 10 gb because ram is cheap nowadays.
The same documentation recommends settings innodb_log_file_size to 25% of innodb_buffer_pool_size meaning this can easily be 2 or more gb.

However mysql is only able to handle a combined log file size (Yes, there are 2 of them.) of 4095 mb. …

Sylpheed on FreeBSD bind: permission denied

If you experience the error message

bind: permission denied

when you try to run sylpheed on freebsd you most likely have the false permissions for /tmp and/or /var/tmp.

You should be able to correct the permissions by using the following commands:

# chmod 777 /tmp /var/tmp
# chmod +t /tmp /var/tmp

Also be sure to check the ownership (should be root:wheel) of the directories.

Ruby on rails and active_admin assets on Heroku

If you are using heroku you probably ran into some issues with rake assets:precompile. When using active admin bringing it's assets into your app can also be quite tricky.

The method of precompiling your assets yourself and adding them to your git repository works for sure but it isn't really best practice.

Another way to get the needed assets to be compiled is as foll

  1. Configure the config.assets.initialize_on_precompile = false if you don't have it already (refer to the heroku faq).
  2. Modifiy `config/a…

Don't use cucumber for integration tests

If you're using cucumber you should be carefully examining your tests to make sure you're really writing acceptance tests and not integration tests.

While you can certainly write integration tests in cucumber that is mostly a waste of time because these are easier and faster to write with rspec and capybara.

However I find cucumber a nice tool for the implementation of acceptance tests.

Configure test frameworks and fixture replacements in rails

If you want to use another test framework for rails like rspec and factories instead of fixtures. You should adapt config/application.rb as follows:

config.generators do |g|
  g.test_framework :rspec               # Use RSpec as testing framework.
  g.fallbacks[:rspec] = :test_unit      # Fallback to Test-Unit if RSpec is not available.
  g.fixture_replacement :factory_girl   # Use FactoryGirl instead of fixtures.

Howto split a git repository into two

Sometimes you'll want or have to split a git repository into two. This is usually a sign of not thinking forward enough but hey sh.. happens.
If your repository is structured in a way that you just need a subdirectory of it into a new repository you can follow the steps below.

We assume a repository foo that contains a folder foobar that shall be a new repository called bar.

% git clone --no-hardlinks foo bar
% cd bar
% git filter-branch --subdirectory-filter foobar HEAD  -- --all
% git reset --hard
% git gc...
This website uses cookies to improve usability and analyze traffic.
Accept or learn more