Skip to content

Instantly share code, notes, and snippets.

View sharmaabhinav's full-sized avatar
😀
Working

ABHINAV SHARMA sharmaabhinav

😀
Working
  • Bangalore
View GitHub Profile
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)
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
module Helper
INPUT_SEPRATOR = " "
PAGE = "p"
QUERY = "q"
def self.user_input
user_input = { pages_keywords: [], queries_keywords: [] }
input = read_from_command_line
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]) })
},
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
/*************** FormValidatorMixin ******************/
var FormValidationMixin = {
regex: function(type){
var regex = ""
var type = type.toUpperCase()
switch(type){
var greet = function(callback) {
var todaysGreeting = "Hello, ";
callback(todaysGreeting);
}
var Greeter = function(name) {
this.name = name;
this.sa;
this.sal = function(sa){
@sharmaabhinav
sharmaabhinav / race.rb
Created October 7, 2015 05:18
Solution to a hacker earth problem
# 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(" ")
function skipLeadingZeros (string) {
var str = ''
var start = 0
var end = string.length
while(start < end && string[start] === '0'){
start ++
}
while(start < end){