Tuesday, April 28, 2009

Prototype on Sly is "3x faster"

HTML:
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="Sly.js"></script>

Javascript:
// Overriding CSS Selector Engine.
Sly.handlers = Selector.handlers;
Sly.prototype.findElements = Sly.prototype.search;
Sly.findElement = function(elements, expression, index) {
if (Object.isNumber(expression)) {
index = expression; expression = false;
}
return Sly(expression || '*').filter(elements)[index || 0];
};
Sly.findChildElements = function(element, expressions) {
var result = Sly(expressions.join(',')).search(element);
return Prototype.BrowserFeatures.ElementExtensions ?
result : result.filter(Element.extend);
};
Selector = Sly;
http://slickspeed.firejune.com
http://github.com/digitarald/sly/tree/master

Google Analytics API is Now Available to Developers

It is a good news to web application developers. Google Analytics Data Export API beta is now publicly available to all Analytics users. The Data Export API is easy to use and provides read-only access to all your Analytics data. Any data that’s available through the standard Analytics web interface is available through the API.

Developers can integrate Google Analytics into their existing products and create standalone applications that they sell. Users could see snapshots of their Analytics data in developer created dashboards and gadgets. Individuals and business owners will have opportunities to access their Google Analytics information in a variety of new ways with Google Analytics Data Export API.

For example, you can accessing Analytics from your desktop with Polaris from now on. Polaris is a cross-platform desktop widget for Google Analytics. With 8 standard reports it’s the easiest way keep your data always instantly available. The rich interface and swift navigation make it a pleasure to use.

Desktop Analytics

Traffic Analytics

http://www.webappers.com/2009/04/27/google-analytics-api-is-now-available-to-developers
http://www.desktop-reporting.com/polaris.html

Monday, April 27, 2009

Moonshine

Moonshine is Rails deployment and configuration management done right.

Deploying Your Rails Application with Moonshine in 15 minutes

Requirements

  • A server running Ubuntu 8.10 (Want to see your favorite platform supported? Fork Moonshine on GitHub!)
  • A user on this server that can:
    • Execute commands via sudo
    • Access your application’s Git repository

Instructions

  • ruby script/plugin install git://github.com/railsmachine/moonshine.git
  • Ensure all required gems are declared using config.gem calls in config/environment.rb.
  • ruby script/generate moonshine
  • Edit the configuration file at config/moonshine.yml with your apps’s details. (If you’re using a user other than rails, specify this here)
  • Edit the Moonshine::Manifest::Rails manifest generated for your application at app/manifests/application_manifest.rb to declare other packages, services, or files your application depends on (memcached, sphinx, etc).
  • capify your application
    • Your config/deploy.rb can be super barebones, as Moonshine loads the contents of config/moonshine.yml in as Cap variables and sets some sane defaults. Here’s what I use:
       server "myubuntuserver.com", :app, :web, :db, :primary => true
  • git add . && git commit -am "added moonshine" && git push
  • cap deploy:setup
    • This will bootstrap your Ubuntu server with Ruby Enterprise Edition.
  • cap deploy
    • This will install all needed dependencies for your application and deploy it for the first time. The initial deploy will take awhile, as things such as MySQL, etc, are being installed. It’s worth the wait though, because what you end up with is an extremely maintainable server that you’ll never need to SSH into again!
http://railsnotes.com/161-rails-server-setup
http://github.com/railsmachine/moonshine/tree/master

FileWrapper

FileWrapper is a Rails plugin and RubyGem which wraps the command line utility ‘file’ to detect the mime-type of a file.

Installation as Rails plugin

From the Rails project root, execute:

  script/plugin install git://github.com/Narnach/file_wrapper.git

Installation as gem

Install the gem by executing:

  sudo gem install Narnach-file_wrapper --remote --source http://gems.github.com

Example

Detect the mime-type of a file.

  FileWrapper.get_mime('Rakefile') #=> 'text/plain'

http://github.com/Narnach/file_wrapper/tree/master

RubyGems 1.3.2

Release 1.3.2 fixes some bugs and adds some features.

Select New Features:

  • RubyGems now loads plugins from rubygems_plugin.rb in installed gems. This can be used to add commands (See Gem::CommandManager) or add install/uninstall hooks (See Gem::Installer and Gem::Uninstaller).
  • Gem::Version now understands prerelease versions using letters. (eg. ‘1.2.1.b’) Thanks to Josh Susser, Alex Vollmer and Phil Hagelberg.
  • RubyGems now includes a Rake task for creating gems which replaces rake’s Rake::GemPackageTask. See Gem::PackageTask.
  • Gem::find_files now returns paths in $LOAD_PATH.
  • Added Gem::promote_load_path for use with Gem::find_files
  • Added Gem::bin_path to make finding executables easier. Patch #24114 by James Tucker.
  • Various improvements to build arguments for installing gems.
  • `gem contents` added --all and --no-prefix.
  • Gem::Specification
    • #validate strips directories and errors on not-files.
    • #description no longer removes newlines.
    • #name must be a String.
    • FIXME and TODO are no longer allowed in various fields.
    • Added support for a license attribute. Feature #11041 (partial).
    • Removed Gem::Specification::list, too much process growth. Bug #23668 by Steve Purcell.
  • `gem generate_index`
    • Can now generate an RSS feed.
    • Modern indicies can now be updated incrementally.
    • Legacy indicies can be updated separately from modern.

