LessCss / Less.js With –watch Option Watching Included Files

LessCss No Comments »

Needed a less css compiler who watches changes to a main .less file as well as all those include with an @import statement.

Weighing the options:

One could just use an old version of the less gem that still supported the —watch option, i.e. the 1.x versions. However, the gem won’t track included/imported files, the obsolete more plugin was required for this in Ruby on Rails.

Peeking over the platform wall, the dotless compiler does all this well under Windows and it’s very fast. However, running this app with mono on Linux will not work with the —watch option, it will stop watching files after all and any file changes. This may be due to different backends of the mono FileSystemWatcher implementation on different Linux platforms, so YMMV.

Meanwhile, the author of less.js has declined to support the —watch option and has rejected at least one merge request with this functionality.

Solution:

Alas,  there’s a fork that supports watching the main file as well as all includes:

https://github.com/wvl/less.js

It works great and is stable. All you have to do is clone the repo and add bin/lessc to your path.

Now with a node installation (since recently there is a Windows installer) you should be good to go with silent and effortless server side compilation of less on all platforms.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Debugging Scala with IntelliJ and the SBT Plugin

SBT, Scala No Comments »

Here’s the correct setup, including the remote build configuration:

http://blog.morroni.com/2011/06/30/debugging-scala-projects-in-intellij/comment-page-1/

You may have to restart the IDE to get the debugger to stop when running from the SBT console. Yes, you can actually run your tests on the SBT console that comes with the SBT plugin for IntelliJ (test-only etc.), set breakpoints on your test code, and the debugger will open when it hits the break points. This is really cool.

Snapshot2

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Rails Migration to Convert all Table Names and Column Names to underscore

Ruby on Rails 1 Comment »

This may be useful for legacy database, whose table and column names are in CamelCase. Use with extreme caution:

class ChangeAllColumnsToUnderscore < ActiveRecord::Migration
  include ActiveRecord::ConnectionAdapters::SchemaStatements
  require ‘active_record/connection_adapters/abstract_adapter’

  #not needed in Rails 3
  #pilfered from here:
  #http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-column_exists-3F
  def self.column_exists?(table_name, column_name, type = nil, options = {})
    columns(table_name).any?{ |c| c.name == column_name.to_s &&
        (!type                 || c.type == type) &&
        (!options[:limit]      || c.limit == options[:limit]) &&
        (!options[:precision]  || c.precision == options[:precision]) &&
        (!options[:scale]      || c.scale == options[:scale]) }
  end

  def self.up
    tables.reject {|t| t == “schema_migrations”}.each do |table|
        columns(table.to_sym).each do |column|
          unless self.column_exists?(table.to_sym, column.name.underscore.to_sym)
            rename_column table.to_sym, column.name.to_sym, column.name.underscore.to_sym
          end
        end
        unless table_exists?(table.underscore.to_sym)
          rename_table table, table.underscore
        end
    end
  end

  def self.down
    tables.reject {|t| t == “schema_migrations”}.each do |table|
      columns(table.to_sym).each do |column|
        unless column_exists?(table.to_sym, column.name.camelize.to_sym)
          rename_column table.to_sym, column.name.to_sym, column.name.camelize.to_sym
        end
      end
      unless table_exists?(table.camelize.to_sym)
        rename_table table, table.camelize
      end
    end
  end
end

Hope it helps.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Gitosis Installation on OpenSuse

Git, Gitosis 1 Comment »

The repo info is here (click and expand that page’s silly javascript widgets), so for OpenSuse 11.4 (use sudo for all commands that need it):

zypper addrepo http://download.opensuse.org/repositories/home:elvigia/openSUSE_11.4/home:elvigia.repo

zypper refresh

zypper install gitosis

Then continue as outlined here, slightly adjusted for OpenSuse with user creation:

groupadd git

useradd git -d /home/git -c ‘git version control’ -s /bin/sh -g git -r -m

sudo -H -u git gitosis-init < /tmp/id_rsa.pub

Then just proceed with

git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git

on your local machine etc. etc.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Install RubyGems Legacy Versions

Ruby, Ruby on Rails No Comments »

To install a legacy version of RubyGems, you will need some version installed first, so use aptitude, yum, zypper etc:

apt-get install rubygems

Then revert to an older version (for example 1.3.6):

gem install rubygems-update -v=1.3.6

update_rubygems

Check your version with

gem env

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in