query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
GET /address_ranges/1 GET /address_ranges/1.xml | def show
@address_range = AddressRange.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @address_range }
end
end | [
"def index\n @address_ranges = AddressRange.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @address_ranges }\n end\n end",
"def new\n @address_range = AddressRange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /address_ranges/new GET /address_ranges/new.xml | def new
@address_range = AddressRange.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @address_range }
end
end | [
"def create\n @address_range = AddressRange.new(params[:address_range])\n\n respond_to do |format|\n if @address_range.save\n format.html { redirect_to(@address_range, :notice => 'Address range was successfully created.') }\n format.xml { render :xml => @address_range, :status => :created,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /address_ranges POST /address_ranges.xml | def create
@address_range = AddressRange.new(params[:address_range])
respond_to do |format|
if @address_range.save
format.html { redirect_to(@address_range, :notice => 'Address range was successfully created.') }
format.xml { render :xml => @address_range, :status => :created, :location ... | [
"def index\n @address_ranges = AddressRange.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @address_ranges }\n end\n end",
"def set_Addresses(value)\n set_input(\"Addresses\", value)\n end",
"def new\n @address_range = AddressRange... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /address_ranges/1 PUT /address_ranges/1.xml | def update
@address_range = AddressRange.find(params[:id])
respond_to do |format|
if @address_range.update_attributes(params[:address_range])
format.html { redirect_to(@address_range, :notice => 'Address range was successfully updated.') }
format.xml { head :ok }
else
forma... | [
"def create\n @address_range = AddressRange.new(params[:address_range])\n\n respond_to do |format|\n if @address_range.save\n format.html { redirect_to(@address_range, :notice => 'Address range was successfully created.') }\n format.xml { render :xml => @address_range, :status => :created,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /address_ranges/1 DELETE /address_ranges/1.xml | def destroy
@address_range = AddressRange.find(params[:id])
@address_range.destroy
respond_to do |format|
format.html { redirect_to(address_ranges_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to(addresses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n # @address = Address.find(params[:id])\n @address = Address.find_by_permalink!(params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns INTEGER counting days in current month. | def days_in_current_month
current_month = Time.now.month
current_year = Time.now.year
return Time.days_in_month(current_month, current_year)
end | [
"def days_in_month\n raw = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][self.month]\n self.month == 2 && leap_year? ? raw + 1 : raw\n end",
"def days_in_month\n Time.send(\"month_days\", self.year, self.month)\n end",
"def monthdays; end",
"def day_of_month\n return ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Moves the current history pointer to the previous element (that is one step further in the past) and returns the newly pointed element. | def prev
@history_idx += 1 if @history_idx < @history.length - 1
current
end | [
"def previous\n raise 'No such element' if @size == 0\n @current = @current.previous\n end",
"def previous_history()\r\n @history_offset!=0 ? @the_history[@history_offset-=1] : nil\r\n end",
"def get_previous\n unless @position == 0\n previous_command = @history[@position]\n @p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Moves the current history pointer to the next element (thaat is one step closer to the presetn) and returns the newly pointed element | def next
@history_idx -= 1 if @history_idx > -1
current
end | [
"def next_history()\r\n (@history_offset == @history_length) ? nil : @the_history[@history_offset+=1]\r\n end",
"def get_next\n unless @position == @history.length - 1\n @position += 1\n next_command = @history[@position]\n return next_command\n else\n return nil\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resets the history pointer to the buffer element (that is the one before the first stored history element) | def rewind
@history_idx = -1
end | [
"def reset_history\n @@history = []\n end",
"def invalidate_history!\n @history = nil\n end",
"def history\r\n @_buffer\r\n end",
"def clear_history\n Readline::HISTORY.clear\n end",
"def clear_history\n while ! Readline::HISTORY.empty? do\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove the contents of this history object and rereads the contents from the specified file if possible | def reset(filename)
@history = []
@history_idx = -1
unless filename.nil? or !File.exists? filename
@history = File.readlines(filename).map { |l| l.rstrip }.reverse
end
@backend = File.open filename, "a+" unless filename.nil?
end | [
"def remove_related_file(file)\n @related_files.delete(file)\n @dirty = true\n end",
"def clearHistory\r\n\t\tFile.truncate(\"history.txt\",0)\r\n\tend",
"def remove file\n file.delete\n @files -= [file]\n end",
"def file_revert(file, ref)\n if file_revisions(file).map { |r| r[:commit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
finds an executable in a bin/ subdirectory of kit | def find_executable(name)
@project.from_directory do
Find.find("kit") do |path|
next unless path =~ /bin\/#{name}$/
log.debug("found #{name} executable: #{path}")
return path
end
end
log.debug("#{name} executable not found")
nil
end | [
"def find_executable(name)\n @project.from_directory do\n Find.find(\"kit\") do |path|\n next unless path =~ /bin\\/#{name}$/\n\n log.debug(\"found #{name} executable: #{path}\")\n return path\n end\n end\n\n log.debug(\"#{name} executable not found\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
runs an external executable, returns true on success | def run_executable(full_commandline)
log.debug "running #{full_commandline}"
Process.wait(Process.spawn(full_commandline))
$CHILD_STATUS.exitstatus == 0
end | [
"def check_for_executable; end",
"def executable?() end",
"def run_program(exe_file, args = [])\n\tstr = exe_file + args.join(' ')\n\treturn system str.strip\nend",
"def run(command)\n result = system(command)\n raise(\"error, process exited with status #{$?.exitstatus}\") unless result\nend",
"def execut... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the PortalState object | def portal_state
PortalState.new(@attributes.fetch('portalstate', {}))
end | [
"def portal\n @portal\n end",
"def state\n State.instance\n end",
"def state\n return @state\n end",
"def state\n @state ||= getStateData()\n end",
"def game_state; @game_object.game_state; end",
"def active_pal \n object.current_pal\n end",
"def loc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the SoftwareUpdate object | def software_update
SoftwareUpdate.new(@attributes.fetch('swupdate', {}))
end | [
"def software_update_status_summary()\n return MicrosoftGraph::DeviceManagement::SoftwareUpdateStatusSummary::SoftwareUpdateStatusSummaryRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def software_update_status_summary\n return @software_update_status_summ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the WhitelistUsers collection | def whitelist_users
WhitelistUsers.new(@attributes.fetch('whitelist', {}))
end | [
"def list_users\n response = Flareshow::Service.query({:flows=>{:id => self.id, :limit => 1, :include=>['users']}})\n (Flareshow::CacheManager.assimilate_resources(response[\"resources\"]) || {})[\"users\"]\n end",
"def get_whitelist\n return FavouriteGroup.find(:first, :conditions => { :user_id => self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the DHCP status | def dhcp
@attributes.fetch('dhcp', false)
end | [
"def dhcp?\n config[\"dhcp\"]\n end",
"def get_dhcp_status(server_id, opts = {})\n data, _status_code, _headers = get_dhcp_status_with_http_info(server_id, opts)\n return data\n end",
"def get_dhcp_status(server_id, opts = {})\n data, _status_code, _headers = get_dhcp_status_with_http_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /book_commentaries GET /book_commentaries.json | def index
@book_commentaries = BookCommentary.all
end | [
"def index\n if params[:user_id]\n @comments = find_user.comments\n render json: @comments\n elsif params[:book_id]\n @comments = find_book.comments\n render json: @comments\n else\n @comments = Comment.all\n render json: @comments\n end\n end",
"def index\n @comm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /book_commentaries POST /book_commentaries.json | def create
@book_commentary = BookCommentary.new(book_commentary_params)
respond_to do |format|
if @book_commentary.save
format.html { redirect_to @book_commentary.book, notice: 'Book commentary was successfully created.' }
format.json { render :show, status: :created, location: @book_com... | [
"def create\n @comment_book = CommentBook.new(comment_book_params)\n @comment_book.user_id = current_user.id\n respond_to do |format|\n if @comment_book.save\n format.html { redirect_to @comment_book, notice: 'Comment book was successfully created.' }\n format.json { render :show, status... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /book_commentaries/1 PATCH/PUT /book_commentaries/1.json | def update
respond_to do |format|
if @book_commentary.update(book_commentary_params)
format.html { redirect_to @book_commentary.book, notice: 'Book commentary was successfully updated.' }
format.json { render :show, status: :ok, location: @book_commentary }
else
format.html { ren... | [
"def update\n respond_to do |format|\n if @comment_book.update(comment_book_params)\n format.html { redirect_to @comment_book, notice: 'Comment book was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment_book }\n else\n format.html { render :edit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /book_commentaries/1 DELETE /book_commentaries/1.json | def destroy
@book_commentary.destroy
respond_to do |format|
format.html { redirect_to book_commentaries_url, notice: 'Book commentary was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @comment_book.destroy\n respond_to do |format|\n format.html { redirect_to comment_books_url, notice: 'Comment book was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @commentary.destroy\n respond_to do |format|\n format.htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When compile_time is defined, apply the action immediately and then set the action :nothing to ensure that it does not run a second time. | def after_created
if compile_time
self.run_action(:apply)
self.action :nothing
end
end | [
"def after_created\n if compile_time\n self.run_action(:apply)\n self.action(:nothing)\n end\nend",
"def run_now(resource = nil)\n resource ||= self\n actions = Array(resource.action)\n Chef::Log.debug \"Immediate execution of #{resource.name} #{actions}\"\n resource.action(:nothing)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /pincodes GET /pincodes.json | def index
@pincodes = Pincode.all
end | [
"def index\n @pincode = Pincode.order(:name).where(\"pin_number ilike ?\", \"%#{params[:term]}%\") if params[:term]\n respond_to do |format|\n format.json { render json: @pincode.map(&:pin_number) }\n end\n # render the landing page\n end",
"def index\n @pins = Pin.all\n render json: @pins... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /pincodes POST /pincodes.json | def create
@pincode = Pincode.new(pincode_params)
respond_to do |format|
if @pincode.save
#format.html { redirect_to @pincode, notice: 'Pincode was successfully created.' }
format.html { redirect_to @pincode}
format.json { render :show, status: :created, location: @pincode }
... | [
"def create\n @pincode = Pincode.new(pincode_params)\n\n respond_to do |format|\n if @pincode.save\n format.html { redirect_to @pincode, notice: \"Pincode was successfully created.\" }\n format.json { render :show, status: :created, location: @pincode }\n else\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /pincodes/1 PATCH/PUT /pincodes/1.json | def update
respond_to do |format|
if @pincode.update(pincode_params)
format.html { redirect_to @pincode, notice: 'Pincode was successfully updated.' }
format.json { render :show, status: :ok, location: @pincode }
else
format.html { render :edit }
format.json { render json... | [
"def update\n respond_to do |format|\n if @pincode.update(pincode_params)\n format.html { redirect_to @pincode, notice: 'Pincode was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pinco... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /pincodes/1 DELETE /pincodes/1.json | def destroy
@pincode.destroy
respond_to do |format|
format.html { redirect_to pincodes_url, notice: 'Pincode was successfully destroyed.' }
format.json { head :no_content }
token = session[:access_token]
url = URI.parse(ENDPOINTS_URI)
req = Net::HTTP::Get.new(url.request_uri)
... | [
"def destroy\n @pincode.destroy\n respond_to do |format|\n format.html { redirect_to pincodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pincode.destroy\n respond_to do |format|\n format.html { redirect_to pincodes_url, notice: \"Pincode was successfully ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lock the hour if explicitly set by hour_of_day, but allow for the nearest hour during DST start to keep the correct interval. | def validate_hour_lock(time, schedule)
hour = value || schedule.start_time.send(type)
hour = 24 + hour if hour < 0
if hour >= time.hour
hour - time.hour
else
if dst_offset = TimeUtil.dst_change(time)
hour - time.hour + dst_offset
else
24 - time.hour + ... | [
"def lockOnHour(t)\n l = lockedAt\n return false if t.to_date < l.to_date || t.hour <= l.hour\n\n updateLock(t)\n true\n end",
"def validate_hour_lock(time, schedule)\n h0 = starting_unit(schedule.start_time)\n h1 = time.hour\n if h0 >= h1\n h0 - h1\n else\n if dst_o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For monthly rules that have no specified day value, the validation relies on the schedule start time and jumps to include every month even if it has fewer days than the schedule's start day. Negative day values (from month end) also include all months. Positive day values are taken literally so months with fewer days w... | def validate_day_lock(time, schedule)
days_in_month = TimeUtil.days_in_month(time)
date = Date.new(time.year, time.month, time.day)
if value && value < 0
start = TimeUtil.day_of_month(value, date)
month_overflow = days_in_month - TimeUtil.days_in_next_month(time)
elsif value && ... | [
"def day_of_month(*days)\n @validations[:day_of_month] ||= []\n @validation_types[:day_of_month] ||= IceCube::DayOfMonthValidation.new(self)\n days.each do |day|\n raise ArgumentError.new('Argument must be a valid date') if day.abs > 31 \n raise ArgumentError.new('Argument must be non-zero') if d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
associate messages into a thread. assumes the messages are only between two people, and there cannot be any variation in from/to address names (i ignore the numbers, since sometimes they change slightly) | def threadify(messages)
last_id = {}
messages.map do |message|
last_id[message.from[0]] = message.message_id
message.in_reply_to = last_id[message.to[0]]
message
end
end | [
"def create_new_thread(params = {})\n thread = self.create(:subject => params[:subject])\n message = options[:message_class].constantize.create({\n :thread => thread,\n :sender => params[:sender],\n :body => params[:body]\n })\n recipients = (params[:recipients... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks whether auto validations are currently disabled (see +disable_auto_validations+ method that takes a block) | def disabled_auto_validations?
@disable_auto_validations || false
end | [
"def without_auto_validations\n previous, @disable_auto_validations = @disable_auto_validations, true\n yield\n ensure\n @disable_auto_validations = previous\n end",
"def without_auto_validations\n previous, @disable_auto_validations = @disable_auto_validations, true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Disable generation of validations for the duration of the given block | def without_auto_validations
previous, @disable_auto_validations = @disable_auto_validations, true
yield
ensure
@disable_auto_validations = previous
self
end | [
"def without_auto_validations\n previous, @disable_auto_validations = @disable_auto_validations, true\n yield\n ensure\n @disable_auto_validations = previous\n end",
"def invalid_blocks\n\t\treturn self.chain.reject( &:valid? )\n\tend",
"def eval_validation_directives_block(state,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pwrake version of backquote command | def pwrake_backquote(cmd)
conn = Pwrake::Shell.current
if conn.kind_of?(Pwrake::Shell)
res = conn.backquote(*cmd)
status = Rake::PseudoStatus.new(conn.status)
else
res = `#{cmd}`
status = $?
status = Rake::PseudoStatus.new(1) if status.nil?
end
... | [
"def quote_cmd cmd\n cmd = [*cmd].join(\" \")\n \"'#{cmd.gsub(/'/){|s| \"'\\\\''\"}}'\"\n end",
"def shell_escape_cmd( cmd ) # :doc:\n cmd.gsub( /[\"$`\\\\]/ ) { |c| '\\\\' + c }\n end",
"def shell_quote(str)\n \"\\\"#{str.gsub(/\\\\/){ '\\\\\\\\' }.gsub(/[\"]/){ \"\\\\\\\"\" }}\\\"\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all patients with a viral load in the selected range and the regimens they are on the given point in time. | def patients
Observation.select('patient_id, birthdate, patient_current_regimen(patient_id, obs_datetime) as regimen')
.joins(:encounter)
.joins('INNER JOIN person USING (person_id)')
.where(concept_id: ConceptName.find_by_name('Viral load').concept_id,
... | [
"def find_visiting_patients(date)\n day_start, day_end = TimeUtils.day_bounds(date)\n query = <<~SQL\n SELECT patient.* FROM patient INNER JOIN encounter USING (patient_id)\n WHERE encounter.encounter_datetime BETWEEN ? AND ?\n AND encounter.encounter_type NOT IN (\n SELECT encounte... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Insert game_object into the map | def insert(game_object)
start_x = ( game_object.bb.left / @grid[0] ).to_i
stop_x = ( game_object.bb.right / @grid[0] ).to_i
(start_x ... stop_x).each do |x|
start_y = ( game_object.bb.top / @grid[1] ).to_i
stop_y = ( game_object.bb.bottom / @grid[1] ).to_i
... | [
"def place_object\n @board.place_object *next_position\n end",
"def add_game_object(obj)\n $window.current_state.add_game_object(obj)\n end",
"def add_gameobject(gameobject)\r\n @gameobjects_by_uuids[gameobject.uuid] = gameobject\r\n return\r\n end",
"def insert(object)\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes a specific game object from the map, replace the cellvalue with nil | def delete(game_object)
range_x, range_y = @game_object_positions[game_object]
return unless range_x && range_y
range_x.each do |x|
range_y.each do |y|
@map[x][y] = nil
end
end
end | [
"def remove_at!(coordinate)\n return nil unless on_board?(coordinate)\n\n figure = @board[coordinate.y][coordinate.x]\n @board[coordinate.y][coordinate.x] = nil\n figure\n end",
"def clear(point)\n @map.cell_at(point).clear\n end",
"def remove_cell(x, y)\n #@current_state.delete_if {|key... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clear the game object residing in the cell given by real world coordinates x/y | def clear_at(x, y)
lookup_x = (x / @grid[0]).to_i
lookup_y = (y / @grid[1]).to_i
@map[lookup_x][lookup_y] = nil
end | [
"def clear(x,y)\n if getsq(x,y)[:mine]\n @game_over=true\n else\n reveal(x,y)\n end\n end",
"def clear(point)\n @map.cell_at(point).clear\n end",
"def remove_cell(x, y)\n #@current_state.delete_if {|key, value| value == Cell.new(x, y) }\n @current_state.delete(Cell.new(x, y).ha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the first game object occupying any of the cells that given 'game_object' covers | def from_game_object(game_object)
start_x = (game_object.bb.left / @grid[0]).to_i
stop_x = (game_object.bb.right / @grid[0]).to_i
(start_x .. stop_x).each do |x|
start_y = (game_object.bb.top / @grid[1]).to_i
stop_y = (game_object.bb.bottom / @grid[1]).to_i
... | [
"def background_object\n game_state.background_object_map.collisions_with(self).first\n end",
"def find_food_on_grid\n image = self.create_screen_capture Snake::Game.game_rectangle\n for y in 0..(Snake::Game.game_rectangle.height/SQUARE_LENGTH).floor\n for x in 0..(Snake::Game.game_rectan... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Yields all game objects occupying any of the cells that given 'game_object' covers | def each_collision(game_object)
start_x = (game_object.bb.left / @grid[0]).to_i
stop_x = (game_object.bb.right / @grid[0]).to_i
(start_x ... stop_x).each do |x|
start_y = (game_object.bb.top / @grid[1]).to_i
stop_y = (game_object.bb.bottom / @grid[1]).to_i
... | [
"def usable_objects(map, battle)\n map.objects_near(self, battle)\n end",
"def get_cells_inside\n return nil if cells.to_a.empty?\n cells = []\n\n for e in @cells\n if inside?(e.x,e.y)\n cells.push(e)\n end\n end\n cells\n end",
"def scan_cells(&block)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initialize auditor proxy with given audit id === Parameters audit_id(Integer):: ID of audit entry that should be appended to | def initialize(audit_id)
@audit_id = audit_id
@buffer = ''
@timer = nil
end | [
"def find_audit!\n @audit = Audit.find(params[:audit_id])\n end",
"def set_audit_log_data\n @audit_log.auditable = @job if @audit_log\n end",
"def retrieve_audit_log(audit_log_id)\n start.uri('/api/system/audit-log')\n .url_segment(audit_log_id)\n .get()\n .go()\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Start new audit section === Parameters title(String):: Title of new audit section, will replace audit status as well options[:category](String):: Optional, must be one of RightScale::EventCategories::CATEGORIES === Return true:: Always return true | def create_new_section(title, options={})
send_request('create_new_section', normalize_options(title, options))
end | [
"def create_new_section(title, options={})\n send_audit(:kind => :new_section, :text => title, :category => options[:category])\n end",
"def create_new_section(title, options = nil)\n send_command(:audit_create_new_section, title, options)\n end",
"def create_new_section(title, options={})\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Append output to current audit section === Parameters text(String):: Output to append to audit entry === Return true:: Always return true | def append_output(text)
EM.next_tick do
@buffer << text
if @buffer.size > MIN_AUDIT_SIZE
flush_buffer
else
reset_timer
end
end
end | [
"def append_output(text)\n RightScale::Log.info text\n true\n end",
"def append_output(text, options = nil)\n send_command(:audit_append_output, text, options)\n end",
"def append_info(text, options = nil)\n send_command(:audit_append_info, text, options)\n end",
"def append_to_lo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Append info text to current audit section. A special marker will be prepended to each line of audit to indicate that text is not some output. Text will be linewrapped. === Parameters text(String):: Informational text to append to audit entry options[:category](String):: Optional, must be one of RightScale::EventCategor... | def append_info(text, options={})
options[:category] ||= EventCategories::NONE # Do not event by default
send_request('append_info', normalize_options(text, options))
end | [
"def append_info(text, options={})\n send_audit(:kind => :info, :text => text, :category => options[:category])\n end",
"def append_info(text, options = nil)\n send_command(:audit_append_info, text, options)\n end",
"def append_info(text, options={})\n true\n end",
"def add_log_text(te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Actually send audits to core agent and log failures === Parameters request(String):: Request that should be sent to auditor actor text(String):: Text to be audited === Return true:: Always return true | def internal_send_request(request, options)
log_method = request == 'append_error' ? :error : :info
log_text = AuditFormatter.send(format_method(request), options[:text])[:detail]
log_text.chomp.split("\n").each { |l| RightLinkLog.__send__(log_method, l) }
options[:audit_id] = @audit_id
Ri... | [
"def aitalk(request)\n talk(\"\", request)\n end",
"def setMessage(content, isRequest)\n\n @txt_input.text = \"Text is not Modified.\".to_java_bytes if @txt_input.textModified\n\n if isRequest\n makelog \"start request audit\"\n @txt_input.text = \"HTTP Request is nil or empty.\".to_java_byt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Normalize options for creating new audit section of updating audit summary === Parameters text(String):: New section title or new status options(Hash):: Optional hash specifying category === Return opts(Hash):: Options hash ready for calling corresponding auditor operation | def normalize_options(text, options)
opts = options || {}
opts[:text] = text
opts[:category] ||= EventCategories::CATEGORY_NOTIFICATION
unless EventCategories::CATEGORIES.include?(opts[:category])
RightLinkLog.warn("Invalid notification category '#{opts[:category]}', using generic catego... | [
"def append_info(text, options={})\n send_audit(:kind => :info, :text => text, :category => options[:category])\n end",
"def create_new_section(title, options={})\n send_audit(:kind => :new_section, :text => title, :category => options[:category])\n end",
"def _normalize_options(options) #:nodoc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Audit formatter method to call to format message sent through +request+ === Parameters request(String):: Request used to audit text === Return method(Symbol):: Corresponding audit formatter method | def format_method(request)
method = case request
when 'update_status' then :status
when 'create_new_section' then :new_section
when 'append_output' then :output
when 'append_info' then :info
when 'append_error' then :error
end
end | [
"def internal_send_request(request, options)\n log_method = request == 'append_error' ? :error : :info\n log_text = AuditFormatter.send(format_method(request), options[:text])[:detail]\n log_text.chomp.split(\"\\n\").each { |l| RightLinkLog.__send__(log_method, l) }\n options[:audit_id] = @audit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Toolbar configuration for CKEditor | def editor_toolbar
[
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord... | [
"def toolbar\n return false if content_mode == :code\n\n [\n # [{'header': [1, 2, 3, 4, false] }],\n ['bold', 'italic', 'underline'],\n ['link', 'image', 'video'], # also 'code-block'\n [{'list': 'ordered'}, { 'list': 'bullet' }],\n [{'align': [] }, 'clean'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
store the last visited controller action | def last_visited(action_name, controller_name)
if(action_name =='find' and controller_name == 'search')
session[:action]='back'
session[:controller]=controller_name
elsif(action_name =='index' and controller_name == 'main_menu')
session[:action]=action_name
session[:controller]=c... | [
"def record_last_action\n\t\t\treturn unless self.stage_num\n\t\t\tact = last_player.last_action\n\t\t\t(self.current_hand_history[self.stage_num] ||= []).push(act)\n\t\tend",
"def set_last_url\n session[:last_url] = request.fullpath if request.method.casecmp('get') == 0\n end",
"def store_recent_url\n s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /countries POST /countries.json | def create
@country = Country.new(country_params)
if @country.save
render json: @country, status: :created, location: @country
else
render json: @country.errors, status: :unprocessable_entity
end
end | [
"def create\n @countries = Countries.new(params[:countries])\n\n respond_to do |format|\n if @countries.save\n flash[:notice] = 'Countries was successfully created.'\n format.html { redirect_to(@countries) }\n format.xml { render :xml => @countries, :status => :created, :location =>... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /countries/1 PATCH/PUT /countries/1.json | def update
@country = Country.find(params[:id])
if @country.update(country_params)
head :no_content
else
render json: @country.errors, status: :unprocessable_entity
end
end | [
"def update\n respond_to do |format|\n if @countries.update(countries_params)\n format.html { redirect_to @countries, notice: 'Countries was successfully updated.' }\n format.json { render :show, status: :ok, location: @countries }\n else\n format.html { render :edit }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the assignedUserPrincipalName property value. UPN of the user the device will be assigned | def assigned_user_principal_name
return @assigned_user_principal_name
end | [
"def assigned_user_principal_name=(value)\n @assigned_user_principal_name = value\n end",
"def assigned_user_name(issue)\n if has_assigned_user?(issue)\n User.find_by(id: issue.user_issue.user_id).name\n else\n if internal_user?\n \"Please assign user\"\n else... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the assignedUserPrincipalName property value. UPN of the user the device will be assigned | def assigned_user_principal_name=(value)
@assigned_user_principal_name = value
end | [
"def on_premises_user_principal_name=(value)\n @on_premises_user_principal_name = value\n end",
"def user_principal_name=(value)\n @user_principal_name = value\n end",
"def assigned_user_principal_name\n return @assigned_user_principal_name\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the groupTag property value. Group Tag of the Windows autopilot device. | def group_tag
return @group_tag
end | [
"def group_tag=(value)\n @group_tag = value\n end",
"def group\n return @group\n end",
"def device_tag\n return @device_tag\n end",
"def device_tag\n return @device_tag\n end",
"def group\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the groupTag property value. Group Tag of the Windows autopilot device. | def group_tag=(value)
@group_tag = value
end | [
"def set_group(group)\n send_request(FUNCTION_SET_GROUP, [group], 'k4', 0, '')\n end",
"def group=(value)\n @group = value\n end",
"def set_group(param)\n @group = param\n end",
"def set_group_name(volume_id, group_name)\n @client.create_tags({\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the hardwareIdentifier property value. Hardware Blob of the Windows autopilot device. | def hardware_identifier
return @hardware_identifier
end | [
"def hardware_identifier=(value)\n @hardware_identifier = value\n end",
"def installed_hardware_id\n return @children['installed-hardware-id'][:value]\n end",
"def hardware_id\n @uuid_generator.generate\n end",
"def hardware_id\n config.hardware_id ||= \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the hardwareIdentifier property value. Hardware Blob of the Windows autopilot device. | def hardware_identifier=(value)
@hardware_identifier = value
end | [
"def hardware_id=(value)\n @children['hardware-id'][:value] = value\n end",
"def hardware_identifier\n return @hardware_identifier\n end",
"def hardware_id\n config.hardware_id ||= \"aal-#{SecureRandom.uuid}\"\n end",
"def physical_device_id=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the importId property value. The Import Id of the Windows autopilot device. | def import_id
return @import_id
end | [
"def import_id=(value)\n @import_id = value\n end",
"def import id\n get_request \"imports/#{id}\"\n end",
"def device_import_status\n return @device_import_status\n end",
"def imported_windows_autopilot_device_identities=(value)\n @im... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the importId property value. The Import Id of the Windows autopilot device. | def import_id=(value)
@import_id = value
end | [
"def import_id\n return @import_id\n end",
"def import=(value)\n @import = value\n end",
"def import id\n get_request \"imports/#{id}\"\n end",
"def imported_windows_autopilot_device_identities=(value)\n @imported_windows_autopilot_device_identities = v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the productKey property value. Product Key of the Windows autopilot device. | def product_key
return @product_key
end | [
"def product_key=(value)\n @product_key = value\n end",
"def product_key\n invoice.generated? ? frozen_product_key : product.key\n end",
"def product_id\n read('product_id')\n end",
"def get_product_key(mfg, product)\n data = YAML.load(open_file('tires', mfg))\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the productKey property value. Product Key of the Windows autopilot device. | def product_key=(value)
@product_key = value
end | [
"def set_ProductKeyword(value)\n set_input(\"ProductKeyword\", value)\n end",
"def product_key\n return @product_key\n end",
"def product_id=(value)\n @product_id = value\n end",
"def set_Product(value)\n set_input(\"Product\", value)\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the serialNumber property value. Serial number of the Windows autopilot device. | def serial_number
return @serial_number
end | [
"def serial_number\n @serial_number ||= read_string(usb_device.iSerialNumber, '?').strip\n end",
"def serial_no\n get_prop('ro.serialno')\n end",
"def serial_number\n @serial_number\n end",
"def serial\n fetch('device.serial')\n end",
"def serial_number=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the serialNumber property value. Serial number of the Windows autopilot device. | def serial_number=(value)
@serial_number = value
end | [
"def serial_number=(value)\n @serial_number = value\n end",
"def serial=(value)\n @serial = value\n end",
"def set_SerialNumbers(value)\n set_input(\"SerialNumbers\", value)\n end",
"def changeSerialNb(value)\n @mainLock.synchronize {\n @dataLock.synchronize {\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /consignments GET /consignments.json | def index
@consignments = Consignment.all
end | [
"def index\n @consignments = Consignment.all\n \n end",
"def index\n @condiments = Condiment.all\n end",
"def index\n @consignees = Consignee.all\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /consignments POST /consignments.json | def create
@consignment = Consignment.new(consignment_params)
respond_to do |format|
if @consignment.save
format.html { redirect_to @consignment, notice: 'Consignment was successfully created.' }
format.json { render action: 'show', status: :created, location: @consignment }
else
... | [
"def create\n @consignment = Consignment.new(consignment_params)\n\n respond_to do |format|\n if @consignment.save\n format.html {redirect_to @consignment, notice: 'Consignment was successfully created.'}\n format.json {render :show, status: :created, location: @consignment}\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /consignments/1 PATCH/PUT /consignments/1.json | def update
respond_to do |format|
if @consignment.update(consignment_params)
format.html { redirect_to @consignment, notice: 'Consignment was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @c... | [
"def update \n respond_to do |format|\n if @consignment.update(consignment_params)\n format.html { redirect_to consignments_url, notice: 'Consignment was successfully updated.' }\n format.json { render :show, status: :ok, location: @consignment }\n \n else\n format.html { ren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /consignments/1 DELETE /consignments/1.json | def destroy
@consignment.destroy
respond_to do |format|
format.html { redirect_to consignments_url }
format.json { head :no_content }
end
end | [
"def destroy\n @concert = Concert.find(params[:id])\n @concert.destroy\n\n respond_to do |format|\n format.html { redirect_to concerts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @concert = Concert.find(params[:id])\n @concert.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wait for CR reception | def wait_cr(tmo=nil)
t = Machine.millis + tmo if tmo
loop {
rsp = self.gets
return rsp.chomp if rsp.size > 0
raise "XBee response timeout" if t && t <= Machine.millis
Machine.delay(10)
}
end | [
"def wait_cr(tmo=nil)\n tmo += Machine.millis if tmo\n s = \"\"\n while true\n c = @wifi.getc\n return s if c == CR\n if c\n s << c\n else\n raise \"XBee-wifi response timeout #{s}\" if tmo && tmo <= Machine.millis\n Machine.delay(1)\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Enter AT command mode | def enter_at_mode
while gets.size > 0; end # discard remain data
Machine.delay(1000) # wait 1 second
loop {
self.write '+'; Machine.delay(1)
self.write '+'; Machine.delay(1)
self.write '+'
Machine.delay(1000) # wait 1 second
rsp = self.gets
return rsp i... | [
"def enter_at_mode\n while gets.size > 0; end # discard remain data\n Machine.delay(1000) # wait 1 second\n 10.times do\n begin\n self.write '+++'\n Machine.delay(1000) # wait 1 second\n rsp = wait_cr(TMO_RESPONSE)\n return rsp\n rescue => e\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Leave AT command mode | def leave_at_mode
at_cr('atcn', 1000)
end | [
"def enter_at_mode\n while gets.size > 0; end # discard remain data\n Machine.delay(1000) # wait 1 second\n 10.times do\n begin\n self.write '+++'\n Machine.delay(1000) # wait 1 second\n rsp = wait_cr(TMO_RESPONSE)\n return rsp\n rescue => e\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
run processes the issue and queues up an issue job. | def run
case issue.action
when "opened"
job = PuppetLabs::Trello::TrelloIssueJob.new
job.issue = issue
delayed_job = job.queue
logger.info "Successfully queued up opened issue #{issue.repo_name}/#{issue.number} as job #{delayed_job.id}"
body = {
'job_id' => delayed_job.id,
... | [
"def queue_job; end",
"def work\n possible_job = pluck_queue_message(:job_requests) # FIX: pluck doesn't delete\n job = Job.build(@instance_id, possible_job)\n job.valid? ? process(job) : process_invalid(job)\n end",
"def run\n case pull_request.action\n when \"opened\"\n job = Pupp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Skip spaces from given position. | def skipSpaces(pos)
max = @src.length
while pos < max
ch = charCodeAt(@src, pos)
break if !isSpace(ch)
pos += 1
end
return pos
end | [
"def skip_space(ix, direction)\n diff = { :left => -1, :right => 1 }[direction]\n ix += diff until ix < 1 || char_at(ix) =~ /[^ \\t]/ || char_at(ix).blank?\n ix\n end",
"def skip_whitespace\n self.advance while self.current == \" \"\n end",
"def skip_space; end",
"def skip_space=(_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Skip spaces from given position in reverse. | def skipSpacesBack(pos, min)
return pos if pos <= min
while (pos > min)
return pos + 1 if !isSpace(charCodeAt(@src, pos -= 1))
end
return pos
end | [
"def skip_space(ix, direction)\n diff = { :left => -1, :right => 1 }[direction]\n ix += diff until ix < 1 || char_at(ix) =~ /[^ \\t]/ || char_at(ix).blank?\n ix\n end",
"def skip_whitespace\n self.advance while self.current == \" \"\n end",
"def skipSpaces(pos)\n max = @src.le... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Skip char codes from given position | def skipChars(pos, code)
max = @src.length
while pos < max
break if (charCodeAt(@src, pos) != code)
pos += 1
end
return pos
end | [
"def skipCharsBack(pos, code, min)\n return pos if pos <= min\n\n while (pos > min)\n return (pos + 1) if code != charCodeAt(@src, pos -= 1)\n end\n return pos\n end",
"def skip(chars=SPACE_CHARACTERS)\n while chars.include?(current_byte)\n @position += 1\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Skip char codes reverse from given position 1 | def skipCharsBack(pos, code, min)
return pos if pos <= min
while (pos > min)
return (pos + 1) if code != charCodeAt(@src, pos -= 1)
end
return pos
end | [
"def skipChars(pos, code)\n max = @src.length\n while pos < max\n break if (charCodeAt(@src, pos) != code)\n pos += 1\n end\n return pos\n end",
"def backward characters\n if (@char - characters) >= 0\n @char -= characters\n char\n else\n fal... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Draws the kelvins screen on the Shoes app window. | def kelvins_screen
@heading = 'Kelvins = temperature + 273.15'
background('images/conversions_large.png')
# Kelvins screen header
ScreenHeader.new(self, '/title_screen/conversions_screen', @@font, @heading)
# Kelvins screen content
flow(:height => 640, :width => 1080, :scroll => true) do
... | [
"def draw_screen (screen)\n screen.draw(0, 0, ZOrder::BACKGROUND, 0.5, 0.5)\n draw_button(@home, 660, 760, 322, 422)\n end",
"def render_screen(parent_window)\n returning(parent_window.subwin(Ncurses.LINES, Ncurses.COLS, 0, 0)) do |screen|\n screen.border(0,0,0,0,0,0,0,0)\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
caching related releases on release page. either updated in 1 hour or via an updated_at attribute change | def related_releases
Rails.cache.fetch("releases/release-#{id}", :expires_in => 1.hour) do
real_releases.all(:order => 'date DESC', :limit => 15)
end
end | [
"def cache_version\n if Page.current_preview == id\n updated_at.to_s\n else\n published_at.to_s\n end\n end",
"def releases\n revisions_by_status([RevisionInfo::Status::LATEST_RELEASE, RevisionInfo::Status::EXPIRED])\n end",
"def updated_at\n if Content... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Load artist releases upon tracking a new artist on the timeline, limiting to 5 most recent | def timeline_releases
real_releases.order('date DESC').limit(5)
end | [
"def get_latest_five_songs\n @latest_songs = Song.recent(5)\n end",
"def get_artists_releases(artist_id, pagination={})\n query_and_build \"artists/#{artist_id}/releases\", pagination\n end",
"def top_tracks_for_artist\n unless @artist\n @artist = Lineup.select_random_artist\n end\n\n op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
print song title, duration, genre in a single line | def display_song
return "Title: #{song_title}, Duration: #{duration}, Genre: #{genre}"
end | [
"def print_songs\n # #songs returns an array of the artist's songs\n songs.each do |song|\n print song.name += \"\\n\"\n end \n end",
"def print_songs()\r\n puts @songs.collect {|x| x.name}\r\n end",
"def print_additional_movie_info\n puts \"\\n\\n#{self.title} - #{self.tag_lin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add album first check if album exists | def add_album(new_album)
if @albums.include?(new_album)
puts "The album has already been added"
else
@albums.push(new_album)
end
end | [
"def add_album(new_album)\n @albums.include?(new_album) ? (puts \"The album has already been added\") : @albums.push(new_album)\n end",
"def album\n\t\t@album = self.albums.create!(title: 'default')\n\tend",
"def add_album=album\n\t\t@albums << album\n\tend",
"def album\n\t\talbums == nil ? nil : al... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add artist to Top 10 and check if number of artist is not more than 10 | def add_artist(new_artist)
if @artists.length > 10
@artists.shift
else
@artists.push(new_artist)
end
end | [
"def add_artist(new_artist)\n @artists.length > 10 ? @artists.shift : @artists.push(new_artist)\n end",
"def get_top_genres(artists)\n genres_hash = Hash.new\n artists.each do |artist|\n artist.genres.each do |artist_genre|\n if genres_hash.key?(artist_genre)\n genres_hash[arti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build a new stanza type:: [Symbol] or nil, see Iqtype to:: [JID] Recipient | def initialize(type = nil, to = nil)
super("iq")
if not to.nil?
set_to(to)
end
if not type.nil?
set_type(type)
end
end | [
"def send_roster_push(recipient)\n doc = Nokogiri::XML::Document.new\n node = doc.create_element('iq',\n 'id' => Kit.uuid,\n 'to' => recipient.user.jid.to_s,\n 'type' => 'set')\n node << doc.create_element('query', 'xmlns' => NAMESPACES[:roster]) do |query|\n query << ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the type of the Iq stanza The following values are allowed: :get :set :result :error result:: [Symbol] or nil | def type
case super
when 'get' then :get
when 'set' then :set
when 'result' then :result
when 'error' then :error
else nil
end
end | [
"def type(jid,node)\n info = get_info(jid,node)\n return info['type']\n end",
"def get_q_type(item)\n if item.is_a? Exception\n Q_TYPE_EXCEPTION\n elsif item.is_a?(TrueClass) || item.is_a?(FalseClass)\n Q_TYPE_BOOLEAN\n elsif item.is_a? Bignum\n Q_TYPE_LONG\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the type of the Iq stanza (chainingfriendly) v:: [Symbol] or nil | def set_type(v)
self.type = v
self
end | [
"def type= (v)\n add_attribute('type', v)\n end",
"def type=(val)\n case val\n when :error then super('error')\n when :probe then super('probe')\n when :subscribe then super('subscribe')\n when :subscribed then super('subscribed')\n when :unavailable then super('una... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete old elements named newquery.name newquery:: [REXML::Element] will be added | def query=(newquery)
delete_elements(newquery.name)
add(newquery)
end | [
"def remove_all_xpath_queries\n super\n end",
"def delete_query(query)\n @pointer_to_query_map.delete(FFI::Pointer.new(query.object_id).address)\n end",
"def delete_saved_query(query_name)\n url = @base_url + METHODS[:query_saved] + query_name\n make_request url, \"delete\", 2\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the iq's query's namespace, or nil result:: [String] | def queryns
e = first_element('query')
if e
return e.namespace
else
return nil
end
end | [
"def namespace\n unless @namespace\n available = available_namespaces\n @namespace = available[namespace_name] || available[XMLNS_PREFIX]\n end\n\n return @namespace\n end",
"def namespace\n @namespace ||= metadata.xpath('//Schema').first.attributes['Namespace'].v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add an element to the Iq stanza element:: [REXML::Element] Element to add. Will be automatically converted (imported) to a class registered with add_elementclass | def typed_add(element)
if element.kind_of?(REXML::Element) && @@element_classes.has_key?(element.name)
super(@@element_classes[element.name]::import(element))
else
super(element)
end
end | [
"def add(element)\n @content << element\n end",
"def <<(element)\n elements << element\n end",
"def on_qwords_add(qwords, element)\n QWords.new(\n beginning: qwords.beginning,\n elements: qwords.elements << element,\n location: qwords.location.to(element.location)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Iterates the given block for each RDF quad in the input. | def each_quad(&block)
each_statement do |statement|
block.call(*statement.to_quad)
end
end | [
"def each_quad(&block)\n if block_given?\n each_statement do |statement|\n block.call(*statement.to_quad)\n end\n end\n enum_for(:each_quad)\n end",
"def each_quad\n if block_given?\n each_statement do |statement|\n yield(*statement.to_quad)\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set all the level names at once and saves the object. ===Params: levels:: An array containing every level name. A rubric criterion contains RUBRIC_LEVELS levels. If the array is smaller, only the first levels are set. If the array is bigger, higher indexes are ignored. ===Returns: Whether the save operation was success... | def set_level_names(levels)
levels.each_with_index do |level, index|
self['level_' + index.to_s + '_name'] = level
end
save
end | [
"def levels=(levels)\n @levels = levels\n clear_levels_cache!\n end",
"def add_titration_level_set(level_name,type,levels,initial)\n name.set level_name\n type.nil? scheduled.click : unschedule.click\n remove_buttons.each { |remove| remove.click }\n levels.split(',').each_with_ind... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
before_create :build_image def start_generation MiddleMan.worker(:snap_generator_worker).async_generate(:arg => self.id) end | def start_generation
Nanite.request("/nanny/generate", self.id)
end | [
"def generate\n # Trigger all signature image generators\n process\n # Notify with a URL to the waiting client\n notify_client save_signature\n end",
"def create\n @bench_test_photo_gen = BenchTest::PhotoGen.new(params[:bench_test_photo_gen])\n\n # create the album and photos which kicks off th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the bin index corresponding to _value_. | def bin_index(value)
return -1 if(value < @range_min or value > @range_max)
(@num_bins*(value - @range_min)/(@range_max - @range_min)).to_i
end | [
"def bucket_index(value)\n return 0 if value < @min_bucket_value\n return @number_of_buckets - 1 if value >= @max_bucket_value\n\n ((Math.log(value) - Math.log(@min_bucket_value)) / @bucket_size).floor\n end",
"def binary_search(value)\n search_result = binary_search_internal(value)\n retu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the mean value of bin _bin_index_. | def value(bin_index)
@range_min + (bin_index + 0.5)*(@range_max - @range_min)/@num_bins.to_f
end | [
"def bucket_average_value(index)\n (bucket_lower_bound(index) + bucket_upper_bound(index)) / 2\n end",
"def mean_value(data:, index:)\n sum = 0\n data.each { |point| \n sum += point[index]\n }\n sum / data.count.to_f\n end",
"def mean\n @cleaned_data.map(&:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the Kinvar object w/ name _kinvar_ | def [](kinvar)
@kinvars.each{|kv| return kv if(kv.name == kinvar)}; nil
end | [
"def variable_by_name(name)\n @var_set[name]\n end",
"def [](var_name)\n\t\tv = get_variable var_name\n\t\tbegin\n\t\t\traw = cpu.memories[v.memory_name].read_object( v.address, v.size )\n\t\t\treturn v.deserialize raw\n\t\trescue ToolException => ex\n\t\t\traise ToolException.new \"Tinker: error reading vari... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read the next event's kinematic variables (returns their values via Hash) | def read
num_kv = @kinvars.length
unpck = String.new
num_kv.times{unpck += 'd'}
vals = @file.read(num_kv*8).unpack(unpck)
vals_hash = Hash.new
num_kv.times{|kv| vals_hash[@kinvars[kv].name] = vals[kv]}
vals_hash
end | [
"def read_in_t_values\n @dcs_pts = []\n doc = REXML::Document.new(File.new(\"#{@top_dir}/#{@dcs_file}\"))\n global_vars = Hash.new\n doc.elements.each('dcs/global-var'){|glv| \n\tattr = glv.attributes\n global_vars[attr['name'].to_sym] = attr['value'].to_f\n }\n phsp_elem = doc.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
5 points Extend your previous program to act like a smart grandfather clock. Given both the hour of the day and a sound, your program will display the sound that many times. For example: $ ruby exercise6.rb 4 GONGGG! GONGGG! GONGGG! GONGGG! GONGGG! | def grandfather_clock(hour, sound, &block)
hour.times do
block.call(sound)
end
end | [
"def part_6\n use_synth:hoover\n play :G4; sleep 0.5\n play :G4; sleep 0.5\n play :F4; sleep 0.5\n play :D4; sleep 0.5\n play :C4, amp: 1.5, release: 0.8; sleep 0.5\nend",
"def speak(repetitions)\n repetitions.times {puts \"Woof!\"}\n end",
"def play_long_song(times_to_repeat)\n verse_number = times_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Why's aorta method to edit an object in YAML, awesome! Source: | def aorta( obj )
tempfile = File.join('/tmp',"yobj_#{ Time.now.to_i }")
File.open( tempfile, 'w' ) { |f| f << obj.to_yaml }
system( "#{ ENV['EDITOR'] || 'vi' } #{ tempfile }" )
return obj unless File.exists?( tempfile )
content = YAML::load( File.open( tempfile ) )
File.delete( tempfile )
content
end | [
"def edit_in_yaml( object )\n\t\t\tyaml = object.to_yaml\n\n\t\t\tfn = Digest::SHA1.hexdigest( yaml )\n\t\t\ttf = Tempfile.new( fn )\n\n\t\t\ttf.print( yaml )\n\t\t\ttf.close\n\n\t\t\tnew_yaml = edit( tf.path )\n\n\t\t\tif new_yaml == yaml\n\t\t\t\treturn nil\n\t\t\telse\n\t\t\t\treturn YAML.load( new_yaml )\n\t\t\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /definitions/new GET /definitions/new.json | def new
@definition = Definition.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @definition }
end
end | [
"def new\n @define = Define.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @define }\n end\n end",
"def new\n @import_def = ImportDef.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @import_def }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build the url to be called using this class' +base_url+ and a +word+. Returns an url to where +word+'s synonyms can be obtained. | def build_call_url(word)
URI.parse(URI.escape(base_url + word))
end | [
"def build_url\n url = \"http://ws.geonames.org/findNearbyWikipediaJSON?\"\n url += \"lat=#{@lat}\"\n url += \"&lng=#{@long}\"\n url += \"&radius=#{@radius}\"\n url += \"&lang=en\"\n return url\n end",
"def find_synonyms(word)\r\n require 'open-uri'\r\n requi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Obtain synonyms of a +word+ from Educalingo. | def synonyms(word, options = {})
response = call(word)
doc = Nokogiri.HTML(response)
synonyms = Array.new
doc.css('#wordcloud1 > span').each do |synonym|
score = Integer(synonym.values[0])
synonyms.push({
word: synonym.inner_html,
score: score
}) unless score < 75
# A m... | [
"def find_synonyms(word)\r\n require 'open-uri'\r\n require 'timeout'\r\n timeout(5) do\r\n open(SYNONYM_LOOKUP_URI % word) do |stream|\r\n # Grab words linked to dictionary entries as possible synonyms\r\n data = stream.read.gsub(\" \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /byoins/1 GET /byoins/1.json | def show
@byoin = Byoin.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @byoin }
end
end | [
"def index\n @innings = Inning.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @innings }\n end\n end",
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end",
"def index\n @dinos = Dino.where(query_params)\n render... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /byoins/new GET /byoins/new.json | def new
@byoin = Byoin.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @byoin }
end
end | [
"def new\n @newse = Newse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newse }\n end\n end",
"def new\n @inning = Inning.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inning }\n end\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /byoins POST /byoins.json | def create
@byoin = Byoin.new(params[:byoin])
respond_to do |format|
if @byoin.save
format.html { redirect_to @byoin, notice: 'Byoin was successfully created.' }
format.json { render json: @byoin, status: :created, location: @byoin }
else
format.html { render action: "new" }... | [
"def create\n @yaopin = Yaopin.new(params[:yaopin])\n\n respond_to do |format|\n if @yaopin.save\n format.html { redirect_to @yaopin, notice: 'Yaopin was successfully created.' }\n format.json { render json: @yaopin, status: :created, location: @yaopin }\n else\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Search params : byoinNm | def search
#conditions = Byoin.where("\"byoinCd\" NOT ?", nil)
conditions = Byoin.where("1 = ?", 1)
conditions = conditions.where("\"byoinNm\" LIKE ?", params[:byoinNm] + "%") if params[:byoinNm] != ""
logger.debug(conditions)
records = conditions.count
limit = params[:rows].to_i
page = pa... | [
"def search_params\n # TODO Configurar acá la variable params\n params[:query_name]\n end",
"def search\n require \"pp\"\n fields = {}\n fields[:bankname] = params[:bankname] if params[:bankname].present? \n fields[:branchname] = params[:branchname] if params[:branchname].present? \n ... | {
"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.