Wednesday, October 26, 2011
Rhodes
Rhodes is the ONLY framework with: support for Model View Controller (other frameworks force you to put all business logic into the view as JavaScript), synchronized data (the price of entry for enterprise apps), support for ALL devices (Android and iPhone is not “crossplatform”), a hosted build service (RhoHub – which changes the game for mobile app development entirely) and true industrial device capabilities such as NFC. Rhodes has many other major advantages over every other framework and underlying SDK, which can be summarized as modern development goodness for mobile apps.
If you don’t need an IDE and have Ruby already, you can install Rhodes with: “gem install rhodes”. Instructions on how to build your first app are in our Rhodes Tutorial
http://rhomobile.com/products/rhodes/
Thursday, October 6, 2011
fog - The Ruby cloud services library
http://fog.io/0.11.0/
Wednesday, August 31, 2011
defunkt/jquery-pjax - GitHub
what is it?
browser support
$.support.pjax boolean.$('a').pjax() calls will do nothing (aka links work normally) and $.pjax({url:url}) calls will redirect to the given URL.Tuesday, August 2, 2011
Constructable
https://github.com/mkorfmann/constructable
Sunday, July 31, 2011
enumerated_attribute
Typically, in Ruby, enumerated attributes are implemented with strings, symbols or constants. Often the developer is burdened with repeatedly defining common methods in support of each attribute. enumerated_attribute provides a DRY implementation for enumerations in Rails. Repetitive code such as initializers, accessors, predicate and enumeration methods are automatically generated along with the following features:
- ActiveRecord integration
- ActionView form helpers
- Scaffold generator integration
- Definable enumeration labels
- Enum helper methods
- Dynamic predicate methods
- Initialization
- State pattern support (enumerated_state)
Thursday, May 5, 2011
RubyGems 1.8.1
Currently RubyGems does not save the build arguments used to build gems with extensions. You will need to run gem pristine gem_with_extension -- --build-arg to regenerate a gem with an extension where it requires special build arguments.
- 1 minor enhancement:
- Added Gem::Requirement#specific? and Gem::Dependency#specific?
- Added Gem::Requirement#specific? and Gem::Dependency#specific?
- 4 bug fixes:
- Typo on Indexer rendered it useless on Windows
- gem dep can fetch remote dependencies for non-latest gems again.
- gem uninstall with multiple versions no longer crashes with ArgumentError
- Always use binary mode for File.open to keep Windows happy
- Typo on Indexer rendered it useless on Windows
Tuesday, February 22, 2011
vestal_versions for Rails 3
Wednesday, November 24, 2010
Wirble: Tab-Completion and Syntax Coloring for irb
If you haven't got tab-completion and syntax coloring in your irb, you owe it to yourself to follow these instructions right away (should work for Linux, OS X, and Cygwin users). First, install the Wirble gem:
sudo gem install wirbleNext, create or edit a file called .irbrc in your home folder (~/.irbrc), and make sure these lines are included there:
require 'rubygems' require 'wirble' Wirble.init Wirble.colorizeNow play with irb and see joy similar to that in the screenshot above. Try tab-completion too. It's great!
Monday, November 8, 2010
Social Stream
Social networking
Social networks are a new paradigm on web application design. Social networking platforms stand among the most popular websites, while many content oriented applications are supporting social networking features in order to improve engagement, enhance user awareness and stimulate communities around the website.Social Stream is based in Social Network Analysis concepts and methods, including social entities (actors), ties and relations. It also provides a new tie-based access control model.
Activity Streams
Activity Streams is a format for syndicating social activities around the web. It has already been adopted by some of the major social networking platforms.Social Stream provides a database schema based on the Activity Streams specification, leading your application towards a well-known compatible data model design.
Installation
Add to your Gemfile:gem 'social_stream'and run:
bundle updateThen, execute:
rails generate social_stream:installThis will generate the following:
- A jquery:install generation for jQuery support
- A devise:install generation for authentication support
- An initializer configuration file for Social Stream.
- A database seeds file for defining Social Stream relations, along with an entry
- A new application layout
- A migration providing the database schema
rake db:migrate rake db:seed
http://rubydoc.info/gems/social_stream/0.1.0/frames
Tuesday, October 5, 2010
Using acts_as_archive instead of soft delete
acts_as_paranoid or is_paranoid and be done with it, but I've had trouble with that approach before.I've been reading a lot about the trouble with "soft deletes" (flagging a record as deleted instead of deleting it). Using a plugin that monkey patches ActiveRecord can go a long way towards fixing thesee problems, but it's a leaky abstraction and will bite you in the ass in unexpected ways. For example, all your uniqueness validations (and indexes) become much more complicated.
That's why Jeffrey Chupp decided to kill
is_paranoid and Rick Olson doesn't use acts_as_paranoid any more.There are other problems too. If you delete a lot of records, and you keep them in the same table, your table can get quite large, and all your queries slow down. At this point you have to use partitioning or partial indexes to get acceptable performance.
Alternatives to soft delete
In my reading, I found two alternatives to soft delete to be compelling.The first was the suggestion to properly model your domain. Why do you want to delete a record? What does that mean? Udi Dahan puts it this way:
Orders aren’t deleted – they’re cancelled. There may also be fees incurred if the order is canceled too late.Keeping that in mind, what if the task at hand really is to delete the record? The other idea that I liked was to archive the records in another table.
Employees aren’t deleted – they’re fired (or possibly retired). A compensation package often needs to be handled.
Jobs aren’t deleted – they’re filled (or their requisition is revoked).
The first Rails plugin I came across that implemented this was
acts_as_soft_deletable which besides being misnamed doesn't appear to be actively maintained. The author even disavows the plugin somewhat for Rails 2.3:Before using this with a new Rails 2.3 app, you may want to consider using the newThen I founddefault_scopefeature (ornamed_scopes) with adeleted_atflag.
acts_as_archive which is more recently maintained and used in production for a major Rails website. There was only one problem --
acts_as_archive didn't support PostgreSQL. Fortunately, that was easy enough to fix. Restoring deleted records with acts_as_archive
acts_as_archive has the ability to restore a deleted record, but only that record, not associated records.I was troubled by this at first, but after thinking about it I came to the conclusion that restoring a network of objects is an application-dependant problem. Here's one way to achieve it.
Imagine you have a model like this, with Posts having many Comments and Votes.
A Post can be deleted, and when it is, it should take the Comments and Votes with it:
class Post
acts_as_archive
has_many :votes, :dependent => :destroy
has_many :comments, :dependent => :destroy
end
(Assume Comment and Vote also have acts_as_archive.)Now, I can restore a Post with its associated Votes and Comments like this:
def self.restore(id)
transaction do
Post.restore_all(["id = ?", id])
post = Post.find(id)
Vote.restore_all(Vote::Archive.all(:conditions => ["post_id = ?", id]).map(&:id))
Comment.restore_all(Comment::Archive.all(:conditions => ["post_id = ?", id]).map(&:id))
end
In my real code, I've broken apart the two pieces of this into a class method restore and an instance method post_restore which the freshly restored object uses to find its associated records and restore them. post_restore also takes care of post-restore tasks like putting the object back in the Solr index.This all works great. But now let's say Comments can be deleted individually, and we want to restore them.
Here the logic is a little different, because a Comment can't be restored unless its parent Post still exists (unless it's being restored by the Post, as above).
I take care of this logic in the administrative controller, by only showing child objects that it's valid to restore, and my foreign key constraints prevent anyone from getting around that.
I really wanted to delete that!
Sometimes you don't want to archive a deleted object. For example, in the application I'm working on, votes are canceled by re-voting. I don't want to save those votes -- there's no point, and it can even cause problems with restoring. Imagine having several archived votes from a user for a Post, and then deleting and restoring that Post. The restoration will try to bring back all the votes. Again, I catch this with a uniqueness constraint, but I don't want it to happen in the first place.Fortunately
acts_as_archive has me covered.To destroy a record without archiving it, you can use
destroy!. Likewise for deleting, there is delete_all!.http://railspikes.com/2010/2/26/acts-as-archive?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+RailSpikes+%28Rail+Spikes%29
Sunday, October 3, 2010
SlowGrowl
http://github.com/igrigorik/slowgrowl
Monday, August 9, 2010
class UseJsonGemInRailsclass << selfdef save_json_gem_to_jsonrequire 'json'classes.each do |klass|klass.class_eval doalias_method :to_json_from_gem, :to_jsonendendenddef reload_json_gem_to_json(classes + [ActiveSupport::JSON::Variable]).each do |klass|klass.class_eval doalias_method :to_json, :to_json_from_gemendendenddef classes[Object,Hash,Array,String,Numeric,Float,Integer,Regexp,]endendend
http://gist.github.com/461938
Friday, July 30, 2010
Scraping with style: scrAPI toolkit for Ruby
Monday, July 19, 2010
Whenever
Ryan Bates created a great Railscast about Whenever: railscasts.com/episodes/164-cron-in-ruby
Discussion: groups.google.com/group/whenever-gem
http://github.com/javan/whenever
Wednesday, July 14, 2010
Making urls look memorable
- Real-time thumbnails
- Flash 10 Support
- PDF Support
- Quick response times
- REST API
- API clients for PHP, Ruby, Python
- Cache the thumbnails on your server or Webthumbs
- Browser windows from 75x75 to 1280x2048
http://www.paulhammond.org/webkit2png/
http://stackoverflow.com/questions/726660/how-do-i-make-beautiful-screenshots-of-web-pages-using-ruby-and-a-unix-server
rbwebkitgtk: http://github.com/danlucraft/rbwebkitgtk/tree/master
Moz snap shooter: http://www.lilik.it/~mirko/Ruby-GNOME2/moz-snapshooter.rb
http://www.hackdiary.com/2004/06/13/taking-automated-webpage-screenshots-with-embedded-mozilla/
Selenium RC has a Ruby interface and can grab a screenshot using: http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/ruby/classes/Selenium/Client/GeneratedDriver.html#M000220
PageGlimpse is a service providing developers with programatic access to thumbnails of any web page. The thumbnails can be virtually used in any kind of applications that require the display of website screenshots: web sites, windows/linux/mac applications, iPhone/mobile utilities, browser plugins, etc.
Including web site thumbnails in your application will dramatically improve the user experience. The service is easy to use, fast and reliable, no restriction on thumbnail sizes or number of hits. Click here to see how it works.
http://www.pageglimpse.com/
Monday, June 14, 2010
Deep_merge: Ruby Recursive Merging for Hashes
Take this code:
h1 = {:x => {:y => [4,5,6], :z => [7,8,9]}}
h2 = {:x => {:y => [1,2,3], :z => 'xyz'}}If you want to merge these two hashes, what should happen? Well there are several possibilities. Let’s see how deep_merge handles it:h2.deep_merge!(h1)
# results: h2 = {:x=>{:z=>[7, 8, 9], :y=>[1, 2, 3, 4, 5, 6]}}
# notice we overwrote 'xyz'! (That's what the bang means)
# Let's try it without the bang:
h1 = {:x => {:y => [4,5,6], :z => [7,8,9]}}
h2 = {:x => {:y => [1,2,3], :z => 'xyz'}}
h2.deep_merge(h1)
# results: h2 = {:x=>{:z=>"xyz", :y=>[1, 2, 3, 4, 5, 6]}}
# notice 'xyz' didn't get overwritten this time. No bang.Let’s get a little more complicated with a “knockout” merge. We introduce a special string “–” which can “knockout” an element in an existing hash or array element:h1 = {:x => {:y => ["d","e","--c"]}}
h2 = {:x => {:y => ["a","b","c"]}}
h2.ko_deep_merge!(h1)
# h2 = {:x=>{:y=>["a", "b", "d", "e"]}}
# notice no "c" any more!Many of these features are configurable to your needs – feel free to read up in the source code. Home page and installation instructions are here: http://trac.misuse.org/science/wiki/DeepMergehttp://www.misuse.org/science/2008/05/19/deep_merge-ruby-recursive-merging-for-hashes/
Monday, June 7, 2010
BackgrounDRb
http://backgroundrb.rubyforge.org/
Monday, April 26, 2010
DrX
DrX, the good doctor, is a small object inspector for Ruby.
DrX is for newbies and gurus alike.
Instead of focusing on the contents of your object, DrX instead focuses on its object model. As a result, DrX is most suitable for programmers wishing to understand Ruby's object model better. It's especially adept at showing you how a "magical" library works (e.g., DataMapper).
Key features:
- See everything about a Ruby object: its 'klass', 'super', 'iv_tbl', 'm_tbl'. See your singletons with your very own eyes!
- Double-click a method to launch an editor and position the cursor on the exact line where the method is defined!
Installation
At your system prompt type:gem install drx Requirements
require 'drx'Errors and solutions:MissingSourceFile: no such file to load -- tk
- require 'tcltklib' (install Tcl/Tk interface for Ruby)RuntimeError: TkPackage can't find package tile
- install themed widget set provider library for TkRuntimeError: ERROR: Failed to run the 'dot' command. Make sure you have the GraphViz package installed and that its bin folder appears in your PATH.
- install rich set of graph drawing tools (GraphViz)
Thursday, March 25, 2010
Monitoring delayed_job with bluepill
Bluepill is a pure-ruby process monitoring library similar to god/monit. Unlike god, bluepill doesn’t leak memory (according to the bluepill authors anyway :] .)
To set up delayed_job, please have a look at this asciicast (note that you should use the collectiveidea-delayed_job fork for this!)
http://rails.co.za/2009/11/14/monitoring-delayed-job-with-bluepill.html
Thursday, March 11, 2010
Enigmamachine
Enigmamachine is a video processor which queues and encodes videos according to target profiles that you define. Videos must be on a locally mounted filesystem. The processor takes the path to the video, and executes multiple ffmpeg commands on the video. There is a handy web interface for defining encoding tasks, and a restful web service which takes encoding commands.
Enigmamachine is written using Sinatra, Thin, and Eventmachine.
Bookmarks
Generators
- .NET Buttons
- 3D-box maker
- A CSS sticky footer
- A web-based graphics effects generator
- Activity indicators
- Ajax loader
- ASCII art generator
- Attack Ad Generator
- Badge shape creation
- Binary File to Base64 Encoder / Translator
- Browsershots makes screenshots of your web design in different browsers
- Button generator
- Buttonator 2.0
- Color Palette
- Color schemer
- Color Themes
- Colorsuckr: Create color schemes based on photos for use in your artwork & designs
- Create DOM Statements
- CSS Organizer
- CSS Sprite Generator
- CSS Sprites
- CSS Type Set
- Digital Post It Note Generator
- Easily create web forms and fillable PDF documents to embed on your websites
- egoSurf
- Favicon Editor
- Favicon generator
- Flash website generator
- Flip Title
- Flipping characters with UNICODE
- Form Builder
- Free Footer online tools for webmasters and bloggers.
- Free templates
- FreshGenerator
- Genfavicon
- hCalendar Creator
- HTML form builder
- HTML to Javascript DOM converter
- Image Mosaic Generator
- Image reflection generator
- img2json
- JSON Visualization
- Login form design patterns
- Logo creator
- Lorem Ipsum Generator
- LovelyCharts
- Markup Generator
- Mockup Generator
- Online Background Generators
- PatternTap
- Pixenate Photo Editor
- Preloaders
- Printable world map
- punypng
- Regular Expressions
- RoundedCornr
- SingleFunction
- Spam proof
- Stripe designer
- Stripe generator 2.0
- Tabs generator
- Tartan Maker. The new trendsetting application for cool designers
- Test Everithing
- Text 2 PNG
- The Color Wizard 3.0
- tinyarro.ws: Shortest URLs on Earth
- Web 2.0 Badges
- Web UI Development
- Website Ribbon
- wwwsqldesigner
- Xenocode Browser Sandbox - Run any browser from the web
- XHTML/CSS Markup generator
Library
- 12 Steps to MooTools Mastery
- AJAX APIs Playground
- Best Tech Videos
- CSS Tricks
- FileFormat.info
- Grafpedia
- IT Ebooks :: Videos
- Learning Dojo
- Linux Software Repositories
- NET Books
- PDFCHM
- Rails Engines
- Rails Illustrated
- Rails Metal: a micro-framework with the power of Rails: \m/
- Rails Podcast
- Rails Screencasts
- RegExLib
- Ruby On Rails Security Guide
- Ruby-GNOME2 Project Website
- Rubyology
- RubyPlus Video
- Scaling Rails
- Scripteka
- This Week in Django
- WebAppers