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 OperatorDemo | |
| attr_accessor :name | |
| def initialize(params = {}) | |
| self.name = params.fetch(:name, "abhinav") | |
| end | |
| def +(name2) | |
| params = { name: name + " " + name2.name } | |
| obj = create_obj(params) |
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 LocalVariableDemo | |
| def method | |
| 1 | |
| end | |
| def demo_method | |
| puts method # will call method with name "method" | |
| method = 1 if false # Here local variable come in picture |
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
| module Helper | |
| INPUT_SEPRATOR = " " | |
| PAGE = "p" | |
| QUERY = "q" | |
| def self.user_input | |
| user_input = { pages_keywords: [], queries_keywords: [] } | |
| input = read_from_command_line |
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
| var CommentBox = React.createClass({ | |
| getInitialState: function() { | |
| return {data: this.props.data, cur_comment: ''}; | |
| }, | |
| handleAdd: function(e){ | |
| var data = this.state.data | |
| this.setState({ data: data.concat([this.refs.box.getDOMNode().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
| var SetPasswordForm = React.createClass({ | |
| mixins: [FormValidationMixin], | |
| getInitialState: function(){ | |
| return { password: '' , confirm_password: '', errors: [] } | |
| }, | |
| submitForm: function(e){ | |
| var password = this.state.password | |
| var confirm_password = this.state.confirm_password |
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
| /*************** FormValidatorMixin ******************/ | |
| var FormValidationMixin = { | |
| regex: function(type){ | |
| var regex = "" | |
| var type = type.toUpperCase() | |
| switch(type){ |
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
| var greet = function(callback) { | |
| var todaysGreeting = "Hello, "; | |
| callback(todaysGreeting); | |
| } | |
| var Greeter = function(name) { | |
| this.name = name; | |
| this.sa; | |
| this.sal = function(sa){ | |
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
| # Logic : first create list of all players and then remove loosers from that. Using a hash it can be done in O(n) time. | |
| no_of_inputs = 2 ** gets.chomp.to_i - 1 | |
| player_list = Hash.new | |
| inputs = []; | |
| 1.upto(no_of_inputs) do | |
| player1,player2 = gets.split(" ") |
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
| function skipLeadingZeros (string) { | |
| var str = '' | |
| var start = 0 | |
| var end = string.length | |
| while(start < end && string[start] === '0'){ | |
| start ++ | |
| } | |
| while(start < end){ |