background preloader

Web Development

Facebook Twitter

Alphagov/cdn_helpers. Caching, Zipping, and (Amazon CloudFront) CDN For A Rails App - Alfa Jango Blog. 18 June 2010 This is Article #4 of a 4-part series.

Caching, Zipping, and (Amazon CloudFront) CDN For A Rails App - Alfa Jango Blog

For a good primer, check out the first two articles listed below. For the reasoning and analysis behind the "Recommended" option in this article, check out Part 3, How to Combine GZip + CDN for Fastest Page Loads. Otherwise, jump right in! In this article, we're going to speed up our Rails application by up to 75%, simply by optimizing our Rails asset host. The best option for you may depend on your specific needs, but I'll cover both processes below. Prerequisites Cached Stylesheets and Javascripts Another way to reduce page load time is to combine all of your components into as few files as possible. Luckily in Rails, this is easy, simply add :cache => 'cached-file-name' to your stylesheet_link_tag and javascript_include_tag in your application layout. Config.action_controller.perform_caching = true Creating an Amazon AWS Account Setup S3 Buckets Setup CloudFront Distributions Create CNAME Records (optional) Install Rails S3 Synch Plugin.

Josevalim's gist: af7e572c2dc973add221. Railtie is the core of the Rails Framework and provides several hooks to extend Rails and/or modify the initialization process.

josevalim's gist: af7e572c2dc973add221

Every major component of Rails (Action Mailer, Action Controller, Action View, Active Record and Active Resource) are all Railties, so each of them is responsible to set their own initialization. This makes, for example, Rails absent of any ActiveRecord hook, allowing any other ORM to hook in. Developing a Rails extension does not require any implementation of Railtie, but if you need to interact with the Rails framework during boot, or after boot, then Railtie is what you need to do that interaction. For example, the following would need you to implement Railtie in your plugin: creating initializersconfiguring a Rails framework or the Application, like setting a generatoradding Rails config.* keys to the environmentsetting up a subscriber to the Rails +ActiveSupport::Notifications+adding rake tasks into rails Creating your Railtie. Ruby - How do I convert an existing Rails 3 Application into an Engine.

Rails 3.1: Engine vs. Mountable App. HOWTO: Rails 3.1 Engines with RSpec : Mike's burogu. You’ll need RVM and at least Ruby 1.9.2-p290 installed to proceed. Run the following to generate the engine rails plugin new epic_fail --skip-test-unit --full --mountable --dummy-path =spec / dummy Add the following .rvmrc file to your engine’s root folder rvm use 1.9.2 @ rails31 --create --rvmrc This will automatically generate the files and folder structure of your engine. $:. push File . expand_path ( ".. # Maintain your gem's version: require "epic_fail/version" # Describe your gem and declare its dependencies: Gem::Specification . new do | s | s. name = "epic_fail" s. version = EpicFail::VERSION s. authors = [ "TODO: Your name" ]

How to do an HTTP conditional GET with Feedzirra (update an existing feed) - Ruby - feedzirra, conditional-get, rss, atom, feed. Pauldix/feedzirra. jQuery hashchange event. This jQuery plugin enables very basic bookmarkable #hash history via a cross-browser HTML5 window.onhashchange event.

jQuery hashchange event

While this functionality was initially tied to the jQuery BBQ plugin, the event.special window.onhashchange functionality has now been broken out into a separate plugin for users who want just the basic event & back button support, without all the extra awesomeness that BBQ provides. Why is a plugin needed for the hashchange event? Right now, in Internet Explorer 8, Firefox 3.6+, and Chrome 5+, you can bind callbacks to the window.onhashchange event and use it without any kind of plugin.

Of course, what happens when you want your code to work in a browser that doesn’t support window.onhashchange? Well, nothing happens.. because the event doesn’t exist, so it never fires. How does the plugin work? When a browser-native window.onhashchange event is detected, that event is used for the hashchange event automatically. A basic usage example. Twitter Bootstrap.

Useful CSS3 LESS Mixins.

Css

Less.