query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Recursive function to query the OLS database and collect all of the child objects and build up a tree of OntologyTerm's. | def get_children( node=self )
sql = <<-SQL
select
subject_term.identifier as child_identifier,
subject_term.term_name as child_term,
predicate_term.term_name as relation,
object_term.identifier as parent_identifier,
object_term.term_name as parent_term
fro... | [
"def get_all_child_lists\n child_check\n \n if @all_child_terms.nil? and @all_child_names.nil?\n @all_child_terms = []\n @all_child_names = []\n \n self.children.each do |child|\n @all_child_terms.push( child.term )\n @all_child_terms.push( child.all_child_terms )\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Helper function to check whether the children have already been found or not. | def child_check
if @children.nil? or @children.empty?
get_children unless @already_fetched_children
@already_fetched_children = true
end
end | [
"def hasChildren?\n @children.length != 0\n end",
"def has_children?\n @children.length > 0\n end",
"def has_children()\n return 1 if(@children.length > 0)\n 0\n end",
"def match_children?(arg)\n self_childless = @children.nil?\n arg_childless = !arg.is_a?(Enumerable) || arg.c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Helper function to produce the flat lists of all the child terms and names. | def get_all_child_lists
child_check
if @all_child_terms.nil? and @all_child_names.nil?
@all_child_terms = []
@all_child_names = []
self.children.each do |child|
@all_child_terms.push( child.term )
@all_child_terms.push( child.all_child_terms )
@all_child_nam... | [
"def all_child_terms\n get_all_child_lists\n return @all_child_terms\n end",
"def all_child_names\n all_children.map(&:term_name)\n end",
"def children_names\n children.map(&:term_name)\n end",
"def child_terms\n h = {}\n\n # collect the sub-terms of the terms applicable to this n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Write message vbs script on host | def write_msg_to_target(message)
print_status("Writting message script on host...")
location = session.sys.config.getenv('TEMP')
msgvbs = "#{location}\\messenger.vbs"
mg = @client.fs.file.new(msgvbs, "wb")
mg.write("msgbox(\"#{message}\")")
mg.close
return msgvbs
end | [
"def write_msg_to_target(nam,message)\nprint_status(\"Writting message script on host...\")\nlocation = session.sys.config.getenv('TEMP')\nmsgvbs = \"#{location}\\\\msg.vbs\"\nmg = @client.fs.file.new(msgvbs, \"wb\")\nmg.write(\"msgbox(\\\"#{message}\\\")\")\nmg.close\nreturn msgvbs\nend",
"def CliPvtMsg\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Override answered? to ensure last answer was not the user resetting the selection to the default unselected state. | def answered?
if answers.length == 0
return false
end
if answers.last.rationale_choices.size > 0
#
# The last answer is a list containing only one item, and it
# does not contain a key for :choice_id. This is the answer we
# generated in the case of unselecting a ... | [
"def default_answer\n @default_answer ||= false\n end",
"def update_question_status\n question.answered = answer || self.class.where(:question_id => question_id, :answer => true).any?\n question.save\n end",
"def best_answer_selected?(answer_model)\r\n text_exists?(MESSAGE_BEST... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /ocorrencias POST /ocorrencias.json | def create
@ocorrencia = Ocorrencia.new(ocorrencia_params)
respond_to do |format|
if @ocorrencia.save
format.html { redirect_to @ocorrencia, notice: 'Ocorrencia was successfully created.' }
format.json { render action: 'show', status: :created, location: @ocorrencia }
else
f... | [
"def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def create\n @ocorrencia = Ocorrencia.new(ocorrencia_params)\n\n respond_to d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /ocorrencias/1 PATCH/PUT /ocorrencias/1.json | def update
respond_to do |format|
if @ocorrencia.update(ocorrencia_params)
format.html { redirect_to @ocorrencia, notice: 'Ocorrencia was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @ocorr... | [
"def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def update\n @pelicula = Pelicula.find(params[:id])\n @pelicula.update(update_params)\n render js... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def aggregate_schema(type, write: false) end | def aggregate_schema(type, write: false)
in_dir, out_dir = get_dirs(type)
jsons = aggregate(in_dir)
schema = Convert.jsons_to_schema(jsons)
if write
path = "#{out_dir}/schema-#{Time.current.strftime('%s%2N')}.json"
File.write(path, JSON.pretty_generate(schema))
end
... | [
"def aggregate_type\n raise NotImplementedError\n end",
"def aggregate op, type = :fixnum\n check_closed\n\n aggregation_impl op, type\n end",
"def schema\n @_schema\n end",
"def sql_type_metadata; end",
"def generate_schema( measure_candidate )\n end",
"def schema_multir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Walk environment S and look up value of U, if present. | def walk(u, s)
if var?(u)
pr = assp(-> (v) { u == v }, s)
pr ? walk(cdr(pr), s) : u
else
u
end
end | [
"def find_subst u, x\n u.each do |sub|\n if sub[0] == x\n return sub[1]\n end\n end\n nil\n end",
"def eval_prog env\n\t\tresults = env.select { |pair| pair[0] == @s }\n\t\tif results.length > 0\n=begin\n for i in 0..results.length-1\n puts results[i][0]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Call function f with a fresh variable. | def call_fresh(f)
-> (s_c) {
c = cdr(s_c)
f.call(var(c)).call(cons(car(s_c), c + 1))
}
end | [
"def f(x0)\n @f.call(x0)\n end",
"def f4(x)\n y = 100\n z = x + y\n return z\nend",
"def f(x0, y0)\n @f.call(x0, y0)\n end",
"def fresh! \n @fresh = true\n end",
"def test_function_savereg\n c = \"float f(float x; float y) { return x*y; }\n float g() { ret... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a response processor | def create_response_value_processor(endpoint_response)
response_type = endpoint_response.type
if response_type == TYPE_ARRAY
processor_for_values = create_processor_for_type('Response', endpoint_response.items, false)
Sinatra::SwaggerExposer::Processing::SwaggerArrayValueProcessor.ne... | [
"def on_response( &block )\n @postprocessor = block\n end",
"def process(payload)\n response = post(payload)\n Response.new(response.body)\n end",
"def service(request, response)\n process(request, response)\n end",
"def new_response_handler\n ResponseHandler.new\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a parameter processor for a parameter | def create_parameter_value_processor(parameter)
type_name = parameter.type
if type_name == TYPE_ARRAY
if PRIMITIVE_TYPES.include? parameter.items
processor_for_values = Sinatra::SwaggerExposer::Processing::SwaggerPrimitiveValueProcessor.new(
parameter.name,
... | [
"def on_parameter(param_node)\n process(param_node.prefix)\n process(param_node.value)\n end",
"def create_processor_for_type(parameter_name, parameter_type, parameter_required)\n attributes_processors = create_attributes_processors_for_type(parameter_type)\n Sinatra::SwaggerExposer::Pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a type parameter processor for a type parameter | def create_processor_for_type(parameter_name, parameter_type, parameter_required)
attributes_processors = create_attributes_processors_for_type(parameter_type)
Sinatra::SwaggerExposer::Processing::SwaggerTypeValueProcessor.new(
parameter_name,
parameter_required,
attributes... | [
"def create_preprocessor_for_type(parameter_name, parameter_type, parameter_required)\n attributes_preprocessors = create_attributes_preprocessors_for_type(parameter_type)\n Sinatra::SwaggerExposer::Processing::SwaggerTypeValuePreprocessor.new(\n parameter_name,\n parameter_requi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get attributes processor for a type | def create_attributes_processors_for_type(type_name)
type = @types[type_name]
attributes_processors = []
type.properties.each_pair do |property_name, property|
attributes_processors <<
create_processor_for_property(
property_name,
property,
... | [
"def create_attributes_preprocessors_for_type(type_name)\n type = @types[type_name]\n attributes_preprocessors = []\n type.properties.each_pair do |property_name, property|\n attributes_preprocessors <<\n create_preprocessor_for_property(\n property_name,\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a processor for a type property | def create_processor_for_property(name, type_property, required)
property_type = type_property.type
if property_type == TYPE_ARRAY
if PRIMITIVE_TYPES.include? type_property.items
processor_for_values = Sinatra::SwaggerExposer::Processing::SwaggerPrimitiveValueProcessor.new(
... | [
"def create_processor_for_type(parameter_name, parameter_type, parameter_required)\n attributes_processors = create_attributes_processors_for_type(parameter_type)\n Sinatra::SwaggerExposer::Processing::SwaggerTypeValueProcessor.new(\n parameter_name,\n parameter_required,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Translate cell index into point [x,y] | def point(index)
return [index % Grid::MaxCol, index / Grid::MaxCol]
end | [
"def cell_location_at_point(x, y)\n [x / WIDTH, y / HEIGHT ]\n end",
"def cell_at_point(x, y)\n [x / Entity::WIDTH, y / Entity::HEIGHT ]\n end",
"def cell_at_pos(row,column)\n index = row * 9 +column \n @cells[index]\n end",
"def index2pos(idx)\n idx = idx.to_i\n raise InvalidCellErro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Simply check if the value is out of bound | def out_of_bound?(value, min, max)
return value > max || value < min
end | [
"def out_of_range?\n value < 1 || value > 12\n end",
"def out_of_bounds?\n _size > max_size!\n end",
"def check_bounds(value)\n return value >= self.bound.lower_bound && value <= self.bound.upper_bound\n end",
"def x_out_of_bounds?(value)\n value < 1 || value > Terminal.width\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /locks/ or /locks/serial/ This endpoint is used in both lock commissioning and lock status sync | def update
return if params_missing([ :id, :lock_serial ], params, true)
lock = Lock.get_active_else_not(params)
return render_error_modelname(404, :MISSING_RECORD, Lock) if !lock
# Only the owner can update the lock record
return render_error(403, :NOT_BELONGING, Lock) if lock.user_id != @current... | [
"def update\n respond_to do |format|\n if @lock.update(lock_params)\n format.html { redirect_to @lock, notice: 'Lock was successfully updated.' }\n format.json { render :show, status: :ok, location: @lock }\n else\n format.html { render :edit }\n format.json { render json: @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /locks/credentials/:id or /locks/credentials/serial/:lock_serial Fetches the signed account/user_device id and key id data for the lock's keys. | def get_credentials
return if params_missing([ :id, :lock_serial ], params, true)
return if !get_lock_id(params)
lock = @lock || Lock.find(params[:lock_id])
if !lock
render_error_modelname(404, :MISSING_RECORD, Lock)
return
end
json = {
users_devices: {}, # All users_devices u... | [
"def get_lock(account_id, template_id)\n data, _status_code, _headers = get_lock_with_http_info(account_id, template_id)\n return data\n end",
"def get_locks\n HTTParty.get(\"#{$base_url}/partners/#{$partner_id}/locks\", {headers: $headers}).parsed_response['locks']\nend",
"def get_lock_with_htt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Decommission and send notifications. Returns false on error. | def do_decommission(lock, revoker = nil)
if !lock.do_decommission(revoker, request.uuid)
check_save_failure(lock)
return false
end
return true
end | [
"def decommission_command(opts)\n @scheduler.run_decommission { CommandIO.instance.reply(opts[:conn], \"Decommissioned\") }\n end",
"def decommission_command(opts)\n @scheduler.run_decommission { CommandIO.instance.reply(opts[:conn], 'Decommissioned') }\n end",
"def schedule_decommission(options... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /workphases GET /workphases.json | def view
@workphases = Workphase.search_by_phase(params[:search])
end | [
"def index\n @phases = Phase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @phases }\n end\n end",
"def index\n @project_phases = ProjectPhase.all\n end",
"def index\n @phases = Phase.where(project_id: params[:project_id])\n end",
"def i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /workphases POST /workphases.json | def create
@workphase = Workphase.new(workphase_params)
respond_to do |format|
if @workphase.save
format.html { redirect_to @workphase, notice: 'Workphase was successfully created.' }
format.json { render :show, status: :created, location: @workphase }
else
format.html { ren... | [
"def create\n \n @workout_exercise = @plan_workout.workout_exercises.create(workout_exercise_params)\n\n render json: @workout_exercise\n end",
"def create\n @work_plan = WorkPlan.find(params[:work_plan_id])\n @work_step = WorkStep.new(work_step_params)\n @work_step.work_plan=@work_plan\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /workphases/1 PATCH/PUT /workphases/1.json | def update
respond_to do |format|
if @workphase.update(workphase_params)
format.json { respond_with_bip(@workphase) } #this is added as best_in_place update wasn't holding
format.html { redirect_to @workphase, notice: 'Workphase was successfully updated.' }
#format.json { render :show,... | [
"def update\n respond_to do |format|\n if @work_step.update(work_step_params)\n format.html { redirect_to @work_plan, notice: 'Work step was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_plan }\n else\n format.html { render :edit }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /workphases/1 DELETE /workphases/1.json | def destroy
Workphase.find(params[:id]).destroy
#@workphase.destroy
respond_to do |format|
format.html { redirect_to workphases_url, notice: 'Workphase was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @project_phase = ProjectPhase.find(params[:id])\n @project_phase.destroy\n\n respond_to do |format|\n format.html { redirect_to project_phases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @step = RunStep.find(params[:id])\n @step.destroy\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /people/1/contributions GET .people/1/contributions.json | def index
@contributions = @person.contributions
end | [
"def contributions_made\n render json: @user.contributions\n end",
"def index\n @contributions = Contribution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contributions }\n end\n end",
"def get_contributions(repository)\n Git.contributi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST people/1/contributions POST people/1/contributions.json | def create
@contribution = Contribution.new(contribution_params)
@contribution.contributable_type = "Book"
@contribution.person = @person
respond_to do |format|
if @contribution.save
format.html { redirect_to person_contributions_path(@person), notice: 'Contribution was successfull... | [
"def contributions_made\n render json: @user.contributions\n end",
"def create\n @contribution = current_user.contributions.build(contribution_params)\n respond_to do |format|\n \n if @contribution.save\n format.html { redirect_to contributions_path, notice: '新規投稿が完了しました。' }\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A user cannot leave more than one review per product. | def must_not_be_a_duplicate_review
dup_reviews = Review.where(user: user, product: product)
if new_record?
if dup_reviews.length > 0
errors.add(:product, "already has a review from this user.")
end
elsif dup_reviews.length > 0 && !dup_reviews.include?(self)
errors.add(:product, "al... | [
"def prevent_multiple_reviews\n @review = @current_api_user.reviews.find_by(product: @product)\n if @review.present?\n invalid_resource!(@review)\n end\n end",
"def can_create_review?(product)\n return true if @current_user.nil?\n true if product.reviews.where(:user_id => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return an alignment which match columns. The originating sequences should have methods 'empty_copy' and '<<' | def columns_where &block
seqs = []
rows.each do | seq |
new_seq = seq.empty_copy
seq.each_with_index do | e,i |
new_seq << e if block.call(columns[i])
end
seqs << new_seq
end
Alignment.new(seqs)
end | [
"def alignment; end",
"def alignment\n @__alignment__\n end",
"def inspect_alignment(col_width = 20)\n aligned_left_seq, aligned_top_seq = get_optimal_alignment\n s = []\n aligned_left_seq.each_with_index do |left_el, idx|\n top_el = aligned_top_seq[idx]\n delimiter = if elements_are_equa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST start new game Takes a body with comma separated string of names /new_game | def new_game
params_check(params[:player_names]) {
@game = Game.create
params[:player_names].split(",").each do |player_name|
player = Player.create(name: player_name, game: @game)
10.times do |i|
i == 10 ? Frame.create!(game: @game, player: player, position: i, final... | [
"def create\n game = Game.create(game_params)\n render json: game, status: 201\n end",
"def create\n @team_game = TeamGame.new(params[:team_game])\n\n respond_to do |format|\n if @team_game.save\n format.html { redirect_to @team_game, notice: 'Team game was successfully created.' }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /clubs/1 GET /clubs/1.json | def show
@club = Club.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @club }
end
end | [
"def show\n @club = Club.find(params[:id])\n\n render json: @club\n end",
"def show\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n end",
"def index\n @clubs = Club.all\n render json: @clubs\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /clubs/1 PUT /clubs/1.json | def update
@club = Club.find(params[:id])
respond_to do |format|
if @club.update_attributes(params[:club])
format.html { redirect_to @club, notice: 'Club was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { re... | [
"def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n head :no_content\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def update\n club = Club.find(params[:id])\n if club.update(club_params)\n render json: c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
construct the quote list for querying the stock information | def get_quote_list(portfolio = Array.new)
quote_list = Array.new
portfolio.each do |p|
quote_list << p['stock']
end
return quote_list.join(',')
end | [
"def stock_details_for_list(symbol_list)\n\t\t\tsymbol_list = symbol_list.collect { |symbol| sanitize_symbol(symbol) }\n\n return [] if symbol_list.blank?\n\n\t\t\tfield_mappings = {\n\t\t\t\tname: 'n',\n\t\t\t\tsymbol: 's',\n\t\t\t\task: 'a',\n\t\t\t\task_realtime: 'b2',\n\t\t\t\tbid: 'b',\n\t\t\t\tbid_realti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
calculates profit for the given portfolio | def calculate_portfolio(portfolio = Array.new)
qs = get_quote_info(get_quote_list(portfolio))
portfolio.each do |p|
p['info'] = qs[p['stock']]
value_orderd = p['amount']*p['price']
value_now = p['amount']*p['info'].lastTrade
p['profit_amount'] = value_now - value_orderd
end
return portfolio
end | [
"def profit\n temp_trades = get_temp_trades\n\n result = 0\n temp_trades.each do |trade|\n result -= trade.num_shares * trade.price\n end\n\n truncate_round(result)\n end",
"def portfolio_return\r\n \r\n num_stocks = @stock_names.length # number of assets in portfolio\r\n openval = @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
printing the actual portfolio | def print_portfolio(portfolio = Array.new)
template=<<EOT
STOCK:\tLASTTRADE €
\tAMOUNT @ PRICE € -> PROFIT €
EOT
money = portfolio.reduce(0) do |memo, p|
t = template.dup
t.sub!('STOCK', p['stock'])
t.sub!('LASTTRADE', "#{p['info'].lastTrade}")
t.sub!('AMOUNT', p['amount'].to_s)
t.sub!('PRICE', p['price'].t... | [
"def display\n\t\tif @portfolio.empty?\n\t\t\tputs \"Your portfolio is empty!\"\n\t\telse\t\n\t\t\tputs \"Your portfolio holdings:\"\n\t\t\t@portfolio.each do |stock, amount|\n\t\t \t\tputs \"#{stock.display_name}: #{amount}\"\n\t\t\tend\n\t\tend\t\t\n\tend",
"def display\n puts \"Title: #{@title}\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /seasons/1 PATCH/PUT /seasons/1.json | def update
respond_with @season.update(season_params)
end | [
"def update\n @season = Season.find(params[:id])\n\n respond_to do |format|\n if @season.update_attributes(params[:season])\n format.html { redirect_to @season, notice: 'Season was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /user_logins GET /user_logins.json | def index
@user_logins = UserLogin.all
end | [
"def logins()\n _params = {}\n return @master.call 'users/logins', _params\n end",
"def index\n @logins = Login.all\n\n render json: @logins\n end",
"def index\n @logins = Login.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /sign_ups GET /sign_ups.json | def index
@sign_ups = SignUp.all
end | [
"def index\n @signups = Signup.where(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @signups }\n end\n end",
"def index\n @signups = Signup.all\n end",
"def index\n @user_signups = UserSignup.all\n end",
"def inde... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
so I can have require_remote 'require' a javascript filename over the internet, asynchronously, so you'll have to delay before using. Should be fine if typed by hand but if scripted add delay | def require_js(*urls, &block)
# used to use this, but don't want to depend on opal-jquery
# Element.find("head").append("<script src='#{js_filename}' type='text/javascript'></script>")
promises = []
opts = urls.last.is_a?(Hash) ? urls.pop : {}
clear_promises = lambda do
promises.each do |promise|
... | [
"def script_load(script); end",
"def load_asynchronously(element, url)\n javascript = \"jQuery.get('#{url}', function(data) { jQuery('#{element}').html(data) })\"\n end",
"def javascript_include_async_notification_server\n html = <<HTML\n<script type='text/javascript' id='__notification_server'></scr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches the complete octodex | def completeOctodex
cURL($baseURL)
end | [
"def oct2_hex()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Oct2Hex::Oct2HexRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def get_xml\n @xml ||= Nokogiri::XML(\n open(\"#{PLOS_INFO_URL}?uri=inf... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches a random octocat | def randomOctocat
cURL($baseURL+"?random")
end | [
"def random(response)\n db = init_db\n row = db[\"\n select id, data->'img' as img, data->'title' as title, data->'alt' as alt\n from comics\n order by RANDOM()\n limit 1\"\n ][:data]\n comic = Comic.new(row[:id], row[:img], row[:title], row[:alt])\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches an octocat by its number | def numberedOctocat (number)
cURL($baseURL+"?number=#{number}")
end | [
"def read_octal_char(c)\n r = c.ord - '0'.ord\n if !nextoct?\n return r\n end\n\n r = (r << 3) | (readc.ord - '0'.ord)\n if !nextoct?\n return r\n end\n\n (r << 3) | (readc.ord - '0'.ord)\n end",
"def next_octal\n c = self.next\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /rests POST /rests.json | def create
@rest = Rest.new(rest_params)
@rest.owners << current_owner
respond_to do |format|
if @rest.save
format.html { redirect_to @rest, notice: 'Rest was successfully created.' }
format.json { render :show, status: :created, location: @rest }
else
format.html { rende... | [
"def index\n @rests = Rest.all\n end",
"def add_weather_by_rest(auth,weather_json)\n rest_agent=RestClient::Resource.new(\"http://#{auth[:host]}:#{auth[:port]}/#{auth[:reststr]}/ry/weather\")\n rest_agent.post(weather_json, :content_type=>\"application/json;charset=utf-8\")\n end",
"def create\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /rests/1 PATCH/PUT /rests/1.json | def update
respond_to do |format|
if @rest.update(rest_params)
format.html { redirect_to @rest, notice: 'Rest was successfully updated.' }
format.json { render :show, status: :ok, location: @rest }
else
format.html { render :edit }
format.json { render json: @rest.errors,... | [
"def patch *args\n make_request :patch, *args\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.vali... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /rests/1 DELETE /rests/1.json | def destroy
@rest.destroy
respond_to do |format|
format.html { redirect_to rests_url, notice: 'Rest was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @rest_api.destroy\n respond_to do |format|\n format.html { redirect_to rest_apis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resturant = Resturant.find(params[:id])\n @resturant.destroy\n self.headers.merge!('Content-Type' => 'application/json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set attribute (field) obtained from matching pattern in raw_line | def raw_setter xfield,pattern
field = "@#{xfield}"
m = self.raw_line.match pattern
return false if m.nil?
#p "#{field} => #{m.inspect}"
if BOOL_ATTRIBUTES.include? xfield
self.instance_variable_set(field, true)
return true
end
if STR_ATTRIBUTES.... | [
"def create_from_line(line, id=nil, attr: '')\r\n t = @format_mask.to_s.gsub(/\\[!(\\w+)\\]/, '(.*)').sub(/\\[/,'\\[')\\\r\n .sub(/\\]/,'\\]')\r\n line.match(/#{t}/).captures\r\n \r\n a = line.match(/#{t}/).captures\r\n h = Hash[@fields.z... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if request fully finished reading | def finished_reading?; @finished_read; end | [
"def finished?\n\t\t\t\t@finished && @body.length >= @headers['CONTENT_LENGTH']\n\t\t\tend",
"def finished_reading?; @finished_read; end",
"def complete?\n if received?(REQUEST_SIZE)\n if put?\n if record_count == 1\n true\n else\n received?(REQUEST_SIZE + (RE... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the body, if a block is given, the body is streamed to the block as the chunks become available, until the body has been read. If no block is given, the entire body will be read from the connection into the body buffer and then returned. | def body
raise "no connection given" unless @connection
if block_given?
# Callback from the http_parser will be calling add_body directly
@on_body = Proc.new
# clear out body buffered so far
yield read_from_body(nil) if @body
until finished_reading?
@conn... | [
"def body(&block)\n call_once\n @body ||= begin\n if entity = @response.get_entity\n EntityConverter.new.read_entity(entity, &block)\n end\n rescue Java::JavaIo::IOException, Java::JavaNet::SocketException, IOError => e\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the own video service id | def id
case self.service
when :youtube then parse_video_id_for_youtube
when :vimeo then parse_video_id_for_vimeo
end
end | [
"def video_id_public\n if video\n video.id_public\n end\n end",
"def video_id\n values[:video_id]\n end",
"def unique_id\n video_id[/videos\\/([^<]+)/, 1]\n end",
"def set_video_id\n send(\"#{provider}_video_id\")\n end",
"def video_teleconference_id\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the URL for this video embedded === Parameters options Configuration for the embedded URL. === Options :autoplay Autoplay on or off (default on) | def embedded(options={})
autoplay = options[:autoplay].nil? ? true : options[:autoplay]
autoplay = !!autoplay ? '1' : '0'
embeded_template = case self.service
when :youtube then YOUTUBE_EMBEDDED_TEMPLATE
when :vimeo then VIMEO_EMBEDDED_TEMPLATE
... | [
"def embeddable_url\n return 'https://www.youtube.com/embed/' + video_id if source == 'youtube'\n return 'https://player.vimeo.com/video/' + video_id if source == 'vimeo'\n end",
"def oembed_url\n \"https://www.youtube.com/oembed?format=json&url=#{source_url}\"\n end",
"def source_url\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set video_id for a given regexp and index of match result | def parse_video_id_for_regexp_and_index(regexp, index)
match_result = self.url.match(regexp)
return match_result[index] if !!match_result
end | [
"def parse_video_id_for_vimeo\n parse_video_id_for_regexp_and_index(VIMEO_REGEXP, 4)\n end",
"def parse_video_id_for_youtube\n parse_video_id_for_regexp_and_index(YOUTUBE_REGEXP, 6)\n end",
"def set_url_video_id\r\n # Get the URL and put in this variable that will be filtered\r\n # down to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse the youtube video_id and set it in self | def parse_video_id_for_youtube
parse_video_id_for_regexp_and_index(YOUTUBE_REGEXP, 6)
end | [
"def youtube_video_id\n video_id = link.match(/\\?v=/) ? link.split('?v=')[1] : link.split('/').last\n video_id = video_id.split('&')[0] if video_id =~ /&/\n self.vid = video_id\n end",
"def youtube_video_id\t\t\n\t\tif self.video_url.nil?\n\t\t\tnil\n\t\telse\n\t\t\tself.video_url.rpartit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse the vimeo video_id and set it in self | def parse_video_id_for_vimeo
parse_video_id_for_regexp_and_index(VIMEO_REGEXP, 4)
end | [
"def vimeo_video_id\n self.vid = link.split('/').last\n end",
"def youtube_video_id\n video_id = link.match(/\\?v=/) ? link.split('?v=')[1] : link.split('/').last\n video_id = video_id.split('&')[0] if video_id =~ /&/\n self.vid = video_id\n end",
"def setVideoId(video_id)\n\t\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns number of gems | def gems_count
@gems_count ||= gems.count
end | [
"def gems_used\n tree = repository.repo.lookup(revision).tree\n gemfile = tree.select{|blob| blob[:name] == 'Gemfile'}.first\n return 0 if !gemfile\n blob = gemfile[:oid]\n\n content = Rugged::Blob.lookup(repository.repo,blob).content\n Ripper.sexp(content).flatten.count('gem')\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches data for each gem | def fetch_gems_data
puts "Fetching data for..."
# slice 100 to avoid too many requests on RubyGems and GitHub APIs
gems.each_slice(100) do |batch|
each_concurrently(batch) do |gem|
begin
retries ||= 0
# set verbose to true to stdout the gem name
... | [
"def gems\n # TODO: need to get more questions - Apply paginates\n parse_gems\n end",
"def gems_dataset\n lid = request.cookies['lid']\n if(lid)\n AllGems.db[:versions].join(:gems, :id => :gem_id).join(:gems_lids, :version_id => :versions__id).join(:lids, :id => :gems_l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Starts a thread to process the given gem | def gem_thread(gem)
Thread.new do
begin
retries ||= 0
# set verbose to true to stdout the gem name
gem.prepare_data(verbose: true)
# rescue SocketError, Faraday::ConnectionFailed...
rescue StandardError
(retries += 1) <= RETRIES ? ret... | [
"def cookbook_gem_start(gems); end",
"def start\n @thread = Thread.new {\n run\n }\n puts \"==== spawn_start\"\n @process = @executor.execute();\n end",
"def run_gemstash\n await_port_status(false) # don't start until any old servers are dead\n\n STDERR.puts \"Clearing gemstash d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove the resource from given parent | def remove_from_parent
@change_set = ChangeSet.for(resource)
parent_resource = find_resource(parent_resource_params[:id])
authorize! :update, parent_resource
parent_change_set = ChangeSet.for(parent_resource)
current_member_ids = parent_resource.member_ids
parent_change_set.member_ids = current... | [
"def removeFromParent\n @parent.remove(self) if @parent\n end",
"def unlink\n @parent.unlink(self)\n end",
"def remove_from_parent!\n @parent.remove!(self) unless root?\n end",
"def remove_item\n @parent.remove_item(self)\n end",
"def remove_from_parent!\n @parent.remove!(self) ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The activesupport to_query extension doesn't escape the = character as it's meant for a primary query string | def to_query(params)
params.to_query.gsub("=", "%3D").gsub("&", "%26")
end | [
"def stringToQuery (val)\n\t\t\n\tend",
"def to_query\n \"#{self.name}=#{CGI.escape(self.value.to_s)}\"\n end",
"def to_query(key)\n \"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}\"\n end",
"def format_hash_as_query_string(query_params)\n # replace Ruby => assignment operators w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method for sending mail notifying signatures are complete | def send_signature_complete_mail(document)
DocumentMailer.with(email: document.user.email,
document: document).signing_complete.deliver_later
DocumentEvent.create!(document: document, message: "Varsel om ferdig signering sendt til #{document.user.email} ")
end | [
"def email_complete; end",
"def fir_complete_notification (design, release_review_id, reviewer, current_user)\n\n to_list = [reviewer.email]\n cc_list = [current_user.email]\n subject = 'FIR Completed - ' + MailerMethods.subject_prefix(design)\n\n @pcb_display = design.pcb_display\n @release_rev... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method for making a viable ActiveStorage blob from attachment | def attachment
mail.attachments.map do |attachment|
blob = ActiveStorage::Blob.create_after_upload!(
io: StringIO.new(attachment.decoded),
filename: attachment.filename,
content_type: attachment.content_type
)
return blob
end
end | [
"def blob\n active_storage_blob\n end",
"def uploaded_blob(name, serialized_json)\n gzipped = gzip(serialized_json)\n s3_client = ActiveStorage::Blob.service.client\n bucket = ActiveStorage::Blob.service.bucket\n blob = ActiveStorage::Blob.new\n io = StringIO.new(gzipped)\n blob.filename = n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve email_token from mail | def email_token
recipient = mail.recipients.find { |r| MATCHER.match?(r) }
recipient[MATCHER, 1]
end | [
"def extract_token_from_email(token_name)\n mail_body = last_email.body.to_s\n mail_body[/#{token_name.to_s}_token=([^\"]+)/, 1]\n end",
"def extract_token_from_email(token_name)\n mail_body = last_email.body.to_s\n mail_body[/#{token_name.to_s}_token=([^\"]+)/, 1]\n end",
"def get_token_fro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new SlimcdGateway The gateway requires that valid credentials be passed in the +options+ hash. ==== Options :client_id Assigned by the Slim CD administrator. (REQUIRED) :site_id Assigned by the Slim CD administrator. (REQUIRED) :price_id Assigned by the Slim CD administrator. (REQUIRED) :password Plaintext pa... | def initialize(options = {})
requires!(options, :client_id, :site_id, :price_id, :password, :key)
@options = options
super
end | [
"def new_client(options = { })\n c = DirectClient.new(OPTIONS.merge(options))\n if block_given?\n yield(c)\n else\n c\n end\n end",
"def client\n return @client if instance_variable_defined?(:@client) && @client.hash == options.hash\n @client = DeskApi::Client.new(options)\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Credit an account. This transaction is also referred to as a Refund and indicates to the gateway that money should flow from the merchant to the customer. ==== Parameters money The amount to be credited to the customer. Either an Integer value in cents or a Money object. identification The ID of the original transactio... | def credit(money, identification, options = {})
post = { :gateid => identification }
commit('CREDIT', money, post)
end | [
"def credit(money, identification, options = {})\n requires!(options, :card_number)\n\n post = { :ref_trans_id => identification,\n :card_num => options[:card_number]\n }\n add_invoice(post, options)\n\n commit('CREDIT', money, post)\n end",
"def cred... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return pointer for use with pack('L') | def str_to_ptr(v)
[v].pack('p*').unpack('L')[0]
end | [
"def pack(p0) end",
"def unpack_pointer(packed_pointer)\n if is_64bit\n # Assume little endian\n packed_pointer.unpack('Q<')[0]\n else\n packed_pointer.unpack('V')[0]\n end\n end",
"def byte_pointer; end",
"def long_to_pointer(long)\n long < 0 ? long + (2 ** LPARAM_BITS) : long... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delivers integer of sum number of equipments owned by character instance | def total_items
items = Inventory.where(character_id: self.id)
items.size
end | [
"def attack\n atk = 0\n count = 0\n ship_items.each do | itm |\n if itm.equiped\n if (itm.item.attack_w > 0)\n atk += itm.item.attack_w\n count+=1\n end\n end\n end\n mods = get_crew_mods\n atk += mods[:attack]*count\n if count == 0\n count = 1\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /bestgames/1 GET /bestgames/1.json | def show
@bestgame = Bestgame.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @bestgame }
end
end | [
"def index\n @games = Game.available\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n @games = Game.all\n render json: @games, status: 200\n end",
"def index\n @games = Game.all\n render json: @games\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /bestgames POST /bestgames.json | def create
@bestgame = Bestgame.new(params[:bestgame])
respond_to do |format|
if @bestgame.save
format.html { redirect_to @bestgame, notice: 'Bestgame was successfully created.' }
format.json { render json: @bestgame, status: :created, location: @bestgame }
else
format.html ... | [
"def create\n game = Game.create(game_params)\n render json: game, status: 201\n end",
"def create\n g = SpreadapediaGames.new(params[:spreadapedia_games])\n g.line_result(params[:spreadapedia_games][:lresult])\n g.overunder_result(params[:spreadapedia_games][:ouresult])\n g.save()\n\n respo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /bestgames/1 PUT /bestgames/1.json | def update
@bestgame = Bestgame.find(params[:id])
respond_to do |format|
if @bestgame.update_attributes(params[:bestgame])
format.html { redirect_to @bestgame, notice: 'Bestgame was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "... | [
"def update\n @game.update(game_params)\n render json: @game, status: 200\n end",
"def update\n @game.update!(game_params) # anticipated possible exceptions rescued in BaseController\n render json: @game, status: 200\n end",
"def update\n @spreadapedia_game = SpreadapediaGames.find(par... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /bestgames/1 DELETE /bestgames/1.json | def destroy
@bestgame = Bestgame.find(params[:id])
@bestgame.destroy
respond_to do |format|
format.html { redirect_to bestgames_url }
format.json { head :no_content }
end
end | [
"def destroy\n @bettergame = Bettergame.find(params[:id])\n @bettergame.destroy\n\n respond_to do |format|\n format.html { redirect_to bettergames_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game.destroy\n respond_to do |format|\n format.json { head :no... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an Array containing the segments of a constant path. | def constant_segments(node)
segments = []
if node.children[0]
segments.concat(constant_segments(node.children[0]))
end
segments << node.children[1].to_s
return segments
end | [
"def segments_from_path(path)\n # Remove leading ^ and trailing $ from each segment (left-overs from regexp joining)\n strip = proc { |str| str.gsub(/^\\^/, '').gsub(/\\$$/, '') }\n segments = []\n while match = (path.match(SEGMENT_REGEXP))\n segments << strip[match.pre_match] u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Don't do fill setup | def fill_setup(_gc)
end | [
"def fill_setup(gc)\n end",
"def setup\n setup! unless setup?\n end",
"def setup\n setup! unless setup?\n end",
"def before_setup\n # do nothing by default\n end",
"def fill\n \t@fill\n end",
"def setup\n end",
"def fills; end",
"def setup\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /hacks/1 GET /hacks/1.json | def show
@hack = Hack.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @hack }
end
end | [
"def show\n @hack = Hack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hack }\n end\n end",
"def show\n @hacker = Hacker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /hacks/new GET /hacks/new.json | def new
@hack = Hack.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @hack }
end
end | [
"def new\n @hack = Hack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hack }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hacker }\n end\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /hacks/1 PUT /hacks/1.json | def update
@hack = Hack.find(params[:id])
respond_to do |format|
if @hack.update_attributes(params[:hack])
format.html { redirect_to @hack, :notice => 'Hack was successfully updated.' }
format.json { head :ok }
else
format.html { render :action => "edit" }
format.jso... | [
"def update\n @hack = Hack.find(params[:id])\n\n respond_to do |format|\n if @hack.update_attributes(params[:hack])\n format.html { redirect_to @hack, notice: 'Hack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /hacks/1 DELETE /hacks/1.json | def destroy
@hack = Hack.find(params[:id])
@hack.destroy
respond_to do |format|
format.html { redirect_to hacks_url }
format.json { head :ok }
end
end | [
"def destroy\n @hack = Hack.find(params[:id])\n @hack.destroy\n\n respond_to do |format|\n format.html { redirect_to hacks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hack = Hack.find(params[:id])\n @hack.destroy\n\n respond_to do |format|\n format.h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Show news content + 2 GT links "next" and "previous" | def show
@news = News.find(params[:id])
@next = News.where("publication_date <= ? AND id != ?", @news.publication_date, @news.id).order("publication_date DESC").first;
@previous = News.where("publication_date >= ? AND id != ?", @news.publication_date, @news.id).order("publication_date DESC").last;
end | [
"def page_links_next\n @page_links_next ||= \"Next >\"\n end",
"def next_and_previous_links_listitems(work, chapter)\n links = next_and_previous_links(work, chapter)\n links.collect {|link| \"<li>\" + link + \"</li>\\n\"}\n end",
"def top_news_sources\n\n end",
"def next_and_previou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to set a translation engine +translator+ Instance of translation engine. Refer to `engines/aws` for example ==== Raises `InvalidInputException` when the argument `translator` is not an instance of Translator class | def set_translator(translator)
if translator && !(translator.is_a? Translator)
raise InvalidInputException.new("Argument is not an instance of Translator")
end
end | [
"def translator=(translator)\n @@translator = translator\n end",
"def translator\n @translator ||= Translator.new\n end",
"def translator\n @@translator ||= Translator.new\n end",
"def configure(&block)\n unless provider\n raise 'Translation provider not selected ye... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to translate the caption from one language to another +src_lang+ can be inferred using infer_language method +target_lang+ Target 2 letter ISO language code to which the source needs to be translated in to. +output_file+ Output file. Can be a fully qualified path or just file name ==== Raises InvalidInputExcepti... | def translate(src_lang, target_lang, output_file)
# Check if a non empty output file is present and error out to avoid
# the danger or overwriting some important file !!
if File.exists?(output_file) && File.size(output_file) > 0
raise InvalidInputException.new("Output file #{output_file} is not empty.... | [
"def translate(input_text, src_lang, target_lang)\n response = @translate_service.translate_text({ :text => \"#{input_text}\" , \n :source_language_code => \"#{src_lang}\", :target_language_code => \"#{target_lang}\"})\n response.translated_text\n end",
"def translate(input_text, src_lang, target_lang... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to convert from one caption type to other types. If the src_lang is not provided then all source languages will be converted to target types. For example, if a ttml file has "en" and "es" and target_type is vtt and no src_lang is provided 2 vtt files would be created one per language in the source. if a target_l... | def transform_to(types, src_lang, target_lang, output_dir)
if (types - supported_transformations).size != 0
raise InvalidInputException.new("Unknown types provided for conversion in input #{types}")
end
unless File.directory?(output_dir)
FileUtils.mkdir_p(output_dir)
end
# Basic validati... | [
"def translate(src_lang, target_lang, output_file)\n # Check if a non empty output file is present and error out to avoid\n # the danger or overwriting some important file !!\n if File.exists?(output_file) && File.size(output_file) > 0\n raise InvalidInputException.new(\"Output file #{output_file} is ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to report on the supported transformations. Each implementor is free to return the types to which it can convert itself to ==== Returns An array of one or more types defined as +TYPE_+ constants here | def supported_transformations
raise "Not Implemented. Class #{self.class.name} doesn't implement supported_transformations"
end | [
"def transformers\n []\n end",
"def transformations\n @transformations ||= []\n end",
"def transformations\n @transformations ||= []\n end",
"def compose_transformers(transformers, types); end",
"def transform_content_type\n\t\tself.log.debug \"Applying content-type trans... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /pashiris GET /pashiris.json | def index
@pashiris = Pashiri.all
end | [
"def index\n @pals = Pal.all\n\n render json: @pals\n end",
"def index\n @pizzas = Pizza.all\n render json: @pizzas\n end",
"def show\n @plushki = Plushki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plushki }\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /pashiris POST /pashiris.json | def create
@pashiri = Pashiri.new(pashiri_params)
respond_to do |format|
if @pashiri.save
format.html { redirect_to @pashiri, notice: 'Pashiri was successfully created.' }
format.json { render :show, status: :created, location: @pashiri }
else
format.html { render :new }
... | [
"def create\n @plushki = Plushki.new(params[:plushki])\n\n respond_to do |format|\n if @plushki.save\n format.html { redirect_to plushkis_path, notice: 'Plushki was successfully created.' }\n format.json { render json: @plushki, status: :created, location: @plushki }\n else\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
+list_ids+ array +paras+ must contain: :is_double_opt_in => 0 or 1 :contacts => array of hashes, required elements: :contact_email => string | def add_list_contacts(list_ids, params = {})
contact_params = params[:contacts].each_with_object({}).with_index do |(value, hash), index|
hash[index.to_s.to_sym] = value
end
request = @request.post(self_path, {
list_ids: list_ids.join(','),
contact: contact_params,
**pa... | [
"def list_contacts(*args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n list_id = args.first\n raise \"No list_id given!\" if list_id.nil?\n\n response = get ENDPOINT, options.merge(list_id: list_id)\n response.body\n end",
"def ffcrm_list_ids\n confi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Eager load the inclusions for the provided documents. | def eager_load(docs)
criteria.inclusions.reject! do |metadata|
metadata.eager_load(eager_loaded_ids(docs, metadata)) if !docs.empty?
end
self.eager_loaded = true
end | [
"def load_inclusions(docs)\n criteria.inclusions.each do |metadata|\n metadata.eager_load(eager_loaded_ids(docs, metadata)) if !docs.empty?\n end\n end",
"def eager_load(docs)\n criteria.inclusions.reject! do |metadata|\n unless docs.empty?\n parent_ids = doc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the ids that to be used to eager load documents. | def eager_loaded_ids(docs, metadata)
if metadata.stores_foreign_key?
docs.flat_map{ |doc| doc.send(metadata.foreign_key) }
else
docs.map(&:id)
end
end | [
"def collection_ids\n @ids ||= collection.map {|e| e[\"id\"] }\n end",
"def ids\n map { |x| x.id }\n end",
"def ids\n @ids ||= []\n end",
"def ids\n pluck primary_key\n end",
"def ids_reader\n if loaded?\n load_target.reject(&:marked_for_destruction?).map(&:id)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is this context able to be eager loaded? | def eager_loadable?
!eager_loaded && !criteria.inclusions.empty?
end | [
"def eager_loading?\n @should_eager_load ||=\n eager_load_values.any? ||\n includes_values.any? && (joined_includes_values.any? || references_eager_loaded_tables?)\n end",
"def eager_load; end",
"def eager?\n content.type == :eager\n end",
"def uses_eager_load?\n return ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If the provided document exists, eager load its dependencies or return nil. | def with_eager_loading(document)
selecting do
return nil unless document
doc = Factory.from_db(klass, document, criteria.object_id)
eager_load([ doc ]) if eager_loadable?
doc
end
end | [
"def with_eager_loading(document)\n selecting do\n return nil unless document\n doc = Factory.from_db(klass, document, criteria.object_id)\n eager_load_one(doc) if eager_loadable?(doc)\n doc\n end\n end",
"def eager_load(docs)\n criteria.inclusions.rej... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete all the result data for this competition. Note: only works for Time Results and External Results.... (Judged events do not work). | def destroy_all_results
authorize @competition
results = @competition.scoring_helper.all_competitor_results
if results.present?
Competition.transaction do
results.each(&:destroy)
end
flash[:notice] = "Deleted all data for this competition"
else
flash[:alert] = "No result... | [
"def destroy\n @external_result.destroy\n\n respond_to do |format|\n format.html { redirect_to competition_external_results_path(@competition) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_result.destroy\n\n respond_to do |format|\n format.html { redirect_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Link to the current user's page (using link_to_user) or to the login page (using link_to_login_with_IP). | def link_to_current_user(options={})
if logged_in?
link_to_user current_user, options
else
content_text = options.delete(:content_text) || 'not signed in'
# kill ignored options from link_to_user
[:content_method, :title_method].each{|opt| options.delete(opt)}
link_to_login_with_I... | [
"def link_to_current_user(options={})\n if current_user\n link_to_user current_user, options\n else\n content_text = options.delete(:content_text) || I18n.t(\"not signed in\", :default => \"not signed in\")\n # kill ignored options from link_to_user\n [:content_method, :title_method].each{... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the top / header line of a function definition file, and get function name and swapped form | def getTopLine(text)
functionName = text.match(/(?<=function )([^\(]+)/)[0]
swapped = "#{functionName}: #{text.gsub(/(?<=function) [^\(]+/, '')}"
return({:name => functionName, :swap => swapped})
end | [
"def funcHeader\n svlines = readData\n line = svlines.join(\" \")\n if line =~ /^\\s+def\\s+(\\S+.*)$/\n func = $1.sub(/ +#.*$/, '')\n if line =~ /\\(([^\\)]+)\\)/\n args, parms = $1, ''\n args.split(/\\s*,\\s*/).each do |aparm|\n parms << \"* %10s: \\n\" % [aparm.sub(/\\s*... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Must be: (a) an expanding parameter, and (b) a singleton already (i.e. doesn't respond to :each) | def expandable_singleton?(p, arg)
self.class.expanding_parameters.include?(p) && !arg.respond_to?(:each)
end | [
"def expanded_args; end",
"def expand\n end",
"def double_collections_by_parameter_name; end",
"def expand(*args)\n self.new(*args).expand\n end",
"def splat=(_); end",
"def __splat(x) end",
"def auto_inject=(_arg0); end",
"def AssocSplat(value); end",
"def deep_each\n \n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For each parameter/attribute foo we try to invoke a validate_foo | def validate
self.class.parameters.each do |param, default|
method = "validate_#{param}"
if self.respond_to? method
attribute = "@#{param}"
val = instance_variable_get(attribute)
if val.respond_to? :each
new_val = val.map.with_index{ |v, i| send(method, v, i) }
... | [
"def validate_params\n validate_size\n validate_mine_density\n validate_first_click\n type_specific_checks\n end",
"def validate_command_attrs\n self.class.validation_logics.each do |attr, logics|\n val = self.instance_variable_get(\"@#{attr}\".to_sym)\n logics.each do |l|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the deck's configuration | def deck_conf
@deck.conf
end | [
"def get_deck\n return @deck\n end",
"def config\n @config_data\n end",
"def configuration\n rateable.configuration\n end",
"def configuration\n provider.configuration\n end",
"def get_config(reference)\n game_state.manager(:resource).get_config(reference)\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
NOTE : I think this api is very badly designed. 1. parameter : giving 'id' parameter will filter by chat id. so instead of 'id' it should use 'chat_id' to make it more clear 2. response : I would probably return list and does group_by on the client side, or I would create another end point that returns grouped_by resul... | def index
list = current_user.chats.pluck :id
options = filter_params
options[:id] = filter_params[:id] == 'all' ? list : [filter_params[:id]]
@messages = ChatMessage.filter options
@messages = @messages.group_by(&:chat_id)
end | [
"def get_chat_messages\n # get chat messages\n chats = Message.includes(:user).where(receiver_id: @current_user.id, user_id: params[:user_id], request_id: params[:request_id]).or(Message.includes(:user).where(user_id: @current_user.id, receiver_id: params[:user_id], request_id: params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merge `s` and `t` the brute force way (nonrecursive, no edgemerge) | def merge_states(glts, s, t)
data = STATE_AGGREGATOR.merge(s.data, t.data)
# reconnect `t`'s edges to s
t.in_edges.each do |in_edge|
source = (in_edge.source == t ? s : in_edge.source)
glts.connect(source, s, in_edge.data)
end
t.out_edges.each do |out_edge|
... | [
"def growEqualityGraph(s_vertices, t_vertices, s_neighbors, s_neighbors_not_in_t) #weights, s_vertices, t_vertices, s_neighbors_not_in_t, s_neighbors)\n\t\t\n\t\t#update labels\n\t\t\n\t\t\n\t\tlabelUpdateVal = nil\n\t\t\n\t\t#We want to grow T in order to up the chance we can have a match\n\t\t\n\t\tunconnected_y_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /guest_books GET /guest_books.xml | def index
@guest_books = GuestBook.find(:all, :order=>'created_at desc')
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @guest_books }
end
end | [
"def show\n @guest_book = GuestBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @guest_book }\n end\n end",
"def index\n @books = Book.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /guest_books/1 GET /guest_books/1.xml | def show
@guest_book = GuestBook.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @guest_book }
end
end | [
"def index\n @guest_books = GuestBook.find(:all, :order=>'created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @guest_books }\n end\n end",
"def show\n @book = Book.get!(params[:id])\n\n respond_to do |format|\n format.html # sho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /guest_books/new GET /guest_books/new.xml | def new
@guest_book = GuestBook.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @guest_book }
end
end | [
"def new\n @guestbook = Guestbook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @guestbook }\n end\n end",
"def new\n @book = Book.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /guest_books POST /guest_books.xml | def create
@guest_book = GuestBook.new(params[:guest_book])
respond_to do |format|
if @guest_book.save
flash[:notice] = 'Thank you for signing the guestbook'
# format.html { redirect_to(@guest_book) }
format.html { render :action => "created" }
format.xml { render :xml =>... | [
"def create\n @guest_book = GuestBook.new(name: guest_book_params[:name], comment: guest_book_params[:comment])\n\n respond_to do |format|\n if @guest_book.save\n format.html { redirect_to @guest_book, notice: t(\"guest_books.create.notice\") }\n format.json { render json: @guest_book, stat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /guest_books/1 PUT /guest_books/1.xml | def update
@guest_book = GuestBook.find(params[:id])
respond_to do |format|
if @guest_book.update_attributes(params[:guest_book])
flash[:notice] = 'GuestBook was successfully updated.'
format.html { redirect_to(@guest_book) }
format.xml { head :ok }
else
format.html... | [
"def update\n @guestbook = Guestbook.find(params[:id])\n\n respond_to do |format|\n if @guestbook.update_attributes(params[:guestbook])\n flash[:notice] = 'Guestbook was successfully updated.'\n format.html { redirect_to(@guestbook) }\n format.xml { head :ok }\n else\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /guest_books/1 DELETE /guest_books/1.xml | def destroy
@guest_book = GuestBook.find(params[:id])
@guest_book.destroy
respond_to do |format|
format.html { redirect_to(guest_books_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @guestbook = Guestbook.find(params[:id])\n @guestbook.destroy\n\n respond_to do |format|\n format.html { redirect_to(guestbooks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n #expire_page :controller => 'guestbook', :action => 'index'\n @guestbook = Gues... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.