RSS

Archive for the ‘Plugins’ Category

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Advanced Rails

Advanced Rails offers you an in-depth look at techniques for dealing with databases, security, performance, web services and much more.

O’Reilly Media, Inc. published an intermediate-to-expert Rails book, authored by Brad Ediger:

Chapters in this book help you understand not only the tricks and techniques used within the Rails framework itself, but also how to make use of ideas borrowed from other programming paradigms. Advanced Rails pays particular attention to building applications that scale — whether “scale” means handling more users, or working with a bigger and more complex database.

16 Mar 2008

Advanced Rails: Go to the next level with Rails

Author: ceefour | Filed under: Books, News, Plugins, Rails, Reviews, Ruby, Web 2.0

A common stumbling block for beginner Rails developers is learning the basics required to write plugins. This is made more complicated by the fact that Ruby is inherently dynamic and offers many techniques for code reuse.

Luckily, if you can write Rails applications you can write plugins by simply drawing on a handful of basic patterns.

Why write plugins?

Writing a plugin will:

  • Help make sharing code more efficient, whether it’s between projects or within the same project
  • Allow you to publish generic code to the community
  • Save time and increase your confidence by testing once and reusing many times
27 Jan 2008

Overview of A Rails Plugin

Author: ceefour | Filed under: Beginner, Plugins, Rails, Tips, Tools, Tutorials

As easy as:
has_timezone :fields => [ :start_datetime, :end_datetime]
Timezone_fu makes it really easy to deal with datetime fields in your models. It adds a method to your models, has_timezone.

The README for the plugin describes all of the options but below is an example:

class Event < ActiveRecord::Base
    has_timezone :fields => [ :start_datetime, :end_datetime]
end

The model has three fields a start_datetime and end_datetime and a timezone. Adding has_timezone to the model changes the behavior of the two datetime attributes.
Notice below that calling event.start_datetime shows the time in local time (”America/New York”).

21 Jan 2008

Sexy Time Zones in Ruby on Rails with Timezone_Fu

Author: ceefour | Filed under: Cool, Plugins, Rails, Ruby, Tips, Tools, Web 2.0

We’ve been doing a lot of scraping and mashups lately. So we’d love to share on how to do this. Fortunately Schadenfreude has written a good tutorial about using Mechanize and Hpricot to scrape Gmail.

The tutorial uses mechanize and hpricot to login to gmail and return a list of Unread emails.

Installation of required tools

gem install mechanize --include-dependencies

This will install both mechanize and hpricot.

Usage

Before we can scrape our gmail account, we will need to login. Mechanize is a lib for “automating interaction with websites”. It can store and send cookies as well so once we login our script will now have a session to putter around in as if it was a web browser.

ActiveScaffold is a plugin for Ruby on Rails (also known as Rails) that provides dynamic model-based view generation. Instead of having to create pages by hand that display your models, ActiveScaffold will introspect your ActiveRecord models and dynamically generate a CRUD (create, read, update, delete) user interface for managing those objects.

Installing ActiveScaffold

As ActiveScaffold is a Rails plugin, you can install it from a remote Web or Subversion server. The command below will check out the ActiveScaffold plugin from the ActiveScaffold Subversion server.

Install the latest version of the plugin:

script/plugin install http://activescaffold.googlecode.com/svn/tags/active_scaffold

Add this to your layout:

1 Jan 2008

Turbocharge Ruby on Rails with ActiveScaffold

Author: ceefour | Filed under: Cool, GUI, Plugins, Rails, Ruby, Tips, Tools, Web 2.0

Using jRails, you can get all of the same default Rails helpers for javascript functionality using the lighter jQuery library.

jRails is a drop-in jQuery replacement for Prototype/script.aculo.us on Rails. It has the features and the visual effect.The visual effects in jRails are based on the new jquery-fx library. jRails currently uses a slightly modified version of jquery fx code to get some of the desired effects.

Features of jRails :

