This file contains 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
When the constraints block is active, I get RoutingError: No route matches "/" when going to localhost:3000. If I comment the block out, it works just fine. But I need both: | |
http://example.com should render PagesController#show with params[:permalink] being 'index' | |
http://clemensk.example.com should render ProfilesController#show | |
Hints anyone? | |
Thanks! |
This file contains 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
After upgrading OSX, the cucumber features down with *phantomJS not found* error. | |
In terminal was all ok. | |
Soltion: | |
Just install https://github.com/int3h/SublimeFixMacPath plugin for ST3. |
This file contains 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
Dear Candidate | |
Thank you for applying for the Ruby on Rails Developer position at Product Madness. In order to take you through to the next stage interview we would like you to complete a short skill text. | |
With reference to the below red text please add your code instead of the '# Put your code here’ line. You need to implement developer class so DataBase#find_developer method does not fail. Try to add as few lines of code as possible. | |
class Developer | |
# Put your code here | |
end |
This file contains 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 Developer | |
def initialize | |
@chain = [] | |
end | |
def are | |
@chain << "I" | |
self | |
end |
This file contains 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 flattify(array) | |
array.each_with_object([]) do |element, flattened| | |
flattened.push *(element.is_a?(Array) ? flattify(element) : element) | |
end | |
end |
This file contains 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
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04 | |
How To Install and Configure Redis on Ubuntu 16.04 | |
PostedMay 11, 2016 51.6k views NOSQL REDIS UBUNTU UBUNTU 16.04 | |
Introduction | |
Redis is an in-memory key-value store known for its flexibility, performance, and wide language support. In this guide, we will demonstrate how to install and configure Redis on an Ubuntu 16.04 server. | |
Prerequisites | |
To complete this guide, you will need access to an Ubuntu 16.04 server. You will need a non-root user with sudo privileges to perform the administrative functions required for this process. You can learn how to set up an account with these privileges by following our Ubuntu 16.04 initial server setup guide. |
This file contains 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
This is a demo task. | |
A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such that 0 ≤ P < N and the sum of elements of lower indices is equal to the sum of elements of higher indices, i.e. | |
A[0] + A[1] + ... + A[P−1] = A[P+1] + ... + A[N−2] + A[N−1]. | |
Sum of zero elements is assumed to be equal to 0. This can happen if P = 0 or if P = N−1. | |
For example, consider the following array A consisting of N = 8 elements: | |
A[0] = -1 | |
A[1] = 3 |
This file contains 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
module AuthenticityTokenCatcher | |
extend ActiveSupport::Concern | |
included do | |
rescue_from ActionController::InvalidAuthenticityToken do |exception| | |
if request.referrer | |
flash[:error] = I18n.t :authenticit_token_error | |
redirect_to request.referrer | |
else | |
raise exception | |
end |
This file contains 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
Dir["app/assets/images/*"].each do |image| | |
name = File.basename(image) | |
if Dir.glob("**/*").reject {|fn| File.directory?(fn) }. | |
map{|fn| File.read(fn).include?(name) ? fn : nil }.any? | |
p image | |
else | |
p "To delete: #{image}" | |
File.delete image | |
end | |
end |
This file contains 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
# Let we have Post(title, body) -> Comments(body). | |
# Write the active record query to get all posts, where "query" is into title or body or comment. | |
class Post < ActiveRecord::Base | |
#title, body | |
has_many :comments | |
scope :search, ->(text) { | |
wildcard_search = "%#{text}%" | |
joins(:comments).where("title ILIKE :search OR body ILIKE :search OR comments.body ILIKE :search", search: wildcard_search) |
OlderNewer