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
| # frozen_string_literal: true | |
| class UserService | |
| include SessionsHelper | |
| def sigin_user | |
| user = User.find_by_email(@email) | |
| if user.present? | |
| login(user) | |
| response = { success: 'User Logged In successfully.' } | |
| else |
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
| HTTP_ERRORS = [ | |
| EOFError, | |
| Errno::ECONNRESET, | |
| Errno::EINVAL, | |
| Net::HTTPBadResponse, | |
| Net::HTTPHeaderSyntaxError, | |
| Net::ProtocolError, | |
| Timeout::Error, | |
| Errno::ENETDOWN | |
| ] |
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
| Ruby: | |
| type: programming | |
| ace_mode: ruby | |
| codemirror_mode: ruby | |
| codemirror_mime_type: text/x-ruby | |
| color: "#701516" | |
| aliases: | |
| - jruby | |
| - macruby | |
| - rake |
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
| # Hey guys I got a problem with my reviews controller when it comes to post a review, I'm using devise , is a online shop, and To post a review Im using AJAX, but the AJAX does not work | |
| # this is my ReviewsController: | |
| class ReviewsController < ApplicationController | |
| #before_action :set_shirt, only: [:show] | |
| def create | |
| @shirt = shirt_url.find(params[:shirt_id]) |
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 Lazy | |
| attr_reader :value | |
| def initialize(function:, value:) | |
| @function = function | |
| @value = value | |
| @cached = nil | |
| @is_cached = false | |
| 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 Search | |
| attr_reader :verbose | |
| def initialize(search, verbose: false) | |
| @parts = search.split.map(&:downcase) | |
| @verbose = verbose | |
| end | |
| def self.matches?(search:, record:) | |
| new(search).matches?(record) |
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 Struct | |
| def self.from_hash(attributes) | |
| new(*attributes.keys).new(*attributes.values) | |
| end | |
| end | |
| user = Struct.from_hash(id: 1, name: "?") | |
| user.id # => 1 | |
| user.names # => NoMethodError (undefined method `names' for #<struct id=1, name="?">) |
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
| # Example: Lazy.new(lambda { |id| API::HackerNews.item(id) }, 0) | |
| class Lazy | |
| attr_reader :value | |
| def initialize(function:, value:) | |
| @function = function | |
| @value = value | |
| @cached = nil | |
| @is_cached = false |
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
| Capybara.register_driver :selenium_chrome do |app| | |
| options = Selenium::WebDriver::Chrome::Options.new | |
| options.add_argument("--window-size=1440,900") | |
| options.add_argument("--proxy-server=localhost:8080") | |
| options.add_argument("--disable-infobars") | |
| options.add_argument("--disable-notifications") | |
| options.add_argument("--disable-sync") | |
| options.add_argument("--mute-audio") | |
| options.add_extension( | |
| File.expand_path("../tmp/ublock.crx", File.dirname(__FILE__)) |
