Links tagged with “Ruby”
- All (24)
- Entries (5)
- Links (19)
- Photos (0)
Ruby Hash Tricks
Some really cool tricks with Ruby hashes–if you supply a block to Hash.new, that will act as a default value for a given key. For example, here’s a Fibonacci hash I put together which caches the values (making it pretty quick):
fibonacci = Hash.new do |h,k|
if k < 2
h[k] = k
else
h[k] = h[k-1] + h[k-2]
end
end
fibonacci[6] # => 8
fibonacci[100] # => 354224848179261915075
The Official Viddler Ruby Gem
I just announced our new Ruby gem over on the Viddler blog. It’s a fairly basic wrapper for our v2 API for now, but I definitely have plans for some really cool features, like having ActiveModel compatible classes for stuff like videos, playlists, users, etc., as well as making it easy to integrate into existing ActiveRecord models in Rails.
So, if you’re into Ruby and you’re looking for a way to integrate video into your site, definitely check us out. We have a really great API, and now that there’s an official gem, it’s easier than ever to get started.
Canable: The Flesh Eating Permission System
John Nunemaker releases his super-simple way to implement permissions in a Rails app. I love how this does away with a complicated role system and just deals with whether or not a user can do specific action. Simplicity at its finest.
Rack::Codehighlighter
A really clever solution to highlighting code through Rack middleware. I’m going to have to replace my current Javascript solution with this, seems a lot less kludgy.
RSpec and Sinatra Quick Start
Quick and easy way to test a Sinatra app with RSpec.
Eight tips for getting the most out of your Rails app
Some good tips on optimizing your Rails site. I’m already using a couple of these on this site, but I definitely want to try out the rest of them as well.
Filestore Cache Expires_in Plugin
Adds an :expires option to filestore caching in Rails–I’ll definitely have to try this out on this site, as standard cache expiration using sweepers and observers is a huge pain.
That’s Not a Memory Leak, It’s Bloat
Excellent post by the team over at EngineYard on common memory issues in Rails, as well as how to fix them. Also be sure to check out the comments below, as there are a lot more suggestions on how to improve your app.
Compiling Ruby, RubyGems, and Rails on Snow Leopard
Dan Benjamin walks through how to install Ruby, RubyGems, and Rails on Snow Leopard. Also be sure to check out his other Snow Leopard guides for Mercurial, Git, and MySQL.
Simple APIs using SerializeWithOptions
Viget Labs rolls out a Rails plugin to cleanup your API’s code.
Instead of doing this in the controller:
@speaker.to_xml(
:methods => [:average_rating, :avatar_url],
:except => [:email, :claim_code],
:include => {
:talks => {
:methods => :average_rating,
:except => :creator_id
}
}
)
You move it to the class like this:
class Speaker < ActiveRecord::Base
serialize_with_options do
methods :average_rating, :avatar_url
except :email,
:claim_code
includes :talks
end
end
Great way to DRY up your code.
Haml/Sass 2.2 Released
Haml/Sass 2.2 was released today, and it’s got a lot of great new features. While I’ve never tried Haml, I use Sass for this site, and I can’t wait to try out 2.2. My favorite update: mixins with arguments
Practical Sorcery with irb
Clinton from Viget Labs posted some great ways to extend your ~/.irbrc file. I especially like the auto-indent trick–definitely helps to make irb a lot easier to use.
