Monday, March 9, 2009

Growl4Rails


Growl4Rails
==============
Growl4Rails is a javascript component that provides the UI for growl-like notifications in your rails application.
This plugin requires Prototype 1.6 or higher and Scriptaculous 1.7 or higher.

Installation
===============
If you are on Rails 2.1 or higher:
$ script/plugin install git://github.com/jfiorato/growl4rails.git

http://github.com/jfiorato/growl4rails/tree/master
http://www.writebetterbits.com/2009/01/update-to-growl4rails.html

TinyTable JavaScript Table Sorter - 2.5KB

Table Sorter

This updated table sorter script is easy to use and feature packed at only 2.5KB. New features include column highlighting, optional pagination, support for links, and date/link parsing. A few other features are alternate row highlighting, header class toggling, auto data type recognition and selective column sorting. More updates will follow soon.

To initialize a table sorter follow the pattern below:

var sorter = new TINY.table.sorter("sorter");
sorter.head = "head"; //header class name
sorter.asc = "asc"; //ascending header class name
sorter.desc = "desc"; //descending header class name
sorter.even = "evenrow"; //even row class name
sorter.odd = "oddrow"; //odd row class name
sorter.evensel = "evenselected"; //selected column even class
sorter.oddsel = "oddselected"; //selected column odd class
sorter.paginate = true (false); //toggle for pagination logic
sorter.pagsize = 15 (20); //toggle for pagination logic
sorter.currentid = "currentpage"; //current page id
sorter.limitid = "pagelimit"; //page limit id
sorter.init("table",1);

Before initialization, a new table sorter object must be created. The parameter taken by TINY.table.sorter is the variable name used for the object. The object.init function takes 2 parameters: the id of the table and the initially sorted column index (optional). If you want to exclude a column from sorting add class=”nosort” to the appropriate table header. Table styling is completely customizable via the CSS.

TinyTable has been tested in Firefox 2/3, IE 6/7/8, Opera, Safari and Chrome. Please send bug reports to michael@leigeber.com with the subject “BUG REPORT”. This script is available free of charge any project, personal or commercial, under the creative commons license and is offered AS-IS, no free support provided. Click here to inquire about paid support.

Click here for the demo.

Click here to download the source code.

http://www.leigeber.com/2009/03/table-sorter/

drails

drails allows you to use RJS with Dojo in your Rails application. It completely replaces the need for Prototype/Scriptaculous in your application and let's you use the powerful Dojo Toolkit as your Javascript library.

Examples:
=========
The best way to see how to use drails helpers is to view the specs. Most people will be interested in prototype_helper_spec.rb and scriptaculous_helper_spec.rb. For a quick taste, here is an example of how you can create an link that replaces the "success_response" div on successful completion of an ajax call with the HTML returned by the server:

<%=link_to_remote "my link", :update => [ :success => "_response" ], :url => { :action => "myaction" }%>
<div id="success_response">...some html to be replaced...</div>

To see the usages for the drails generators for dojo modules, dijits, and build profiles, type this from the command line:

cd my_rails_app; script/generate dojo

drails comes with some handy rake tasks for incorporating dojo builds. To see what is available, type this from the command line.

cd my_rails_app; rake -T | grep drails

http://github.com/foobarfighter/drails/tree/v1.0.0

RRSync (Ruby RSync)

RRsync is a Rsync backup script that's written in Ruby. It performs the simple operation of syncing the contents of a given folder to a remote location via SSH. The script allows you to control the level of output (log files, screen output) , it is ideal for calling from a cron or launchd.

The backups are structured as such:

/remote/location/current - The current folder contains the the latest clone of the intended backup folder.
/remote/location/backup_dir - The backup directory, which by default is the current day (monday, tuesday, etc) contains the difference to current since it was last run. So it will contain any new files, any files that were deleted.

http://github.com/RichGuk/rrsync/tree/master

Wednesday, March 4, 2009

Dump Method

The Dump method is based on one of the tags available in Coldfusion ( ) providing the ability to display simple and complex variables in a user friendly way that is perfect for debugging/inspecting data. There is no way to do this with javascript and often I had wanted a method to do this. This method will do just that allowing for an infinite amount of data nesting complete with color coding for different data types, the ability to show/hide the data's type (String/Number/Boolean/Object/Array/Function), expandable and collapsible tables/keys and cross browser support.

Click on the buttons bellow to see some examples in action, toggle the Show Data Types box to see javascript data typing in action (not possible in Coldfusion).

Thanks to John Wilson for providing the jQuery plugin.

Browser Support

Internet Explorer 6, Internet Explorer 7, Firefox 1.5, Opera 8, Safari 1.2 (Mac), Firefox (Mac) - all tested, should also work in most other browsers

Download

Click here to download the latest version (1.08)
Click here to download the latest jQuery plugin

http://www.netgrow.com.au/files/javascript_dump.cfm

Setting up a production rails server step-by-step

Pushing your app to the real world with Rails can be a very daunting task to someone who is used to just uploading flat html or php files.

If you’ve never dealt with Apache, mod_rewrite, or proxy servers, prepare to spend a lot of time hammering out a solution. Worried about performance, or your need to scale out at a later date? Pick a solution that won’t leave you wondering if your site will be able to take a spike in traffic.

For Rails, there are lots of deployment strategies, some are tuned for compatibility with shared hosting (fastcgi), and some are built for speed and minimum configuration (Litespeed Nginx and Lighttpd), and some are built to leverage the strength and flexibility of stable and established server software (Apache+Mongrel).

If you want to scale, you’re going to need a load balancing proxy. The choices here are pound, pen, and apache’s mod_proxy_balancer.

An abundance of choice is a double-edged sword. Competition is good in any arena, but it makes it very hard for someone who hasn’t tried them all to choose one.

I’ve chosen to setup my Rails server using the Apache+Mongrel+mod_proxy_balancer combination.

For the operating system, I’ve chosen the newest Ubuntu 7.10 (Gusty) server. Ubuntu uses the Debian-style apt package management, but with more current packages than Debian stable, and is the current cool kid on the block for Linux systems. I have been using Ubuntu for years and can attest to its stability and cutting edge (but not bleeding edge) packages.

I’ve gone through and built a Rails server by hand before, but poorly documenting what I had done, and not securing it properly. When I stumbled upon Slicehost’s server setup articles, I knew I had found exactly what I needed to build a server configured like a pro, and all the documentation I should have written in the first place.

Here is the step-by-step setup for a production Rails server. I’ve tested this setup and can vouch for its awesomeness. I encourage you to make some changes specific to your setup where appropriate. You should be able to skip unneccesary stuff like php and virtual hosts if you don’t need them.

As you can see, most of these are from Slicehost’s documentation articles. They also detail setup for several other major linux distributions and other deployment strategies like nginx. Major props to slicehost for putting such excellent documentation together.

http://unixmonkey.net/?p=8

Hoptoad

Send your Rails application errors to our hosted service and reclaim your inbox.

Hoptoad provides easy access to all your data via an XML-based, RESTful API.

There is one prerequisite to using the API: you must have an auth_token. When logged in, you can find your auth_token at the "My Profile" page.

http://www.hoptoadapp.com