query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102 values |
|---|---|---|---|---|---|---|
Allows for returning a product. Checks if a transaction has been made in the store. It takes a product and a defect argument. The defect argument if true signals that the product bought has a defect. | def return_product(product, defect = false)
if Transaction.find_by(customer: self, product: product).empty?
raise NotRecordedTransactionError, "There was no such transaction recorded."
else
ProductReturn.new(self, product, defect)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def purchase(product)\n \t\tif product.in_stock?\n \t\t\tTransaction.new(self, product)\n \t\telse\n \t\t\traise OutOfStockError, \"#{product.title} is out of stock\"\n \t\tend\n \tend",
"def determine_valid_product(product)\n valid = true\n if @products.has_key?(product)\n valid\n else\n ... | [
"0.6345241",
"0.62344027",
"0.6205176",
"0.6150152",
"0.6091521",
"0.6077948",
"0.6050113",
"0.5984292",
"0.5981422",
"0.59573865",
"0.59494066",
"0.5923946",
"0.59215933",
"0.5913597",
"0.5913597",
"0.5908349",
"0.58826417",
"0.5873261",
"0.5870277",
"0.5859097",
"0.582599",... | 0.8138255 | 0 |
returns the difference between the sum of the squares of numbers 1 to n, and the square of the sum of numbers from 1 to n | def difference_between_sum_sq_and_sq_sum(n)
square_sum(n) - sum_squares(n)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_square_difference(n)\n integers = (1..n).to_a\n\n square_of_sum = integers.sum ** 2\n sum_of_squares = integers.map { |n| n ** 2 }.sum\n\n square_of_sum - sum_of_squares\nend",
"def sum_square_difference(n)\n # square_of_sum = (1..n).reduce(:+) ** 2\n # sum_of_squares = (1..n).reduce { |sum, num| ... | [
"0.8952461",
"0.8950762",
"0.8922446",
"0.89194417",
"0.8889993",
"0.8879714",
"0.8869145",
"0.88132656",
"0.8807752",
"0.87976676",
"0.87274456",
"0.8543132",
"0.85014004",
"0.8384352",
"0.83467937",
"0.83293927",
"0.8321711",
"0.8320477",
"0.827168",
"0.8260442",
"0.8241736... | 0.85207313 | 12 |
def logo image_tag("logo.png", :height => 75, :alt => "The Hastings Co.") end | def logo
content_tag(:span, "HASTINGS FINE HOMES", class: "logo")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logo\n image_tag(\"boulder.png\", :width => \"100\", \n :height => \"75\",\n :alt => \"Learning RoR\", \n :class => \"round\")\n end",
"def logo\n image_tag('rubyLogo.png', alt: 'Ruby on Rails Sample App', class: 'roun... | [
"0.9155077",
"0.88573754",
"0.8772004",
"0.8696916",
"0.8696916",
"0.86860436",
"0.86200833",
"0.860193",
"0.8522485",
"0.7858701",
"0.7858701",
"0.7819328",
"0.78030103",
"0.7715543",
"0.7645759",
"0.7577226",
"0.72125816",
"0.71147",
"0.707723",
"0.7051588",
"0.69802535",
... | 0.7531097 | 16 |
=begin This method adds the details of this comment to the log file. It will be called after a successful creation of the comment Inputs: none Output: none Author: Menisy =end | def add_to_log
user_name = self.user.name || self.user.email.split('@')[0]
Log.create!(loggingtype: 2,user_id_1: self.user.id ,user_id_2: nil,admin_id: nil,story_id: self.story.id ,interest_id: nil,message: (user_name+" commented on \"" + self.story.title + "\" with \"" + self.content + "\"").to_s )
Admin.push_notifications "/admins/index" ,""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_comment(comment); end",
"def log_create(target = self.target)\n return unless target&.respond_to?(:log)\n\n target.log(:log_comment_added, summary: summary, touch: true)\n end",
"def add_comment comment\n \"\\n###### #{comment} ######\\n\" \n end",
"def create\n\t\t\tsuper\n\t\t\tprintComm... | [
"0.696004",
"0.68861306",
"0.6857673",
"0.6472247",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"0.6439953",
"... | 0.61783576 | 37 |
=begin This method checks if a user thumbed up this comment before Inputs: user who we want to check if he upped or not. Output: boolean true or false Author: Menisy =end | def upped_by_user?(user)
up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # get the up that a user gave to this comment before "if exists"
!up.nil? # if up is nil then return false if not then return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downed_by_user?(user)\n down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before \"if exists\"\n !down.nil? # if down is nil then return false if not then return true\n end",
"def up_comment(user)\n upped_before = self.upped_by_user?(... | [
"0.7199514",
"0.707595",
"0.653329",
"0.6292011",
"0.6243375",
"0.6200053",
"0.61881196",
"0.6110206",
"0.6005291",
"0.5989424",
"0.5957557",
"0.59369016",
"0.59129316",
"0.59000254",
"0.58777636",
"0.5843153",
"0.58414036",
"0.58069694",
"0.58015496",
"0.57767844",
"0.575156... | 0.7711889 | 0 |
=begin This method checks if a user thumbed down this comment before Inputs: user who we want to check if he upped or not. Output: boolean true or false Author: Menisy =end | def downed_by_user?(user)
down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before "if exists"
!down.nil? # if down is nil then return false if not then return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upped_by_user?(user)\n up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # get the up that a user gave to this comment before \"if exists\"\n !up.nil? # if up is nil then return false if not then return true\n end",
"def up_comment(user)\n upped_before = self.upped_by_user?(user)\n ... | [
"0.7538691",
"0.69439965",
"0.6871517",
"0.62694585",
"0.61994",
"0.61727524",
"0.5876259",
"0.58750856",
"0.5789535",
"0.57670224",
"0.5731327",
"0.5716213",
"0.5642832",
"0.56402373",
"0.5636984",
"0.5636606",
"0.5629734",
"0.5592459",
"0.5584061",
"0.55372924",
"0.5511598"... | 0.7611069 | 0 |
=begin Returns number of ups for a comment Inputs: none Output: int number of ups Author: Menisy =end | def get_num_ups
ups = self.comment_up_downs.find_all_by_action(1).size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_comment_score(c)\n upcount = (c['up'] ? c['up'].length : 0)\n downcount = (c['down'] ? c['down'].length : 0)\n upcount-downcount\nend",
"def get_num_downs\n downs = self.comment_up_downs.find_all_by_action(2).size\n end",
"def increment_num_comments\n\n end",
"def compute_comment_sc... | [
"0.6960234",
"0.69509375",
"0.6933406",
"0.6806268",
"0.66469365",
"0.6492806",
"0.640031",
"0.62952965",
"0.62896365",
"0.62858915",
"0.619988",
"0.616674",
"0.6156696",
"0.6102019",
"0.61011696",
"0.60990554",
"0.60990554",
"0.60471517",
"0.5991153",
"0.5976966",
"0.5916078... | 0.77432495 | 0 |
=begin Returns number of downs for a comment Inputs: none Output: int number of downs Author: Menisy =end | def get_num_downs
downs = self.comment_up_downs.find_all_by_action(2).size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_ups\n ups = self.comment_up_downs.find_all_by_action(1).size\n end",
"def compute_comment_score(c)\n upcount = (c['up'] ? c['up'].length : 0)\n downcount = (c['down'] ? c['down'].length : 0)\n upcount-downcount\nend",
"def compute_comment_score(c)\n upcount = (c['up'] ? c['up'].... | [
"0.7143779",
"0.70730305",
"0.7051696",
"0.68160594",
"0.6667954",
"0.6358727",
"0.62098014",
"0.6004241",
"0.59985244",
"0.5978681",
"0.59504306",
"0.59256",
"0.59256",
"0.5914564",
"0.58918214",
"0.5891177",
"0.5890678",
"0.58732986",
"0.58191663",
"0.5803583",
"0.57873106"... | 0.78357047 | 0 |
=begin Ups a comment. Input: user who is upping the comment. Output: boolean indicating success or failure Author: Menisy =end | def up_comment(user)
upped_before = self.upped_by_user?(user)
downed_before = self.downed_by_user?(user)
if !upped_before && !downed_before then #if user never upped or downed the comment then up it
up = CommentUpDown.new(:action => 1)
up.comment = self
up.user = user
up.save
up.add_to_log(self.user)
#Author: Omar
#adding the notification to the database for liking a comment
if user != self.user
UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)
self.user.notifications = self.user.notifications.to_i + 1
self.user.save
end
#############################
return true
elsif downed_before then
self.comment_up_downs.find_by_user_id_and_action(user.id,2).destroy #if user disliked it, now make him like it!
up = CommentUpDown.new(:action => 1)
up.comment = self
up.user = user
up.save
up.add_to_log(self.user)
#Author: Omar
#adding the notification to the database for liking a comment
if comment.user != self.user
UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:5 , new:true)
self.user.notifications = self.user.notifications.to_i + 1
self.user.save
end
#############################
return true
elsif upped_before
old_up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # if upped before, then un-up
old_up.add_to_log(self.user,2)
old_up.destroy
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upped_by_user?(user)\n up = self.comment_up_downs.find_by_user_id_and_action(user.id,1) # get the up that a user gave to this comment before \"if exists\"\n !up.nil? # if up is nil then return false if not then return true\n end",
"def upcomment\n comm = Comment.find_by_id(params[:id])\n if !com... | [
"0.64954954",
"0.61798835",
"0.61450386",
"0.61450386",
"0.6125262",
"0.5901997",
"0.59014744",
"0.5804496",
"0.5791708",
"0.5778875",
"0.57758504",
"0.57027066",
"0.56988496",
"0.5698222",
"0.56838405",
"0.56787574",
"0.56494707",
"0.56389534",
"0.56368935",
"0.5634246",
"0.... | 0.63475513 | 1 |
=begin Downs a comment. Input: user who is downing the comment. Output: boolean indicating success or failure Author: Menisy =end | def down_comment(user)
upped_before = self.upped_by_user?(user)
downed_before = self.downed_by_user?(user)
if !upped_before && !downed_before then #if user never upped or downed the comment then up it
down = CommentUpDown.new(:action => 2)
down.comment = self
down.user = user
down.save
down.add_to_log(self.user)
#Author: Omar
#adding the notification to the database for disliking a comment
if comment.user != self.user
UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)
self.user.notifications = self.user.notifications.to_i + 1
self.user.save
end
###################################
return true
elsif upped_before then
self.comment_up_downs.find_by_user_id_and_action(user.id,1).destroy #if user disliked it, now make him like it!
down = CommentUpDown.new(:action => 2)
down.comment = self
down.user = user
down.save
down.add_to_log(self.user)
#Author: Omar
#adding the notification to the database for disliking a comment
if user != self.user
UserNotification.create(owner:self.user_id , user:user.id, story:self.story_id , comment:self.id , notify_type:6 , new:true)
self.user.notifications = self.user.notifications.to_i + 1
self.user.save
end
###################################
return true
elsif downed_before
old_down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) #if downed before then un-down
old_down.add_to_log(self.user,2)
old_down.destroy
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downed_by_user?(user)\n down = self.comment_up_downs.find_by_user_id_and_action(user.id,2) # get the down that a user gave to this comment before \"if exists\"\n !down.nil? # if down is nil then return false if not then return true\n end",
"def downcomment\n comm = Comment.find_by_id(params[:id])\n... | [
"0.72441554",
"0.7017349",
"0.6250808",
"0.6222246",
"0.58906364",
"0.5852679",
"0.5828789",
"0.5695721",
"0.5638064",
"0.5624087",
"0.55421865",
"0.55421865",
"0.55078185",
"0.5454527",
"0.54468954",
"0.5445814",
"0.5431789",
"0.54209906",
"0.5407877",
"0.5404402",
"0.540270... | 0.7527961 | 0 |
=begin Description: This story is mainly used in the notification system to summarize the content of the comment to fit within a certain length input: char_num:Int which is the number of chars it will be summarized to output: String > The summarized String Author: Kiro =end | def summarize_content (char_num)
if self.content.length <= char_num
return self.content
else return self.content[0..(char_num-1)] + "..."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comment_length\n\t120\nend",
"def description_complexity(pr)\n pull_req = pull_req_entry(pr[:id])\n (pull_req['title'] + ' ' + pull_req['body']).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end",
"def description_from_string(str)\n len = 12\n return str unless str.length > len\n ... | [
"0.70011026",
"0.6411546",
"0.63406503",
"0.6306612",
"0.61043483",
"0.607377",
"0.6041252",
"0.6026639",
"0.60241747",
"0.60133034",
"0.5949859",
"0.59486544",
"0.59285885",
"0.5905003",
"0.590407",
"0.5899543",
"0.5890872",
"0.5882059",
"0.5857261",
"0.58479726",
"0.58358",... | 0.77979815 | 0 |
This is the stub for a systemwide error handler. we will funnel system messages through this API. Global messages defined in the config file. | def initialize(id)
@error_code = id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handleError(msg)\n # For right now, throw an exception\n raise \"Error in obtaining information from LIMS. \" +\n \"Error from LIMS : \" + msg\n end",
"def initialize_error_handlers\n #When an error occurrs, write nothing to stdout. We'll handle the errors ourselves\n Cspice_wr... | [
"0.66247505",
"0.64327425",
"0.6383515",
"0.6360325",
"0.63536876",
"0.63095057",
"0.62860376",
"0.62854975",
"0.62813836",
"0.62360775",
"0.60945886",
"0.60638654",
"0.6059355",
"0.6037437",
"0.60135615",
"0.5963554",
"0.5958585",
"0.5950381",
"0.5943309",
"0.59183043",
"0.5... | 0.0 | -1 |
Reply and previous tweet | def reply?
!!in_reply_to_status_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_reply_to_user\n previous_tweet.try(:author).try(:screen_name) || params[:in_reply_to_user]\n end",
"def get_in_reply_to(t)\n if t\n id = t.in_reply_to_status_id\n if id\n if r = $tweets[id]\n get_in_reply_to(r)\n elsif $buff[id]\n get_in_reply_to(r)\n else\n ... | [
"0.6814464",
"0.67171884",
"0.6710001",
"0.6454624",
"0.64500445",
"0.63366455",
"0.6322527",
"0.62949777",
"0.62840176",
"0.6261413",
"0.6234904",
"0.61191595",
"0.6086721",
"0.6065399",
"0.6041803",
"0.6021239",
"0.60071474",
"0.5991872",
"0.5983279",
"0.5967489",
"0.596514... | 0.57269347 | 52 |
Field assigments Assigns the tweet's fields from a Twitter status object Returns the tweet record without saving it and persisting the changes to the database | def assign_fields(status)
self.text = expand_urls(status.text, status.urls)
self.in_reply_to_user_id = status.in_reply_to_user_id
self.in_reply_to_status_id = status.in_reply_to_status_id
self.source = status.source
self.lang = status.lang
self.retweet_count = status.retweet_count
self.favorite_count = status.favorite_count
self.created_at = status.created_at
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_database(t, i)\n created_at = DateTime.strptime(t['created_at'], '%a %b %d %H:%M:%S %z %Y')\n # get rid of annoying Asian characters\n location = t['user']['location']#.gsub(/[^\\p{Latin}\\/ \\-,]/, '')\n\n begin\n # if the object contains latitude and longitude and retweeted status\n if t['co... | [
"0.5984665",
"0.57777435",
"0.5751553",
"0.56884736",
"0.55796427",
"0.55776656",
"0.55295026",
"0.5526155",
"0.5499975",
"0.5488875",
"0.54535866",
"0.5430363",
"0.5409972",
"0.53913707",
"0.5380252",
"0.5376062",
"0.5368158",
"0.5348213",
"0.5313817",
"0.5303217",
"0.530129... | 0.68355423 | 1 |
Assigns a certain workflow state given a symbol or string Knows about a whitelist of valid states | def assign_state(state)
state &&= state.try(:to_sym)
raise "Unknown state: #{ state }" unless Tweet.available_states.include?(state)
case state
when :conversation then self.state ||= state # do not override existing states with :conversation state
else self.state = state
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_to_state(s)\n case s.to_sym\n when :pending\n register if passive?\n when :active\n activate if pending? || deleted?\n unsuspend if suspended?\n when :suspended\n suspend if passive? || pending? || active?\n when :deleted\n delete if passive? || pending? || active? ... | [
"0.6481978",
"0.64131534",
"0.63184446",
"0.62278825",
"0.60918456",
"0.604355",
"0.6011745",
"0.59891486",
"0.59716976",
"0.59408146",
"0.5933534",
"0.5921859",
"0.5919237",
"0.5900503",
"0.58076984",
"0.57849354",
"0.5759678",
"0.5756897",
"0.5755993",
"0.57469743",
"0.5724... | 0.658227 | 0 |
Only logged in users can gain access to all the actions | def create
@user = User.find(params[:user_id])
@resourcethread = @user.resource_threads.find(params[:resource_thread_id])
@resourcethread.increment!(:resource_count)
@resource = @resourcethread.resources.create(resource_params)
@resource.update_attribute(:trust, 100)
@resource.update_attribute(:user, @current_user)
redirect_to user_resource_thread_path(@user, @resourcethread)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_access_control_all\n @user = User.find(params[:user_id])\n\n unless !@user.admin? && current_user.admin? || current_user?(@user)\n response_access_denied\n end\n\n rescue\n response_access_denied\n end",
"def check_access_control_all\n @user = User.find(params[:user... | [
"0.7802231",
"0.76084745",
"0.7595346",
"0.75416934",
"0.73721224",
"0.73371416",
"0.7319035",
"0.7294776",
"0.72890043",
"0.71676904",
"0.7158603",
"0.7142669",
"0.7099145",
"0.7090903",
"0.70887",
"0.70840037",
"0.7039707",
"0.70393634",
"0.7026379",
"0.70149964",
"0.701452... | 0.0 | -1 |
Confirms a loggedin user. | def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Please log in."
redirect_to user_login_url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n message = \"currently logged in as #{current_user.name}. Not you? \"\n message += \"#{view_context.link_to('Log out.', log_out)}\".html_safe\n flash[:warning] = message\n redirect_to(root_url)\n ... | [
"0.70087826",
"0.6982988",
"0.6919373",
"0.688131",
"0.6845446",
"0.68326277",
"0.67944413",
"0.67929715",
"0.6642435",
"0.6624581",
"0.66114175",
"0.66022736",
"0.6589018",
"0.65539706",
"0.65349805",
"0.65303934",
"0.6512816",
"0.650312",
"0.64878744",
"0.6487622",
"0.64804... | 0.0 | -1 |
Confirms the correct user. | def correct_user
redirect_to(root_url) unless current_user?(@user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n msg = \"You do not have permission to update another user's information\"\n require_correct_user(@user, msg)\n end",
"def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n... | [
"0.7474259",
"0.73411936",
"0.7317917",
"0.7183303",
"0.7174887",
"0.7049758",
"0.70130193",
"0.7012358",
"0.7006517",
"0.7006201",
"0.7003461",
"0.69663024",
"0.69136065",
"0.6911695",
"0.690295",
"0.6892608",
"0.68439376",
"0.6842948",
"0.68397075",
"0.683463",
"0.6826711",... | 0.66520107 | 98 |
Confirms an admin user. | def admin_user
redirect_to(root_url) unless current_user.is_admin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirm_admin\n \tunless session[:admin]\n \t\tflash[:notice] = \"You are not an admin.\"\n \t\tredirect_to(user_path( :id => session[:user_id]))\n \tend\n end",
"def admin_user\n\t\t\tflash_text = \"Administrative privilege required to perform this action.\"\n\t\t\tflash[:danger] = flash_text unless cu... | [
"0.79044944",
"0.767215",
"0.76483077",
"0.76210374",
"0.7605678",
"0.7605678",
"0.75945777",
"0.7588445",
"0.7588445",
"0.7503662",
"0.74675834",
"0.7451482",
"0.7424005",
"0.7411313",
"0.74107665",
"0.7402138",
"0.73993605",
"0.7358812",
"0.7329228",
"0.73179626",
"0.731276... | 0.70904475 | 53 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def user_params
params.require(:user).permit(:username, :name, :year_of_birth, :email, :password, :city_of_birth)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
in seconds since epoc | def getpdf
# source info page: https://github.com/usgpo/link-service
#Query: bill number, bill type, congress, bill version OR most recent
#Parameters:
#collection: Required - Value is bills.
#billtype: Required - Values are hr, s, hjres, sjres, hconres, sconres, hres, sres.
#billversion: Optional - If bill version is not provided, the most recent version of a bill is returned. Values are as, cps, fph, lth, ppv, rds, rhv,
# rhuc, ash, eah, fps, lts, pap, rev, rih, sc, eas, hdh, nat, pwah, reah, ris, ath, eh, hds, oph, rah, res, rsv, ats, eph, ihv, ops, ras, renr, rth,
# cdh, enr, iph, pav, rch, rfh, rts, cds, esv, ips, pch, rcs, rfs, s_p, cph, fah, isv, pcs, rdh, rft, sas, mostrecent. <-----
#billnum: Required - This is the numerical bill number. Sample value is 1027.
#congress: Required - This is the numerical Congress number. Sample value is 112.
#link-type: Optional - This is the format of the returned document. Default is pdf. Other values are xml, html, mods, premis, contentdetail.
#Examples:
#https://api.fdsys.gov/link?collection=bills&billtype=hr&billversion=ih&billnum=1&congress=112
#https://api.fdsys.gov/link?collection=bills&billtype=hconres&billnum=17&congress=112&link-type=xml
# the above api accepts mostrecent as an argument, which is why I will be using it (that way I dont have to infer version through status, which would
# be overhead).
# replace tempfile location by a location in a folder under meritmoot. After returning the file to the user
# check the last checked time. If its been a bit (like 2 hours), go through and delete all files that havent been
# accessed in, like, a day.
# I have noticed that some pdfs dont load on meritmoot.com. I am gueeesssssssing this is due to timeout. This is probably extendable in javascript.
# extend it to 15 seconds.
#capture crap
logWatch("GetBillPdf") { |log|
require 'net/http'
require 'time'
billType = params['billtype']
billNum = params['billnum']
billCongress = params['congress']
billVersion = 'mostrecent'
billVersion = params['billversion'] if not params['billversion'].nil?
theFile = nil
prefix = "moot-pdf"
theFileName = "#{prefix}-#{billCongress}-#{billType}-#{billNum}-#{billVersion}.pdf"
#figure out if we allready have it
files = Dir.entries("/tmp")
files.select!{ |name| name == theFileName }
p "files: #{files}"
if files.length == 1
theFile = "/tmp/" + theFileName
theFile = File.open(theFile)
createTime = theFile.ctime
billUpdateTime = Mmbill.find_by(bill_id: "#{billType}#{billNum}-#{billCongress}".downcase)
if billUpdateTime == nil
logWatch("pdfs_related_Mmbill_not_found"){
p("#{billType}#{billNum}-#{billCongress} - #{theFileName}")
}
billUpdateTime = Time.new(1990) #something a long time ago
else
billUpdateTime = Time.parse(billUpdateTime.bulk['history']['active_at'])
end
#outdated?
if createTime > billUpdateTime
#No just pass it back
send_file(theFile, filename: theFileName, type: 'application/pdf', disposition: 'inline')
else
#Yes it is outdated. delete it
theFile.close
File.delete("/tmp/" + theFileName)
theFile = nil
end
end
if theFile == nil
theFile = File.open("/tmp/" + theFileName, "w", :encoding => 'ascii-8bit')
#https://api.fdsys.gov/link?collection=bills&billtype=sres&billversion=mostrecent&billnum=14&congress=116
Net::HTTP.get_response(URI.parse("https://api.fdsys.gov/link?collection=bills&billtype=#{billType}&billversion=#{billVersion}&billnum=#{billNum}&congress=#{billCongress}")) do |r|
p "code: #{r.code}"
ApiController.passingAround(r, theFile)
end
send_file(theFile, filename: theFileName, type: 'application/pdf', disposition: 'inline')
theFile.close()
end
#bit of cleanup.
#delete old ones
files = Dir.entries("/tmp")
#select ones we handle, and that are three days since last accesssed
files.select!{|name| name[prefix] != nil and File.atime("/tmp/" + name) < Time.now - ( 3 * 24 * 60 * 60 ) }
for rejectFile in files
#rejectFile.close
File.delete("/tmp/#{rejectFile}")
end
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seconds\n _nudge[2]\n end",
"def tv_sec() end",
"def seconds\n (Time.now - @start_time).to_i\n end",
"def seconds\n ((@died_at - @time) / 1000).to_i\n end",
"def seconds\n @time\n end",
"def sec\n return @t_sec\n end",
"def time_sec; Time.now.sec; end",
"def in_seconds\n ... | [
"0.7479998",
"0.731223",
"0.7217995",
"0.7195561",
"0.7142358",
"0.71105367",
"0.70702714",
"0.7025795",
"0.7011202",
"0.69435483",
"0.6933598",
"0.687083",
"0.6800444",
"0.6761454",
"0.6747267",
"0.672955",
"0.67148197",
"0.6710942",
"0.6699333",
"0.66987884",
"0.66987884",
... | 0.0 | -1 |
Creates a new instance based on the current, in the process optionally merging new values in. | def copy_changed(**values)
self.class.new(**self.to_hash.merge!(values))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def produce_instance\n @instance ||= super\n end",
"def dup\n new_object = super\n new_object.send :initialize_attributes, @attributes\n new_object\n end",
"def dup\n self.class.new(@value, **(@object || {}))\n end",
"def new(attrs = {})\n instance = super()\n... | [
"0.6292059",
"0.6186013",
"0.60048056",
"0.59807086",
"0.59795535",
"0.5888796",
"0.58297384",
"0.57840353",
"0.57726306",
"0.5758097",
"0.57502234",
"0.5708884",
"0.56783956",
"0.56783956",
"0.5671655",
"0.56663674",
"0.5623973",
"0.56209403",
"0.56196636",
"0.56043077",
"0.... | 0.0 | -1 |
Implement an instance method in your Ingredient class that helps check whether an ingredient is valid (i.e., contains only the ingredient names above)? | def allowed_ingredients
SAFE_INGREDIENTS.include?(name.downcase)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_ingredient?(ingredient_name)\n ingredient_names.include?(ingredient_name)\n end",
"def must_have_at_least_one_ingredient\n errors.add(:ingredients, \"must exist!\") if self.ingredients.empty?\n end",
"def strict_matching(ingredient_name,item)\n return item.downcase.include?(ingredient_na... | [
"0.6767781",
"0.6306675",
"0.6278676",
"0.6172744",
"0.61275464",
"0.611898",
"0.61106807",
"0.6100629",
"0.60225934",
"0.59977853",
"0.5893108",
"0.58866984",
"0.5877923",
"0.5819596",
"0.5810549",
"0.58058375",
"0.58023393",
"0.57733536",
"0.5744651",
"0.57437634",
"0.57387... | 0.7081761 | 0 |
skip_before_filter :ranking, :only =>['ranking' ] | def admin
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_filter; end",
"def reset_filter!\n skip_before_action(:filter_access_filter) if method_defined?(:filter_access_filter)\n before_action :filter_access_filter\n end",
"def skip_actions; end",
"def filter\n setup_instance_variables\n render 'index'\n end",
"def requi... | [
"0.6767949",
"0.6451886",
"0.6050146",
"0.5920447",
"0.58323896",
"0.58235794",
"0.580696",
"0.5782584",
"0.57488763",
"0.57488763",
"0.57488763",
"0.5729448",
"0.5687753",
"0.56752807",
"0.5627849",
"0.5627849",
"0.5627849",
"0.5627849",
"0.5626716",
"0.5616882",
"0.55761254... | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
#@user = User.find(params[:id])
if user_signed_in?
#@user = current_user
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @user }
end
else
redirect_to new_user_session_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.81046426",
"0.7703556",
"0.77011716",
"0.76262826",
"0.7582106",
"0.74818",
"0.7461394",
"0.7446168",
"0.730656",
"0.7300699",
"0.72902125",
"0.72781444",
"0.72358584",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.722... | 0.0 | -1 |
GET /users/new GET /users/new.json | def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end",
"def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n ... | [
"0.8287397",
"0.8169197",
"0.8155916",
"0.80483407",
"0.8022376",
"0.8021751",
"0.8009459",
"0.7950995",
"0.793078",
"0.793078",
"0.7873476",
"0.7873476",
"0.7873476",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0... | 0.0 | -1 |
POST /users POST /users.json | def create
@user = User.new(params[:user])
#o usuário está sendo criado no devise registration.
respond_to do |format|
if @user.save
format.html { redirect_to @user, :notice => 'User was successfully created.' }
format.json { render :json => @user, :status => :created, :location => @user }
else
format.html { render :action => "new" }
format.json { render :json => @user.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.77179813",
"0.75206673",
"0.73831296",
"0.72405374",
"0.719841",
"0.7140812",
"0.71038526",
"0.7058827",
"0.7041636",
"0.70236504",
"0.7003128",
"0.70021695",
"0.70021695",
"0.70021695",
"0.69936967",
"0.6990463",
"0.6980393",
"0.6979075",
"0.69788617",
"0.69788617",
"0.69... | 0.0 | -1 |
PUT /users/1 PUT /users/1.json | def update
params[:user][:born_date] = Date.strptime(params[:user][:born_date], '%d/%m/%Y').strftime.to_s
@user = current_user
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to @user, :notice => 'User was successfully updated.' }
format.json { head :no_content }
else
format.html { render :action => "edit" }
format.json { render :json => @user.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.74114245",
"0.73920554",
"0.73041475",
"0.7254177",
"0.7202618",
"0.70756376",
"0.70535713",
"0.7029043",
"0.70075685",
"0.69883573",
"0.6983195",
"0.694263",
"0.69409895",
"0.692315",
"0.6909438",
"0.687742",
"0.68486536",
"0.6834162",
"0.6821841",
"0.6801179",
"0.6770304... | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
#@user = User.find(params[:id])
@user = current_user
@user.destroy
respond_to do |format|
format.html { redirect_to users_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\... | [
"0.78750724",
"0.77518034",
"0.7713981",
"0.7610077",
"0.747295",
"0.74073994",
"0.74073994",
"0.7369968",
"0.7346072",
"0.7340465",
"0.7328618",
"0.7309635",
"0.73095363",
"0.7306841",
"0.7297868",
"0.72917855",
"0.7291585",
"0.7289111",
"0.7284347",
"0.7250935",
"0.7250935"... | 0.0 | -1 |
Retorna un ls sobre el directorio | def do_ls()
if @system_type == WINDOWS then
return %x(dir #{@path})
end
if @system_type == UNIX then
return %x(ls #{@path})
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ls(path = '.')\n Cd.cd.ls(path)\n end",
"def ls(path = '/')\n dirlist = []\n @sftp.dir.foreach(path) do |element|\n dirlist << element\n end\n return dirlist\n end",
"def ls(path) \n ary = Array.new\n Dir.chdir(path) {\n Dir.glob(\"*\").each {|dir|\n ary.push(dir... | [
"0.7486923",
"0.73250186",
"0.72490007",
"0.71984345",
"0.7184171",
"0.7127247",
"0.7103844",
"0.70893407",
"0.70751625",
"0.7053697",
"0.704742",
"0.7020492",
"0.69601595",
"0.6950356",
"0.69302946",
"0.69237393",
"0.68343633",
"0.6773838",
"0.6764797",
"0.67616296",
"0.6700... | 0.72104204 | 3 |
Called after every test method runs. Can be used to tear down fixture information. | def teardown
# Do nothing
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_teardown; end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def tear... | [
"0.8025238",
"0.79543626",
"0.79543626",
"0.78571093",
"0.7845288",
"0.7845288",
"0.7845288",
"0.7845288",
"0.7845288",
"0.7845288",
"0.7845288",
"0.7845288",
"0.78336143",
"0.78336143",
"0.7750328",
"0.77483624",
"0.77483624",
"0.7734571",
"0.7713144",
"0.7711698",
"0.771169... | 0.0 | -1 |
get the document an allowable privacy object for the document according to the db_tag raise if it is an invalid db_tag | def get_privacy db_tag
privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}
raise unless privacy_obj
return privacy_obj
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_privacy db_tag\r\n privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}\r\n raise unless privacy_obj\r\n self.update_attribute(\"privacy\",privacy_obj.db_tag)\r\n return privacy_obj\r\n end",
"def document_auth doc_id=nil\n doc_id ||= params[:doc]\n doc_id = doc_id.d... | [
"0.7015408",
"0.57167286",
"0.5583481",
"0.55200374",
"0.5388634",
"0.5336983",
"0.53242034",
"0.52800137",
"0.5251779",
"0.51859087",
"0.5156365",
"0.51321447",
"0.512183",
"0.5118841",
"0.5115315",
"0.5111158",
"0.50635034",
"0.50543433",
"0.5051888",
"0.50420666",
"0.50346... | 0.8157782 | 0 |
set the document privacy according to the db_tag raise if it is an invalid db_tag | def set_privacy db_tag
privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}
raise unless privacy_obj
self.update_attribute("privacy",privacy_obj.db_tag)
return privacy_obj
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_privacy db_tag\r\n privacy_obj = privacy_objects.find{|p| p.db_tag == db_tag}\r\n raise unless privacy_obj\r\n return privacy_obj \r\n end",
"def propagate_privacy\n return unless name_tag\n name_tag.is_global = List.exists? name_tag_id: name_tag_id, availability: [0,1]\n name... | [
"0.6345327",
"0.5905161",
"0.55838084",
"0.55792767",
"0.54093903",
"0.53289783",
"0.52577215",
"0.5215325",
"0.52100235",
"0.5175946",
"0.5159295",
"0.5102317",
"0.5069592",
"0.49712023",
"0.49712023",
"0.49661666",
"0.4869075",
"0.48646545",
"0.48379436",
"0.48318478",
"0.4... | 0.8162818 | 0 |
GET /subscriptions GET /subscriptions.json | def index
if is_client_app?
if params[:user_id].present?
t = Subscription.arel_table
s = Subscription.statuses
@subscriptions = Subscription.where(user_id: params[:user_id]).where(t[:status].eq(s[:authorized]).or(t[:status].eq(s[:paused])))
else
@subscriptions = Subscription.all
end
render json: @subscriptions
else
response.headers['X-Total-Count'] = @subscriptions.count.to_s
@subscriptions = @subscriptions.page(params[:page]) if params[:page].present?
@subscriptions = @subscriptions.per(params[:per]) if params[:per].present?
_render collection: @subscriptions, flag: params[:flag].try(:to_sym)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscriptions\n url = url_with_api_version(@base_url, 'subscriptions')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n end",
"def all_subscriptions\n get(url_(\"subscription\"))\n end",
"def list_subscriptions(user)\n get(\"/#{user}/lists/subscriptions... | [
"0.8178023",
"0.8074406",
"0.79446816",
"0.76912534",
"0.7649479",
"0.7582659",
"0.75117826",
"0.74919003",
"0.7431205",
"0.7413858",
"0.7406451",
"0.7406451",
"0.7404672",
"0.738646",
"0.73743445",
"0.73743445",
"0.73651445",
"0.7320728",
"0.7301819",
"0.72662437",
"0.726576... | 0.6976334 | 41 |
GET /subscriptions/1 GET /subscriptions/1.json | def show
_render member: @subscription, flag: :complete
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscriptions\n url = url_with_api_version(@base_url, 'subscriptions')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n end",
"def show\n @subscription = current_user.subscriptions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | [
"0.7863251",
"0.7584557",
"0.7584557",
"0.75726175",
"0.7567996",
"0.74486554",
"0.734854",
"0.73362416",
"0.73362416",
"0.72566754",
"0.7242567",
"0.7242567",
"0.7242567",
"0.7242567",
"0.7234481",
"0.7231595",
"0.7203714",
"0.71969527",
"0.71899897",
"0.7187209",
"0.7187031... | 0.0 | -1 |
POST /subscriptions POST /subscriptions.json | def create
@subscription = Subscription.new(subscription_params)
if @subscription.save
render json: @subscription, status: :created, location: @subscription
else
render json: @subscription.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n megam_rest.post_subscriptions(to_hash)\n end",
"def post body=nil, headers={}\n @connection.post \"subscriptions.json\", body, headers\n end",
"def create\n s_params = params[:subscription]\n s_params.delete(:id)\n @subscription = Subscription.new(s_param... | [
"0.7878452",
"0.78267294",
"0.7545708",
"0.7432098",
"0.7428383",
"0.7351888",
"0.7329232",
"0.7227739",
"0.7155769",
"0.7136345",
"0.7112945",
"0.71125585",
"0.7020447",
"0.7004615",
"0.69523484",
"0.6893254",
"0.68890435",
"0.6831791",
"0.68234247",
"0.6818618",
"0.6788453"... | 0.7648211 | 2 |
PATCH/PUT /subscriptions/1 PATCH/PUT /subscriptions/1.json | def update
@subscription = Subscription.find(params[:id])
if @subscription.update(subscription_params)
head :no_content
else
render json: @subscription.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @subscription = Subscription.get(params[:id])\n @subscription.update(params[:subscription])\n respond_with(@subscription.reload)\n end",
"def update\n @subscription = current_user.subscriptions.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(par... | [
"0.7237877",
"0.71868026",
"0.7146975",
"0.7088031",
"0.70832556",
"0.7082959",
"0.70335835",
"0.7015554",
"0.7015554",
"0.7015554",
"0.69606966",
"0.6954959",
"0.6939982",
"0.6907186",
"0.6907186",
"0.6896157",
"0.6876353",
"0.68551904",
"0.68187803",
"0.67266816",
"0.672580... | 0.71870714 | 1 |
DELETE /subscriptions/1 DELETE /subscriptions/1.json | def destroy
@subscription.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete options={}, headers={}\n @connection.delete \"subscriptions.json\", options, headers\n end",
"def destroy\n subscription = current_user.subscriptions.find(params[:id])\n subscription.destroy!\n\n render json: { status: 'success'}\n end",
"def delete_subscriptions\n end",
... | [
"0.8083839",
"0.7971518",
"0.7749676",
"0.77227986",
"0.76973474",
"0.76788694",
"0.76788694",
"0.76788694",
"0.76788694",
"0.766344",
"0.75745755",
"0.75242066",
"0.7512467",
"0.74898785",
"0.74766344",
"0.74766344",
"0.74766344",
"0.74766344",
"0.74766344",
"0.7430863",
"0.... | 0.75494754 | 11 |
=> [1, 2, 3] (destructive) x now returns [1, 2, 3] y also returns [1, 2, 3] | def test(f)
f.map { |letter| "I like the letter: #{letter}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skips(x)\n (0..x.length-1).map do |i|\n (y = x.dup).delete_at(i);y\n end\nend",
"def get_arr_x(x, y) \n x # this coordinate doesn't change\nend",
"def trimmed_coordinates_array(x_values, y_values)\n coordinates_array = x_values.zip(y_values)\n # [[1, 2], [1, 3], [1, 4], [1, 5]]\n coordinates... | [
"0.6355265",
"0.6314719",
"0.6179839",
"0.6155703",
"0.6138706",
"0.6110919",
"0.6110919",
"0.610016",
"0.6087251",
"0.6025466",
"0.59926486",
"0.59887224",
"0.59747136",
"0.59668696",
"0.5914152",
"0.5914152",
"0.5877992",
"0.58733803",
"0.5863853",
"0.5757391",
"0.5634236",... | 0.0 | -1 |
=> ["I like the letter: a", "I like the letter: b", "I like the letter: c"] e => the original array | def test_b(h)
h.map! { |letter| "I like the letter: #{letter}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def letters_to_guess\n @letters.map do |letter|\n if @user_guesses.include?(normalize_letter(letter))\n letter\n else\n nil\n end\n end\n end",
"def guess_letters\n guess_array = []\n @current_word.each do\n guess_array << \"_\"\n end\n return guess_array\n e... | [
"0.6238608",
"0.62090826",
"0.6139773",
"0.61182475",
"0.60914177",
"0.60819805",
"0.6037126",
"0.6032938",
"0.60148674",
"0.5931469",
"0.59199494",
"0.5909309",
"0.59071577",
"0.59041184",
"0.58935547",
"0.58790374",
"0.5878315",
"0.58635855",
"0.5862479",
"0.5837508",
"0.58... | 0.0 | -1 |
Return the vCloud data associated with vApp | def initialize(id)
unless id =~ /^#{self.class.id_prefix}-[-0-9a-f]+$/
raise "#{self.class.id_prefix} id : #{id} is not in correct format"
end
@id = id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vapp(vAppId)\n params = {\n 'method' => :get,\n 'command' => \"/vApp/vapp-#{vAppId}\"\n }\n\n response, headers = send_request(params)\n\n vapp_node = response.css('VApp').first\n if vapp_node\n name = vapp_node['name']\n ... | [
"0.7129758",
"0.6764978",
"0.6090582",
"0.6081625",
"0.60284114",
"0.5994421",
"0.58871275",
"0.58300906",
"0.58104545",
"0.57651174",
"0.5669137",
"0.56623125",
"0.56526566",
"0.5639783",
"0.55802107",
"0.5560721",
"0.5535915",
"0.550397",
"0.5467481",
"0.54337037",
"0.54169... | 0.0 | -1 |
Return the vCloud data associated with vAppTemplate | def vcloud_attributes
Vcloud::Core::Fog::ServiceInterface.new.get_vapp_template(id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vapp_template(vAppId)\n params = {\n 'method' => :get,\n 'command' => \"/vAppTemplate/vappTemplate-#{vAppId}\"\n }\n\n response, headers = send_request(params)\n\n vapp_node = response.css('VAppTemplate').first\n if vapp_node\n n... | [
"0.71081287",
"0.70635027",
"0.6211215",
"0.6018454",
"0.59863305",
"0.59576523",
"0.58353865",
"0.5812524",
"0.5775796",
"0.5667276",
"0.56505835",
"0.5600491",
"0.5588983",
"0.5534086",
"0.55229366",
"0.551654",
"0.547936",
"0.5463351",
"0.5443816",
"0.5424494",
"0.53998023... | 0.7795347 | 0 |
Return the name of vAppTemplate | def href
vcloud_attributes[:href]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template_name\n name.split(\"::\").last.downcase.gsub(/onebox/, \"\")\n end",
"def template_name; end",
"def template_name; end",
"def template_name\n command.text_value\n end",
"def template\n Kernel.const_get(template_name.upcase << '_TEMPLATE')\n end",
"def name\n ... | [
"0.7598668",
"0.7504039",
"0.7504039",
"0.7135556",
"0.71219385",
"0.69970185",
"0.6872652",
"0.6859603",
"0.6836964",
"0.6794226",
"0.6741407",
"0.67186403",
"0.6715654",
"0.67018145",
"0.6649003",
"0.6636977",
"0.6611179",
"0.6557344",
"0.651008",
"0.651008",
"0.64635146",
... | 0.0 | -1 |
Return the name of vAppTemplate | def name
vcloud_attributes[:name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template_name\n name.split(\"::\").last.downcase.gsub(/onebox/, \"\")\n end",
"def template_name; end",
"def template_name; end",
"def template_name\n command.text_value\n end",
"def template\n Kernel.const_get(template_name.upcase << '_TEMPLATE')\n end",
"def name\n ... | [
"0.7598668",
"0.7504039",
"0.7504039",
"0.7135556",
"0.71219385",
"0.69970185",
"0.6872652",
"0.6859603",
"0.6836964",
"0.6794226",
"0.6741407",
"0.67186403",
"0.6715654",
"0.67018145",
"0.6649003",
"0.6636977",
"0.6611179",
"0.6557344",
"0.651008",
"0.651008",
"0.64635146",
... | 0.0 | -1 |
stop_data contains any information we need for creating new stops. e.g. city id's stop time and ticket price | def update(stop_data)
@color = stop_data.fetch(:color, @color)
DB.exec("UPDATE trains SET color = '#{@color}' WHERE id = #{@id};")
times = stop_data.fetch(:times, [])
stop_data.fetch(:city_ids, []).each_with_index do |city_id, index|
DB.exec("INSERT INTO stops (train_id, city_id, time) VALUES (#{@id}, #{city_id}, '#{times[index] ? times[index] : "00:00:00"}');")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(stop_data)\n @name = stop_data.fetch(:name, @name)\n DB.exec(\"UPDATE cities SET name = '#{@name}' WHERE id = #{@id};\")\n times = stop_data.fetch(:times, [])\n stop_data.fetch(:train_ids, []).each_with_index do |train_id, index|\n DB.exec(\"INSERT INTO stops (city_id, train_id, time) V... | [
"0.6656736",
"0.650241",
"0.6382034",
"0.62685996",
"0.6268304",
"0.6213005",
"0.6146444",
"0.61268073",
"0.61259097",
"0.60939354",
"0.60435146",
"0.60259885",
"0.60218275",
"0.5953063",
"0.5927397",
"0.59246105",
"0.59229445",
"0.59229445",
"0.59097373",
"0.59014356",
"0.58... | 0.6591327 | 1 |
GET /sortiment/:id/dryck GET /sortiment/:id/dryck.json | def index
@drinks = Drink.all
@drink_types = DrinkType.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @disabilities = Disability.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @disabilities }\n end\n end",
"def index\n @bottlings = handle_sorting(:bottling, :sku, :wine, :bottle_size)\n\n respond_to do |format|\n format.html... | [
"0.59155554",
"0.59108746",
"0.5893164",
"0.58219963",
"0.5804669",
"0.57647103",
"0.57415265",
"0.5740778",
"0.5740269",
"0.5728043",
"0.5721069",
"0.57041043",
"0.56844324",
"0.56776565",
"0.5676699",
"0.5674293",
"0.5635764",
"0.56254894",
"0.56162107",
"0.56125456",
"0.56... | 0.0 | -1 |
GET /sortiment/:id/dryck/1 GET /sortiment/:id/dryck/1.json | def show
unless @drink.label_url.present?
api_info = brewery_labels
@drink.label_url = api_info.labels.large if api_info && api_info.labels
end
@have_drank = cookies[@drink.slug]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getArrondissement\r\n \tvil = params[:id]\r\n \trender json: Arrondissement.where(vil_id: vil)\r\n end",
"def index\n \n # if params[:dress_id]\n # @dress = Dress.find(params[:dress_id])\n @ratings = Rating.all\n render json: @ratings, except:[:created_at, :updated_at] ,status: 200\n ... | [
"0.5948088",
"0.58100957",
"0.5797564",
"0.5760678",
"0.570273",
"0.56906235",
"0.5672995",
"0.56567407",
"0.56471133",
"0.5645233",
"0.56432503",
"0.56384975",
"0.56256354",
"0.56036913",
"0.5594356",
"0.55795455",
"0.55710655",
"0.55687726",
"0.556784",
"0.556532",
"0.55498... | 0.0 | -1 |
POST /sortiment/:id/dryck POST /sortiment/:id/dryck.json | def create
@drink = Drink.new(drink_params)
respond_to do |format|
if @drink.save
format.html { redirect_to new_drink_path, notice: 'Drycken skapades.' }
format.json { render :show, status: :created, location: @drink }
else
format.html { render :new }
format.json { render json: @drink.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_thought(n_dink)\n\t#format thought\n\tputs n_dink\n\t#n_dink[\"duedate\"] = ;\n\tn_dink[\"timestamp\"] = Time.now.getutc\n\tn_dink[\"id\"] = (Random.rand() * 10000).to_i\n\t#read json\n\tfile = File.read(\"./public/history.json\")\n\tdata_hash = JSON.parse(file)\n\tnew_data = []\n\tfor dink in data_hash\n... | [
"0.54693776",
"0.5303369",
"0.51821494",
"0.5172421",
"0.5161261",
"0.5032387",
"0.5021262",
"0.5004437",
"0.4977543",
"0.49628145",
"0.49267727",
"0.4900093",
"0.489163",
"0.48808828",
"0.4870154",
"0.48601368",
"0.48500934",
"0.48475096",
"0.48472092",
"0.48457596",
"0.4841... | 0.5241454 | 2 |
PATCH/PUT /sortiment/:id/dryck/1 PATCH/PUT /sortiment/:id/dryck/1.json | def update
respond_to do |format|
if @drink.update(drink_params)
format.html { redirect_to edit_drink_path(@drink), notice: 'Drycken uppdaterades.' }
format.json { render :show, status: :ok, location: @drink }
else
format.html { render :edit }
format.json { render json: @drink.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl ... | [
"0.60671705",
"0.60479087",
"0.5979313",
"0.5972023",
"0.58599126",
"0.5814795",
"0.5778354",
"0.5774378",
"0.57658",
"0.5759956",
"0.5755549",
"0.5747105",
"0.5746886",
"0.5742375",
"0.57225597",
"0.57224756",
"0.5711658",
"0.5706211",
"0.5694221",
"0.5688826",
"0.5685677",
... | 0.56658995 | 26 |
DELETE /sortiment/:id/dryck/1 DELETE /sortiment/:id/dryck/1.json | def destroy
@drink.destroy
respond_to do |format|
format.html { redirect_to drinks_url, notice: 'Drink was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n render_json_auto @survey.delete_filter(params[:id].to_i) and return\n end",
"def destroy\n @stage_drymass = StageDrymass.find(params[:id])\n @stage_drymass.destroy\n\n respond_to do |format|\n format.html { redirect_to stage_drymasses_url }\n format.json { head :no_content }\... | [
"0.7065158",
"0.6997197",
"0.6952644",
"0.6896922",
"0.6869125",
"0.6864023",
"0.6841059",
"0.68388104",
"0.6832834",
"0.68295366",
"0.6821671",
"0.68204147",
"0.681717",
"0.6815881",
"0.6808531",
"0.67973346",
"0.6792132",
"0.6771393",
"0.676624",
"0.67648923",
"0.67548066",... | 0.0 | -1 |
get the ten first hits from the breweryDB | def db_list
beername = params[:name]
@beer_info = BREWERY.search.beers(q: beername, withBreweries: 'Y').first(10)
@beers_with_breweries = []
@beerlist = @beer_info.map do |drink|
drink_object(drink)
end
render json: @beerlist
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topTenBooks\n\t\t@requests = requests.order('count desc').limit(10)\n\tend",
"def retrieve_for_index(index)\n page = (index / 10) + 1\n populate_results(API.search(@query, page))\n end",
"def first(n=1)\n query(@sql + ' LIMIT ' + n.to_s, cache: false)\n end",
"def top_ten\n Rails.cache... | [
"0.6203957",
"0.61502975",
"0.60688925",
"0.603724",
"0.59218013",
"0.5807932",
"0.5802249",
"0.5774838",
"0.5739761",
"0.57225984",
"0.57061094",
"0.569189",
"0.5655257",
"0.5605034",
"0.5594972",
"0.553642",
"0.5521013",
"0.5520722",
"0.5511041",
"0.5468716",
"0.54476935",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_drink
@drink = Drink.friendly.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def drink_params
permitted = [:name, :brewery, :country, :percentage, :price, :drink_type_id, :description, :instock, :label_url]
params.require(:drink).permit(*permitted)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Set up all the steps for processing, including validating the spreadsheet_id, and pulling all the values we'll be operating on | def initialize(spreadsheet_id)
# Initialize the API
@service = Google::Apis::SheetsV4::SheetsService.new
@service.client_options.application_name = APPLICATION_NAME
@service.authorization = authorize
# Prints the names and majors of students in a sample spreadsheet:
# https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit
# spreadsheet_id = "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
# range = "Insert your updates here!A3:E"
range = "'Published factchecks'!A:Q"
response = @service.get_spreadsheet_values spreadsheet_id, range
puts "No data found." if response.values.empty?
@spreadsheet_id = spreadsheet_id
@values = response.values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process\n uploaded_workbook = Spreadsheet.open self.path\n @records_matched = 0\n @records_updated = 0\n @records_failed = 0\n @failed_queries = 0\n @skipped_records = 0\n\n product_sheet = uploaded_workbook.worksheet(0)\n perform(product_sheet)\n\n if not uploaded_workbook.worksheet(1).nil?\n vari... | [
"0.6807867",
"0.66459835",
"0.6291309",
"0.6095432",
"0.6003874",
"0.57418203",
"0.5722642",
"0.5714362",
"0.57080144",
"0.57065916",
"0.5676959",
"0.564049",
"0.5632519",
"0.5628784",
"0.5594937",
"0.55781126",
"0.5573592",
"0.5568315",
"0.55349046",
"0.5499037",
"0.5497785"... | 0.6307966 | 2 |
Run all the processing | def process
progressbar = ProgressBar.create(title: "Rows", total: @values.count, format: "%B | %c/%u | %p% | %E ")
rows = [["Valid Original URL?", "Valid Article URL?"]]
@values.each_with_index do |row, index|
next if index == 0
valid_original_url = validate_url(row[9]) ? "" : "DIRTY"
valid_article_url = validate_url(row[10]) ? "" : "DIRTY"
rows << [valid_original_url, valid_article_url]
progressbar.increment
end
update_sheet(rows)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_processing_run(faids)\n perform_analysis(faids)\n perform_processing!\n end",
"def process!\n end",
"def run_all()\n end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def ... | [
"0.75878906",
"0.72011226",
"0.70884836",
"0.7060549",
"0.7060549",
"0.7060549",
"0.7060549",
"0.7060549",
"0.7060549",
"0.7060549",
"0.7060549",
"0.69959456",
"0.69959456",
"0.69923913",
"0.6974905",
"0.6974905",
"0.6797452",
"0.6794056",
"0.6662708",
"0.66526353",
"0.662487... | 0.0 | -1 |
Ensure valid credentials, either by restoring from the saved credentials files or intitiating an OAuth2 authorization. If authorization is required, the user's default browser will be launched to approve the request. | def authorize
client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH
token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH
authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store
user_id = "default"
credentials = authorizer.get_credentials user_id
if credentials.nil?
url = authorizer.get_authorization_url base_url: OOB_URI
puts "Open the following URL in the browser and enter the " \
"resulting code after authorization:\n" + url
code = ask "code?: "
credentials = authorizer.get_and_store_credentials_from_code(
user_id: user_id, code: code, base_url: OOB_URI
)
end
credentials
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials use... | [
"0.69323707",
"0.67216325",
"0.6658172",
"0.6651308",
"0.6555863",
"0.6524707",
"0.649825",
"0.6493513",
"0.6472096",
"0.6463644",
"0.64555514",
"0.6454093",
"0.6451952",
"0.6449939",
"0.64482194",
"0.6437596",
"0.6408479",
"0.64000255",
"0.63946193",
"0.63938075",
"0.6385079... | 0.64405745 | 15 |
Check if the URL is valid by first checking if it passes a regex. Second, if it resolves to a 200 | def validate_url(url)
results = /\A(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?\z/.match(url)
return false if results.nil? || results.length == 0
response = Typhoeus.get(url)
return true if response.code == 200
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_url?(url)\n resp = Curl.get url\n\n if resp.body_str.include? @invalid_text\n return false\n else\n return true\n end\nend",
"def valid_url?(url)\n begin\n Net::HTTP.get_response(URI(url)).code == \"200\" ? true : false\n rescue SocketError\n false\n end\nend",
"def check_url(pat... | [
"0.7474573",
"0.74340713",
"0.73269325",
"0.7312319",
"0.72817117",
"0.72326356",
"0.71225625",
"0.70499736",
"0.70081174",
"0.7007038",
"0.6991357",
"0.6966782",
"0.6898965",
"0.6889834",
"0.6883453",
"0.6875627",
"0.6873403",
"0.6856323",
"0.68135035",
"0.6798069",
"0.67647... | 0.66475284 | 28 |
Update the sheet with the go/nogo values | def update_sheet(rows)
a1_notation = "'Published factchecks'!R1:S#{rows.count}"
request_body = Google::Apis::SheetsV4::BatchUpdateValuesRequest.new
value_range = Google::Apis::SheetsV4::ValueRange.new
value_range.range = a1_notation
value_range.major_dimension = "ROWS"
value_range.values = rows
request_body.data = [value_range]
request_body.include_values_in_response = true
request_body.value_input_option = "RAW"
response = @service.batch_update_values(@spreadsheet_id, request_body)
puts response.to_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_value(row,col,value,sheet=nil)\n sheet = @default_sheet unless sheet\n raise RangeError, \"sheet not set\" unless sheet\n #@@ Set and pass sheet_no\n begin\n sheet_no = sheets.index(sheet)+1\n rescue\n raise RangeError, \"invalid sheet '\"+sheet.to_s+\"'\"\n end\n row,col = n... | [
"0.6290119",
"0.622141",
"0.5964924",
"0.5964924",
"0.59599894",
"0.5827659",
"0.5686042",
"0.5680056",
"0.56161904",
"0.55750555",
"0.55575186",
"0.55575186",
"0.54161173",
"0.54161173",
"0.5409983",
"0.5404171",
"0.5373949",
"0.53346384",
"0.53304774",
"0.53169316",
"0.5300... | 0.59686637 | 2 |
answer "" for all unexpected calls | def method_missing(m, *args, &block)
""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doNothing\n\n system(%Q{say -v \"karen\" \"You do nothing and watch as 5 innocent men die\"})\n system(%Q{say -v \"karen\" \"Choosing to do nothing is still a chose\"})\n system(%Q{say -v \"karen\" \"You are responsible for these mens deaths\"})\n system(%Q{say -v \"karen\" \"and th... | [
"0.66577536",
"0.6499136",
"0.64680016",
"0.6317308",
"0.62703776",
"0.6220558",
"0.6211194",
"0.62051654",
"0.61884993",
"0.6188232",
"0.61642796",
"0.61583364",
"0.6152237",
"0.6147045",
"0.6147045",
"0.6147045",
"0.6138358",
"0.6138358",
"0.6117474",
"0.61154974",
"0.60986... | 0.0 | -1 |
act like any duck | def respond_to?(method_name, include_private = false)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generic?; true; end",
"def abstract!; end",
"def same; end",
"def for_cop(cop); end",
"def any; end",
"def direct_dependency(type, result = T.unsafe(nil)); end",
"def wrapper; end",
"def make(thing) end",
"def cop=(_); end",
"def cop=(_); end",
"def make_it_quack(duck)\n duck.quack\nend"... | [
"0.5900459",
"0.5866042",
"0.58528817",
"0.5824319",
"0.58108264",
"0.5799593",
"0.5736011",
"0.5703646",
"0.57025224",
"0.57025224",
"0.5693474",
"0.568474",
"0.5659443",
"0.5659443",
"0.5659443",
"0.5659443",
"0.5638124",
"0.56196135",
"0.56108063",
"0.55734617",
"0.5507375... | 0.0 | -1 |
Here are our methods | def dist(line_start, stop_start, stop_finish)
x = $mta[line_start].index(stop_start)
y = $mta[line_start].index(stop_finish)
return (x - y).abs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def probers; end",
"def operations; end",
"def operations; end",
"def implementation; end",
"def implementation; end",
"def suivre; end",
"def formation; end",
"def apply\n\t\t\n\tend",
"def apply\n\t\t\n\tend",
"def refutal()\n end",
"def weber; ... | [
"0.7603634",
"0.67801857",
"0.6753929",
"0.65450233",
"0.65450233",
"0.65118206",
"0.65118206",
"0.64790374",
"0.6465835",
"0.6326218",
"0.6326218",
"0.63173103",
"0.630146",
"0.62885076",
"0.62556875",
"0.62556875",
"0.62556875",
"0.62556875",
"0.6232442",
"0.6232442",
"0.62... | 0.0 | -1 |
CSRF won't be able to be verified on returning from the OpenID server, so we will bypass that check for this strategy | def store?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_authenticity_token; end",
"def verified_request?\r\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\r\n end",
"def verified_request?\n super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN'])\n end",
"def verified_request?\n super || valid_authen... | [
"0.7376418",
"0.7265402",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7226555",
"0.7217411",
"0.7217411",
"0.7217411",
"0.7217411",
"0.71578974",
"0.7118049",
... | 0.0 | -1 |
Handles incoming provider response | def handle_response!
logger.debug "Attempting OpenID auth: #{provider_response.inspect}"
case provider_response.status
when :success
resource = find_resource || build_resource || create_resource
if resource && validate(resource)
begin
update_resource!(resource)
rescue
fail! $!
else
success!(resource)
end
else
fail! "This OpenID URL is not associated with any registered user"
end
when :cancel
fail! "OpenID authentication cancelled"
when :failure
fail! "OpenID authentication failed"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_response(provider_response)\n nil\n end",
"def process_response(provider_response)\n nil\n end",
"def handle_response(response); end",
"def handle_response(response); end",
"def receive_response(response); end",
"def handle_response(response)\n handler_for_cod... | [
"0.74769324",
"0.74769324",
"0.69911903",
"0.69911903",
"0.6476617",
"0.64216244",
"0.6421063",
"0.6359647",
"0.6281708",
"0.61874574",
"0.6095895",
"0.6092627",
"0.6092627",
"0.6092627",
"0.6092627",
"0.6092627",
"0.6092627",
"0.6092627",
"0.6092627",
"0.6092627",
"0.6092627... | 0.6798185 | 4 |
Use callbacks to share common setup or constraints between actions. | def set_annotation
@annotation = Annotation.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def annotation_params
params.require(:annotation).permit(:body)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
input = two arguments, a positive integer representing salary, and a boolean output = an integer representing bonus for salary rules: if boolean == true, bonus is half of salary if boolean == false, bonus is 0 test cases: what if salary is 0 and boolean is true? what if salary is an odd number, should integer or float division be used? => float logic if condition to check value of boolean IF true, return salary.to_f / 2 ELSE false, return 0 def calculate_bonus(salary, boolean) if boolean return salary.to_f / 2 else return 0 end end refactor for brevity using ternary operator | def calculate_bonus(salary, boolean)
boolean ? (salary.to_f / 2) : 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_bonus(salary, boolean)\n return salary / 2 if boolean == true \n return 0 if boolean == false\nend",
"def calculate_bonus(salary, boolean)\n boolean ? (salary/2.0) : 0\nend",
"def calculate_bonus(salary,boolean)\n \n if boolean == true\n return (salary / 2) \n else\n return 0\n end\... | [
"0.91724765",
"0.9143219",
"0.9095274",
"0.90872914",
"0.9069101",
"0.89350736",
"0.89265174",
"0.8810697",
"0.8810228",
"0.86985445",
"0.85585463",
"0.8485025",
"0.8485025",
"0.8485025",
"0.8485025",
"0.8485025",
"0.84756905",
"0.84292835",
"0.84292835",
"0.84292835",
"0.842... | 0.91687465 | 1 |
1131 => 211311 [2 1's][1 1's][1 3's][1 1's] repeat RLE in other terms | def digitcount(num)
# Convert the number into an array, 1131 -> [1,1,3,1] so we can iterate through
digits = num.to_s.chars.map(&:to_i)
# Track the count of seen numbers
count = 0
# Track the n-1 array value
prev = nil
# The resulting string
result = ''
# For each digit
digits.each do |d|
if prev == d
# If it's the same number as we've seen before we should inc the counter
count += 1
else
# This isn't a match, so output the previous count and number, reset the counter and carry on
result += count.to_s + prev.to_s if count > 0
count = 1
end
# In the next loop iteration the previous is the current digit
prev = d
end
# Return the result, don't forget the last digit we inspected
return result += count.to_s + prev.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def luhns(a)\n\tb = a.to_s[0..-2].reverse.split(\"\").to_a.map{|v|v.to_i}\n\t(b.each_index{|i|i.even? ? b[i]=b[i]*2>9?b[i]*2-9:b[i]*2:i=i}.inject(:+)+a)%10==0\nend",
"def letra_x(n)\n result = \"\" \n t = n-1\n (n).times do |i| \n n.times do |b| \n if... | [
"0.6155837",
"0.61488706",
"0.6107804",
"0.5942966",
"0.5905561",
"0.5731302",
"0.5687082",
"0.5668494",
"0.563021",
"0.5614535",
"0.5589821",
"0.55776674",
"0.5549196",
"0.5512476",
"0.54648834",
"0.54565746",
"0.5452719",
"0.54345703",
"0.54125106",
"0.54118556",
"0.5410564... | 0.0 | -1 |
GET /roster_squares/1/edit edit the behavior squares available to a student | def edit
@roster_square = RosterSquare.new
@roster_squares = RosterSquare.all
@student = Student.find_by_id(params[:id])
@student_squares = RosterSquare.where(student_id: @student.id)
@not_student_squares = []
#Set the squares for the specific school
@school_squares = Square.where(school_id: @student.school_id)
@square = Square.find_by_id(params[:id])
@squares = Square.all
if params[:remove_square]
if params[:remove_square_id] != nil
@roster_squares.delete(RosterSquare.find(params[:remove_square_id]))
# flash[:success] = 'Roster square was successfully removed.'
redirect_to "/roster_squares/#{params[:id]}/edit"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_roster_square\n #Sets the edit page to the specified student\n @roster_squares = RosterSquare.all\n @student = Student.find(params[:id])\n end",
"def edit\n respond_with(@sicoss_location)\n end",
"def edit\n respond_with(@sicoss_situation)\n end",
"def edit\n board_games\... | [
"0.7591398",
"0.6604159",
"0.64801496",
"0.64296114",
"0.6410641",
"0.6361647",
"0.63563746",
"0.6353334",
"0.6278119",
"0.6259901",
"0.6250012",
"0.62411696",
"0.6158141",
"0.61566734",
"0.6146029",
"0.6146029",
"0.61211026",
"0.61089665",
"0.6098568",
"0.6098052",
"0.605273... | 0.7454045 | 1 |
Below are helpers methods that when called allow you to check certain fields that would otherwise be unavailable | def set_roster_id (roster_square)
@roster_id = RosterSquare.find(roster_square.square_id).screen_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_fields\n %w[email author].each do |field|\n value = self.send(field)\n abort \"Hoe #{field} value not set. aborting\" if value.nil? or value.empty?\n end\n end",
"def check_fields\n raise NotImplementedException\n end",
"def check_fields\n fields = %w{ipaper_id ... | [
"0.7315085",
"0.72841805",
"0.72831154",
"0.7132645",
"0.70112664",
"0.69439703",
"0.6943045",
"0.6738752",
"0.6680654",
"0.66429436",
"0.663504",
"0.6619284",
"0.6611587",
"0.6587845",
"0.655292",
"0.6472988",
"0.64482236",
"0.64482236",
"0.638695",
"0.636603",
"0.63548946",... | 0.0 | -1 |
Checks if the square is used for the specific student. Unused at the moment | def is_student_square(square)
@is_square = false
@student_squares.each do |student_square|
if square.id == student_square.square_id
@is_square = true
break
end
if @is_square != true
@is_square = false
end
end
if @is_square == false
@not_student_squares.push(square)
end
@is_square
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isSquare()\n\n truth = (@rowSize == @colSize) ? true : false\n truth\n\n end",
"def square_available?(square)\n board.values.include?(square)\n end",
"def square?()\n return (@height == @width) & (@type == \"rectangle\")\n end",
"def valid_square?(pos)\n y, x = pos\n y.between?(0... | [
"0.65709186",
"0.6449969",
"0.6416244",
"0.6334376",
"0.63267237",
"0.6305692",
"0.62639636",
"0.6201371",
"0.6155469",
"0.6153109",
"0.61430776",
"0.61420405",
"0.6140051",
"0.612233",
"0.60141087",
"0.5997237",
"0.59910303",
"0.598717",
"0.59691674",
"0.5961965",
"0.5955282... | 0.8055263 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_roster_square
#Sets the edit page to the specified student
@roster_squares = RosterSquare.all
@student = Student.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def roster_square_params
params.require(:roster_square).permit(:square_id, :student_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /recipes GET /recipes.json | def index
@recipes = Recipe.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def index\n info = Aws.get_recipes_from_db\n render... | [
"0.8315941",
"0.76739687",
"0.76456314",
"0.75547504",
"0.7492078",
"0.7476003",
"0.74459517",
"0.7393438",
"0.7300475",
"0.7273354",
"0.72657275",
"0.7214473",
"0.7162102",
"0.71540695",
"0.7122386",
"0.71124816",
"0.7101849",
"0.70503086",
"0.69963014",
"0.6985436",
"0.6985... | 0.7057095 | 29 |
GET /recipes/1 GET /recipes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def show(id) \n response = request(:get, \"/recipes/#{id}.json\")\n response.first[1]\n end",
"def show\n resp... | [
"0.79414284",
"0.790214",
"0.75844485",
"0.756833",
"0.7435937",
"0.7432573",
"0.7403042",
"0.7356558",
"0.7325271",
"0.7305129",
"0.72860897",
"0.726182",
"0.723712",
"0.71111596",
"0.70902306",
"0.7004932",
"0.70041907",
"0.69779086",
"0.69637275",
"0.6949757",
"0.6949757",... | 0.0 | -1 |
TODO: Use Acts as State Machine gem | def post_to_twitter
if valid?
ActiveRecord::Base.transaction do
self.published = true
self.published_at = DateTime.now
save!
tweet = client.update(text)
self.tweet_id = tweet.id
save!
return true
end
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state\n end",
"def states; end",
"def enter_state\n end",
"def known_states; end",
"def known_states; end",
"def known_states; end",
"d... | [
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7597168",
"0.7540766",
"0.7316112",
"0.7092373",
"0.7092373",
"0.7092373",
"0.70001835",
"0.68278223",
"0.68278223",
"0.6821809",
"0.6787851",
"0.6758319",
"0.6758319",
... | 0.0 | -1 |
TODO: Use Acts as State Machine gem | def delete_from_twitter
self.post_at = nil
if valid?
ActiveRecord::Base.transaction do
self.published = false
self.published_at = nil
self.save!
client.destroy_status(tweet_id) if tweet_id.present?
end
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state\n end",
"def states; end",
"def enter_state\n end",
"def known_states; end",
"def known_states; end",
"def known_states; end",
"d... | [
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7696144",
"0.7597168",
"0.7540766",
"0.7316112",
"0.7092373",
"0.7092373",
"0.7092373",
"0.70001835",
"0.68278223",
"0.68278223",
"0.6821809",
"0.6787851",
"0.6758319",
"0.6758319",
... | 0.0 | -1 |
See files in the same directory: Given `helper_test.md`, returns `helper_modified.md`. | def number_questions_and_add_answer_templates(text)
# Number the first question
modified = "1." + text[1..-1]
# Number the rest of the questions and add answer templates
number = 1
new_question = /\n# [A-Z]/
answer_template = "\n<details><summary><b>Answer</b></summary>\n<p>\n\n``\n\n</p>\n</details>"
divider = "\n\n---\n\n"
modified.gsub!(new_question) do |str|
number += 1
"#{answer_template}#{divider}#{number}. #{str[-1]}"
end
# Add answer template to the last question
modified + answer_template
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def helper_files\n glob = Dir.glob(File.join(test_folder, \"helpers\", \"*/**/*\"))\n glob.reject { |f| File.directory?(f) }\n end",
"def helper_files\n glob = File.join(\"helpers\", \"*/**/*\")\n Util.safe_glob(config[:test_base_path], glob).reject { |f| File.directory?(f) }\n ... | [
"0.62671226",
"0.60273993",
"0.60212994",
"0.59757805",
"0.5852637",
"0.56840265",
"0.5517935",
"0.5509494",
"0.5456811",
"0.5443863",
"0.54235363",
"0.53968596",
"0.5389566",
"0.53659165",
"0.5333496",
"0.52943134",
"0.52478755",
"0.52107805",
"0.5208",
"0.51974064",
"0.5184... | 0.0 | -1 |
Get an Array of all scripts that have been imported into the Plot. | def imported_scripts
@imported_scripts ||= []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scripts\n @parts.values.map(&:script).compact\n end",
"def list_all_scripts\n scripts = []\n\n Hook.hooks(event_instance.class).each_value do |klass|\n scripts.concat(list_scripts(klass))\n end\n\n scripts\n end",
"def scripts\n @scripts\n end",
"def scripts\n ... | [
"0.74343014",
"0.7068649",
"0.690905",
"0.68276185",
"0.6801287",
"0.6754027",
"0.6659049",
"0.64578724",
"0.6320397",
"0.6320397",
"0.62072533",
"0.60786325",
"0.60341024",
"0.60105026",
"0.59371144",
"0.59022814",
"0.58862406",
"0.5868887",
"0.5866156",
"0.58411753",
"0.583... | 0.80782133 | 0 |
Get an Array of the Plot's current Syntaxes. | def syntaxes
playbook.syntaxes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_syntaxes\n uri = URI.parse(\"#{BASE_URL}/syntaxes\")\n response = JSON.parse(@client.get(uri).body)\n return response['syntaxes'].map { |obj| Pastee::Syntax.new(obj) } if response['success']\n\n throw_error(response)\n end",
"def syntax(tokens)\n tokens = expect(:\".syntax\", tokens)\n ... | [
"0.6616718",
"0.5914168",
"0.58122456",
"0.5598634",
"0.54084706",
"0.52474123",
"0.5245073",
"0.51947457",
"0.51875925",
"0.5181786",
"0.51713645",
"0.50887334",
"0.5070031",
"0.5057521",
"0.5021981",
"0.5012417",
"0.49847165",
"0.49529937",
"0.49337205",
"0.49230424",
"0.49... | 0.64173704 | 1 |
Prepare the Plot for the next turn of gameplay. This method is typically called by the Engine that manages game execution. | def ready
playbook.freeze
@running = true
# Call the initial state to make sure it's set
initial_state
call_ready
call_player_ready
p_subplots.each { |s| s.ready }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_drawing\n calculate_spread\n calculate_increment\n sort_data if @sort # Sort data with avg largest values set first (for display)\n set_colors\n normalize\n setup_graph_measurements\n sort_norm_data if @sorted_drawing # Sort norm_data with avg largest values set first (... | [
"0.596435",
"0.554813",
"0.5506805",
"0.5471333",
"0.53879887",
"0.53865236",
"0.52942634",
"0.52837384",
"0.52837384",
"0.52837384",
"0.52837384",
"0.52761114",
"0.52709645",
"0.52677715",
"0.5199208",
"0.51697457",
"0.51651394",
"0.51200175",
"0.511894",
"0.5058235",
"0.505... | 0.47269943 | 60 |
Update the Plot's current turn of gameplay. This method is typically called by the Engine that manages game execution. | def update
entities.each { |e| e.flush }
call_before_player_update
p_players.each { |p|
p.performed nil
p.scene.update
}
p_entities.each { |e| e.update }
call_player_update
call_update
p_subplots.each { |s| s.update unless s.concluded? }
p_subplots.delete_if { |s| s.concluded? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_turn\n board.render\n pos = get_pos\n decision = get_decision\n if decision == \"r\"\n board.reveal(pos)\n elsif decision == \"f\"\n board.flag(pos)\n else\n @saved_board = board.to_yaml\n end\n end",
"def update\n i... | [
"0.6222782",
"0.62025565",
"0.6129455",
"0.6088473",
"0.6061912",
"0.60595727",
"0.6029764",
"0.6022649",
"0.59729767",
"0.58718914",
"0.5867517",
"0.58624524",
"0.585256",
"0.5841424",
"0.5809253",
"0.5805975",
"0.5755483",
"0.575347",
"0.5752374",
"0.5742185",
"0.5738354",
... | 0.0 | -1 |
Load a script into the current Plot. This method is similar to Kernelrequire, except that the script is evaluated within the Plot's context via stage. | def script path
imported_script = source.export(path)
if imported_script.nil?
raise LoadError.new("cannot load script -- #{path}")
end
if !@working_scripts.include?(imported_script) and !imported_scripts.include?(imported_script)
@working_scripts.push imported_script
# @hack Arguments need to be in different order if source returns proc
if imported_script.read.kind_of?(Proc)
stage &imported_script.read
else
stage imported_script.read, imported_script.absolute_path
end
@working_scripts.pop
imported_scripts.push imported_script
true
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def script(script_file)\n load script_file\n\n self\n end",
"def load_script(name)\r\n script = File.read(name)\r\n eval script, binding, name\r\nend",
"def script_load(script); end",
"def load_script(path)\n eval(load_data(path))\nend",
"def load_script(debug)\n @file_path = @path\n @l... | [
"0.6849809",
"0.68381834",
"0.67507166",
"0.67363286",
"0.6653091",
"0.6417115",
"0.60755235",
"0.6071626",
"0.60593086",
"0.5974236",
"0.59297115",
"0.59249145",
"0.59249145",
"0.59249145",
"0.5741269",
"0.57376105",
"0.5728885",
"0.5722586",
"0.56824595",
"0.5640526",
"0.55... | 0.6213732 | 6 |
Show invalid properties with the reasons. Usually used together with valid? | def list_invalid_properties
invalid_properties = super
if @class_id.nil?
invalid_properties.push('invalid value for "class_id", class_id cannot be nil.')
end
if @object_type.nil?
invalid_properties.push('invalid value for "object_type", object_type cannot be nil.')
end
pattern = Regexp.new(/^$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
if !@uuid.nil? && @uuid !~ pattern
invalid_properties.push("invalid value for \"uuid\", must conform to the pattern #{pattern}.")
end
pattern = Regexp.new(/^$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
if !@vdisk_id.nil? && @vdisk_id !~ pattern
invalid_properties.push("invalid value for \"vdisk_id\", must conform to the pattern #{pattern}.")
end
invalid_properties
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil.... | [
"0.76497203",
"0.76497203",
"0.76497203",
"0.76497203",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7637422",
"0.7334807",
"0.72685325",
"0.7238964",
"0.7231359",
"0.72258264",
"0.7208294",
"0.71760833",
"0.7170241",
"0.717024... | 0.7356452 | 12 |
Check to see if the all the properties in the model are valid | def valid?
return false if @class_id.nil?
class_id_validator = EnumAttributeValidator.new('String', ["virtualization.VmwareVirtualDisk"])
return false unless class_id_validator.valid?(@class_id)
return false if @object_type.nil?
object_type_validator = EnumAttributeValidator.new('String', ["virtualization.VmwareVirtualDisk"])
return false unless object_type_validator.valid?(@object_type)
compatibility_mode_validator = EnumAttributeValidator.new('String', ["notApplicable", "physicalMode", "virtualMode"])
return false unless compatibility_mode_validator.valid?(@compatibility_mode)
disk_mode_validator = EnumAttributeValidator.new('String', ["persistent", "independent_persistent", "independent_nonpersistent", "nonpersistent", "undoable", "append"])
return false unless disk_mode_validator.valid?(@disk_mode)
disk_type_validator = EnumAttributeValidator.new('String', ["flatDisk", "rdmDisk"])
return false unless disk_type_validator.valid?(@disk_type)
sharing_validator = EnumAttributeValidator.new('String', ["sharingNone", "sharingMultiWriter"])
return false unless sharing_validator.valid?(@sharing)
storage_allocation_type_validator = EnumAttributeValidator.new('String', ["notApplicable", "thin", "lazyZeroedThick", "eagerZeroedThick"])
return false unless storage_allocation_type_validator.valid?(@storage_allocation_type)
return false if !@uuid.nil? && @uuid !~ Regexp.new(/^$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
return false if !@vdisk_id.nil? && @vdisk_id !~ Regexp.new(/^$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
true && super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_properties\n true\n end",
"def validate_properties\n true\n end",
"def validate\n super\n\n check_optional_property :collection, String\n check_optional_property :create, String\n check_optional_property :delete, String\n check_optional_property :... | [
"0.78992486",
"0.78992486",
"0.70971805",
"0.70782334",
"0.7032205",
"0.7031276",
"0.69510347",
"0.6869891",
"0.6858077",
"0.6858077",
"0.68287027",
"0.6823878",
"0.6820306",
"0.68144894",
"0.6794656",
"0.6752167",
"0.66843414",
"0.6676546",
"0.6667755",
"0.66296124",
"0.6618... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def class_id=(class_id)
validator = EnumAttributeValidator.new('String', ["virtualization.VmwareVirtualDisk"])
unless validator.valid?(class_id)
fail ArgumentError, "invalid value for \"class_id\", must be one of #{validator.allowable_values}."
end
@class_id = class_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def object_type=(object_type)
validator = EnumAttributeValidator.new('String', ["virtualization.VmwareVirtualDisk"])
unless validator.valid?(object_type)
fail ArgumentError, "invalid value for \"object_type\", must be one of #{validator.allowable_values}."
end
@object_type = object_type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def compatibility_mode=(compatibility_mode)
validator = EnumAttributeValidator.new('String', ["notApplicable", "physicalMode", "virtualMode"])
unless validator.valid?(compatibility_mode)
fail ArgumentError, "invalid value for \"compatibility_mode\", must be one of #{validator.allowable_values}."
end
@compatibility_mode = compatibility_mode
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def disk_mode=(disk_mode)
validator = EnumAttributeValidator.new('String', ["persistent", "independent_persistent", "independent_nonpersistent", "nonpersistent", "undoable", "append"])
unless validator.valid?(disk_mode)
fail ArgumentError, "invalid value for \"disk_mode\", must be one of #{validator.allowable_values}."
end
@disk_mode = disk_mode
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def disk_type=(disk_type)
validator = EnumAttributeValidator.new('String', ["flatDisk", "rdmDisk"])
unless validator.valid?(disk_type)
fail ArgumentError, "invalid value for \"disk_type\", must be one of #{validator.allowable_values}."
end
@disk_type = disk_type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def sharing=(sharing)
validator = EnumAttributeValidator.new('String', ["sharingNone", "sharingMultiWriter"])
unless validator.valid?(sharing)
fail ArgumentError, "invalid value for \"sharing\", must be one of #{validator.allowable_values}."
end
@sharing = sharing
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def storage_allocation_type=(storage_allocation_type)
validator = EnumAttributeValidator.new('String', ["notApplicable", "thin", "lazyZeroedThick", "eagerZeroedThick"])
unless validator.valid?(storage_allocation_type)
fail ArgumentError, "invalid value for \"storage_allocation_type\", must be one of #{validator.allowable_values}."
end
@storage_allocation_type = storage_allocation_type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Custom attribute writer method with validation | def uuid=(uuid)
pattern = Regexp.new(/^$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
if !uuid.nil? && uuid !~ pattern
fail ArgumentError, "invalid value for \"uuid\", must conform to the pattern #{pattern}."
end
@uuid = uuid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_writer_tag(text); end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def writer(*args)\n attr_writer(*args)\n args\n end",
"def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at... | [
"0.6472992",
"0.6315012",
"0.6315012",
"0.62821025",
"0.6279224",
"0.6211609",
"0.61891466",
"0.6182247",
"0.60683644",
"0.6032628",
"0.5995443",
"0.5988785",
"0.5959885",
"0.5938289",
"0.5931089",
"0.58951056",
"0.5859927",
"0.5851703",
"0.58493423",
"0.58465594",
"0.5832836... | 0.0 | -1 |
Custom attribute writer method with validation | def vdisk_id=(vdisk_id)
pattern = Regexp.new(/^$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
if !vdisk_id.nil? && vdisk_id !~ pattern
fail ArgumentError, "invalid value for \"vdisk_id\", must conform to the pattern #{pattern}."
end
@vdisk_id = vdisk_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_writer_tag(text); end",
"def allowed_attributes=(_arg0); end",
"def allowed_attributes=(_arg0); end",
"def writer(*args)\n attr_writer(*args)\n args\n end",
"def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at... | [
"0.6472992",
"0.6315012",
"0.6315012",
"0.62821025",
"0.6279224",
"0.6211609",
"0.61891466",
"0.6182247",
"0.60683644",
"0.6032628",
"0.5995443",
"0.5988785",
"0.5959885",
"0.5938289",
"0.5931089",
"0.58951056",
"0.5859927",
"0.5851703",
"0.58493423",
"0.58465594",
"0.5832836... | 0.0 | -1 |
Checks equality by comparing each attribute. | def ==(o)
return true if self.equal?(o)
self.class == o.class &&
class_id == o.class_id &&
object_type == o.object_type &&
compatibility_mode == o.compatibility_mode &&
controller_key == o.controller_key &&
device_name == o.device_name &&
disk_mode == o.disk_mode &&
disk_type == o.disk_type &&
key == o.key &&
limit == o.limit &&
lun_uuid == o.lun_uuid &&
serial == o.serial &&
shares == o.shares &&
sharing == o.sharing &&
storage_allocation_type == o.storage_allocation_type &&
unit_number == o.unit_number &&
uuid == o.uuid &&
vdisk_id == o.vdisk_id &&
vendor == o.vendor &&
virtual_disk_path == o.virtual_disk_path &&
vm_identity == o.vm_identity &&
datastore == o.datastore &&
virtual_machine == o.virtual_machine && super(o)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n attributes == other.attributes\n end",
"def ==(other) # :nodoc:\n @attrs == other.attrs\n end",
"def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n en... | [
"0.7291717",
"0.7188103",
"0.70395297",
"0.7007927",
"0.68874705",
"0.6861532",
"0.6707156",
"0.6660597",
"0.66147524",
"0.658478",
"0.6584619",
"0.6580019",
"0.65543133",
"0.6543933",
"0.65068495",
"0.6479513",
"0.6456241",
"0.6415999",
"0.6412208",
"0.6412208",
"0.6412208",... | 0.0 | -1 |
Calculates hash code according to all attributes. | def hash
[class_id, object_type, compatibility_mode, controller_key, device_name, disk_mode, disk_type, key, limit, lun_uuid, serial, shares, sharing, storage_allocation_type, unit_number, uuid, vdisk_id, vendor, virtual_disk_path, vm_identity, datastore, virtual_machine].hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n ... | [
"0.7118691",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.68960655",
"0.67847186",
"0.6707762",
"0.670052",
"0.6688737",
"0.66705376",
"0.6489735",
"0.6462376",
"0.6462376",
"0.64444333",
"0.6413127",
"0.6395483",
"0.638... | 0.0 | -1 |
Builds the object from hash | def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
super(attributes)
VirtualizationVmwareVirtualDisk.openapi_types.each_pair do |key, type|
if attributes[VirtualizationVmwareVirtualDisk.attribute_map[key]].nil? && VirtualizationVmwareVirtualDisk.openapi_nullable.include?(key)
self.send("#{key}=", nil)
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[VirtualizationVmwareVirtualDisk.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[VirtualizationVmwareVirtualDisk.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[VirtualizationVmwareVirtualDisk.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[VirtualizationVmwareVirtualDisk.attribute_map[key]]))
end
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(hash)\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v if variables[k]\n end\n return obj\n end",
"def build_from_hash(attributes)\n\n end",
"def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically ... | [
"0.8011074",
"0.7470833",
"0.7457607",
"0.7256629",
"0.72455454",
"0.70060325",
"0.6973257",
"0.6955014",
"0.69459796",
"0.69398683",
"0.69363195",
"0.6917627",
"0.6872358",
"0.6796184",
"0.6783521",
"0.67575246",
"0.67575246",
"0.67560464",
"0.67514306",
"0.67136854",
"0.666... | 0.0 | -1 |
Deserializes the data based on type | def _deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
# models (e.g. Pet) or oneOf
klass = IntersightClient.const_get(type)
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s... | [
"0.7330926",
"0.7274019",
"0.72504056",
"0.7245751",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
"0.72291344",
... | 0.0 | -1 |
Returns the string representation of the object | def to_s
to_hash.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @object.to_s\n end",
"def to_s\n object.to_s\n end",
"def serialize(object)\n object.to_s\n end",
"def to_s\n self.inspect\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"de... | [
"0.901024",
"0.89506465",
"0.84703195",
"0.83409667",
"0.8337169",
"0.8337169",
"0.8332247",
"0.82546586",
"0.8145818",
"0.8144667",
"0.81357557",
"0.812714",
"0.8093436",
"0.8086725",
"0.8073356",
"0.8039774",
"0.80308646",
"0.80064154",
"0.80064154",
"0.80064154",
"0.800641... | 0.0 | -1 |
to_body is an alias to to_hash (backward compatibility) | def to_body
to_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_body\r\n to_hash\r\n end",
"def to_body\n to_hash\nend",
"def to_body\n to_hash\nend"
] | [
"0.84283537",
"0.8347048",
"0.8347048"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.