module A; end
module B; end
class C; end
class D < C; end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Framework | |
| # =========================================== | |
| module ContextAccessor | |
| def context | |
| Thread.current[:context] | |
| end | |
| end | |
| module Context | |
| include ContextAccessor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The code can be seen here: gist.github.com/2711153 (it does use a small bit | |
| # from the Rails framework, just for the persisted LedgerEntry and to create | |
| # attribute readers). Some notes about the code: | |
| # - Each Role is a class, having only (public) class methods. To help | |
| # avoid them being called outside of their Context, a Role Method only has | |
| # access to its associated object while the role's context is the | |
| # current/active global context. | |
| # - Following Trygve's approach: "Roles are referenced by name. If I mean | |
| # the Role I write the role name, not 'self'." | |
| # - For referencing the object playing a role, I've overridden the Role's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Expand print panel by default | |
| defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true | |
| # Disable the “Are you sure you want to open this application?” dialog | |
| defaults write com.apple.LaunchServices LSQuarantine -bool false | |
| # Enable subpixel font rendering on non-Apple LCDs | |
| defaults write NSGlobalDomain AppleFontSmoothing -int 2 | |
| # Disable press-and-hold for keys in favor of key repeat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DashboardPresenter < ClassicPresenter::Base | |
| def navigation | |
| if context.controller_name == 'vendors' | |
| context.render 'shared/dashboard/vendor_navigation' | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ----------------------------------------- | |
| Boilerplate code (in rails_app_root/lib) | |
| ----------------------------------------- | |
| module ContextAccessor | |
| def context | |
| Thread.current[:context] | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def screenshot | |
| require 'capybara/util/save_and_open_page' | |
| now = Time.now | |
| p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}" | |
| Capybara.save_page body, "#{p}.html" | |
| path = Rails.root.join("#{Capybara.save_and_open_page_path}" "#{p}.png").to_s | |
| page.driver.render path | |
| Launchy.open path | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Organization | |
| def to_param | |
| "42" | |
| end | |
| def saved? | |
| rand > 0.5 | |
| end | |
| end | |
Dear Rubyists,
I just lost a contract because of my code in a Rails project.
The specific code in question is related to a "posting a comment" feature. Here are the details:
In this project, "posting a comment" does not simply entail inserting a row into the database. It involves a procedure to yes, insert a row, but also detect its language, check for spam, send emails, and "share" it to Twitter and Facebook. I believe this algorithm should be encapsulated. I do not believe it belongs in a controller or a model. I do not believe Active Record callbacks should be used.
The "senior developer", whom is the stake holder's right hand man, said this:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sete Atitudes para Hackear a Indústria de Software | |
| By Klaus Wuestefeld | |
| 1) Torne-se excelente. | |
| Seja realmente bom em alguma coisa. Não fique só choramingando ou | |
| querendo progredir às custas dos outros. Não pense q pq vc sentou 4 | |
| anos numa faculdade ouvindo um professor falar sobre software q vc | |
| sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo |