Monday, October 27, 2008

Humanize numbers with Ruby

Install
#config/initializers/numeric_humanize.rb

 1  class Numeric
2 def humanize(rounding=2,delimiter=',',separator='.')
3 value = respond_to?(:round_with_precision) ? round(rounding) : self
4
5 #see number with delimeter
6 parts = value.to_s.split('.')
7 parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
8 parts.join separator
9 end
10 end

Usage:
puts 1.humanize
#=> 1
puts 1000000.humanize
#=> 1,000,000
puts 1000.12345.humanize
#=> 1,000.12345

A DB admin interface written in Rails

The Rails Rumble 2008 took place last week end and we took this contest as an opportunity to bootstrap a project we had in mind for some time. I teamed up with Jessy Bernal, with whom I am developing at Massive Brain Games, and Sylvain Utard, the creator of Live On Bankiz. The said project is a DB interface written in Rails and meant as a replacement for the classic phpMyAdmin. Not an extremely original idea I must confess but we found nonetheless a few reasons that motivated this project.

http://dev.massivebraingames.com/past/2008/10/21/a_db_admin_interface_written

Easy Upload via URL with attachment_fu

Allowing file uploads with attachment_fu is super easy, but I've found that users sometimes want to be able to "upload" a file directly from a URL. This saves them the steps of downloading the file, finding it on their computer, uploading it into your app, etc.

I did a bit of digging around before I came across this handy trick that makes it pretty painless to add uploading via a URL to your app. I've wrapped up the code a bit and added in a few niceties that I found necessary to avoid raising exceptions unnecessarily.

The best part is that you don't need to change anything about your controller in order to get this to work. All you need is to add the uri attribute to your model and views, and you're good to go.

http://almosteffortless.com/2008/10/24/easy-upload-via-url-with-attachment_fu/

Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint 2007 File Formats

Open, edit, and save documents, workbooks, and presentations in the file formats new to Microsoft Office Word, Excel, and PowerPoint 2007.

By installing the Compatibility Pack in addition to Microsoft Office 2000, Office XP, or Office 2003, you will be able to open, edit, and save files using the file formats new to Word, Excel, and PowerPoint 2007. The Compatibility Pack can also be used in conjunction with the Microsoft Office Word Viewer 2003, Excel Viewer 2003, and PowerPoint Viewer 2003 to view files saved in these new formats. For more information about the Compatibility Pack, see Knowledge Base article 924074.

http://www.microsoft.com/downloads/details.aspx?FamilyId=941B3470-3AE9-4AEE-8F43-C6BB74CD1466&displaylang=en

Monday, October 20, 2008

Blackbird


Blackbird offers a dead-simple way to log messages in JavaScript and an attractive console to view and filter them. You might never use alert() again.

The code (blackbird.js, blackbird.css) and image assets (blackbird_panel.png, blackbird_icons.png) were created by G. Scott Olson.

The concept for Blackbird was sparked by JavaScript Logging, an article by David F. Miller. The first iteration of this project, named jsLogger, was developed for internal use at Orbitz. In the fall of 2007, jsLogger was rewritten from the ground up, given a facelift, and named project Blackbird.

http://www.gscottolson.com/blackbirdjs/