jRails provides drop-in functionality for these existing Rails methods.

    • Scriptaculous
    • draggable_element
    • drop_receiving_element
    • sortable_element
    • visual_effect
    • RJS
    • hide
    • insert_html
    • remove
11 Dec 2007

jRails: jQuery On Rails

Author: ceefour | Filed under: Ajax, Cool, HTML, Plugins, Rails, Ruby, Tips, Tools, Web 2.0

Selenium Core provides an easy way to test Rails application.

This plugin does four things:

  1. The Selenium Core files don‘t have to pollute /public.
  2. No need to create suite files, they are generated on the fly — one suite per directory in /test/selenium (suites can be nested).
  3. Instead of writing the test cases in HTML you can use a number of better formats (see Formats).
  4. Loading of fixtures and wiping of session (/selenium/setup).

Installation

  1. Install Selenium on Rails: script/plugin install http://svn.openqa.org/svn/selenium-on-rails/selenium-on-rails
  2. If you‘re on Windows, gem install win32-open3
9 Dec 2007

Selenium on Rails

Author: ceefour | Filed under: Ajax, Cool, HTML, Plugins, Rails, Tips, Tools, Web 2.0

The Statemachine library is a simple yet full-featured Finite Statemachine framework. Define your statemachine in Ruby code and execute it in your system.

A statemachine keeps track of the status(state) of an application or device and responds to different inputs, which alter the state of the machine.

We have identified 3 fundamental components to a statemachine: States, Transitions, and Events.

  • State: This is the status of the device or application the statemachine is being used for. At any given time, the statemachine is in one of its predefined states.
25 Nov 2007

Statemachine: Finite Statemachine framework

Author: ceefour | Filed under: Cool, Plugins, Rails, Reviews, Ruby, Tips, Tools, Web 2.0

Shave your Semantic (or semantic?) Web

microformats has been only two years old, yet it has brought significant changes in a relatively short time.

What is it, actually? According to microformats.org, “[microformats is] designed for humans first and machines second, [they] are a set of simple, open data formats built upon existing and widely adopted standards.”

Enough with the fluff, let’s see how it actually works, microformats in action:

Arie Kusuma Atmaja nampang gitu lhoh
Flickr picture source

The above picture is me browsing to the LinkedIn profile of one of Indonesia’s renowned Ruby on Rails experts, Arie Kusuma Atmaja. The overlay window that contains these semantic information is not a LinkedIn feature. Rather, it is the easily usable, cross-browser Microformats Bookmarklet by LeftLogic. Go on… try it if you haven’t!

Tau gak twitter tuh punya API

Twittervision

Ini contoh penggunaannya:

ceefour@ojalanow:~/bin$ salsabeela 'untuk sekarang enak gini'
Sending salsabeela 'untuk sekarang enak gini' '.... OK!
ceefour@ojalanow:~/bin$ salsabeela 'gak perlu mandi tiap hari :P '
Sending salsabeela 'gak perlu mandi tiap hari :P '.... OK!
ceefour@ojalanow:~/bin$ cat salsabeela
#!/usr/bin/ruby
require "#{File.dirname(__FILE__)}/twitter_pm"
send_pm 'salsabeela', ARGV.join(' ')

isi twitter_pm.rb :

ceefour@ojalanow:~/bin$ cat twitter_pm.rb
require 'rubygems'
gem 'twitter4r', '>=0.2.0'
require 'twitter'

def send_pm(recipient_id, message)
t = Twitter::Client.new(:login => 'gauldong@gmail.com', :password => ****************)
message = ARGV.join(' ')
sent = false
begin
recipient = t.user(recipient_id)
rescue
raise("Cannot find user #{recipient_username}")
end
print "Sending #{recipient.screen_name} '#{message}'"
$stdout.flush
sending = Thread.new { t.message(:post, message, recipient); sent= true; }
status = Thread.new { until sent; print '.'; sleep(0.5); $stdout.flush; end }
sending.join
status.join
puts ' OK!'
end