-
Implement a Class, name it RecentFiles
-
You can start implementing your class from 2nd line onwards.
-
You can run the test code, which will test your code using the following command:
rspec file_name.rb -
You can replace the
file_name.rbwith your actual file which you are working with. -
If you get any errors such as
rspec not foundetc, please do:sudo gem install rspec -
The class should be able to handle the following scenarios:
- Output a list of most recent accessed files.
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
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
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
| #====== Implement your solution below: | |
| # class RecentFiles | |
| # end | |
| #====== Solution implementation ends | |
| require 'rspec' |
-
http://ruby-doc.org/core-2.2.0/File.html#method-c-directory-3F
-
Loop Recursively Until no Directories are left to loop over.
-
Use
File.readto read the YML file one at a time. -
require 'yaml' module to start using it.
-
Use the
YAMLmodule'sloadmethod to convert the YAML into a Ruby data structure, ie:Hash
FriendInviter is a web based application that can be used to, well, wait for it: Invite Friends :P. The goal of the application is to allow a user to invite a maximum of 3 of their friends using their email addresses. Here are some requirements:
- Initial user can be either hardcoded or seeded manually in the application from a console etc.
- Initial user sends out an email invite to 3 of his/her friends aka Recepients.
- Recepients receive email invitations to join FriendInviter.
- Upon acceptance of each invite, the person who sent the Invite is credited with points. Each successful invite yields 50 points.
- If all 3 invites are successfully accepted, a bonus of 200 points is also awarded.
- Invites should be valid for a maximum of 15 minutes.
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 Component extends React.Component { | |
| component___Mount() { // didMount? willMount? | |
| window.api.asyncCallToBackend() // returns promise | |
| } | |
| render() { | |
| return (<data here that depends on response of async call in one lifecycle methods>) | |
| } |
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 ApplicationController | |
| before_action :authenticate_user | |
| def authenticate_user | |
| response = TokenAuthService.call(token: request.headers['Api-Token'] || params[:api_token]) | |
| if response.failure? | |
| render json: { | |
| error: 'Not Authorized', | |
| message: response.error |
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
| from collections import defaultdict | |
| def stableMatching(n, menPreferences, womenPreferences): | |
| # Initially, all n men are unmarried | |
| unmarriedMen = list(range(n)) | |
| # None of the men has a spouse yet, we denote this by the value None | |
| manSpouse = [None] * n | |
| # None of the women has a spouse yet, we denote this by the value None | |
| womanSpouse = [None] * n | |
| # Each man made 0 proposals, which means that |
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
| # [5] pry(main)> r.exclusion_rules | |
| # => [#<ExclusionRule _id: 611e94fa7d8fbc102109e5cd, type: "wday", value: [1], exclusionary: true>] | |
| # [6] pry(main)> r.exclusion_rules = [ExclusionRule.new(id: '611e94fa7d8fbc102109e5cd', type: 'wday', value: [2])] | |
| # => [#<ExclusionRule _id: 611e94fa7d8fbc102109e5cd, type: "wday", value: [2], exclusionary: true>] | |
| # [7] pry(main)> r.save | |
| # => true | |
| # [8] pry(main)> r.exclusion_rules | |
| # => [#<ExclusionRule _id: 611e94fa7d8fbc102109e5cd, type: "wday", value: [1], exclusionary: true>] |
OlderNewer