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
set tabstop=2 shiftwidth=2 expandtab | |
set autoindent | |
set smarttab | |
syntax on | |
set shell=/bin/bash | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() |
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 Utils | |
def self.compare(reports, n: 10) | |
Benchmark.bm do |x| | |
reports.each do |report| | |
if report.is_a?(Proc) | |
x.report { n.times { report.call } } | |
else | |
x.report(report.first) { n.times { report.last.call } } | |
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
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__)) |
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
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
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 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
# 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
Ruby: | |
type: programming | |
ace_mode: ruby | |
codemirror_mode: ruby | |
codemirror_mime_type: text/x-ruby | |
color: "#701516" | |
aliases: | |
- jruby | |
- macruby | |
- rake |