query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
POST /PicTimeLine/create To create the images/pictures references in the local mobile database. Currently we are not able to receive blob reference in the rhosync server. Now we receive as NIL when we inspect BLOB in the rhosync server. We have already posted this issue for assistance in the RHOMOBILE GOOGLE GROUP. Fol...
def create @pictimeline = PicTimeLine.new(@params['pictimeline']) p "@pictimeline #{@pictimeline}" p "@params #{@params.inspect}" @pictimeline.save #SyncEngine::dosync redirect :action => :index end
[ "def create\n #@photo = Photo.new(params[:photo])\n @photo = Photo.new(:taker=>params[:taker], :location=>params[:gps])\n if params[:taker].present?\n dt = Time.now.strftime(\"%Y%m%d%H%M%S\")\n @photo.name = dt\n t = @photo.taker.split('-')\n @photo.taker_id = t.first\n @photo.take...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /core/status_desembaracos/1 GET /core/status_desembaracos/1.json
def show @core_status_desembaraco = Core::StatusDesembaraco.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @core_status_desembaraco } end end
[ "def show\n @core_status_unidade_carga = Core::StatusUnidadeCarga.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @core_status_unidade_carga }\n end\n end", "def show\n @core_status_processamento = Core::StatusProcessamento.find(params...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /core/status_desembaracos/new GET /core/status_desembaracos/new.json
def new @core_status_desembaraco = Core::StatusDesembaraco.new respond_to do |format| format.html # new.html.erb format.json { render json: @core_status_desembaraco } end end
[ "def new\n @statusentrega = Statusentrega.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @statusentrega }\n end\n end", "def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /core/status_desembaracos POST /core/status_desembaracos.json
def create @core_status_desembaraco = Core::StatusDesembaraco.new(params[:core_status_desembaraco]) respond_to do |format| if @core_status_desembaraco.save format.html { redirect_to @core_status_desembaraco, notice: 'Status desembaraco was successfully created.' } format.json { render jso...
[ "def create\n @devolucao = Devolucao.new(devolucao_params)\n @reserva.update(status: 'Devolvido')\n @veiculo.update(status: devolucao_params[:status])\n\n respond_to do |format|\n if @devolucao.save\n format.html { redirect_to @devolucao, notice: 'Devolucao was successfully created.' }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /core/status_desembaracos/1 PUT /core/status_desembaracos/1.json
def update @core_status_desembaraco = Core::StatusDesembaraco.find(params[:id]) respond_to do |format| if @core_status_desembaraco.update_attributes(params[:core_status_desembaraco]) format.html { redirect_to @core_status_desembaraco, notice: 'Status desembaraco was successfully updated.' } ...
[ "def destroy\n @cooperativa = Cooperativa.find(params[:id])\n @cooperativa.update_attributes :status => Status.find_by_descricao('Inativo')\n\n respond_to do |format|\n format.html { redirect_to admin_cooperativas_path }\n format.json { head :ok }\n end\n end", "def destroy\n @destaque =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /core/status_desembaracos/1 DELETE /core/status_desembaracos/1.json
def destroy @core_status_desembaraco = Core::StatusDesembaraco.find(params[:id]) @core_status_desembaraco.destroy respond_to do |format| format.html { redirect_to core_status_desembaracos_url } format.json { head :no_content } end end
[ "def destroy\n @core_status_unidade_carga = Core::StatusUnidadeCarga.find(params[:id])\n @core_status_unidade_carga.destroy\n\n respond_to do |format|\n format.html { redirect_to core_status_unidade_cargas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @core_status...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /viewers GET /viewers.json
def index @viewers = Viewer.where(user_id: current_user.id) end
[ "def viewers\n stats = Stats.new(\"Success\", params[:code], {\n viewers: @link.viewers\n })\n render json: stats\n end", "def index\n @viewers = Viewer.all\n end", "def viewers(options = {})\n if !defined?(@viewers)\n arguments = [self.fullID]\n cmdO...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /viewers POST /viewers.json
def create @search_club = User.find(current_user.id).information_personals @viewer = Viewer.new(viewer_params.merge(user_id: current_user.id, club: @search_club[0].club)) respond_to do |format| if @viewer.save format.html { redirect_to viewers_path, notice: t('visor.alert_succesful') } ...
[ "def add_viewer(id, **params)\n _post(\"/graphs/#{id}/relationships/viewers\", params) { |json| json }\n end", "def index\n @viewers = Viewer.all\n end", "def viewers\n stats = Stats.new(\"Success\", params[:code], {\n viewers: @link.viewers\n })\n render json: st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /viewers/1 DELETE /viewers/1.json
def destroy @viewer.destroy respond_to do |format| format.html { redirect_to viewers_url, notice: t('visor.alert_delete') } format.json { head :no_content } end end
[ "def destroy\r\n @viewer = current_user.viewers.find(params[:id])\r\n @viewer.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to viewers_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @viewer.destroy\n respond_to do |format|\n format...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Skip the filter if the current user is permitted to take workflow actions on the work corresponding to the SolrDocument with id = `blacklight_params[:id]`
def only_active_works(solr_parameters) return if user_has_active_workflow_role? || depositor? super end
[ "def only_active_works(solr_parameters)\n current_work = ::SolrDocument.find(blacklight_params[:id])\n return if user_has_active_workflow_role?(current_work: current_work)\n return if depositor?(current_work: current_work)\n super\n end", "def apply_permissive_visibility_filter(solr_params)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Constrain the distance between bob and anchor between min and max
def constrain_length(bob, minlen, maxlen) dir = bob.location - @anchor d = dir.mag # Is it too short? if d < minlen dir.normalize! dir *= minlen # Reset location and stop from moving (not realistic physics) bob.location = @anchor + dir bob.velocity *= 0 elsif d > maxlen...
[ "def constrain_length(bob, minlen, maxlen)\n dir = PVector.sub(bob.location, @anchor)\n d = dir.mag\n # Is it too short?\n if d < minlen\n dir.normalize\n dir.mult(minlen)\n # Reset location and stop from moving (not realistic physics)\n bob.location = PVector.add(@anchor, dir)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength Use the existence of an organizationlevel task to prevent duplicates since there should only ever be one orglevel task active at a time for a single appeal.
def verify_org_task_unique # do not verify for split appeal process return if appeal.appeal_split_process == true return if !open? if appeal.tasks.open.where( type: type, assigned_to: assigned_to, parent: parent ).any? && assigned_to.is_a?(Organization) fail( Caseflo...
[ "def verify_org_task_unique\n return if !active?\n\n if appeal.tasks.active.where(\n type: type,\n assigned_to: assigned_to,\n parent: parent\n ).any? && assigned_to.is_a?(Organization)\n fail(\n Caseflow::Error::DuplicateOrgTask,\n appeal_id: appeal.id,\n task_type...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
N.B. that this does not check permissions, only assignee Use task_is_assigned_to_users_organization? if that is needed.
def task_is_assigned_to_organization?(org) assigned_to.is_a?(Organization) && assigned_to == org end
[ "def potential_task_assignees(task)\n if task.assigned_to.is_a?(Organization)\n task.assigned_to.users.active\n elsif task.parent&.assigned_to.is_a?(Organization)\n task.parent.assigned_to.users.active.reject { |check_user| check_user == task.assigned_to }\n else\n []\n end\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is for copying a task and its ancestors to a new appeal stream
def copy_with_ancestors_to_stream(new_appeal_stream, extra_excluded_attributes: [], new_attributes: {}) return unless parent new_task_attributes = attributes .except(*ATTRIBUTES_EXCLUDED_FROM_TASK_COPY, *extra_excluded_attributes) .merge(new_attributes) new_task_attributes["appeal_id"] = new_ap...
[ "def copy_ds_tasks_to_new_stream\n new_completed_task = DocketSwitchGrantedTask.assigned_to_any_user.find_by(appeal: old_docket_stream).dup\n new_completed_task.assign_attributes(\n appeal_id: new_docket_stream.id,\n parent_id: new_docket_stream.root_task.id,\n status: Constants.TASK_STATUSES.c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Purpose: This method is triggered by callback 'after_update'. This method calls a variety of abstract private methods that are prepended in app/models/prepend/va_notifiy. These private methods will update an appeal's state within the 'Appeal State' table when certain tracked task types have their statuses updated to ei...
def update_appeal_state_on_status_change update_appeal_state_when_ihp_cancelled update_appeal_state_when_ihp_completed update_appeal_state_when_privacy_act_cancelled update_appeal_state_when_privacy_act_complete update_appeal_state_when_appeal_cancelled end
[ "def update_appeal_state_when_ihp_completed\n if IHP_TYPE_TASKS.include?(type) &&\n !IHP_TYPE_TASKS.include?(parent&.type) &&\n status == Constants.TASK_STATUSES.completed\n MetricsService.record(\"Updating VSO_IHP_COMPLETED column to TRUE & VSO_IHP_PENDING column to FALSE in Appeal\"\\\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Purpose: This method is triggered by callback 'after_create'. This method calls a variety of abstract private methods that are prepended in app/models/prepend/va_notifiy. These private methods will update an appeal's state within the 'Appeal State' table when certain tracked tasks are created. Params: NONE Response: Th...
def update_appeal_state_on_task_creation update_appeal_state_when_privacy_act_created update_appeal_state_when_appeal_docketed update_appeal_state_when_ihp_created end
[ "def update_appeal_state_when_ihp_created\n if IHP_TYPE_TASKS.include?(type)\n MetricsService.record(\"Updating VSO_IHP_PENDING column to TRUE & VSO_IHP_COMPLETE column to FALSE in\"\\\n \" Appeal States Table for #{appeal.class} ID #{appeal.id}\",\n service: nil,\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If an Education predocket RPO task is completed and sent to BVA Intake then the parent Education EMO task should also be completed.
def update_task_if_children_tasks_are_completed if type == EducationDocumentSearchTask.name && children.last.completed? update!(status: Constants.TASK_STATUSES.completed) else update!(status: Constants.TASK_STATUSES.assigned) end end
[ "def completed\n set_state(:completed)\n parent_op.child_completed(application) unless parent_op_id.nil?\n end", "def adjust_prerequisites #:nodoc:\n prerequs = (self.prerequisites.presence || {})[:for_setup]\n return unless prerequs.present?\n my_participants = selected_participants\n my_sessi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Processes an incoming counter measurement Normalize for sample rate provided Adds the value to any existing values by the same
def handle(key, value, sample_rate) if sample_rate value = value.to_f / sample_rate.gsub("@", "").to_f end key = "counters:#{key}" @active_counters[key] = @active_counters[key].to_i + value.to_i @counters[key] = nil end
[ "def handle(key, value, sample_rate)\n if sample_rate\n value = value.to_f / sample_rate.gsub(\"@\", \"\").to_f\n end\n key = \"counters:#{key}\"\n value = value.to_i\n hash = key.hash\n @retentions.size.times do |i|\n slot = @key_slot_map[key] ||= hash % @slots[i]\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Flushes the accumulated counters that are pending in
def flush puts "Current threadpool queue for counters: #{@threadpool.size}" if ENV["VVERBOSE"] # Flushing is usually very fast, but always fix it so that the # entire thing is based on a constant start time # Saves on time syscalls too flush_start = Time.now.to_i n = @active_counter...
[ "def flush\n _log.debug { 'flushing counters buffer' }\n data = @data.synchronize { @data.dup.tap { @data.clear } }\n return self unless data.any?\n _redis_lua_run(\n 'counters_flush',\n keys: [_key],\n argv: _serialize(data).flatten)\n self\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
To calculate the area from Parent Class
def getArea return "Area from Parent class is #{@width * @height}" end
[ "def getArea\n return \"Area from Parent class is #{@width*@height}\"\n end", "def getArea\n return \"Area from Parent class is #{@width * @height}\"\n end", "def area\n return @base * @altura\n end", "def total_area\n\t\tarea = 0\n\t\tshapes.each do |shape|\n\t\t\tarea = area + ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /abouts POST /abouts.json
def create @about = current_user.abouts.build(about_params) respond_to do |format| if @about.save format.html { redirect_to abouts_url, notice: 'about was successfully created.' } format.json { render :show, status: :created, location: @about } else format.html { render :new } forma...
[ "def create\n @about = About.new(params[:about])\n\n respond_to do |format|\n if @about.save\n format.html { redirect_to @about, notice: 'About was successfully created.' }\n format.json { render json: @about, status: :created, location: @about }\n else\n format.html { render ac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /abouts/1 PATCH/PUT /abouts/1.json
def update respond_to do |format| if @about.update(about_params) format.html { redirect_to admin_abouts_path, notice: 'about was successfully updated.' } format.json { render :show, status: :ok, location: @about } else format.html { render :edit } format.json { render json: @about.erro...
[ "def update\n @about = About.find(params[:id])\n\n respond_to do |format|\n if @about.update_attributes(params[:about])\n format.html { redirect_to @about}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ab...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /abouts/1 DELETE /abouts/1.json
def destroy @about.destroy respond_to do |format| format.html { redirect_to abouts_url, notice: 'about was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @about = About.find(params[:id])\n @about.destroy\n\n respond_to do |format|\n format.html { redirect_to abouts_url }\n format.json { head :ok }\n end\n end", "def destroy\n @about = About.find(params[:id])\n @about.destroy\n\n respond_to do |format|\n format.ht...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /archivos/1 PATCH/PUT /archivos/1.json
def update respond_to do |format| if @archivo.update(archivo_params) format.html { redirect_to @archivo, notice: 'Archivo was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @archivo.errors, s...
[ "def update\n\n params[:archivo][:url] = \"#{Rails.root}/attachments/archivos/\"+params[:archivo][:url]\n\n @archivo = Archivo.find(params[:id])\n\n respond_to do |format|\n if @archivo.update_attributes(params[:archivo])\n format.html { redirect_to archivos_path+\"##{@archivo.idioma_id}\", fla...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /archivos/1 DELETE /archivos/1.json
def destroy @archivo.destroy respond_to do |format| format.html { redirect_to archivos_url } format.json { head :no_content } end end
[ "def destroy\n @archivo = Archivo.find(params[:id])\n @archivo.destroy\n\n respond_to do |format|\n format.html { redirect_to archivos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @archivo = Archivo.find(params[:id])\n @archivo.destroy\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /dis_dispensable_generics/1 PATCH/PUT /dis_dispensable_generics/1.json
def update respond_to do |format| if @dis_dispensable_generic.update(dis_dispensable_generic_params) format.html { redirect_to @dis_dispensable_generic, notice: 'Combination dose was successfully updated.' } format.json { render :show, status: :ok, location: @dis_dispensable_generic } el...
[ "def update\n respond_to do |format|\n if @dispensible_generic.update(dispensible_generic_params)\n format.html { redirect_to @dispensible_generic, notice: 'Dispensible generic was successfully updated.' }\n format.json { render :show, status: :ok, location: @dispensible_generic }\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /dis_dispensable_generics/1 DELETE /dis_dispensable_generics/1.json
def destroy @dis_dispensable_generic.destroy respond_to do |format| format.html { redirect_to dis_dispensable_generics_url, notice: 'Combination dose was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @dis_generic.destroy\n respond_to do |format|\n format.html { redirect_to dis_generics_url, notice: 'Dis generic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /parking_spots/1 GET /parking_spots/1.json
def show @parking_spot = ParkingSpot.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @parking_spot } end end
[ "def spots\n @spots = Spot.find_all_by_discipline_id(params[:id]).paginate(:per_page => 10, :page =>params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spots.to_json(:only => [:name, :spot_id, :local]) }\n end\n end", "def index\n @spots = Sp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /parking_spots/new GET /parking_spots/new.json
def new @parking_spot = ParkingSpot.new respond_to do |format| format.html # new.html.erb format.json { render json: @parking_spot } end end
[ "def new\n @spot = Spot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def create\n @parking_spot = ParkingSpot.new(params[:parking_spot])\n\n respond_to do |format|\n if @parking_spot.save\n format.html { redir...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /parking_spots POST /parking_spots.json
def create @parking_spot = ParkingSpot.new(params[:parking_spot]) respond_to do |format| if @parking_spot.save format.html { redirect_to @parking_spot, notice: 'Parking spot was successfully created.' } format.json { render json: @parking_spot, status: :created, location: @parking_spot } ...
[ "def create\n spot2 = Spot.order(\"created_at\").last\n id = (spot2.id.to_i) + 1\n @spot = Spot.new(spot_params)\n @spot.id = id\n respond_to do |format|\n if @spot.save\n HTTParty.post(\"http://localhost:3000/spots?name=#{spot_params[:name]}&lat=#{spot_params[:lat]}&lon=#{spot_params[:lo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /parking_spots/1 DELETE /parking_spots/1.json
def destroy @parking_spot = ParkingSpot.find(params[:id]) @parking_spot.destroy respond_to do |format| format.html { redirect_to parking_spots_url } format.json { head :no_content } end end
[ "def destroy\n HTTParty.delete(\"http://localhost:3000/spots/#{@spot.id}\")\n @spot.destroy\n respond_to do |format|\n format.html { redirect_to spots_url, notice: 'Spot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @spot.destroy\n\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses the CSV file for data matching the given filter, or all if no filter provided.
def read(filter = {}) CSVFileTransaction.new(@path).read do |existing_data| existing_data.select do |row| filter.keys.all? do |key| row[key] == filter[key] end end end end
[ "def parse(args={})\n csv_args = {:skip_blanks=>true,:col_sep=>\",\"}\n csv_args[:col_sep] = args[:col_sep] if args[:col_sep]\n args[:value_filter] ||= Csv2sql.method :default_value_filter\n i = 0\n CSV.foreach(@filename,csv_args) do |row|\n values = row\n #values_filter is for whole row\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates an existing task in the CSV file.
def update(id, data) CSVFileTransaction.new(@path).write do |tasks| task_data = tasks.find do |task| task[:id] == id end task_data&.merge!(data) generate(tasks) end end
[ "def update \n\t logger.debug \"Params --------------------------------------- #{params}\"\n\n\t logger.debug \"task params --------------------------------------#{task_params}\"\n\t format_task_attributes(task_params)\n\t \n\t logger.debug \"-------------------------------------------------------------\"\n\t ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes an existing task from the CSV file.
def delete(id) CSVFileTransaction.new(@path).write do |existing_data| generate(existing_data.reject { |task| task[:id] == id }) end end
[ "def remove_task(task); end", "def delete_task\n\n puts 'Enter task number(ID), please'\n\n entered_id = get_id_input\n\n if @tasks[entered_id]\n\n @tasks.delete(entered_id)\n\n else\n\n no_entry_message\n\n end\n\n end", "def remove(task_id)\n # We pass in a 1-indexed ID because ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instantiate an instance of +klass+ and pass +output+
def respond_with(klass, output) klass.new(self, output) end
[ "def output_from new_output\n return @output = new_output.new(self) if Class === new_output\n\n klass =\n case new_output.to_s\n when /^(Player::)?benchmark$/i then Benchmark\n when /^(Player::)?stream$/i then Stream\n when /^(Player::)?suite$/i then Suite\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /system_modules GET /system_modules.json
def index @system_modules = SystemModule.all respond_to do |format| format.html # index.html.erb format.json { render json: @system_modules } end end
[ "def show\n @system_module = SystemModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system_module }\n end\n end", "def client_modules\n get 'client/modules'\n end", "def kernel_modules\n cmd_exec('cat /proc/modules...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /system_modules/1 GET /system_modules/1.json
def show @system_module = SystemModule.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @system_module } end end
[ "def index\n @system_modules = SystemModule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @system_modules }\n end\n end", "def module_details id\n begin\n print_verbose \"Retrieving details for command module [id: #{id}]\"\n response = RestCl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /system_modules/new GET /system_modules/new.json
def new @system_module = SystemModule.new respond_to do |format| format.html # new.html.erb format.json { render json: @system_module } end end
[ "def new\n @system_module = SystemModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @system_module }\n end\n end", "def create\n @system_module = SystemModule.new(params[:system_module])\n\n respond_to do |format|\n if @system_module.s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /system_modules POST /system_modules.json
def create @system_module = SystemModule.new(params[:system_module]) respond_to do |format| if @system_module.save format.html { redirect_to system_modules_path, notice: 'System module was successfully created.' } format.json { render json: @system_module, status: :created, location: @sys...
[ "def create\n @system_module = SystemModule.new(params[:system_module])\n\n respond_to do |format|\n if @system_module.save\n format.html { redirect_to(@system_module, :notice => 'SystemModule was successfully created.') }\n format.xml { render :xml => @system_module, :status => :created, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /system_modules/1 PUT /system_modules/1.json
def update @system_module = SystemModule.find(params[:id]) respond_to do |format| if @system_module.update_attributes(params[:system_module]) format.html { redirect_to system_modules_path, notice: 'System module was successfully updated.' } format.json { head :no_content } else ...
[ "def update\n @system_module = SystemModule.find(params[:id])\n\n respond_to do |format|\n if @system_module.update_attributes(params[:system_module])\n format.html { redirect_to(@system_module, :notice => 'SystemModule was successfully updated.') }\n format.xml { head :ok }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /system_modules/1 DELETE /system_modules/1.json
def destroy @system_module = SystemModule.find(params[:id]) @system_module.destroy respond_to do |format| format.html { redirect_to system_modules_url } format.json { head :no_content } end end
[ "def destroy\n @system_module = SystemModule.find(params[:id])\n @system_module.destroy\n\n respond_to do |format|\n format.html { redirect_to(system_modules_url) }\n format.xml { head :ok }\n end\n end", "def delete_module(org_unit_id, module_id) # DELETE\n query_string = \"/d2l/api/le/#...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a list of navigation items for mobile
def mobile_navigation_items @mobile_navigation_items ||= begin result = [] # Collect the four basic navigaton links %i[meditations tracks streams articles].each do |role| next if role == :streams && !Stream.public_stream.any? static_page = static_page_preview_for(role) re...
[ "def mobile_navigation_items\n @mobile_navigation_items ||= begin\n result = []\n\n # Collect the four basic navigaton links\n %i[meditations tracks streams classes articles].each do |role|\n next if role == :streams && !Stream.public_stream.any?\n\n static_page = StaticPage.preview(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
tests that activity tracker control thread do not start if number of active id's reduced to 1
def test_start_stop start_time_for={} stop_time=nil at=Activity_tracker.new do |id| assert((Time.now-start_time_for[id]-at.timeout).to_f.abs<at.tick_time) end if at.tresholds<3 puts "Warning: this test supposed to run successfully"+ "only wich tresholds>3" end 4.times do ...
[ "def minimum_number_of_instances_are_not_running?\n !(minimum_number_of_instances_are_running?)\n end", "def check_concurrent_tasks\n max_tasks = max_concurrent_tasks || Settings.transformation.limits.max_concurrent_tasks_per_conversion_host\n active_tasks.count < max_tasks\n end", "def stop_if_u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /counties GET /counties.json
def index @counties = Entity.where(entity_type: 'County').order(:entity_name) respond_with(@counties) end
[ "def counties\n @retailer = Retailer.find(params[:retailer_id])\n @counties = Spree::County.find_all_by_state_id(@retailer.physical_address.state_id)\n end", "def get_counties state_id\n request(\"Local.getCounties\", \"stateId\" => state_id)\n end", "def get_counties\n @counseling...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
As a test, only publish if they are a living legend
def set_published_state self.published = payload["isLivingLegend"] end
[ "def show_legend; end", "def legend; end", "def non_generic_charts_available?\n false\n end", "def use_hidden_layers?\n end", "def on_has_external_subset\n end", "def process_legend_input(input)\n process_boolean_input(input, :legend_extend)\n end", "def on_has_external_subset\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
To generate quartiles (1/4, 2/4, 3/4): gen_probs(4)
def gen_probs(num, from=0, to=1) step = (to - from) / num.to_f ((from + step)...to).step(step).to_a end
[ "def get_quartiles(scores)\n quartile_size = scores.length / 4\n for i in 0..3\n total=0\n (i*quartile_size .. ((i+1)*(quartile_size))-1).each{|x| total+=scores[x]}\n yield total\n end\n end", "def get_quartiles(scores)\r\n (0..scores.length-1).each do |i|\r\n sum = 0\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates weighted quantiles. The +data+ is a list of pairs of values and their corresponding weight: [10, 4], [20, 3], [30, 2]
def wquantiles(data, probs=QUARTILES) grouped = data.group_by(&:first).map { |a, b| [a, b.reduce(0) { |sum, e| sum + e.last }] } values, weights = grouped.sort_by(&:first).transpose sum = 0 cum_weights = weights.map { |e| sum += e } probs.map do |prob| h = 1 + (sum - 1) * prob mod = h % 1 k1 = ...
[ "def wmean_quantiles(data, probs=QUARTILES)\n data = data.sort_by(&:first)\n\n total_weight = data.map(&:last).reduce(:+)\n\n if $inegi\n # The INEGI splits the data by integers of the total size divided by ten.\n # If the total size is 109, the chunks would be: 10, 10, 10, 10, 10, 10, 10, 10, 10, 19\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the Gini coefficient. The +data+ is a list of pairs of values and their corresponding weight: [10, 4], [20, 3], [30, 2]
def gini(data) sorted = data.sort_by(&:first) sum_values = 0 sum_weights = 0 # total acumulated value total = sorted.each_with_index.map do |(value, weight), i| sum_values += value * weight sum_weights += weight next_weight = (i + 1 < sorted.size) ? sorted[i + 1].last : 0 sum_values * (weight...
[ "def gini_impurity(list)\n purity = 0.0\n histogram = list.to_hist\n length = list.length.to_f \n \n # sigma( f(i,j) * f(i,k) where j != k )\n list.each do |item_j|\n list.each do |item_k|\n unless item_j == item_k\n purity += ( histogram[item_j].to_f/length * histogram[item_k].to_f/length )\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calcula la duracion de la actividad y recursivamente la de sus hijas, este metodo solo funciona cuando no se sabe aun la duracion de la actividad, es decir, cuando se calcula por primera vez
def calcular_tiempo(actividades, fecha_inicio) if self.start_time.nil? || self.end_time.nil? || self.start_time < fecha_inicio.ctime self.start_time = 0.business_hour.after(fecha_inicio) self.end_time = esfuerzo.to_i.business_hour.after(fecha_inicio) actividades.each do |a| if a.is_child_o...
[ "def recalcular_tiempo(e_participacion, actividades)\n latest_start = self.proyecto.fecha_inicio\n self.participacion += (e_participacion / 100)\n\n latest_start = self.start_time if anteriores.split(/\\s*,\\s*/).count == 0\n anteriores.split(/\\s*,\\s*/).each do |ant|\n a = Actividad.find_by(nombr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Recalcula la duracion de la actividad y recursivamente la de sus hijas cuando se asigna un nuevo trabajador a la actividad y por ello cambia la duracion de la actividad
def recalcular_tiempo(e_participacion, actividades) latest_start = self.proyecto.fecha_inicio self.participacion += (e_participacion / 100) latest_start = self.start_time if anteriores.split(/\s*,\s*/).count == 0 anteriores.split(/\s*,\s*/).each do |ant| a = Actividad.find_by(nombre: ant) l...
[ "def registro_inicio(vaca,num_horas)\n estim_reg = Time.now.advance(:hours => -num_horas.to_i).localtime\n estimate_time = estim_reg.change(:min => 0)\n return estimate_time \n end", "def trabajo(n)\n\n if entradas[n] < am_4(entradas[n])\n tiempo_amanecer = (am_4(entradas[n]) - entradas[n])...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper class method to look up all tracks for trackable class name and trackable id.
def find_tracks_for_trackable(trackable_str, trackable_id) find(:all, :conditions => ["trackable_type = ? and trackable_id = ?", trackable_str, trackable_id], :order => "created_at DESC" ) end
[ "def tracks\n @tracks ||= fetch_collection(:trackKeys, Track)\n end", "def tracks\n ids = track_keys\n return [] if not ids\n return ids.map {|id| Track.get id}\n end", "def related_tracks\n tracks = Scrobbler::Track.new(self.artist, self.source_id).similar[0..13]\n \n cat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper class method to look up a trackable object given the trackable class name and id
def find_trackable(trackable_str, trackable_id) trackable_str.constantize.find(trackable_id) end
[ "def get_object_by_id(class_name, id)\n obj = nil\n get_objects_of_class(class_name).each do |o|\n if o.id == id\n obj = o\n break\n end\n end\n obj\n end", "def get_track(id)\n return @tracks.find {|s| s.track_id == id}\n end", "def g...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a hash of attributes for the Stripe::Customer object
def customer_attributes owner = pay_customer.owner attributes = case owner.class.pay_braintree_customer_attributes when Symbol owner.send(owner.class.pay_braintree_customer_attributes, pay_customer) when Proc owner.class.pay_braintree_customer_attributes.call(pay_cus...
[ "def customer_attributes\n owner = pay_customer.owner\n\n attributes = case owner.class.pay_stripe_customer_attributes\n when Symbol\n owner.send(owner.class.pay_stripe_customer_attributes, pay_customer)\n when Proc\n owner.class.pay_stripe_customer_attributes.call(pay_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve the Braintree::Customer object If no processor_id is present, creates a Customer. When 'payment_method_token' is present, it will also set the default payment method
def customer if processor_id? customer = gateway.customer.find(processor_id) if payment_method_token? add_payment_method(payment_method_token, default: true) pay_customer.payment_method_token = nil end customer else result = gat...
[ "def customer\n stripe_customer = if processor_id?\n ::Stripe::Customer.retrieve({id: processor_id, expand: [\"tax\", \"invoice_credit_balance\"]}, stripe_options)\n else\n sc = ::Stripe::Customer.create(customer_attributes.merge(expand: [\"tax\"]), stripe_options)\n pay_cus...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /payment_entries GET /payment_entries.json
def index @payment_entries = PaymentEntry.all end
[ "def index\n @payment_entries = ReceiptEntry.all.where(\"user_id =?\", current_user.id)\n end", "def index\n @payment_methods = @user.payment_methods.page(params[:page]).per(params[:per])\n render json: @payment_methods\n end", "def index\n @payment_requests = PaymentRequest.all\n\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /payment_entries POST /payment_entries.json
def create @payment_entry = PaymentEntry.new(payment_entry_params) respond_to do |format| if @payment_entry.save format.html { redirect_to :back, notice: 'Payment entry was successfully created.' } format.json { render :show, status: :created, location: @payment_entry } else ...
[ "def index\n @payment_entries = PaymentEntry.all\n end", "def add_payment(post, payment)\n post['AccountName'] = payment.name\n post['AccountNumber'] = payment.account_number\n post['SortCode'] = payment.routing_number\n end", "def create\n @payment = Payment.new(params[:payment...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /payment_entries/1 PATCH/PUT /payment_entries/1.json
def update respond_to do |format| if @payment_entry.update(payment_entry_params) format.html { redirect_to @payment_entry, notice: 'Payment entry was successfully updated.' } format.json { render :show, status: :ok, location: @payment_entry } else format.html { render :edit } ...
[ "def update\n [:amount, :refund_amount].each do |a|\n next unless params[:payment].has_key?(a)\n params[:payment][a].gsub!(/[$,]/, \"\")\n params[:payment][a] = (params[:payment][a].to_f * 100).to_i\n end\n\n respond_to do |format|\n if @payment.update(payment_params)\n format.ht...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /payment_entries/1 DELETE /payment_entries/1.json
def destroy @payment_entry.destroy respond_to do |format| format.html { redirect_to payment_entries_url, notice: 'Payment entry was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @billing_entry.destroy\n respond_to do |format|\n format.html { redirect_to billing_entries_url }\n format.json { head :no_content }\n end\n end", "def delete_payment\n @data.our_ref = ''\n @data.handler = :handle_delete\n @data.label = 'deleted'\n get_payment\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Example: makeNegative(1); return 1 makeNegative(5); return 5 makeNegative(0); return 0
def make_negative(num) num > 0 ? -num : num end
[ "def makeNegative(num)\n if num > 0\n return num * -1\n elseif num == 0\n return 0\n else num < 0\n return num\n end\nend", "def negative(integer)\n return integer if integer * -1 > 0\n return integer * -1\nend", "def negative(number)\n if number > 0\n -number\n else\n return number\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This calls the normal Jiveapps::Helper run() method, detects if there is an error, and if there is, removes the livedev run/lock file and quits with an error.
def run(cmd) result = super(cmd) if result.error? display "FAILURE" display result.error remove_livedev_run_file exit 1 end end
[ "def remove_crash(app_name)\n user_name = %x[whoami].chomp\n crash_dir = \"/Users/\"+user_name+\"/Library/Application Support/CrashReporter\"\n crash_file = %x[find \"#{crash_dir}\" -name \"#{app_name}_*\"].chomp\n if File.exist?(crash_file)\n if $verbose == 1\n puts \"Deleting crash file: \"+crash_fi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find links of the passed in type. Example: story.link_for("html") => story.link_for("nothing") => nil Returns an the content of that link if found, or nil if not found.
def link_for(type) if link = self.links.find { |link| link.type == type } link.to_s end end
[ "def existing_links(ticket, type = \"Wiki Page\")\n ticket.remotelink\n .all\n .select { |l| l.attrs[\"relationship\"] == type }\n .map { |e| e.attrs[\"object\"][\"url\"] }\n end", "def fulltext_link(type = 'first')\n fulltext_links.each do |link|\n if link...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Write a method that returns a boolean indicating whether a string has repeating letters. Capital letters count as repeats of lowercase ones, e.g., repeating_letters?("Aa") => true
def repeating_letters?(str) # your code goes here str.downcase.chars.uniq.length != str.downcase.chars.length end
[ "def repeating_letters?(str)\n str.downcase.chars.uniq.length != str.length\nend", "def repeating_letters?(str)\n # your code goes here\n str.downcase.chars.uniq.length != str.length\nend", "def repeating_letters?(str)\n # your code goes here\n str.downcase.chars.uniq.length != str.downcase.chars.lengt...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Write a method that returns the range of a string of commaseparated integers, e.g., str_range("4,1,8") => 7
def str_range(str) split = str.split(",") minimum = split.min.to_i maximum = split.max.to_i range = maximum - minimum return range end
[ "def str_range(str)\n range(str.split(',').map{ |num_str| num_str.to_i})\nend", "def str_range(str)\n # your code goes here\n # print str.split(\",\").map{ |n| n.to_i}\n range(str.split(\",\").map{ |n| n.to_i})\nend", "def str_range(str)\n to_i = lambda { |num| num.to_i }\n nums = str.split(',').map(&to_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
EXPERT Write a method that is functionally equivalent to the rotate(offset) method of arrays. offset=1 ensures that the value of offset is 1 if no argument is provided. HINT: use the take(num) and drop(num) methods. You won't need much code, but the solution is tricky!
def my_rotate(arr, offset=1) # your code goes here drop(offset) + take(offset) end
[ "def my_rotate(arr, offset=1)\n # your code goes here\n arr.drop(offset % arr.length) + arr.take(offset % arr.length)\nend", "def my_rotate(arr, offset=1)\n # your code goes here\n arr.drop(offset%arr.length) + arr.take(offset%arr.length)\nend", "def my_rotate(arr, offset=1)\n # your code goes here\n r = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
VA file number can be up to 10 digits long; An optional leading 'c' or 'C' followed by 79 digits. The file number field on the 4142 form has space for 9 characters so trim the potential leading 'c' to ensure the file number will fit into the form without overflow.
def extract_va_file_number(va_file_number) return va_file_number if va_file_number.blank? || va_file_number.length < 10 va_file_number.sub(/^[Cc]/, '') end
[ "def file_number\n header_field_as_string 'X-VA-File-Number'\n end", "def file_number\n auth_headers.dig('X-VA-File-Number')\n end", "def dig_for_serial_number\n # Chomp extension and _F of the end of the file name leaving shot\n # seq and descriptor:\n #\n # 0024_000146_017_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Read all the lines of the file, but don't store them until we find one that satisfies sentinel
def load_data @data=[] marker_found=false @file.rewind @file.each_line do |line| if !marker_found && @sentinel.call(line) then marker_found=true end @data << line if marker_found end end
[ "def read_line_at(line_count)\n line = \"\"\n (0...line_count).each do |idx|\n line = @file.gets\n \n while line && line.strip == \"\"\n line = @file.gets\n end\n \n if line.nil? # reached the end of the file\n reset...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return body for display as HTML
def get_body_for_html_display text = self.body.strip text = CGI.escapeHTML(text) text = MySociety::Format.make_clickable(text, :contract => 1) text = text.gsub(/\n/, '<br>') return text end
[ "def body\n @body ||= Page.convert_raw_to_html(raw_body)\n end", "def render_body\r\n @rendered_body\r\n end", "def body\n render text: fetch_email(params[:id]).body, content_type: 'text/html'\n end", "def html_safe_body\n safe_body = RedCloth.new(body)\n safe_body.filter_html = true\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Starts all of the writers, then starts the reader. Child readers must call this to make sure the writers are all running and ready for data before the reader starts pushing data onto its Channel.
def start(callback) start_loop = EM.tick_loop do if @writers.empty? || @writers.all?(&:running?) :stop end end start_loop.on_stop { callback.call } log "Starting writers for reader #{self.__id__}..." EM::Iterator.new(@writers).each do |writer, ite...
[ "def start\n read_thread = Thread.new { read(@irc) }\n write_thread = Thread.new { dequeue_replies }\n read_thread.join\n write_thread.join\n end", "def write_incoming_messages_to_child_processes(master_reader, client_writers)\n Thread.new do\n while incoming = master_reader.gets\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
One method of adding a Writer to the Reader. Use this method to add an a) already instantiated Writer object, or b) a Writers from a class of Writer objects.
def add_writer(obj, *args) if obj.is_a? Class @writers << obj.new(*args, @write_to_channel) elsif obj.kind_of?(Pants::Writers::BaseWriter) || obj.kind_of?(Pants::Seam) @writers << obj else raise Pants::Error, "Don't know how to add a writer of type #{obj.class}" ...
[ "def <<(reader_or_munge_or_writer)\n case reader_or_munge_or_writer\n when Reader\n @readers << reader_or_munge_or_writer\n when Munge\n @munges << reader_or_munge_or_writer\n when Writer\n @writers << reader_or_munge_or_writer\n else\n fail \"You must add a Read...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes a writer object from the internal list of writers.
def remove_writer(obj, key_value_pairs=nil) if obj.is_a? Class @writers.delete_if do |writer| writer.is_a?(obj) && key_value_pairs.all? { |k, v| writer.send(k) == v } end elsif obj.is_a? String writer = begin uri = obj.is_a?(URI) ? obj ...
[ "def remove_writer(arg)\n chg_permission(writers, arg, :remove)\n end", "def remove_watcher(watcher)\n @watcher_lock.synchronize do\n @watchers.delete_if {|th| th == watcher}\n end\n end", "def remove( name ) @appenders.delete(name) end", "def remove!\n @queue_for_remova...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Allows for adding a Pants::Seam (or child) object to the reader's list of internal writers. For more info on Seams, see the docs for Pants::Seam.
def add_seam(klass, *args) @writers << klass.new(@core_stopper_callback, @write_to_channel, *args) @writers.last end
[ "def register(writer)\n writers.push writer\n end", "def add_writer(obj, *args)\n if obj.is_a? Class\n @writers << obj.new(*args, @write_to_channel)\n elsif obj.kind_of?(Pants::Writers::BaseWriter) || obj.kind_of?(Pants::Seam)\n @writers << obj\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add category into item_id
def add_categories_into_items(category_id) client = create_db_client client.query("insert into item_categories values (#{@id}, #{category_id})") end
[ "def add_category(category)\r\n OpportunityCategory.create(opportunity_id: opportunity_id, category: category)\r\n end", "def update_category_counter\n category = item.category\n category.update_items_counter if category\n end", "def add_to_category\n @product = Product.find(params[:id])\n @cat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /myers_briggs_types GET /myers_briggs_types.xml
def index @myers_briggs_types = MyersBriggsType.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @myers_briggs_types } end end
[ "def show\n @myers_briggs_type = MyersBriggsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @myers_briggs_type }\n end\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /myers_briggs_types/1 GET /myers_briggs_types/1.xml
def show @myers_briggs_type = MyersBriggsType.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @myers_briggs_type } end end
[ "def index\n @myers_briggs_types = MyersBriggsType.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @myers_briggs_types }\n end\n end", "def new\n @myers_briggs_type = MyersBriggsType.new\n\n respond_to do |format|\n format.html # n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /myers_briggs_types/new GET /myers_briggs_types/new.xml
def new @myers_briggs_type = MyersBriggsType.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @myers_briggs_type } end end
[ "def new\n @boat_type = BoatType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boat_type }\n end\n end", "def new\n @brew_type = BrewType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @br...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /myers_briggs_types POST /myers_briggs_types.xml
def create @myers_briggs_type = MyersBriggsType.new(params[:myers_briggs_type]) respond_to do |format| if @myers_briggs_type.save flash[:notice] = 'Myers Briggs Type was successfully created.' format.html { redirect_to(@myers_briggs_type) } format.xml { render :xml => @myers_brig...
[ "def index\n @myers_briggs_types = MyersBriggsType.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @myers_briggs_types }\n end\n end", "def new\n @myers_briggs_type = MyersBriggsType.new\n\n respond_to do |format|\n format.html # n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /myers_briggs_types/1 PUT /myers_briggs_types/1.xml
def update @myers_briggs_type = MyersBriggsType.find(params[:id]) respond_to do |format| if @myers_briggs_type.update_attributes(params[:myers_briggs_type]) flash[:notice] = 'Myers Briggs Type was successfully updated.' format.html { redirect_to(@myers_briggs_type) } format.xml {...
[ "def update\n @boat_type = BoatType.find(params[:id])\n\n respond_to do |format|\n if @boat_type.update_attributes(params[:boat_type])\n format.html { redirect_to(@boat_type, :notice => 'Boat type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /myers_briggs_types/1 DELETE /myers_briggs_types/1.xml
def destroy @myers_briggs_type = MyersBriggsType.find(params[:id]) @myers_briggs_type.destroy respond_to do |format| format.html { redirect_to(myers_briggs_types_url) } format.xml { head :ok } end end
[ "def destroy\n @boat_sub_type = BoatSubType.find(params[:id])\n @boat_sub_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(boat_sub_types_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @bid_type = BidType.find(params[:id])\n @bid_type.destroy\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /displays/1 GET /displays/1.xml
def show @display = Display.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @display } end end
[ "def index\n @displays = Display.all\n end", "def show\r\n @systems = System.find(params[:id])\r\n respond_to do |format|\r\n format.html #show.html.erb\r\n format.xml { render :xml => @systems.to_xml(:dasherize => false) }\r\n end\r\n end", "def show\n @url_monitor = subdomain.url_mo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /displays/new GET /displays/new.xml
def new @display = Display.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @display } end end
[ "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @host }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @system }\n end\n end", "def new\n @title = \"Ne...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /displays POST /displays.xml
def create @display = Display.new(params[:display]) respond_to do |format| if @display.save flash[:notice] = 'Display was successfully created.' format.html { redirect_to(@display) } format.xml { render :xml => @display, :status => :created, :location => @display } else ...
[ "def index\n @displays = Display.all\n end", "def create_display(opts = {})\n post 'commandcenter/displays', opts\n end", "def create\n @display = Display.new(display_params)\n\n respond_to do |format|\n if @display.save\n format.html { redirect_to @display, notice: 'Displa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /displays/1 PUT /displays/1.xml
def update @display = Display.find(params[:id]) respond_to do |format| if @display.update_attributes(params[:display]) flash[:notice] = 'Display was successfully updated.' format.html { redirect_to(@display) } format.xml { head :ok } else format.html { render :actio...
[ "def update_display(display_id, opts = {})\n put \"commandcenter/displays/#{display_id}\", opts\n end", "def update\n @display = Display.find(params[:id])\n\n respond_to do |format|\n if @display.update_attributes(params[:display])\n flash[:notice] = 'Display mis a jour!.'\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /displays/1 DELETE /displays/1.xml
def destroy @display = Display.find(params[:id]) @display.destroy respond_to do |format| format.html { redirect_to(displays_url) } format.xml { head :ok } end end
[ "def delete_display(display_id)\n delete \"commandcenter/displays/#{display_id}\"\n end", "def destroy\n @display = Display.find(params[:id])\n @display.destroy\n\n respond_to do |format|\n format.html { redirect_to displays_url }\n format.json { head :no_content }\n end\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new map. Parameters: [t_w] The width of the tiles. [t_h] The height of the tiles. [t_x_count] The horizontal count of tiles in the map. [t_y_count] The vertical count of tiles in the map. [scr_w] Width of the viewport for the map. [scr_h] Height of the viewport for the map. [isometric] Whether to use a isomet...
def initialize(t_w, t_h, t_x_count, t_y_count, scr_w = 800, scr_h = 600, isometric = false, limit_cam = true) @tile_size = Vector.new t_w, t_h @size = Vector.new t_x_count, t_y_count @cam = Rectangle.new 0, 0, scr_w, scr_h @limit_cam = limit_cam @isometric = isometric if isometric ...
[ "def initialize(map, viewport)\n @name = map.delete('name')\n\n @width = {\n :pixels => viewport.delete(:width),\n :tiles => map.delete('width').to_i\n }\n @height = {\n :pixels => viewport.delete(:height),\n :tiles => map.delete('height').to_i\n }\n\n warn_for_size\n\n @tra...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a Vector with the coordinates of the center of the map.
def get_center abs_size = get_absolute_size Vector.new(abs_size.x * 0.5, abs_size.y * 0.5) end
[ "def center_map\n @offset.x = normalize(center.x - width / 2) * @tile_size\n @offset.y = normalize(center.y - height / 2) * @tile_size\n end", "def getCenter\n\t\tbox = self.bbox\n\t\t[ (box[0] + box[2])/2, (box[1] + box[3])/2 ]\n\tend", "def center\n [lat, long]\n end", "def center\n x =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the position in the screen corresponding to the given tile indices. Parameters: [map_x] The index of the tile in the horizontal direction. It must be in the interval 0..t_x_count. [map_y] The index of the tile in the vertical direction. It must be in the interval 0..t_y_count.
def get_screen_pos(map_x, map_y) return Vector.new(map_x * @tile_size.x - @cam.x, map_y * @tile_size.y - @cam.y) unless @isometric Vector.new ((map_x - map_y - 1) * @tile_size.x * 0.5) - @cam.x + @x_offset, ((map_x + map_y) * @tile_size.y * 0.5) - @cam.y end
[ "def get_tile_position(x, y)\n spacing = Vector2.new((assets.tile_width/2.0).round, (assets.tile_height/2.0).round)\n Vector2.new((-x * spacing.x) + (y * spacing.x) - y + x,\n (x * spacing.y) + (y*spacing.y) - y - x)\n end", "def get_tile_at position\n c = get_map_cell position\n @map[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the tile in the map that corresponds to the given position in the screen, as a Vector, where x is the horizontal index and y the vertical index. Parameters: [scr_x] The xcoordinate in the screen. [scr_y] The ycoordinate in the screen.
def get_map_pos(scr_x, scr_y) return Vector.new((scr_x + @cam.x) / @tile_size.x, (scr_y + @cam.y) / @tile_size.y) unless @isometric # Gets the position transformed to isometric coordinates v = get_isometric_position scr_x, scr_y # divides by the square size to find the position in the matrix ...
[ "def get_screen_pos(map_x, map_y)\n return Vector.new(map_x * @tile_size.x - @cam.x, map_y * @tile_size.y - @cam.y) unless @isometric\n Vector.new ((map_x - map_y - 1) * @tile_size.x * 0.5) - @cam.x + @x_offset,\n ((map_x + map_y) * @tile_size.y * 0.5) - @cam.y\n end", "def get_tile_a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Verifies whether a tile is inside the map. Parameters: [v] A Vector representing the tile, with x as the horizontal index and y as the vertical index.
def is_in_map(v) v.x >= 0 && v.y >= 0 && v.x < @size.x && v.y < @size.y end
[ "def is_tile_flipped_v?(x, y)\n false\n end", "def tile_exists_at? position\n c = get_map_cell position\n c[0] >=0 and c[0] <@width-1 and c[1] >=0 and c[1] <=@height-1\n end", "def check_building(building, x, y)\n (0..Unit.tile_width(building) - 1).each do |dx|\n (0..Unit.tile_height(buil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the top left corner of the viewport to the given position of the map. Note that this is not the position in the screen. Parameters: [cam_x] The xcoordinate inside the map, in pixels (not a tile index). [cam_y] The ycoordinate inside the map, in pixels (not a tile index).
def set_camera(cam_x, cam_y) @cam.x = cam_x @cam.y = cam_y set_bounds end
[ "def set_camera player_x, player_y\n\n # Start by putting the player in the middle of the screen\n @camera_x = player_x - ( SCREEN_WIDTH / 2 )\n @camera_y = player_y - ( SCREEN_HEIGHT / 2 )\n\n # Then normalise so that we don't sail off the edge of the world\n if @camera_x < 0\n @camera_x = 0\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Moves the viewport by the given amount of pixels. Parameters: [x] The amount of pixels to move horizontally. Negative values will cause the camera to move to the left. [y] The amount of pixels to move vertically. Negative values will cause the camera to move up.
def move_camera(x, y) @cam.x += x @cam.y += y set_bounds end
[ "def move x, y; @x += x; @y += y; end", "def moveto(x, y)\n # center screen upon player\n center(x, y)\n # empty movement command buffer\n update_buffer(nil)\n # move each actor to the same position\n (@actors - [player]).each {|actor| actor.moveto(x, y)}\n end", "def change_vie...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /hhcodes/1 GET /hhcodes/1.json
def show @hhcode = Hhcode.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @hhcode } end end
[ "def get_by_code(code)\n HttpClient::Preconditions.assert_class('code', code, String)\n r = @client.request(\"/harmonization/codes/#{CGI.escape(code)}\").get\n ::Io::Flow::V0::Models::HsCode.new(r)\n end", "def new\n @hhcode = Hhcode.new\n\n respond_to do |format|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /hhcodes/new GET /hhcodes/new.json
def new @hhcode = Hhcode.new respond_to do |format| format.html # new.html.erb format.json { render json: @hhcode } end end
[ "def new\n @title = t('view.codes.new_title')\n @code = Code.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @code }\n end\n end", "def new\n @code = Code.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { ren...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /hhcodes POST /hhcodes.json
def create @hhcode = Hhcode.new(params[:hhcode]) respond_to do |format| if @hhcode.save format.html { redirect_to @hhcode, notice: 'Hhcode was successfully created.' } format.json { render json: @hhcode, status: :created, location: @hhcode } else format.html { render action:...
[ "def new\n @hhcode = Hhcode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hhcode }\n end\n end", "def create_phaxcode(options)\n send_post(\"/createPhaxCode\", options)\n end", "def create\n @hab_code = HabCode.new(hab_code_params)\n\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /hhcodes/1 PUT /hhcodes/1.json
def update @hhcode = Hhcode.find(params[:id]) respond_to do |format| if @hhcode.update_attributes(params[:hhcode]) format.html { redirect_to @hhcode, notice: 'Hhcode was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } ...
[ "def update\n @event_code = EventCode.find(params[:id])\n\n if @event_code.update(event_code_params)\n head :no_content\n else\n render json: @event_code.errors, status: :unprocessable_entity\n end\n end", "def hput(path, data)\n\t\t\trequest = Net::HTTP::Put.new(\"#{@server.path}#{path}\")...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /hhcodes/1 DELETE /hhcodes/1.json
def destroy @hhcode = Hhcode.find(params[:id]) @hhcode.destroy respond_to do |format| format.html { redirect_to hhcodes_url } format.json { head :no_content } end end
[ "def destroy\n @hab_code.destroy\n respond_to do |format|\n format.html { redirect_to hab_codes_url, notice: 'Hab code was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @code = Code.find(params[:id])\n @code.destroy\n\n respond_to do |forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Confirms an professor user.
def professor_user unless this_is_professore?(current_user) flash[:danger] = "You don't have the rights for this action." redirect_to(root_url) end end
[ "def professor_user\n unless this_is_professore?(current_user)\n flash[:danger] = \"You don't have the rights for this page.\"\n redirect_to(root_url)\n end\n end", "def is_professor?\n return (role == 1)\n end", "def professor?\n if current_user.role == 'Professor'...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Serializes the item stack into two ENV variables. This is done to preserve backward compatibility with earlier versions of cli/ui. This ensures that any code that relied upon previous stack behavior should continue to work.
def serialize(items) colors = [] styles = [] items.each do |item| colors << item.color.name styles << item.frame_style.name end ENV[COLOR_ENVVAR] = colors.join(':') ENV[STYLE_ENVVAR] = styles.join(':') end
[ "def stack(app_env)\n name, env = app_env.split(SEPARATOR)\n stack = settings['stack'] || {}\n (stack[name] && stack[name][env]) || stack['all']\n end", "def stack(app_env)\n name, env = app_env.split(SEPERATOR)\n stacks = self.settings['stacks'] || {}\n stacks[name].try(\"[]\", e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the default image ID for the compute provider's given region.
def default_image_id region_name = config[:compute_provider]["#{config[:compute_provider][:name]}_region".to_sym] region_map = images.fetch('regions', {}).fetch(region_name, {}) image_id = region_map && region_map[instance.platform.name] if image_id.nil? error("Could not deter...
[ "def default_image\n return @default_image_id unless @default_image_id.nil?\n @default_image_id = Fog.credentials[:brightbox_default_image] || select_default_image\n end", "def default_flavor_id\n flavor_id = images['default_flavor_id']\n\n if flavor_id.nil?\n error...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve provider's default flavor id from image map
def default_flavor_id flavor_id = images['default_flavor_id'] if flavor_id.nil? error("Could not determine default flavor_id for platform #{instance.platform.name} via #{config[:compute_provider][:name]}") end flavor_id end
[ "def default_image_id\n region_name = config[:compute_provider][\"#{config[:compute_provider][:name]}_region\".to_sym]\n region_map = images.fetch('regions', {}).fetch(region_name, {})\n image_id = region_map && region_map[instance.platform.name]\n\n if image_id.nil?\n error(\"C...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
submits time out to timesheet table
def submit_time_out(user_id,time,date) db_params = { host: ENV['host'], port: ENV['port'], dbname: ENV['dbname'], user: ENV['user'], password: ENV['password'] } db = PG::Connection.new(db_params) # db.exec("UPDATE info SET status= 'out' WHERE user_id ...
[ "def cancel_timeout; end", "def timeout_after(time); end", "def timed_out\r\n self.to_inactive\r\n end", "def timeout(time, *args); end", "def timeout(*) end", "def set_Timeout(value)\n set_input(\"Timeout\", value)\n end", "def timer_timed_out\n self.log(\"Globaler Timer is...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }