Archive for 2009/07:

LessCSS goodies


If you haven’t heard about LessCSS then check it out, really cool solution for writing css code in concise way. I’m planning to use it in some of my projects (and probably for this blog’s styles) and I’ve created two tools which could ease my work with LessCSS.

First tool, css2less, is CSS-to-LessCSS converter. Of course it can’t use all of LessCSS features because only programmer knows where to use variables and other stuff properly for specific project. However what it can do is to find all rules that can be nested and outputs them for given css file.

Grab it from github and use like that:

ruby css2less.rb my.css > my.less

You will get .less file with all styles from original .css file but with nested rules notation. It’s a good start for further tweaking, ie adding variables.

Second tool, rack-lesscss, is a Rack middleware which converts .less files into .css files on the fly during request. It’s main purpose is to ease development stage when you change your .less files frequently. With rack-lesscss middleware enabled you don’t need to compile .less files by hand after every change. LessCSS compiler has an option to watch for changes in .less file and automatically recompiles it but you need to remember to run compiler in watch mode for every stylesheet every time you start development session. There are also at least two Rails plugins which nicely integrates LessCSS into the app but this middleware can be used with Rails as well as with other ruby web frameworks like Merb or Sinatra.

Install gem:

sudo gem install --source http://gems.github.com sickill-rack-lesscss

or grab it from github.

Enable by adding following to your rackup file (config.ru, or config/rack.rb in Merb app):

require 'rack-lesscss'
use Rack::LessCss, :less_path => File.join(APP_ROOT, "public", "css"), :css_route => "/css"

Above code will enable on-the-fly .less files compilation for all requests matching /css/*.css.

It accepts two arguments:

  • :less_path – directory where source .less files are stored (required)
  • :css_route – route which this middleware will handle (optional, default is /stylesheets)

And don’t use it on production for obvious reason :) It’s meant to be used for development only.

View Comments

Open File Fast 0.9.4 released for Netbeans and JEdit


Here we go again. Open File Fast 0.9.4 has just been released into the wild. And there is big news: with this release I’m introducing Open File Fast for JEdit!

I’ve spent some time refactoring OFF code, extracting search functionality into reusable module and cleaning up here and there. The result is the core functionality is now being used by Netbeans plugin as well as by JEdit plugin. They both share search engine, search dialog and options panel. Thanks to that I’ll be able to release OFF for both platforms at the same time without any additional platform specific work (theoretically of course).

Besides all of above here are the changes for this release:

  • underscores at the beginning of filenames are ignored (when searching for _foo.html.erb enter just foo)
  • masks in options panel (hide files / move files to bottom of the results) have been changed from regular expression format to wildcard format – just use ‘*’ as replacement for string of any length
  • added indexing status indicator to search dialog.

Netbeans NBM package: off-netbeans-0.9.4.nbm
JEdit jar file: off-jedit-0.9.4.jar (requires JEdit 4.3pre16 and ProjectViewer 2.1.3.7)

View Comments

Archlinux + Nginx + Passenger


UPDATE: I’ve added this package to AUR. You can grab it here if you prefer to build it from AUR. Note: it automatically builds passenger’s nginx module so step 2. is not needed for it, you only need to have passenger gem installed.

If someone needs to setup Nginx web server with Passenger support quick on Archlinux here are few simple steps to get it running in minutes.

1. Make sure you have the latest Passenger gem installed:

sudo gem install passenger

2. Compile Passenger module for Nginx:

cd `passenger-config --root`; sudo rake nginx

3. Download this PKGBUILD (modified PKGBUILD of nginx-0.7.61-1 from community repository with passenger module added)

4. Unpack and build package (if running as non-root be sure you have fakeroot package installed):

tar xf archlinux-nginx-passenger.tgz
cd nginx
makepkg

5. Install package:

sudo pacman -U nginx-0.7.61-1-i686.pkg.tar.gz

6. Set Passenger’s root directory in /etc/nginx/conf/nginx.conf:

http {
  ...
  passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4;
  ...
}

7. Enable Passenger in your vhost:

server {
  listen 80;
  server_name foo.bar.net;
  root /var/www/foo.bar.net/public;
  passenger_enabled on;
}

Restart nginx and that’s it. Now your Arch can serve ruby apps under Passenger.

Kudos for Phusion guys for creating such simple and really good working solution for hassle-free deployment!

View Comments