Select Bugs Fixed:

  • Better gem activation error message. Patch #23082.
  • Kernel methods are now private. Patch #20801 by James M. Lawrence.
  • Fixed various usability issues with `gem check`.
  • `gem update` now rescues InstallError and continues. Bug #19268 by Gabriel Wilkins.
  • Allow ‘https’, ‘file’ as a valid schemes for --source. Patch #22485.
  • `gem install`
    • Now removes existing path before installing. Bug #22837.
    • Uses Gem::bin_path in executable stubs to work around Kernel#load bug in 1.9.
    • Correctly handle build args (after --) via the API. Bug #23210.
  • --user-install
    • `gem install --no-user-install` now works. Patch #23573 by Alf Mikula.
    • `gem uninstall` can now uninstall from ~/.gem. Bug #23760 by Roger Pack.
  • setup.rb
    • Clarify RubyGems RDoc installation location. Bug #22656 by Gian Marco Gherardi.
    • Allow setup to run from read-only location. Patch #21862 by Luis Herrera.
    • Fixed overwriting ruby executable when BASERUBY was not set. Bug #24958 by Michael Soulier.
    • Ensure we’re in a RubyGems dir when installing.
    • Deal with extraneous quotation mark when autogenerating .bat file on MS Windows. Bug #22712.

Deprecation Notices:

  • Gem::manage_gems has been removed.
  • Time::today will be removed in RubyGems 1.4.

For a full list of changes to RubyGems and the contributor for each change, see the ChangeLog file.

http://blog.segment7.net/articles/2009/04/15/rubygems-1-3-2

David Black’s Ruby 1.9 Video Tutorials

dblackenvycasts.jpg

Popular Ruby trainer and author David A Black has partnered up with Envycasts (from the Rails Envy guys) to produce a set of two Ruby 1.9 video tutorials / screencasts. You can buy each part (part 1, 2) on its own for $9 or the two together as a set for $16. If you choose the set, you'll also get a 40%-off coupon for David's new book, The Well Grounded Rubyist (the followup to Ruby for Rails).

http://www.rubyinside.com/david-blacks-ruby-19-video-tutorials-1695.html

jsPDF

jsPDF is an open-source library for generating PDF documents using nothing but Javascript. You can use it in a Firefox extension, in Server Side Javascript and with Data URIs in some browsers.

http://code.google.com/p/jspdf
http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript

MHTML - when you need data: URIs in IE7 and under

MHTML is MIME HTML, or if you insist on me spelling it out completely is like "Multipurpose Internet Mail Extensions HyperText Markup Language". In short it's HTML but like email with attachments. In one "multipart" email you can have several... hm, things - HTML version of the email, text-only version, attachment, another attachment...

MHTML is the same but for HTML. In one file you put a bunch of stuff (e.g. image files) and you save on the precious HTTP requests.

http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/

Thursday, April 16, 2009

Sorting Algorithm Animations

These pages show 8 different sorting algorithms on 4 different initial conditions. These visualizations are intended to:

  • Show how each algorithm operates.
  • Show that there is no best sorting algorithm.
  • Show the advantages and disadvantages of each algorithm.
  • Show that worse-case asymptotic behavior is not the deciding factor in choosing an algorithm.
  • Show that the initial condition (input order and key distribution) affects performance as much as the algorithm choice.

The ideal sorting algorithm would have the following properties:

  • Stable: Equal keys aren't reordered.
  • Operates in place, requiring O(1) extra space.
  • Worst-case O(n·lg(n)) key comparisons.
  • Worst-case O(n) swaps.
  • Adaptive: Speeds up to O(n) when data is nearly sorted or when there are few unique keys.

There is no algorithm that has all of these properties, and so the choice of sorting algorithm depends on the application.

http://www.sorting-algorithms.com
http://www.nihilogic.dk/labs/sorting_visualization

Monday, April 6, 2009

Active Merchant

Ruby library for dealing with credit cards and payment processors and shipping.

Active Merchant is an extraction from the e-commerce system Shopify. Shopify's requirements for a simple and unified API to access dozens of different payment gateways with very different internal APIs was the chief principle in designing the library.

Active Merchant has been in production use since June 2006 and is now used in most modern Ruby applications which deal with financial transactions.

It was developed to for usage in Ruby on Rails web applications and integrates seamlessly as a plugin but it also works excellently as a stand alone library.

http://www.activemerchant.org/