query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
POST /code_factors POST /code_factors.xml | def create
@code_factor = CodeFactor.new(params[:code_factor])
respond_to do |format|
if @code_factor.save
format.html { redirect_to(@code_factor, :notice => 'CodeFactor was successfully created.') }
format.xml { render :xml => @code_factor, :status => :created, :location => @code_factor ... | [
"def create\n params.permit!\n @power_factor = Power::Factor.new(params[:power_factor])\n\n respond_to do |format|\n if @power_factor.save\n format.html { redirect_to(@power_factor, :notice => 'Factor was successfully created.') }\n format.xml { render :xml => @power_factor, :status => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /code_factors/1 PUT /code_factors/1.xml | def update
@code_factor = CodeFactor.find(params[:id])
respond_to do |format|
if @code_factor.update_attributes(params[:code_factor])
format.html { redirect_to(@code_factor, :notice => 'CodeFactor was successfully updated.') }
format.xml { head :ok }
format.json { head :ok }
... | [
"def update\n @what_factor = WhatFactor.find(params[:id])\n\n respond_to do |format|\n if @what_factor.update_attributes(params[:what_factor])\n format.html { redirect_to(@what_factor, :notice => 'WhatFactor was successfully updated.') }\n format.xml { head :ok }\n else\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /code_factors/1 DELETE /code_factors/1.xml | def destroy
@code_factor = CodeFactor.find(params[:id])
@code_factor.destroy
respond_to do |format|
format.html { redirect_to(code_factors_url) }
format.xml { head :ok }
format.json { head :ok }
end
end | [
"def destroy\n @risk_factor = RiskFactor.find(params[:id])\n @risk_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to(risk_factors_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @primary_expr = PrimaryExpr.find(params[:id])\n @primary_expr.destroy\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /star/facts/1 GET /star/facts/1.json | def show
@star_fact = Star::Fact.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @star_fact }
end
end | [
"def cat_fact\n document_received = JSON.load(open(FACT_URL))\n fact = document_received[\"facts\"][0]\n STDOUT.puts fact\n end",
"def new\n @star_fact = Star::Fact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @star_fact }\n end\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /star/facts/new GET /star/facts/new.json | def new
@star_fact = Star::Fact.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @star_fact }
end
end | [
"def new\n @fact = Fact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fact }\n end\n end",
"def new\n @fact = fact_type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fact }\n end\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /star/facts POST /star/facts.json | def create
@star_fact = Star::Fact.new(params[:star_fact])
respond_to do |format|
if @star_fact.save
format.html { redirect_to @star_fact, notice: 'Fact was successfully created.' }
format.json { render json: @star_fact, status: :created, location: @star_fact }
else
format.h... | [
"def create\n @fact = @cat.facts.create!({ fact: api_request })\n if @fact.save\n render json: @fact\n else\n render error: { message: \"Não foi possível criar esse fato para este gatinho! :(\" }, status: 400\n end\n end",
"def create\n results = food_params.to_h\n results[\"tags\"] =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /star/facts/1 PUT /star/facts/1.json | def update
@star_fact = Star::Fact.find(params[:id])
respond_to do |format|
if @star_fact.update_attributes(params[:star_fact])
format.html { redirect_to @star_fact, notice: 'Fact was successfully updated.' }
format.json { head :no_content }
else
format.html { render action:... | [
"def update\n json_update(factType,factType_params, FactType)\n end",
"def update\n @fact = Fact.find(params[:id])\n\n respond_to do |format|\n if @fact.update_attributes(params[:fact])\n format.html { redirect_to @fact, notice: 'Fact was successfully updated.' }\n format.json { head ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /star/facts/1 DELETE /star/facts/1.json | def destroy
@star_fact = Star::Fact.find(params[:id])
@star_fact.destroy
respond_to do |format|
format.html { redirect_to star_facts_url }
format.json { head :no_content }
end
end | [
"def destroy\n @fact = Fact.find(params[:id])\n @fact.destroy\n\n respond_to do |format|\n format.html { redirect_to facts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fact.destroy\n respond_to do |format|\n format.html { redirect_to facts_url }\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List my bought orders | def bought_orders
@orders = current_user.bought_orders
end | [
"def buys\n orders[:buys]\n end",
"def list_orders()\n get_request('listOrders?'+get_url_parameters({})).body\n end",
"def list_orders\n Order.list(@current_user)\n end",
"def get_orders\n orders\n end",
"def list_orders(basket)\n basket.inject([]) do |orders, (id, quantity)|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /task_managers GET /task_managers.json | def index
@task_managers = TaskManager.all
end | [
"def managers\n response = request(:get, \"/manager\")\n response_to_array(response, \"managers\", KontaktIo::Resource::Manager)\n end",
"def managers(params = {})\n response = get('/api/manager', params)\n\n response.map do |manager|\n Finfolio::API::Manager.new(manager)\n end\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /task_managers POST /task_managers.json | def create
@task_manager = TaskManager.new(task_manager_params)
respond_to do |format|
if @task_manager.save
format.html { redirect_to @task_manager, notice: 'Task manager was successfully created.' }
format.json { render :show, status: :created, location: @task_manager }
else
... | [
"def create\n @todo_manager = TodoManager.new(todo_manager_params)\n\n respond_to do |format|\n if @todo_manager.save\n format.html { redirect_to @todo_manager, notice: 'Todo manager was successfully created.' }\n format.json { render :show, status: :created, location: @todo_manager }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /task_managers/1 PATCH/PUT /task_managers/1.json | def update
respond_to do |format|
if @task_manager.update(task_manager_params)
format.html { redirect_to @task_manager, notice: 'Task manager was successfully updated.' }
format.json { render :show, status: :ok, location: @task_manager }
else
format.html { render :edit }
... | [
"def update\n respond_to do |format|\n if @todo_manager.update(todo_manager_params)\n format.html { redirect_to @todo_manager, notice: 'Todo manager was successfully updated.' }\n format.json { render :show, status: :ok, location: @todo_manager }\n else\n format.html { render :edit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /task_managers/1 DELETE /task_managers/1.json | def destroy
@task_manager.destroy
respond_to do |format|
format.html { redirect_to task_managers_url, notice: 'Task manager was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @personal_task = PersonalTask.find(params[:id])\n @personal_task.destroy\n\n respond_to do |format|\n format.html { redirect_to personal_tasks_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @todo_manager.destroy\n respond_to do |format|\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Signals the worker threads to terminate. If :how is set to :graceful, then the worker threads will terminate after processing any currently running executions. If :how is set to :now, then kill will be sent to each thread and we block until each thread is no longer alive?. | def shutdown(how = :graceful)
case how
when :graceful
@queue.shutdown
threads.each{ |thread| thread.join }
when :now
threads.each do |thread|
thread.kill
Thread.pass while thread.alive?
end
end
true
end | [
"def kill\n\n threads.each { |t| t.raise(KillSignal) }\n end",
"def kill_threads\n @workers.each &:kill\n @workers = []\n end",
"def kill_threads\n threads.each{|thread| thread.terminate}\n self.threads = []\n end",
"def terminate\n Sleeper.sleepers.delete(self)\n thread.te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of Ruby threads in the pool. | def threads
@workers.collect{ |worker| worker.thread }
end | [
"def threads\n @pool\n end",
"def thread_pool\n @thread_pool ||= []\n end",
"def threads\n @threads ||= []\n end",
"def threads\n list = []\n @processes.each do |p|\n p.threads.each do |t|\n list.push(t)\n end\n end\n\n list\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determine which converter to use based on this convertible's extension. Returns the Converter instance. | def converter
@converter ||= self.site.converters.find { |c| c.matches(self.ext) }
end | [
"def converter(renderer)\n result = nil\n renderer_config = read_config[renderer.to_s]\n result = render_type(renderer_config) if renderer_config\n result ||= DefaultConverter.new(nil)\n result\n end",
"def find_converter transform\n @converters.each do |candidate|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Transform the content using Tilt ext The file extension, used to find the right templating engine. content The content of the template. params A hash of values to use for the context. Returns transformed content. | def render_tilt_in_context(ext, content, params={})
context = ClosedStruct.new(params)
context.extend(TiltHelpers)
Tilt[ext].new{content}.render(context) if Tilt[ext]
end | [
"def process_template(content)\n ERB.new(content, 0, \"%<>\").result(binding)\n end",
"def transform\n case self.content_type\n when 'textile'\n self.ext = \".html\"\n self.content = self.site.textile(self.content)\n when 'markdown'\n self.ext = \".html\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /concessionaries GET /concessionaries.json | def index
@concessionaries = Concessionary.all.order(:name).paginate(page: params[:page], per_page:20)
end | [
"def index\n @comentaries = Comentary.all\n end",
"def index\n @existences = Existence.all\n\n render json: @existences\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def index\n @conductors = Conductor.all\n render :json => @conductors\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /concessionaries POST /concessionaries.json | def create
@concessionary = Concessionary.new(concessionary_params)
respond_to do |format|
if @concessionary.save
format.html { redirect_to @concessionary, notice: 'Concessionario creado satisfactoriamente.' }
format.json { render :show, status: :created, location: @concessionary }
... | [
"def create\n @canary = Canary.new(canary_params)\n @canary.created_by = current_user\n @canary.uuid = SecureRandom.uuid\n\n respond_to do |format|\n if @canary.save\n format.html { redirect_to @canary, notice: 'Canary was successfully created.' }\n format.json { render :show, status:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /concessionaries/1 DELETE /concessionaries/1.json | def destroy
@concessionary.destroy
respond_to do |format|
format.html { redirect_to concessionaries_url, notice: 'Concessionario fue borrado.' }
format.json { head :no_content }
end
end | [
"def destroy\n @concession = Concession.find(params[:id])\n @concession.destroy\n\n respond_to do |format|\n format.html { redirect_to concessions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @condominios = Condominio.find(params[:id])\n @condominios.destroy\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /passenger_details GET /passenger_details.json | def index
@passenger_details = PassengerDetail.all
end | [
"def show\n @passenger_record = PassengerRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @passenger_record }\n end\n end",
"def index\n @passengers = Passenger.all\n\n respond_to do |format|\n format.html\n format.j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /passenger_details POST /passenger_details.json | def create
@passenger_detail = PassengerDetail.new(passenger_detail_params)
respond_to do |format|
if @passenger_detail.save
format.html { redirect_to @passenger_detail, notice: 'Passenger detail was successfully created.' }
format.json { render :show, status: :created, location: @passeng... | [
"def index\n @passenger_details = PassengerDetail.all\n end",
"def create\n passenger = Passenger.new(:name => params[:name], :contact_number => params[:contact_number], :nationality => params[:nationality], :meal_pref => params[:meal_pref])\n passenger.save\n render :json => passenger\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /passenger_details/1 PATCH/PUT /passenger_details/1.json | def update
respond_to do |format|
if @passenger_detail.update(passenger_detail_params)
format.html { redirect_to @passenger_detail, notice: 'Passenger detail was successfully updated.' }
format.json { render :show, status: :ok, location: @passenger_detail }
else
format.html { ren... | [
"def update\n respond_to do |format|\n if @ride_passenger.update(ride_passenger_params)\n format.html { redirect_to @ride_passenger, notice: 'Ride passenger was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /passenger_details/1 DELETE /passenger_details/1.json | def destroy
@passenger_detail.destroy
respond_to do |format|
format.html { redirect_to passenger_details_url, notice: 'Passenger detail was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @ride_passenger.destroy\n respond_to do |format|\n format.html { redirect_to @root }\n format.json { head :no_content }\n end\n end",
"def destroy\n @passenger = Passenger.find(params[:id])\n @passenger.destroy\n\n respond_to do |format|\n format.html { redirect_to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
display_board method represents a cell as a string with 3 spaces | def display_board
cell = " "
print cell+"|"+cell+"|"+cell+"\n-----------\n"+cell+"|"+cell+"|"+cell+"\n-----------\n"+cell+"|"+cell+"|"+cell+"\n"
end | [
"def display_board\n cell_one = \" \"\n cell_two = \" \"\n cell_three = \" \"\n cell_four = \" \"\n cell_five = \" \"\n cell_six = \" \"\n cell_seven = \" \"\n cell_eight = \" \"\n cell_nine = \" \"\n divider = \"|\"\n row = \"-----------\"\n puts cell_one + divider + cell_two + divide... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /attris GET /attris.json | def index
@attris = Attri.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @attris }
end
end | [
"def show\n @attri = Attri.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attri }\n end\n end",
"def show\n @attr = Attr.find(request_params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /attris/1 GET /attris/1.json | def show
@attri = Attri.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @attri }
end
end | [
"def show\n @attr = Attr.find(request_params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attr }\n end\n end",
"def index\n @attris = Attri.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /attris/new GET /attris/new.json | def new
@attri = Attri.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @attri }
end
end | [
"def new\n @attr_def = AttrDef.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attr_def }\n end\n end",
"def new\n @attr_val = AttrVal.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /attris POST /attris.json | def create
@attri = Attri.new(params[:attri])
respond_to do |format|
if @attri.save
format.html { redirect_to @attri, notice: 'Attri was successfully created.' }
format.json { render json: @attri, status: :created, location: @attri }
else
format.html { render action: "new" }... | [
"def create\n @attri = Attri.new(attri_params)\n\n respond_to do |format|\n if @attri.save\n format.html { redirect_to @attri, notice: 'Attri was successfully created.' }\n format.json { render :show, status: :created, location: @attri }\n else\n format.html { render :new }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /attris/1 PUT /attris/1.json | def update
@attri = Attri.find(params[:id])
respond_to do |format|
if @attri.update_attributes(params[:attri])
format.html { redirect_to @attri, notice: 'Attri was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.jso... | [
"def update\n @attri = Attri.find(params[:id])\n\n respond_to do |format|\n if @attri.update_attributes(params[:attri])\n format.html { redirect_to @attri, notice: 'Attri was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /attris/1 DELETE /attris/1.json | def destroy
@attri = Attri.find(params[:id])
@attri.destroy
respond_to do |format|
format.html { redirect_to attris_url }
format.json { head :ok }
end
end | [
"def destroy\n @attri = Attri.find(params[:id])\n @attri.destroy\n\n respond_to do |format|\n format.html { redirect_to attris_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @attri.destroy\r\n respond_to do |format|\r\n format.html { redirect_to attris_ur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ex: it_should_require_logged_out_for_actions :index, :show it_should_require_logged_out_for_actions :index, :show, :some_id => 1 | def it_should_require_logged_out_for_actions *actions_and_params
# extract custom action params if the last argument is a hash,
# for instance, if another key is necessary to test the route
action_params = { :id => 1 }
if actions_and_params.last.instance_of? Hash
action_params.merge! act... | [
"def apphelp_index_actions( name, obj, user_id_or_obj = nil )\n\n if ( user_id_or_obj.nil? )\n show_method = \"#{ name }_path\"\n edit_method = \"edit_#{ name }_path\"\n arg = obj\n elsif ( user_id_or_obj.is_a?( String ) || user_id_or_obj.is_a?( Fixnum ) )\n show_method = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /rcomments POST /rcomments.json | def create
@rcomment = Rcomment.new(rcomment_params)
respond_to do |format|
if @rcomment.save
format.html { redirect_to :back, notice: 'Comment added.' }
format.json { render :show, status: :created, location: @rcomment }
else
format.html { render :new }
format.json ... | [
"def postComment(cardId, commentText)\n\tresponse = RestClient.post(\n\t\t'https://api.trello.com/1/cards/'+cardId+'/actions/comments',\n\t\t:text => commentText,\n\t\t:key =>$key,\n\t\t:token =>$token\n\t)\n\tresponse = JSON.parse(response)\nend",
"def create\n @api_v1_comment = @post.comments.new(params[:com... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /rcomments/1 DELETE /rcomments/1.json | def destroy
@rcomment.destroy
respond_to do |format|
format.html { redirect_to rcomments_url, notice: 'Rcomment was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @rb_comment.destroy\n respond_to do |format|\n format.html { redirect_to rb_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_comm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
boolean whether the digit_sum modulo 10 is 0 | def modulo(digit_sum)
digit_sum % 10 == 0
end | [
"def check_card \n @sum_digits.to_i % 10 == 0 \n end",
"def divisible_by_10?(num)\n if num % 10 == 0 then true else false end\n end",
"def check_card\n\t\tif digit_sum % 10 == 0 \n\t\t\ttrue\n\t\telse\n\t\t\tfalse \n\t\tend\n\tend",
"def is_valid?\n sum_all_doubled_numbers % 10 == 0\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the message from the parsed JSON response | def response_message
parsed_response['message']
end | [
"def message_from(response)\n response['msg']\n end",
"def message\n http_response.message\n end",
"def convert_to_messages(response)\n json = JSON.parse(response.content)\n end",
"def message_from(response)\n response[:message]\n end",
"def parse_error_message(re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
put aside num coins for this 'transaction' | def hold_coins num
@held_coins = num
end | [
"def increase_coins(amt = 0)\n increment!(:coins, amt)\n end",
"def increment_coins!(n)\n self.class.update_counters(self.id, coins: n) == 1\n end",
"def calculate_coins_value\n @amount = 0\n\n @coins.each do |coin|\n @amount += COINS[coin.weight]\n end\n end",
"def return_coins\n us... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the specified message is to be shown for this action. | def show_message?(key)
@show_messages.include?(key)
end | [
"def message_rendered?\n @_message_rendered\n end",
"def show_action?\n action?('show')\n end",
"def show(msg)\n puts msg\n true\n end",
"def shown?\n return !!shown\n end",
"def ask_msg?\r\n msg_type == 'ask'\r\n end",
"def notice_message?\n true if messa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Indicates that the specified messages are to be shown for this action. Mainly useful when specific logic is needed within an action method to determine whether or not to show a message. | def show_messages(*keys)
@show_messages.merge(keys)
end | [
"def show_message?(key)\n @show_messages.include?(key)\n end",
"def show(msg)\n puts msg\n true\n end",
"def show_action?\n action?('show')\n end",
"def display\n @notice.display(true)\n end",
"def message_action_flag\n return @message_action_flag\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Causes the specified messages to be persisted in the session. | def save_messages(*keys)
session[:messages].merge(keys)
end | [
"def save(msg = 'you forgot a msg!')\n msg += \" (processed at #{Time.now.httpdate})\"\n persist(msg)\n end",
"def _message_set_all(messages)\n @message_stack = messages\n end",
"def store_remembered_messages\n if configuration.single_delivery\n File.open(seen_messages_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Causes the specified messages to be cleared from the session. | def clear_messages(*keys)
keys.each {|key| session[:messages].delete(key)}
end | [
"def clear_messages\n @message_list.clear\n end",
"def clear_messages!\n @received_messages = []\n end",
"def reset\n @messages = []\n end",
"def clear_messages\n Facter::Log.clear_messages\n end",
"def clear_log\n @messages = []\n end",
"def clear!\n messages = [ ]\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if set number is less than 6 | def set_number_is_less_than_six
if set_number.present? && set_number > 5
errors.add(:set_number, 'cannot be greater than 5')
end
end | [
"def cheat number\n if number > 0 && number < 7\n @numberShowing = number\n return true\n end\n return false\n end",
"def check_digits(n, low, high)\n if n.to_s.length == 6 and n >= low and n <= high\n true\n else\n false\n end\nend",
"def featured(number)\n seven_multiple = 7\n c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if one score is over 25 then the other must be behind by 2 points | def score_must_be_at_least_two_points_behind_if_over_twenty_five
if home_score.present? && home_score > 25 && away_score != home_score-2
errors.add(:home_score, 'must have more than a 2 point lead when over 25')
elsif away_score.present? && away_score > 25 && home_score != away_score-2
errors.add(:a... | [
"def <=>(another_post)\n if self.score < another_post.score\n -1\n elsif self.score > another_post.score\n 1\n else\n 0\n end\n end",
"def compareScore(oldScore, newScore)\n if(!newScore[:violateReason].nil?) then\n return false ;\n elsif(oldScore.nil?) then\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a compc task for the provided swc | def initialize(swc_file)
super(swc_file, FlexSDK::compc)
end | [
"def javac(args, &block)\n JavacTask.define_task(args, &block)\nend",
"def create_compile_ext_tasks(source_root, dest_root, invoking_task)\n compiled_ext = \"#{source_root}/#{SPECIAL_BUNDLE_NAMES[File.basename(source_root)] || File.basename(source_root)}.bundle\"\n create_copy_file_tasks(FileList[compiled_ext]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new +Canvas+ element, yields it and returns the resulting javascript for the block call. This includes everything generated within it. | def canvas(*args, &block)
if args.last.kind_of?(Hash)
options = args.last
args = args[0...-1]
else
options = {}
end
# TODO: Is there a way to detect if the block is called inline or
# is included as erb text?
c = Canvas.new(*args, &block)
yield c
... | [
"def << (js)\n @element.canvas << js\n end",
"def render\n tag.canvas(**html_options)\n end",
"def initialize(width, height, &block)\n raise ArgumentError, \"give me a block, pretty please\" unless block_given?\n \n @width, @height = Integer(width), Integer(height)\n @canvas ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializes the canvas element. It takes the same parameters as the raphael +canvas+ element: four integers representing starting point, width and height, or a string and two integers, representing the id of the DOM holder, width and height | def initialize(*args, &block)
is_integer = Proc.new{|i| i.kind_of? Integer}
if args[0].kind_of? Symbol or args[0].kind_of? String
@dom_element = args[0].to_s
raise BadConstructorException(args[1,2]) unless args[1, 2].all?(&is_integer)
@width, @height = args[1, 2]
... | [
"def canvas(element_id, width, height)\n (element_id.is_a? String) ?\n @element_id = element_id : raise(ArgumentError, \"element_id has to be a String\")\n (width.is_a? Fixnum) ?\n @width = width : raise(ArgumentError, \"width has to be a Fixnum\")\n (height.is_a? Fixnum) ?\n @he... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a +Circle+ object | def circle(*args)
Circle.new(self, *args)
end | [
"def create_circle(x,y,z,radius,normal=nil)\n \tbegin\n \t\tnormal ||= Ag::Vector3d.ZAxis\n \tcirc = Ads::Circle.new(Ag::Point3d.new(x, y, z), normal, radius)\n rescue Exception => e\n puts_ex e\n end\t\n circ\n end",
"def circle(*args)\n Rafa::Elements::Circle.new(self, *args)\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a +Rect+ object | def rect(*args)
Rect.new(self, *args)
end | [
"def rect(*args)\n Rafa::Elements::Rect.new(self, *args)\n end",
"def Rect(x, y, w, h, style='')\n\t\t#Draw a rectangle\n\t\tif (style=='F')\n\t\t\top='f';\n\t\telsif (style=='FD' or style=='DF')\n\t\t\top='B';\n\t\telse\n\t\t\top='S';\n\t\tend\n\t\tout(sprintf('%.2f %.2f %.2f %.2f re %s', x * @k, (@h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates an +Ellipse+ object | def ellipse(*args)
Ellipse.new(self, *args)
end | [
"def ellipse(*args)\n Rafa::Elements::Ellipse.new(self, *args)\n end",
"def draw_ellipse(xc,yc,height,width,r,g,b)\n draw_circle(xc,yc,height,r,g,b,width)\n end",
"def variable_ellipse(x, y, px, py)\n speed = (x - px).abs + (y - py).abs\n stroke(speed)\n ellipse(x, y, speed, speed)\nend",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a +Text+ object | def text(*args)
Text.new(self, *args)
end | [
"def create_sample_text\n Text.new(0, viewport, 0, 0, 0, 0, ' ')\n end",
"def generate_text(data, pdf)\n pdf.text(data.text, size: 9)\n pdf.move_down 2\n end",
"def create_text(text)\n new_text = Text.new(title: text[\"title\"], paragraphs: text[\"paragraphs\"], reference: text... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a +Bar+ chart object | def barchart(*args)
Bar.new(self, *args)
end | [
"def test_bar_1\n \n mychart = GerbilCharts::Charts::BarChart.new( :width => 300, :height => 150, :style => 'brushmetal.css')\n mychart.setmodelgroup(@modgroup)\n mychart.render('/tmp/c_barchart1.svg')\n \n end",
"def bar_chart(path=nil, title=nil, &block)\n Graphene.gruff do\n chart(Gruf... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a +Dot+ chart object | def dotchart(*args)
Dot.new(self, *args)
end | [
"def generate_png!\n build! unless @built\n file = Tempfile.new 'ax_elements_graph'\n file.write self.to_dot\n `dot -Tpng #{file.path} > #{file.path}.png`\n \"#{file.path}.png\"\n end",
"def to_dot\n template = <<-eos\ndigraph \"<%= uid || 'graph' %>\" {\n node[ style = \"filled, solid\"];\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a +Line+ chart object | def linechart(*args)
Line.new(self, *args)
end | [
"def create_line_chart(fields)\n dataset = []\n fields.each do |field|\n # Add \"field\" to dataset\n active_dataset =\n ProjectStat.all.reduce({}) do |h, e|\n h.merge(e.created_at => e[field])\n end\n dataset << {\n name: t('.' + field),\n data: active_data... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a +Path+ object. It yields itself if given a block. | def path(*args, &block)
Path.new(self, *args, &block)
end | [
"def build(&block)\n PathBuilder.new(self, &block)\n end",
"def path(*args, &block)\n Rafa::Elements::Path.new(self, *args, &block)\n end",
"def each_path\n iter = iterator\n iter.extend IteratorPathMixin\n iter.graph = graph\n if block_given?\n while tru... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns +true+ if +attribute+ is an attribute method, +false+ otherwise. class Person include ActiveModel::Validations attr_accessor :name end User.attribute_method?(:name) => true User.attribute_method?(:age) => false | def attribute_method?(attribute)
method_defined?(attribute)
end | [
"def match_attribute_method?(method_name)\n rebuild_attribute_method_regexp unless defined?(@@attribute_method_regexp) && @@attribute_method_regexp\n @@attribute_method_regexp.match(method_name)\n end",
"def define_attribute_checker(attribute_name)\n define_method \"#{attribute_name}?\" ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copy validators on inheritance. | def inherited(base) # :nodoc:
dup = _validators.dup
base._validators = dup.each { |k, v| dup[k] = v.dup }
super
end | [
"def inherited(base)\n dup = _validators.dup\n base._validators = dup.each { |k, v| dup[k] = v.dup }\n super\n end",
"def validators\n parent_validators = self == Tram::Policy ? [] : superclass.validators\n (parent_validators + local_validators).uniq\n end",
"def skip_superclass_v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /car_images/1 GET /car_images/1.json | def show
@car_image = CarImage.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @car_image }
end
end | [
"def show\n @image = Image.find(params[:id])\n\n render json: @image\n end",
"def show\n render json:@web_display_car_image\n end",
"def image_list\n @images = Picture.where(album_id: params[:album_id])\n respond_to do |format|\n format.json { render json: @images.to_json(methods: [:path])... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /car_images/new GET /car_images/new.json | def new
@car_image = CarImage.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @car_image }
end
end | [
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image }\n end\n end",
"def new\n @title = t('view.images.new_title')\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /car_images POST /car_images.json | def create
@car_image = CarImage.new(params[:car_image])
respond_to do |format|
if @car_image.save
format.html { redirect_to @car_image, notice: 'Car image was successfully created.' }
format.json { render json: @car_image, status: :created, location: @car_image }
else
... | [
"def create\n @car_image = CarImage.new(car_image_params)\n\n respond_to do |format|\n if @car_image.save\n format.html { redirect_to @car_image, notice: 'Car image was successfully created.' }\n format.json { render :show, status: :created, location: @car_image }\n else\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /car_images/1 DELETE /car_images/1.json | def destroy
@car_image = CarImage.find(params[:id])
@car_image.destroy
respond_to do |format|
format.html { redirect_to car_images_url }
format.json { head :no_content }
end
end | [
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n render json: {status: \"success\"}, status: :ok\n end",
"def destroy\n @image.destroy\n\n respond_to do |format|\n format.json { head... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lists instance profiles ==== Parameters options: 'Marker': used to paginate subsequent requests 'MaxItems': limit results to this number per page 'PathPrefix': prefix for filtering results ==== Returns response: body: 'InstanceProfiles': instance_profile : Arn CreateDate InstanceProfileId InstanceProfileName Path Roles... | def list_instance_profiles(options={})
request({
'Action' => 'ListInstanceProfiles',
:parser => Fog::Parsers::AWS::IAM::ListInstanceProfiles.new
}.merge!(options))
end | [
"def list_app_profiles instance_id\n execute do\n instances.list_app_profiles(\n instance_path(instance_id)\n )\n end\n end",
"def list_app_profiles instance_id\n instances.list_app_profiles parent: instance_path(instance_id)\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
public: Determine the filename for this game If one is provided in the config file, use that value Otherwise, format the game name to lowercase and remove nonalphanumerics "The Binding Of Isaac: Rebirth" => "the_binding_of_isaac_rebirth" | def filename
return @filename if @filename
name.downcase.gsub(/\W/, '_').squeeze('_')
end | [
"def default_game_filename\n 'metro'\n end",
"def filename\n timestamp = turns.detect {|t| t.timestamp != nil }.timestamp rescue Time.now.to_i\n time = Time.at(timestamp).strftime(\"%Y%m%d_%H%M%S\")\n player1 = players.first.name\n player2 = players.last.name\n \"#{t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Start the producer client | def start
@state = STARTED
logger.info "Starting producer with host_params:#{@host_params}"
@connection_start_time = Time.new
@stomp = start_server(@host_params, @options.user, @options.passwd)
rescue => e
logger.error "Error occurred while starting a connection: #{e}\n #{e.backtrace.j... | [
"def start\n @producer.start\n self\n end",
"def start\n broker.start\n end",
"def start_broker()\n\n Thread.new do\n `ruby -r 'simplepubsub' -e \"SimplePubSub::Broker.start port: '55000'\"`\n end\n\n end",
"def start\n configure_log!\n client_configuration!\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract an archive to a specific location | def extract_archive(archive_filename, destination, overwrite = true)
zf = OpenStudio::UnzipFile.new(archive_filename)
zf.extractAllFiles(destination)
end | [
"def extract_archive( dest )\n end",
"def extract_archive(archive_filename, destination, overwrite = true)\r\n zf = OpenStudio::UnzipFile.new(archive_filename)\r\n zf.extractAllFiles(destination)\r\n end",
"def extract_from_archive(archive_path, destination_path, pattern=/.*/, &block)\n read_fr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a hash, detect whether it's extended & by which module. | def extended_with(hash)
hash.__angry_hash_extension if hash.respond_to?(:__angry_hash_extension)
end | [
"def _extended?(_module)\n _extended.include?(_module)\n end",
"def include_hash? hash\n return super unless hash.class <= ::Hash\n return (hash.to_a - self.to_a).empty?\n end",
"def hash?(hash)\n return false if hash.nil?\n if hash =~ /^[a-fA-F0-9]{40}$/\n return true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /providers/opening_times GET /providers/opening_times.json | def index
@providers_opening_times = Providers::OpeningTime.paginate(page: params[:page], per_page: 5).order('id Desc').all
render :layout =>false
end | [
"def show\n @opening_time = OpeningTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @opening_time }\n end\n end",
"def create\n @providers_opening_time = Providers::OpeningTime.new(providers_opening_time_params)\n\n respond_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /providers/opening_times POST /providers/opening_times.json | def create
@providers_opening_time = Providers::OpeningTime.new(providers_opening_time_params)
respond_to do |format|
if @providers_opening_time.save
format.html { redirect_to providers_opening_times_path, notice: 'Opening time was successfully created.' }
format.json { render :show, stat... | [
"def create\n @opening_time = OpeningTime.new(params[:opening_time])\n\n respond_to do |format|\n if @opening_time.save\n format.html { redirect_to session.delete(:return_to), :notice => 'Opening time was successfully created.' }\n format.json { render :json => @opening_time, :event => :cre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /providers/opening_times/1 PATCH/PUT /providers/opening_times/1.json | def update
respond_to do |format|
if @providers_opening_time.update(providers_opening_time_params)
format.html { redirect_to providers_opening_times_path, notice: 'Opening time was successfully updated.' }
format.json { render :show, status: :ok, location: @providers_opening_time }
else
... | [
"def update\n @opening_time = OpeningTime.find(params[:id])\n\n respond_to do |format|\n if @opening_time.update_attributes(params[:opening_time])\n format.html { redirect_to @opening_time, :notice => 'Opening time was successfully updated.' }\n format.json { head :no_content }\n else\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /providers/opening_times/1 DELETE /providers/opening_times/1.json | def destroy
@providers_opening_time.destroy
respond_to do |format|
format.html { redirect_to providers_opening_times_url, notice: 'Opening time was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @opening_time = OpeningTime.find(params[:id])\n @opening_time.destroy\n\n respond_to do |format|\n format.html { redirect_to opening_times_url }\n format.json { head :no_content }\n end\n end",
"def deleteEntityOpening_times( entity_id)\n params = Hash.new\n params['ent... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copy explicitly configured snippets to the right path so kibana can pick them up when you click "open in console" and then warn the user that they are lame. | def handle_override_snippet(block, snippet)
snippet_path = "snippets/#{snippet}"
normalized = block.normalize_system_path snippet_path
if File.readable? normalized
copy_override_snippet block, normalized, snippet_path
warn_override_snippet block
else
error block: block, m... | [
"def handle_override_snippet(block, snippet)\n snippet_path = \"snippets/#{snippet}\"\n normalized = block.normalize_system_path(\n snippet_path, block.document.base_dir\n )\n if File.readable? normalized\n copy_override_snippet block, normalized, snippet_path\n migration_warn block, bloc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Writes a snippet extracted from the asciidoc file into the snippets directory. | def write_snippet(block, snippet, uri)
info block: block, message: "writing snippet #{uri}"
write_proc = block.document.attr 'write_snippet'
if write_proc
# Delegate to a proc for copying if one is defined. Used for testing.
write_proc.call(uri, snippet)
else
destination ... | [
"def write_snippet(block, snippet, uri)\n info block: block, message: \"writing snippet #{uri}\"\n write_proc = block.document.attr 'write_snippet'\n if write_proc\n # Delegate to a proc for copying if one is defined. Used for testing.\n write_proc.call(uri, snippet)\n else\n destination ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the total number of words in the included paragraphs. | def total_included_words
included_paragraphs_joined.split(' ').size
end | [
"def total_included_characters\n included_paragraphs_joined.split(/./).size\n end",
"def tot_words()\n\t\ttot_words = 0\n\t\t@overlap.each {|overlap| tot_words += overlap[0]}\n\t\treturn tot_words\n\tend",
"def total_words\n self.title.to_s.count_words + self.content.to_s.count_words\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the total number of characters in the included paragraphs. | def total_included_characters
included_paragraphs_joined.split(/./).size
end | [
"def total_included_words\n included_paragraphs_joined.split(' ').size\n end",
"def num_paragraphs\r\n paragraphs.length\r\n end",
"def num_paragraphs\n @paragraphs.length\n end",
"def num_paragraphs\n @paragraphs.length\n end",
"def text_number_of_chars\n @t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a string of the included paragraphs joined by two \n's | def included_paragraphs_joined
PARAGRAPHS.join("\n\n")
end | [
"def output_paragraphs\n if @number <= self.class.total_included_paragraphs\n PARAGRAPHS[0, @number].join(\"\\n\\n\")\n else\n repeat = (@number / self.class.total_included_paragraphs.to_f).ceil\n (PARAGRAPHS * repeat)[0, @number].join(\"\\n\\n\")\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Outputs the correct number of paragraphs based on the number | def output_paragraphs
if @number <= self.class.total_included_paragraphs
PARAGRAPHS[0, @number].join("\n\n")
else
repeat = (@number / self.class.total_included_paragraphs.to_f).ceil
(PARAGRAPHS * repeat)[0, @number].join("\n\n")
end
end | [
"def paragraph_counter\n # Separate pharagraphs \n paras = @text.split(\"\\n\", -1)\n paras.count.times do |i|\n # Removes new line characters\n paras[i] = paras[i].gsub(\"\\n\", \"\")\n end\n @paragraph = paras\n return @paragraph.count\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Outputs the correct number of words based on the number | def output_words
if @number <= self.class.total_included_words
convert_paragraphs_to_words(self.class.included_paragraphs_joined)
else
repeat = (@number / self.class.total_included_words.to_f).ceil
convert_paragraphs_to_words((PARAGRAPHS * repeat).join("\n\n"))
end
... | [
"def in_words(num)\n num_array = num.to_s.split('')\n phrase = \"\"\n case num_array.length\n when 1\n phrase = WORDS[num]\n when 2\n phrase += WORDS[(num_array[-2] + \"0\").to_i] + \"-\" + WORDS[(num_array[-1]).to_i]\n when 3\n phrase += WORDS[(num_array[-3]).to_i] + \" hundred \"\n if num_array[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts paragraphs to the correct number of basic words by splitting on a space | def convert_paragraphs_to_words(str)
str.split(' ')[0, @number].join(' ')
end | [
"def split_into_words text\n text.gsub(/\\s+/m, ' ').strip.split(\" \")\n end",
"def split_paragraphs(input)\n return input.split(/\\n[ ]*\\n+/)\n end",
"def words\n @phrase.\n split(/[\\n ,]/).\n map {|w| normalize_word(w) }.\n delete_if {|w| w.empty? }\n end",
"def make_paragr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
find first house over total | def search_by(step_count, total_presents, start=0)
p "Search by: #{pn(step_count)} for #{pn(total_presents)} starting at #{pn(start)}"
presents = 0
house_num = start
house = House.new(0) # remove obj creation "cost"
while presents < total_presents
house_num += step_count
house.number = house_num
p... | [
"def paintHouses(homes)\n cost = homes[0].dup\n \n homes[1..-1].each do |h|\n new_cost = [0] * 3\n \n new_cost[0] = h[0] + [cost[1], cost[2]].min\n new_cost[1] = h[1] + [cost[0], cost[2]].min\n new_cost[2] = h[2] + [cost[0], cost[1]].min\n \n cost = new_cost... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
for a given state, tabulate all possible outcomes | def tabulate_outcomes(state)
#return early if we have a cached solution for the given [state]
if out = @TAB_CACHE[state.board_bits]
return out
end
@iteration_count += 1
out = {x: 0, o: 0, cat:0}
#if this state has a winner, it's easy
if w = state.winner
out[w] = 1
... | [
"def construct_table\n @table = Table.new(index_label: :State)\n @grammar.terminals.each { |x| @table.add_column(x) }\n @grammar.nonterminals.each { |x| @table.add_column(x) unless x == @grammar.start }\n @table.group_add(:Action, *@grammar.terminals.to_a)\n @table.group_add(:Goto, *@gramma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cache all symmetric layouts of [state] | def cache_solution(state, outcomes)
@TAB_CACHE[state.board_bits] = outcomes
alt = state
3.times do
alt = rotate_state alt
@TAB_CACHE[alt.board_bits] = outcomes
end
alt = flip_state state
@TAB_CACHE[alt.board_bits] = outcomes
3.times do
alt = rotate_state alt
@TAB... | [
"def _layout(*); end",
"def page_layout\r\n @user = self.logged_in_user\r\n @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup\r\n session[:page_layout] = @blocks\r\n %w(top left right).each {|f| session[:page_layout][f] ||= [] }\r\n @block_options = []\r\n BLOCKS.each {|k, v| @block_op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a list of ymd values in array to display on suppression form for start_timestamp the day must always be the beginning of the month pass orgininal date to include original date if it is in the past. | def start_ymd_select_list(original_date = nil)
ymd_array=[]
date = Time.now #parse("2011-04-05 00:00:00")
ymd_array << ["#{original_date.strftime("%Y-%m")}-#{original_date.beginning_of_month.strftime("%d")}"] unless original_date.nil?
12.times do
ymd_array << ["#{date.strftime("%Y-%m")}-#{date.beg... | [
"def end_ymd_select_list(original_date = nil)\n ymd_array=[]\n date = Time.now\n ymd_array << [\"#{original_date.strftime(\"%Y-%m\")}-#{original_date.end_of_month.strftime(\"%d\")}\"] unless original_date.nil?\n 12.times do\n ymd_array << [\"#{date.strftime(\"%Y-%m\")}-#{date.end_of_month.strftime(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a list of ymd values in array to display on suppression form for end_timestamp the day must always be the end of the month | def end_ymd_select_list(original_date = nil)
ymd_array=[]
date = Time.now
ymd_array << ["#{original_date.strftime("%Y-%m")}-#{original_date.end_of_month.strftime("%d")}"] unless original_date.nil?
12.times do
ymd_array << ["#{date.strftime("%Y-%m")}-#{date.end_of_month.strftime("%d")}"]
date... | [
"def start_ymd_select_list(original_date = nil)\n ymd_array=[]\n date = Time.now #parse(\"2011-04-05 00:00:00\")\n ymd_array << [\"#{original_date.strftime(\"%Y-%m\")}-#{original_date.beginning_of_month.strftime(\"%d\")}\"] unless original_date.nil?\n 12.times do\n ymd_array << [\"#{date.strftime(\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return a hash of scores that the team has received for the questions | def get_scores(questions)
scores = Hash.new
scores[:team] = self # This doesn't appear to be used anywhere
assignment.questionnaires.each do |questionnaire|
scores[questionnaire.symbol] = Hash.new
scores[questionnaire.symbol][:assessments] = Response.all(:joins => :map,
... | [
"def get_scores(questions)\n scores = Hash.new\n scores[:team] = self # This doesn't appear to be used anywhere\n assignment.questionnaires.each do |questionnaire|\n scores[questionnaire.symbol] = Hash.new\n scores[questionnaire.symbol][:assessments] = Response.all(:joins => :map,\n :condi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /admin/books POST /admin/books.json | def create
@book = Book.new(admin_book_params)
respond_to do |format|
if @book.save
format.html { redirect_to admin_book_path(id: @book.id), notice: 'Book was successfully created.' }
format.json { render :show, status: :created, location: @book }
else
format.html { render :... | [
"def create\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to [:admin, @book], :notice => 'Book was successfully created.' }\n format.json { render :show, :status => :created, :location => @book }\n else\n format.html { render :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /admin/books/1 PATCH/PUT /admin/books/1.json | def update
respond_to do |format|
if @book.update(admin_book_params)
format.html { redirect_to admin_book_path(id: @book.id), notice: 'Book was successfully updated.' }
format.json { render :show, status: :ok, location: @book }
else
format.html { render :edit }
format.jso... | [
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to [:admin, @book], notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.er... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /transfer_products/1 GET /transfer_products/1.json | def show
@title = t('view.transfer_products.show_title')
@transfer_product = TransferProduct.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @transfer_product }
end
end | [
"def index\n @transfered_products = TransferedProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transfered_products }\n end\n end",
"def show\n @transfered_product = TransferedProduct.find(params[:id])\n\n respond_to do |format|\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /transfer_products/new GET /transfer_products/new.json | def new
@title = t('view.transfer_products.new_title')
@transfer_product = TransferProduct.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @transfer_product }
end
end | [
"def new\n @transfered_product = TransferedProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transfered_product }\n end\n end",
"def new\n @breadcrumb = 'create'\n @inventory_transfer = InventoryTransfer.new\n @stores = stores_drop... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /transfer_products POST /transfer_products.json | def create
@title = t('view.transfer_products.new_title')
@transfer_product = TransferProduct.new(params[:transfer_product])
respond_to do |format|
if @transfer_product.save
# Printer.print_transfer_report(@transfer_product)
format.html { redirect_to @transfer_product, notice: t('view... | [
"def create\n @transfered_product = TransferedProduct.new(params[:transfered_product])\n\n respond_to do |format|\n if @transfered_product.save\n format.html { redirect_to branch_transfer_path(@branch,@transfer), notice: 'Transfered product was successfully created.' }\n format.json { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /transfer_products/1 DELETE /transfer_products/1.json | def destroy
@transfer_product = TransferProduct.find(params[:id])
@transfer_product.destroy
respond_to do |format|
format.html { redirect_to transfer_products_url }
format.json { head :ok }
end
end | [
"def destroy\n @transfered_product = TransferedProduct.find(params[:id])\n @transfered_product.destroy\n\n respond_to do |format|\n format.html { redirect_to transfered_products_url }\n format.json { head :no_content }\n end\n end",
"def delete(options = nil)\n request = Request.new(@c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /complex_services/1 GET /complex_services/1.xml | def show
@complex_service = ComplexService.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @complex_service }
end
end | [
"def show\n @server_service = subdomain.servers.find(params[:server_id]).server_services.where('id = ?', params[:id])\n render :xml => @server_service \n end",
"def new\n @complex_service = ComplexService.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :x... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /complex_services/new GET /complex_services/new.xml | def new
@complex_service = ComplexService.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @complex_service }
end
end | [
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml\n end\n end",
"def new\n @page_id = \"services\"\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /complex_services POST /complex_services.xml | def create
@complex_service = ComplexService.new(params[:complex_service])
respond_to do |format|
if @complex_service.save
format.html { redirect_to(@complex_service, :notice => 'ComplexService was successfully created.') }
format.xml { render :xml => @complex_service, :status => :create... | [
"def add_service(service={})\n request :post, '/services', service\n end",
"def new\n @complex_service = ComplexService.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @complex_service }\n end\n end",
"def create\n service_plan = service_plan... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /complex_services/1 PUT /complex_services/1.xml | def update
@complex_service = ComplexService.find(params[:id])
respond_to do |format|
if @complex_service.update_attributes(params[:complex_service])
format.html { redirect_to(@complex_service, :notice => 'ComplexService was successfully updated.') }
format.xml { head :ok }
else
... | [
"def update\n #ensure empty groups get cleared out\n if !params['wsdl']['xsd_ids']\n @wsdl.xsds.clear\n end\n\n respond_to do |format|\n if @wsdl.update_attributes(params[:wsdl])\n flash[:notice] = 'Wsdl was successfully updated.'\n format.html { redirect_to wsdl_url(@wsdl) }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /complex_services/1 DELETE /complex_services/1.xml | def destroy
@complex_service = ComplexService.find(params[:id])
@complex_service.destroy
respond_to do |format|
format.html { redirect_to(complex_services_url) }
format.xml { head :ok }
end
end | [
"def delete service\n\t @name_services.delete service\n\tend",
"def destroy\n @atomic_service = AtomicService.find(params[:id])\n @atomic_service.destroy\n\n respond_to do |format|\n format.html { redirect_to(atomic_services_url) }\n format.xml { head :ok }\n end\n end",
"def test_ser... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handle API specific whitelisted cookies Author: Aman Date: 16/02/2018 Reviewed By: Sunil | def handle_whitelisted_api_cookies
new_api_cookies = request.cookies[GlobalConstant::Cookie.new_api_cookie_key.to_sym]
return if new_api_cookies.blank?
whitelisted_api_cookies = [GlobalConstant::Cookie.user_cookie_name]
whitelisted_api_cookies.each do |key|
whitelisted_cookie = new_api_cookies[key... | [
"def handle_whitelisted_api_cookies\n new_api_cookies = request.cookies[GlobalConstant::Cookie.new_api_cookie_key.to_sym]\n return if new_api_cookies.blank?\n whitelisted_api_cookies = [GlobalConstant::Cookie.user_cookie_name, GlobalConstant::Cookie.last_used_env_cookie_name, GlobalConstant::Cookie.device_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /form_messages/1 PATCH/PUT /form_messages/1.json | def update
respond_to do |format|
if @form_message.update(form_message_params)
format.html { redirect_to @form_message, notice: 'Form message was successfully updated.' }
format.json { render :show, status: :ok, location: @form_message }
else
format.html { render :edit }
... | [
"def update\n respond_to do |format|\n @message.update!(message_params)\n format.json { head :no_content }\n end\n end",
"def update\n message = Message.find(params[:id])\n message.update(message_params)\n render json: message\n end",
"def update\n @message_field = MessageField.fin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /form_messages/1 DELETE /form_messages/1.json | def destroy
@form_message.destroy
respond_to do |format|
format.html { redirect_to form_messages_url, notice: 'Form message was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @message.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @message_field = MessageField.find(params[:id])\n @message_field.destroy\n\n respond_to do |format|\n format.html { redirect_to message_fields_url }\n format.j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a template variable for yes/no options for radio buttons on a form for use with govuk_collection_radio_buttons method. include hash for radio button hints if required, e.g. yes_no_options will print no hints under individual radio buttons yes_no_options(yes: 'this means Go!', no: 'This means Stop') will print h... | def yes_no_options(radio_hints = {})
[
RadioOption.new(true, I18n.t("generic.yes"), radio_hints[:yes]),
RadioOption.new(false, I18n.t("generic.no"), radio_hints[:no]),
]
end | [
"def boolean_radio_input(method, options)\n options[:true] ||= \"Yes\"\n options[:false] ||= \"No\"\n\n choices = [ {:label => options[:true], :value => true}, {:label => options[:false], :value => false} ]\n\n @template.content_tag(:fieldset, \n %{<legend><span>#{label_text(met... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /content_types/1 GET /content_types/1.xml | def show
@content_type = ContentType.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @content_type }
end
end | [
"def index\n @content_types = ContentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @content_types }\n end\n end",
"def show\n @content_type = ContentType.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /content_types/new GET /content_types/new.xml | def new
@content_type = ContentType.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @content_type }
end
end | [
"def new\n @content_type = ContentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content_type }\n end\n end",
"def new\n @type = Type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @type... | {
"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.