FridayHug.com http://fridayhug.com
The Smallest Rails App http://thesmallestrailsapp.com
%w(action_controller/railtie coderay).each &method(:require)| #Model | |
| @user.should have(1).error_on(:username) # Checks whether there is an error in username | |
| @user.errors[:username].should include("can't be blank") # check for the error message | |
| #Rendering | |
| response.should render_template(:index) | |
| #Redirecting | |
| response.should redirect_to(movies_path) |
| "use strict"; | |
| // Uses jQuery and Q. | |
| var API_KEY = "whatever"; | |
| function getFlickrResponseAsync(method, responseProperty, params) { | |
| var deferred = Q.defer(); | |
| $.ajax("http://www.flickr.com/services/rest/", { |
| def saop | |
| save_and_open_page | |
| end | |
| def screenshot | |
| page.driver.render("/home/roger/shot.jpg", :full => true) | |
| end | |
| def select_should_have(locator, text) | |
| node = page.find_field(locator) |
FridayHug.com http://fridayhug.com
The Smallest Rails App http://thesmallestrailsapp.com
%w(action_controller/railtie coderay).each &method(:require)[note: this was originally published on 08/27/2012. Other writing can be found here.]
Monitoring tooling has been a fascination of mine since I began hacking on computing systems. Every ops engineer wants to write their own. I get that. I'm one of those guys, too.
However, these endeavours always end up spitting out large, monolithic applications that just aren't as good as the already existing (and somewhat crappy) monolithic applications. I'd prefer to avoid that approach, if only to make it a point that the monitoring story can never be finalized. We will never reach an end state, but the more flexible our tooling the better.
Traditional Unix philsophy gives us something to go on here. What if, instead of writing large applications, we just wrote a bunch of tiny tools. AND - rather than writing each of these tiny tools as sexy network daemons (which
| # Copyright (c) 2013 Stan Chang Khin Boon (http://lxcid.com/) | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: | |
| # | |
| # The above copyright notice and this permission notice shall be included in |
| def rails_between(min, max) | |
| Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new(min) && Gem::Version.new(Rails::VERSION::STRING) <= Gem::Version.new(max) | |
| end | |
| if rails_between('3.0.0', '3.0.18') || rails_between('3.1.0', '3.1.9') || rails_between('3.2.0', '3.2.10') | |
| ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML) | |
| end | |
| if rails_between('2.0.0', '2.3.14') | |
| ActionController::Base.param_parsers.delete(Mime::XML) | |
| end |
| module MyApp | |
| class Application < Rails::Application | |
| require Rails.root + 'lib/custom_public_exceptions' | |
| config.exceptions_app = CustomPublicExceptions.new Rails.public_path | |
| end | |
| end |
| // Grid shortcuts | |
| // use with https://github.com/anjlab/bootstrap-rails | |
| // | |
| // Columns for phones | |
| // - columns: .x[1-12] | |
| // For small devices (tablets and small desktops) | |
| // - columns: .s[1-12] | |
| // - offsets: .so[0-11] | |
| // - pushes: .sr[0-11] | |
| // - pulls: .sl[0-11] |