query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
anonymize the supplied download event | def anonymize_file_download_event( download_event )
# find an anomomyzed version
event = find_existing_download_event( download_event.date, download_event.file_id, nil )
if event.nil? == false
event.downloads += download_event.downloads
else
event = create_new_download_event( download_eve... | [
"def download(event)\n @logger.info '----------------------------------------------------------------'\n @logger.info \"Downloading event '#{event}'...\"\n data = @service.export(@from_days_ago, @to_days_ago, events: [event])\n process event, data\n @logger.info 'Download complete.'\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prepares the app for being staged in one or more environments by loading config(s), middleware, and setting the load path. | def prepare(*env_or_envs)
return if prepared?
# load config for one or more environments
load_config(*env_or_envs)
# load each block from middleware stack
load_middleware
# include pwd in load path
$:.unshift(Dir.pwd) unless $:.include? Dir.pwd
@prepar... | [
"def prepare(env)\n load_env_config(env)\n load_middleware\n $LOAD_PATH.unshift config.app.src_dir\n end",
"def prepare(*env_or_envs)\n return true if prepared?\n\n # load config for one or more environments\n load_env_config(*env_or_envs)\n\n # load each bloc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Defines a route set. | def routes(set_name = :main, &block)
if set_name && block
@@routes[set_name] = block
else
@@routes
end
end | [
"def route_sets; end",
"def route(*args)\n if valid_routeset?(args)\n self.routes += args.map { |elt| route_elt(elt, []) }\n end\n end",
"def routes(&block)\n @routes ||= ActionDispatch::Routing::RouteSet.new_with_config(config)\n @routes.append(&block) if block_given?\n @routes\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Accepts block to be added to middleware stack. | def middleware(&block)
@@middleware << block
end | [
"def rack_app_route_block(block)\n block\n end",
"def add(&block)\n @block_args << block\n end",
"def add_block(name, &block)\n @server_class.class_eval do\n define_method(name) do |*args|\n block.call caller, *args\n end\n end\n end",
"def accept_nonblock(*... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches a stack (before | after) by name. | def stack(which, name)
@@stacks[which][name]
end | [
"def stack(name)\n stacks = (Thread.current[:__moped_threaded_stacks__] ||= {})\n stacks[name] ||= []\n end",
"def find_stack(stack_name)\n stacks = @client.describe_stacks()[:stacks]\n puts \"#{stacks.length} stacks found in total.\" if @verbose\n if stacks.length > 0\n stack = stacks.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a block to the before stack for `stack_name`. | def before(stack_name, &block)
@@stacks[:before][stack_name.to_sym] << block
end | [
"def before(name, options={}, &block)\n self.add_block_container_to_list(\"before_#{name.to_s}\", options, &block)\n nil\n end",
"def after(stack_name, &block)\n @@stacks[:after][stack_name.to_sym] << block\n end",
"def prepend(name, content=nil, &block)\n content = capture(&block)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a block to the after stack for `stack_name`. | def after(stack_name, &block)
@@stacks[:after][stack_name.to_sym] << block
end | [
"def after(name, options={}, &block)\n self.add_block_container_to_list(\"after_#{name.to_s}\", options, &block)\n nil\n end",
"def add_block(name=\"\")\n @raw.basic_blocks.append(name)\n end",
"def before(stack_name, &block)\n @@stacks[:before][stack_name.to_sym] << block\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the application is staged. | def staged?
@staged
end | [
"def staged?\n !Pakyow.app.nil?\n end",
"def staging?\n self.environment == ENV_STAGE\n end",
"def staging?\n environment =~ /stag/\n end",
"def staging?\n status == \"STAGING\"\n end",
"def staging?\n environment == :staging\n end",
"def staging?\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sends data in the response (immediately). Accepts a string of data or a File, mimetype (autodetected; defaults to octetstream), and optional file name. If a File, mime type will be guessed. Otherwise mime type and file name will default to whatever is set in the response. | def send(file_or_data, type = nil, send_as = nil)
if file_or_data.class == File
data = file_or_data.read
# auto set type based on file type
type = Rack::Mime.mime_type("." + String.split_at_last_dot(file_or_data.path)[1])
else
data = file_or_data
end
headers = {... | [
"def send_data!(data, type, file_name = nil)\n status = self.response ? self.response.status : 200\n\n headers = self.response ? self.response.header : {}\n headers = headers.merge({ \"Content-Type\" => type })\n headers = headers.merge({ \"Content-disposition\" => \"attachment; filename=#{file_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Stores set cookies at beginning of request cycle for comparison at the end of the cycle | def set_initial_cookies
@initial_cookies = {}
request.cookies.each {|k,v|
@initial_cookies[k] = v
}
end | [
"def save_cookies!\n return unless @response.headers.to_hash['set-cookie']\n save_cookies @response.headers.to_hash['set-cookie']\n end",
"def propagate_cookies_to_next_request\n return unless response&.cookies\n\n keys = response.cookies.keys\n keys.each do |key|\n cookies[key] = response.co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Array of Sovren position history job categories. | def categories
data['JobCategory'] || []
end | [
"def clil_categories_codes\n self.clil_categories.map{|c| c.code}.uniq\n end",
"def activity_log_student_time_categories_array\n activity_log_student_time_categories.try(:split, \"\\n\").try(:collect, &:strip).to_a\n end",
"def activity_log_non_student_time_categories_array\n activity_log_non_stu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Uses the dockercompose CLI to fetch the associated container IDs | def container_ids
@container_ids ||= DockerCompose.new(project).container_ids
end | [
"def container_id\n command = \"docker ps | grep #{name_matching_string} | head -n 1 | awk '{print $1}'\"\n self.class.system_command(command: command)[:stdout]\n end",
"def get_running_image_ids\n `docker ps -q`.split(\"\\n\").map { |containerId|\n `docker inspect --format='{{.Image}}' #{containerId}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
gets information about the containers from the Docker API | def containers
@containers ||= Docker::Container.all(
all: true, # include stopped containers
filters: { id: container_ids }.to_json
).map(&:json)
end | [
"def running_containers\n request do\n get(path: '/containers/json')\n end\n end",
"def show\n @container.json = Docker::Container.get(@container.cid)\n end",
"def get_container_info(container)\n @logger.debug \"#{@client.api_endpoint} - Container info: #{@client.container(container).... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns that the remote host is always vulnerable | def check
return Exploit::CheckCode::Vulnerable
end | [
"def strict_remote_ip\n GetSecureIp.new(self, whitelisted_ips).to_s\n rescue ActionDispatch::RemoteIp::IpSpoofAttackError\n \"[Spoofed]\"\n end",
"def host_allowed?(arg)\n true\n end",
"def url_is_remote?\n !(url =~ /localhost/ || url =~ /127\\.0\\.0\\.1/ || url =~ /0\\.0\\.0\\.0/)\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The frame's default execution context. | def execution_context
raise "Execution Context is not available in detached frame \"#{frame.url}\" (are you trying to evaluate?)" if @_detached
@_context_promise.value
end | [
"def default_context\n config.default_context || {}\n end",
"def set_default_context\n self.context = Ubiquo::Settings.default_context if self.context.blank?\n end",
"def execution_context\n @context\n end",
"def default_context\n self.app_contexts[:all] ||= AppContext.new(control... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The method evaluates the XPath expression. | def xpath(expression)
document.xpath expression
end | [
"def eval_xpath node\n nodes = node.xpath(as_xpath, as_namespace)\n end",
"def xpath(*args)\n @node.xpath(*args)\n end",
"def match(xpathExpr)\n el = TraceState.getNodeState(self)\n m = REXML::XPath.match(el, xpathExpr)\n return m\n end",
"def xpath(*args)\n @body.xpath(*args)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The method runs document.querySelectorAll within the frame. If no elements match the selector, the return value resolves to []. | def query_selector_all(selector)
document.query_selector_all selector
end | [
"def find_all(selector)\n DOM::NodeList.new `Array.prototype.slice.call(#{@el}.querySelectorAll(#{selector}))`\n end",
"def query_selector_all(node_id:, selector:)\n {\n method: \"DOM.querySelectorAll\",\n params: { nodeId: node_id, selector: selector }.compact\n }\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method fetches an element with selector and focuses it. If there's no element matching selector, the method throws an error. | def focus(selector)
handle = query_selector selector
"No node found for selector: #{selector}" if handle.nil?
handle.focus
handle.dispose
nil
end | [
"def click_on_class_or_css(selector)\n\n find(selector).click\n\n end",
"def scroll_into_view(selector)\n el = find(selector)\n # only do this if the native element is a selenium element\n el.native.send_keys(:null) if el.native.class.to_s.split(\"::\").first == \"Selenium\"\nend",
"def select_by_selecto... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method fetches an element with selector, scrolls it into view if needed, and then uses page.touchscreen to tap in the center of the element. If there's no element matching selector, the method throws an error. | def touchscreen_tap(selector)
handle = query_selector selector
raise "No node found for selector: #{selector}" if handle.nil?
handle.tap
handle.dispose
nil
end | [
"def scroll_into_view(selector)\n el = find(selector)\n # only do this if the native element is a selenium element\n el.native.send_keys(:null) if el.native.class.to_s.split(\"::\").first == \"Selenium\"\nend",
"def click_at(selector, offset_x, offset_y)\n x = left(selector) + width(selector) * offset_x\n y ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /paquetes GET /paquetes.xml | def index
@paquetes = Paquete.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @paquetes }
end
end | [
"def show\n @paquete = Paquete.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @paquete }\n end\n end",
"def show\n @casette = Casette.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.x... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /paquetes/1 GET /paquetes/1.xml | def show
@paquete = Paquete.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @paquete }
end
end | [
"def index\n @paquetes = Paquete.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @paquetes }\n end\n end",
"def show\n @casette = Casette.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /paquetes POST /paquetes.xml | def create
@paquete = Paquete.new(params[:paquete])
respond_to do |format|
if @paquete.save
format.html { redirect_to(@paquete, :notice => 'Paquete was successfully created.') }
format.xml { render :xml => @paquete, :status => :created, :location => @paquete }
else
format.ht... | [
"def create\n @paquete = Paquete.new(params[:paquete])\n respond_to do |format|\n @paquete.personas_id=session[:id]\n if @paquete.save\n NUESTRO_LOG.info \"Se guardo el paquete correctamente\"\n format.html { redirect_to(paquetes_path, :notice => t('paquetecrear')) }\n format.xm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /paquetes/1 DELETE /paquetes/1.xml | def destroy
@paquete = Paquete.find(params[:id])
@paquete.destroy
respond_to do |format|
format.html { redirect_to(paquetes_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @paquete = Paquete.find(params[:id])\n @paquete.destroy\n\n respond_to do |format|\n format.html { redirect_to(@paquete) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @casette = Casette.find(params[:id])\n @casette.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /notesheets GET /notesheets.json | def index
@notesheets = Notesheet.all
end | [
"def get_notes\n Resources::Note.parse(request(:get, \"Notes\"))\n end",
"def index\n @shift_notes = ShiftNote.all\n render json: @shift_notes\n end",
"def index\n @notebooks = Notebook.all\n render json: @notebooks\n end",
"def index\n @recording_sheets = RecordingSheet.all\n\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /notesheets POST /notesheets.json | def create
@notesheet = Notesheet.new(notesheet_params)
respond_to do |format|
if @notesheet.save
if !@notesheet.notepic.url
path = "#{@notesheet.title}-#{@notesheet.id}.txt"
File.open(path, "w+") do |f|
f.write(@notesheet.content)
@noteshee... | [
"def index\n @notesheets = Notesheet.all\n end",
"def create\n @judge_sheet = JudgeSheet.new(params[:judge_sheet])\n\n respond_to do |format|\n if @judge_sheet.save\n format.html { redirect_to @judge_sheet, :notice => 'Judge sheet was successfully created.' }\n format.json { render :j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /notesheets/1 PATCH/PUT /notesheets/1.json | def update
respond_to do |format|
if @notesheet.update(notesheet_params)
format.html { redirect_to @notesheet, notice: 'Notesheet was successfully updated.' }
format.json { render :show, status: :ok, location: @notesheet }
else
format.html { render :edit }
format.json { r... | [
"def update\n @patch_note = PatchNote.find(params[:id])\n if @patch_note.update(patch_note_params)\n render json: {status: :ok}\n else\n render json: {errors: @patch_note.errors.full_messages.to_json}, status: :unprocessable_entity\n end\n end",
"def update\n if @note.update(note_params)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /notesheets/1 DELETE /notesheets/1.json | def destroy
@notesheet.destroy
respond_to do |format|
format.html { redirect_to notesheets_url, notice: 'Notesheet was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @history_note.destroy\n respond_to do |format|\n format.html { redirect_to history_notes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @weekly_note.destroy\n respond_to do |format|\n format.html { redirect_to weekly_notes_url }\n format.js... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Take ARD plist and create new computer objects TODO when a computer object import fails, tell the user what went wrong (by print the computer.errors hash) | def create_import
begin
@computers = ComputerService.import(params[:computer],current_unit)
rescue NoMethodError
e = "Please select a plist file"
rescue => e
end
unless @computers.nil?
@total = @computers.count
# Save each computer. If it doesn't save, leave it out of... | [
"def create_import\n begin\n @computers = ComputerService.import(params[:computer],current_unit)\n rescue NoMethodError\n end\n \n unless @computers.nil?\n @total = @computers.count\n # Save each computer. If it doesn't save, leave it out of the array\n @computers = @computers.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allows a computer to checkin with the server, notifying it of the last successful munki run. May be extended in the future. | def checkin
@computer = Computer.find_for_show(nil, params[:id])
if params[:managed_install_report_plist].present?
report_hash = ManagedInstallReport.format_report_plist(params[:managed_install_report_plist]).merge({:ip => request.remote_ip})
@computer.managed_install_reports.build(report_hash)
... | [
"def checkin\n if params[:managed_install_report_plist].present?\n report_hash = ManagedInstallReport.format_report_plist(params[:managed_install_report_plist]).merge({:ip => request.remote_ip})\n @computer.managed_install_reports.build(report_hash)\n end\n \n if params[:system_profiler_plist]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If buffer slots are free, inserts value and returns true. | def try_insert_new(value)
return false if used == @size
entry = GClockBufferEntry.new(value, 1)
@buffer[@pointer] = entry
advance_pointer
true
end | [
"def en_queue(value)\n return false if @queue.size == @k\n @queue << value\n true\n end",
"def enqueue(value)\n return false if @size + 1 > @capacity\n @q[@tail] = value\n @tail = (@tail + 1) % @capacity\n @size += 1\n true\n end",
"def insert(fingerprint)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Selects the parts of description where query mathches to the items description | def map_description_part(description, query)
start_of_find = description.gsub(/_/, " ").downcase.index(query)
substring_start = if start_of_find - 17 < 0 then 0 else start_of_find - 17 end
substring_end = if start_of_find + 20 > description.size then description.size else start_of_find + 20 end
... | [
"def search_description(target)\n results = []\n @items.each do |item|\n if item.description.include?(target)\n results.push(item)\n end\n end\n results\n end",
"def searchdescription\n end",
"def extract_work_description_display\n description_display_array = {}\n self.find_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
MIDI data must be encoded in 7bit bytes (most significat bit is used to mark STATUS bytes) Korg Monologue encodes data in 7byte chunks | def midi_encoder(bytes)
raise "Invalid data length #{bytes.size}" unless bytes.size % 7 == 0
result = []
(0...bytes.size).step(7).each do |start|
chunk = bytes[start, 7]
msbits = 0
chunk.each_with_index do |b, i|
msbits |= (b & 0x80) >> (7 - i)
end
result << msbits
result += chunk.ma... | [
"def puts_bytes(*data)\r\n\r\n format = \"C\" * data.size\r\n bytes = FFI::MemoryPointer.new(data.size).put_bytes(0, data.pack(format))\r\n\r\n Map.snd_rawmidi_write(@handle, bytes.to_i, data.size)\r\n Map.snd_rawmidi_drain(@handle)\r\n \r\n end",
"def get_program_midi_data(data)\n va... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract program data dump from midi message | def get_program_midi_data(data)
valid = data[0] == 0xF0 &&
data[1] == 0x42 &&
(data[2] & 0xF0 == 0x30) &&
data[3] == 0x00 &&
data[4] == 0x01 &&
data[5] == 0x44 &&
(data[6] == 0x4C || data[6] == 0x40) &&
data[-1] == 0xF7
if data[6] == 0x40
# current program
program = nil
start... | [
"def parse_midi_message(msg)\n pressed = ((msg[2] || 0) >= 64)\n case msg[0]\n when 0x90\n return *xy_for_note(msg[1]), pressed\n when 0xB0\n return *xy_for_controller(msg[1]), pressed\n when 0xF0\n launchpad_id = nil\n if msg.length >= 10 && msg[1] == 0x7E && msg[3] == 0x06\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract program data dump from binary file (like the .prog_bin files that are part of .molglib/.molgpreset packs) | def get_program_file_data(program_file)
File.open(program_file,'rb'){|f| f.read}
end | [
"def parse_program(prog)\n prog_bytes = to_bytes(prog)\n data = {}\n raise \"Invalid program\" unless prog[0, 4] == 'PROG'\n name = prog[4...16]\n data[:name] = program_name(prog)\n\n HR_PARAMS.each do |(key, ms_offset, ls_offset, ls_pos, units)|\n # single byte value\n value = prog_bytes[ms_offset]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse program data dump | def parse_program(prog)
prog_bytes = to_bytes(prog)
data = {}
raise "Invalid program" unless prog[0, 4] == 'PROG'
name = prog[4...16]
data[:name] = program_name(prog)
HR_PARAMS.each do |(key, ms_offset, ls_offset, ls_pos, units)|
# single byte value
value = prog_bytes[ms_offset]
data[key] = val... | [
"def parse_program()\n # puts \"parsing program\"\n parse_statement\n if @tokens.first.kind == Token::EOL\n return\n elsif @tokens.first.kind == Token::EOF\n abort\n else\n puts \"Error: invalid input\"\n abort\n end\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
home page default ads management | def index
@home_page = DefaultAd.find(1)
end | [
"def default\r\n return '' if @parent.session[:is_robot] # don't bother if robot\r\n html = ''\r\n if (ad = find_ad_to_display)\r\n# save to statistics, if not in cms\r\n if @opts[:edit_mode] < 1\r\n DcAdStat.create!(dc_ad_id: ad.id, ip: @parent.request.ip, type: 1 )\r\n# save display counter \r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
stories page default page ads managment | def stories_page
@stories_page = DefaultAd.find(2)
@stories_page_left_top = DefaultAd.find(3)
@stories_page_left_bottom = DefaultAd.find(4)
@stories_page_right = DefaultAd.find(5)
end | [
"def index\n @home_page = DefaultAd.find(1) \nend",
"def default\r\n return '' if @parent.session[:is_robot] # don't bother if robot\r\n html = ''\r\n if (ad = find_ad_to_display)\r\n# save to statistics, if not in cms\r\n if @opts[:edit_mode] < 1\r\n DcAdStat.create!(dc_ad_id: ad.id, ip: @parent.req... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Valida que uns cadena enviado y una clave encriptada sean iguales cuando la cadena se encripta | def clave_valida?(cadena, clave)
# la clave recibida debería ser una instancia de bcrypt, por lo tanto
# implementa la comparación con ==
clave == cadena
end | [
"def validate\n encrypt\n end",
"def clave_valida?(cadena, clave)\n\t\traise NotImplementedError(\"Encriptador.clave_valida?(cadena, clave) se debe implementar en las sublcases\")\n\tend",
"def esClaveValida(clave)\n\tcadena_clave = clave.to_s\n\tmedio_clave = (cadena_clave[1]).to_i + (cadena_clave[2].t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Delete a document. POST uuid a single uuid to delete Examples delete("7cf917de22464ac3adab791a49454180") => true Returns true if the delete was successful | def delete(uuid)
raw_body = api_call(:post, "document/delete", { :uuid => uuid })
raw_body == "true"
end | [
"def delete(opts = {})\n response = Crocodoc.connection.post 'document/delete', :uuid => @uuid\n response.body.chomp.downcase == 'true'\n end",
"def delete(uuid)\n connection.delete_by_query('uuid:' + solr_escape(uuid))\n connection.commit if URIService.commit_after_save?\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Get the url for the viewer for a session. session The uuid of the session (see session) Examples view("CFAmd3Qjm_2ehBI7HyndnXKsDrQXJ7jHCuzcRv_V4FAgbSmaBkF") => Returns a url string for viewing the session | def view(session_id)
"https://crocodoc.com/view/#{session_id}"
end | [
"def get_viewing_url(session)\n \"https://crocodoc.com/view/#{session.key}\"\n end",
"def viewer\n authorize @session\n end",
"def viewer_url(options = {})\n raise AttributeMissingError, 'Document ID is required to launch viewer' unless (options[:document_id].is_a?(String) && !options[:document... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Puts tokens in start places Executes automated actions if any enabled Fills out weights for futher usage | def init
return if @initialized
# Fill start places with tokens to let the process start
put_token(start_place)
start_place[:enabled] = true
# Terminators are used to identify which transitions can be executed
@terminators = {}
@net.places.select(&:start?).each do |start_plac... | [
"def update_tool_token\n return if @tool_effect_delay > 0\n $game_map.events_withtags.each do |event|\n if obj_size?(event, @tool_size) and event.start_delay == 0\n wid = event.token_weapon\n aid = event.token_armor\n iid = event.token_item\n sid = event.token_skill\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Runs all automated transitions which are enabled at the moment | def execute_automated!(source: nil, params: {}, color: {})
@net.transitions.each do |transition|
if transition.automated? &&
source != transition &&
transition_enabled?(transition, color: color)
perform_action!(transition, params: params, color: color)
end
... | [
"def wait_for_state_transitions\n # don't wait for anything unless told otherwise\n end",
"def after_transition(*args, &block); end",
"def update_sm_with_actions\r\n puts_debug \"Update StateMachine with actions:\"\r\n puts_debug @state_machine.adjacency_matrix\r\n @state_machine.adjacency_matrix.v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /options/1 GET /options/1.xml | def show
@option = Options.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @option }
end
end | [
"def show\n\t@option = Option.find(params[:id])\n\n\n\trespond_to do |format|\n\t format.html # show.html.erb\n\t format.xml { render :xml => @option }\n\tend\n end",
"def show\n @opt = Opt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml =>... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /options/new GET /options/new.xml | def new
@option = Option.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @option }
end
end | [
"def new\n @opt = Opt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @opt }\n end\n end",
"def new\n @option = @options.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @option_type = OptionType... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /options/1 DELETE /options/1.xml | def destroy
@option = Option.find(params[:id])
@option.destroy
respond_to do |format|
format.html { redirect_to(options_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @opt = Opt.find(params[:id])\n @opt.destroy\n\n respond_to do |format|\n format.html { redirect_to(opts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @auto_option = AutoOption.find(params[:id])\n @auto_option.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /generator_infos/1 GET /generator_infos/1.json | def show
@generator_info = GeneratorInfo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @generator_info }
end
end | [
"def show\n @generator = Generator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @generator }\n end\n end",
"def new\n @generator_info = GeneratorInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /generator_infos/new GET /generator_infos/new.json | def new
@generator_info = GeneratorInfo.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @generator_info }
end
end | [
"def new\n @generator = Generator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator }\n end\n end",
"def create\n @generator_info = GeneratorInfo.new(params[:generator_info])\n\n respond_to do |format|\n if @generator_info.save\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /generator_infos POST /generator_infos.json | def create
@generator_info = GeneratorInfo.new(params[:generator_info])
respond_to do |format|
if @generator_info.save
format.html { redirect_to @generator_info, notice: 'Generator info was successfully created.' }
format.json { render json: @generator_info, status: :created, location: @g... | [
"def new\n @generator_info = GeneratorInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator_info }\n end\n end",
"def create\n @generator = Generator.new(generator_params)\n\n respond_to do |format|\n if @generator.save\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /generator_infos/1 PUT /generator_infos/1.json | def update
@generator_info = GeneratorInfo.find(params[:id])
respond_to do |format|
if @generator_info.update_attributes(params[:generator_info])
format.html { redirect_to @generator_info, notice: 'Generator info was successfully updated.' }
format.json { head :no_content }
else
... | [
"def update\n respond_to do |format|\n if @generator.update(generator_params)\n format.html { redirect_to @generator, notice: 'Generator was successfully updated.' }\n format.json { render :show, status: :ok, location: @generator }\n else\n format.html { render :edit }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /generator_infos/1 DELETE /generator_infos/1.json | def destroy
@generator_info = GeneratorInfo.find(params[:id])
@generator_info.destroy
respond_to do |format|
format.html { redirect_to generator_infos_url }
format.json { head :no_content }
end
end | [
"def destroy\n @generator = Generator.find(params[:id])\n @generator.destroy\n\n respond_to do |format|\n format.html { redirect_to generators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generator.destroy\n respond_to do |format|\n format.html { redirec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns true iff the audience recalls the scenes happening in the given order. | def recall? *scenes
unmatched = scenes.dup
@@memories.each do |memory|
unmatched.shift if unmatched[0] == memory
end
unmatched.empty?
end | [
"def will_cue? scene\n (@scene.class == scene and @next_scene.nil?) or @next_scene == scene\n end",
"def will_cue? scene\n (@scene.class == scene and @next_scene.nil?) || @next_scene == scene\n end",
"def animate_scenes_reversed?\n default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:animate_s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
releases all players from a team back into the field | def release_players
Player.where(team_id: id).update_all(team_id: nil, active: false)
end | [
"def revive\n @players.each &:revive\n proceed\n end",
"def reordenate_team\n position = 1\n self.players.each do |player|\n player.update_attribute(:position, position)\n position += 1\n end\n end",
"def unassignTeam _args\n \"unassignTeam _args;\" \n end",
"def remove_from... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Recipe.most_popular should return the recipe instance with the highest number of users (the recipe that has the most recipe cards) | def most_popular
# Recipecard.all.select {|rc| rc.recipe ==self}
# most_popular.map {|rc| rc.users}
recipe_hash = {}
RecipeCard.all.each do |recipecard|
if recipe_hash[recipecard.name]==nil
recipe_hash[recipecard.name]=1
else
recipe_hash[recipecard.name]+= 1
... | [
"def find_most_popular\n find(:all).sort {|r1, r2| r1.rate_average <=> r2.rate_average}.last\n end",
"def show_most_popular\n @cards = Card.order(\"impressions_count DESC\")[0..19]\n end",
"def most_used_card(top_how_many_cards)\n sql = <<-SQL\n SELECT cards.id, MAX(cards.name) as name, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Recipeingredients should return all of the ingredients in this recipe | def ingredients
recipeingredient.map {|ri| ri.ingredient}
end | [
"def ingredients\n recipe_ingredients.map do |r|\n r.ingredient\n end\n end",
"def ingredients\n (self.recipe_ingredients + self.steps.select{ |i| i.is_recipe_id }.map{|i|\n Recipe.includes(:recipe_ingredients).find(i.is_recipe_id).ingredients\n }.compact).flatten\n end",
"def cookbook_i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
(0 + km) % n == 0 m = 4 n = 10 k = 5 km % n = 0 km = cn k = cn / m This works (100% performance) but is not best way O(log(n + m)) | def fast_solution(n, m)
# eaten = c * n / m. Find c that makes (c * n) % m == 0.
c = 0
begin
c += 1
c = m / n if m == 1000000000
end until (c * n) % m == 0
c * n / m
end | [
"def optimized_calculate(n, m)\n return 0 if m < n || m > 6 * n\n compositions = (0..n).map do |i|\n (-1)**i * C_n_k(i, n) * C_n_k(n - 1, m - 6 * i - 1)\n end.reduce(:+)\n Rational(compositions) / Rational(6**n)\nend",
"def candies(n, m)\n (m / n).round * n\nend",
"def candies(n, m)\n return m / n * ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build a new trip place from PlacesDetails element | def from_place_details details
components = details[:address_components]
unless components.nil?
components.each do |component|
types = component[:types]
if types.nil?
next
end
if 'street_address'.in? types
self.address1 = component[:long_name]
e... | [
"def from_place_details details\n\n components = details[:address_components]\n unless components.nil?\n components.each do |component|\n types = component[:types]\n if types.nil?\n next\n end\n if 'street_address'.in? types\n self.address = component[:long_n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
discover the zipcode for this trip place from its relationships | def zipcode
return poi.zip unless poi.nil?
return place.zip unless place.nil?
return get_zipcode
end | [
"def zipcode\n return poi.zip unless poi.nil?\n return place.zip unless place.nil?\n return get_zipcode \n end",
"def zip\n address.postal_code\n end",
"def search_zip_code\r\n @addresses = Address.find_by_zip_code(params[:address][:zip_code])\r\n end",
"def route\n self.cust... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return urlsafe base64 HMAC for data, assumes hmac_secret is set. | def compute_hmac(data)
s = [compute_raw_hmac(data)].pack('m').chomp!("=\n")
s.tr!('+/', '-_')
s
end | [
"def hmac_for data\n HMAC::SHA256.digest(KEY, data)\n end",
"def hmac\n @hmac ||= begin\n digest = OpenSSL::Digest.new(\"sha256\")\n raw_hmac = OpenSSL::HMAC.digest(digest, key, encrypted_data)\n Base64.encode64(raw_hmac)\n end\n end",
"def hmac\n @hmac |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a string for the parameter name. This will be an empty string if the parameter doesn't exist. | def param(key)
param_or_nil(key).to_s
end | [
"def param_name\n @param_name.respond_to?(:call) ? @param_name.call : @param_name\n end",
"def base_param_name\n @options[:param_name] || @name\n end",
"def config_param_name\n \"#{self.call_name}.#{self.parameter_name}\"\n end",
"def parameter(name)\n parameters.find { |p| ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return nil by default for values over maximum bytesize. | def over_max_bytesize_param_value(key, value)
nil
end | [
"def check_allowed_bytesize(v, max)\n end",
"def default_max_in_memory_size\n @default_max_in_memory_size || DEFAULT_MAX_IN_MEMORY_SIZE\n end",
"def max_size\n data[:max_size]\n end",
"def default_length\n return @default_length\n end",
"def maximum_bytes... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return nil by default for values with null bytes | def null_byte_parameter_value(key, value)
nil
end | [
"def validates_no_null_byte(atts, opts=OPTS)\n validatable_attributes_for_type(:no_null_byte, atts, opts){|a,v,m| validation_error_message(m) if String === v && v.include?(\"\\0\")}\n end",
"def write_null(_datum)\n nil\n end",
"def _nil\n\n _save = self.pos\n while true # sequ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Don't set an error status when redirecting in an error case, as a redirect status is needed. | def set_redirect_error_status(status)
end | [
"def default_redirect_status\n 302\n end",
"def halt_redirect(errors, render_options = {})\n halt_error(451, errors, render_options)\n end",
"def redirect(location, status = '302'); request.redirect(location, status); end",
"def redirect url_or_path, status=302\n status = status.t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the password hash for the user. When using database authentication functions, note that only the salt is returned. | def get_password_hash
if account_password_hash_column
account![account_password_hash_column]
elsif use_database_authentication_functions?
db.get(Sequel.function(function_name(:rodauth_get_salt), account ? account_id : session_value))
else
# :nocov:
password_hash_ds.get(... | [
"def password_hash(password, salt)\n BCrypt::Engine.hash_secret(password, salt)\n end",
"def hash_user_password\n self.password = sha1_digest(self.user_password, self.salt)\n self.user_password = nil\n end",
"def get_hashed_password(username)\n db = connect()\n hashed_password = db.execute(\"SE... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
In cases where retrying on uniqueness violations cannot work, this will detect whether a uniqueness violation is raised by the block and return the exception if so. This method should be used if you don't care about the exception itself. | def raises_uniqueness_violation?(&block)
transaction(:savepoint=>:only, &block)
false
rescue unique_constraint_violation_class => e
e
end | [
"def retry_transaction(&block)\n tries = 3\n begin\n yield\n rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique\n tries -= 1\n if tries > 0\n retry\n else\n raise\n end\n end\n end",
"def handle_custom_unique_constraint\n yield\n rescue Ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Work around jdbc/sqlite issue where it only raises ConstraintViolation and not UniqueConstraintViolation. | def unique_constraint_violation_class
if db.adapter_scheme == :jdbc && db.database_type == :sqlite
# :nocov:
Sequel::ConstraintViolation
# :nocov:
else
Sequel::UniqueConstraintViolation
end
end | [
"def save_detecting_duplicate_entry_constraint_violation\n begin\n save\n rescue ActiveRecord::StatementInvalid => e\n # Would that rails gave us the nested exception to check...\n if e.message =~ /.*[Dd]uplicate/\n errors.add_to_base(translate_with_theme('duplicate_entry_please_try_agai... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /frontapp_support_sources POST /frontapp_support_sources.json | def create
@support_source = FrontappSupportSource.new(frontapp_support_source_params)
respond_to do |format|
if @support_source.save
format.html { redirect_to support_sources_path,
notice: 'Support source was successfully created.' }
format.json { render :show, status: :created... | [
"def create\n @support_source = SupportbeeSupportSource.new(supportbee_support_source_params)\n\n respond_to do |format|\n if @support_source.save\n format.html { redirect_to support_sources_path,\n notice: 'Support source was successfully created.' }\n format.json { render :show, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /frontapp_support_sources/1 PATCH/PUT /frontapp_support_sources/1.json | def update
respond_to do |format|
if @support_source.update(frontapp_support_source_params)
format.html { redirect_to @support_source,
notice: 'Support source was successfully updated.' }
format.json { render :show, status: :ok, location: @support_source }
else
format.h... | [
"def update\n respond_to do |format|\n if @support_source.update(supportbee_support_source_params)\n format.html { redirect_to @support_source,\n notice: 'Support source was successfully updated.' }\n format.json { render :show, status: :ok, location: @support_source }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /frontapp_support_sources/1 DELETE /frontapp_support_sources/1.json | def destroy
@support_source.destroy
respond_to do |format|
format.html { redirect_to support_sources_url,
notice: 'Support source was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @source_ext.destroy\n respond_to do |format|\n format.html { redirect_to source_exts_url, notice: 'Source ext was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @source.destroy\n respond_to do |format|\n format.html { redire... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
replicate the given item ID on an additional node | def replicate_once(item_id)
current_nodes = find_nodes(item_id)
possible_nodes = @master.data_nodes.values.select {|n| not current_nodes.include?(n)}
target_node = possible_nodes[(rand * possible_nodes.size).floor]
begin
current_nodes[0].replicate_data(item_id, target_node)
... | [
"def replicate_node(node_id)\n data_to_replicate = get_data_list(node_id)\n data_to_replicate.each do |data_id|\n replicate(data_id)\n end\n end",
"def item_id!(node, item_id, element_name=\"#{NS_EWS_TYPES}:ItemId\")\n node.add(element_name) do |iid|\n if (item_id.is_a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
find all nodes this item ID is currently stored on | def find_nodes(item_id)
return @data_to_nodes[item_id]
end | [
"def get_all_items\n items(@nodename)\n end",
"def nodes\n\t\t# Query the database\n\t\tnodeQuery = Node.select(:node_id)\n\t\t# Place the query in an array\n\t\tnodeArray = Array.new\n\t\tnodeQuery.each do |node|\n\t\t\tnodeArray.push [node.node_id]\n\t\tend\n\t\treturn nodeArray\n\tend",
"def node... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
replicate all data on a node | def replicate_node(node_id)
data_to_replicate = get_data_list(node_id)
data_to_replicate.each do |data_id|
replicate(data_id)
end
end | [
"def replicate_data_before_registration\n sorted_hash_keys = @@dynamo_nodes.sort_by { |_k,v| v.first.second.to_i}.map {|_k,v| v.first.second}\n sorted_hash_keys << @@my_key\n sorted_hash_keys = sorted_hash_keys.sort\n\n hash = Hash[sorted_hash_keys.map.with_index.to_a]\n\n nodes_to_be_replicated = []... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /po_receipts POST /po_receipts.json | def create
@po_receipt = PoReceipt.new(po_receipt_params)
respond_to do |format|
if @po_receipt.save
format.html { redirect_to @po_receipt, notice: 'Po receipt was successfully created.' }
format.json { render :show, status: :created, location: @po_receipt }
else
format.html... | [
"def create\n @receipt = current_user.receipts.build(params[:receipt])\n\n respond_to do |format|\n if @receipt.save!\n format.html { redirect_to @receipt, notice: 'Receipt was successfully created.' }\n format.json { render json: @receipt, status: :created, location: @receipt }\n else... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /po_receipts/1 PATCH/PUT /po_receipts/1.json | def update
respond_to do |format|
if @po_receipt.update(po_receipt_params)
format.html { redirect_to @po_receipt, notice: 'Po receipt was successfully updated.' }
format.json { render :show, status: :ok, location: @po_receipt }
else
format.html { render :edit }
format.jso... | [
"def update\n respond_to do |format|\n if @receipt.update(receipt_params)\n format.html { redirect_to client_receipts_path(@receipt.client), notice: 'Receipt was successfully updated.' }\n format.json { render :show, status: :ok, location: url_receipt(@receipt) }\n else\n set_peopl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /po_receipts/1 DELETE /po_receipts/1.json | def destroy
lifnr = @po_receipt.lifnr
lifdn = @po_receipt.lifdn
werks = @po_receipt.werks
@po_receipt.destroy
respond_to do |format|
format.html { redirect_to po_receipts_url(lifnr: lifnr, lifdn: lifdn, werks: werks) }
format.json { head :no_content }
end
end | [
"def destroy\n @receipt = Receipt.find(params[:id])\n @receipt.destroy\n\n respond_to do |format|\n format.html { redirect_to receipts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @receipt = Receipt.find(params[:id])\n @receipt.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /spiders GET /spiders.json | def index
@spiders = Spider.all
end | [
"def listspiders(project=self.project)\n get('listspiders.json', project: project)['spiders']\n end",
"def index\n @spiders = Spider.where(:stop => false)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spiders }\n format.rb {\n render \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /spiders POST /spiders.json | def create
@spider = Spider.new(spider_params)
respond_to do |format|
if @spider.save
format.html { redirect_to @spider, notice: 'Spider was successfully created.' }
format.json { render :show, status: :created, location: @spider }
else
format.html { render :new }
fo... | [
"def create\n @spider = Spider.new(params[:spider])\n\n respond_to do |format|\n if @spider.save\n format.html { redirect_to @spider, notice: 'Spider was successfully created.' }\n format.json { render json: @spider, status: :created, location: @spider }\n else\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /spiders/1 DELETE /spiders/1.json | def destroy
@spider.destroy
respond_to do |format|
format.html { redirect_to spiders_url, notice: 'Spider was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @spider = Spider.find(params[:id])\n @spider.destroy\n\n respond_to do |format|\n format.html { redirect_to spiders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spider_url = SpiderUrl.find(params[:id])\n @spider_url.destroy\n\n respond_to do... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /publications POST /publications.json | def create
@publication = Publication.new(publication_params)
respond_to do |format|
if @publication.save
format.html { redirect_to publications_url, notice: 'Publication was successfully created.' }
format.json { render :show, status: :created, location: @publication }
else
... | [
"def create\n @publication = Publication.new(publication_params)\n\n if @publication.save\n render json: @publication, status: :created\n else\n reponse = { status: \"error\", code: 422,\n message: \"couldn't create the publication\",\n errors: @publication.error... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /crossword_puzzles/new GET /crossword_puzzles/new.json | def new
@crossword_puzzle = CrosswordPuzzle.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @crossword_puzzle }
end
end | [
"def new\n @wordup = Wordup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wordup }\n end\n end",
"def new\n @paper_word = PaperWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paper_word }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /crossword_puzzles POST /crossword_puzzles.json | def create
@crossword_puzzle = CrosswordPuzzle.new(params[:crossword_puzzle])
if !@crossword_puzzle.user && current_user
@crossword_puzzle.user = current_user
end
respond_to do |format|
if @crossword_puzzle.save
if current_user.admin
format.html { redirect_to @crossword_puzzle, n... | [
"def create\n @ppomppu_freeboard_word = PpomppuFreeboardWord.new(ppomppu_freeboard_word_params)\n\n respond_to do |format|\n if @ppomppu_freeboard_word.save\n format.html { redirect_to @ppomppu_freeboard_word, notice: 'Ppomppu freeboard word was successfully created.' }\n format.json { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /crossword_puzzles/1 PUT /crossword_puzzles/1.json | def update
@crossword_puzzle = CrosswordPuzzle.find(params[:id])
respond_to do |format|
if @crossword_puzzle.update_attributes(params[:crossword_puzzle])
format.html { redirect_to edit_crossword_puzzle_path(@crossword_puzzle), notice: 'Puzzle saved!' }
format.json { head :no_content }
... | [
"def update\n if @crossword.update_attributes(update_crossword_params)\n alert_js('SUCCESS crossword updated.')\n else\n alert_js('!!!ERROR updating crossword!!!')\n end\n end",
"def update\n authorize @crossword\n @crossword.update(crossword_params)\n if crossword_params[:leader_bo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prints the map in regards to what the player has seen. Additionally, provides current location and the map's name. | def print_map
# Provide some spacing from the edge of the terminal.
3.times { print " " };
print @map.name + "\n\n"
@map.tiles.each_with_index do |row, r|
# Provide spacing for the beginning of each row.
2.times { print " " }
row.each_with_index do |tile, t|
... | [
"def print_map\n puts \"LIFE: #{player.life} GOLD: #{player.gold} EXPERIENCE: #{player.experience}\".border\n puts\n puts \"-- Dungeon Map --\".align_center\n puts\n puts_formatted_dungeon_map\n puts\n puts \"--- Use arrow keys to move. Beware lurking monsters ---\".border\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prints a minimap of nearby tiles (using VIEW_DISTANCE). | def print_minimap
print "\n"
for y in (@location.first-VIEW_DISTANCE)..(@location.first+VIEW_DISTANCE)
# skip to next line if out of bounds from above map
next if y.negative?
# centers minimap
10.times { print " " }
for x in (@location.second-VIEW_DISTANCE)..(@locatio... | [
"def print_minimap\n print \"\\n\"\n for y in (@location.first-VIEW_DISTANCE)..(@location.first+VIEW_DISTANCE)\n # skip to next line if out of bounds from above map\n next if y < 0\n # centers minimap\n 10.times do\n print \" \"\n end\n for x in (@location.second-VIEW_DIST... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prints the tile based on the player's location. | def print_tile(coords)
if ((@location.first == coords.first) && (@location.second == coords.second))
print "¶ "
else
print @map.tiles[coords.first][coords.second].to_s
end
end | [
"def print_tile(coords)\n if ((@location.coords.first == coords.first) && (@location.coords.second == coords.second))\n print \"¶ \"\n else\n print @location.map.tiles[coords.first][coords.second].to_s\n end\n end",
"def print_tile(coords)\n if ((@location.first == coords.first)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the gold given to a victorious Entity after losing a battle and deducts the figure from the Player's total as necessary | def sample_gold
gold_lost = 0
# Reduce gold if the player has any.
if @gold.positive?
type("Looks like you lost some gold...\n\n")
gold_lost = @gold/2
@gold -= gold_lost
end
gold_lost
end | [
"def gain_gold\n if $game_troop.gold_total > 0\n rate = Grade.rate(:gold)\n gold = $game_troop.gold_total\n gold = gold * rate / 100\n $game_party.gain_gold(gold)\n else\n gold = 0\n end\n return gold\n end",
"def silver\n ( self - gold * 1000 )\n end",
"def gold\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /test_questions/new GET /test_questions/new.json | def new
@test_question = TestQuestion.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @test_question }
end
end | [
"def new\n @question = Question.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end",
"def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /test_questions POST /test_questions.json | def create
@test_question = TestQuestion.new(params[:test_question])
respond_to do |format|
if @test_question.save
format.html { redirect_to @test_question, :notice => 'Test question was successfully created.' }
format.json { render :json => @test_question, :status => :created, :location ... | [
"def create\n @test_question = TestQuestion.new(test_question_params)\n\n respond_to do |format|\n if @test_question.save\n format.html { redirect_to @test_question, notice: 'Test question was successfully created.' }\n format.json { render :show, status: :created, location: @test_question ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /test_questions/1 PUT /test_questions/1.json | def update
@test_question = TestQuestion.find(params[:id])
respond_to do |format|
if @test_question.update_attributes(params[:test_question])
format.html { redirect_to @test_question, :notice => 'Test question was successfully updated.' }
format.json { head :ok }
else
format... | [
"def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /test_questions/1 DELETE /test_questions/1.json | def destroy
@test_question = TestQuestion.find(params[:id])
@test_question.destroy
respond_to do |format|
format.html { redirect_to test_questions_url }
format.json { head :ok }
end
end | [
"def destroy\n @ttest_question.destroy\n respond_to do |format|\n format.html { redirect_to ttest_questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = @test.questions.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Cancel an existing order Void/refund all associated payments Set order status to :canceled | def cancel status=:canceled
result = true
# Refund all transactions associated with order
self.select_order_transactions.payments.each do |t|
result = self.braintree_refund_transaction t
end
# Mark the order as canceled if all braintree refunds succeeded
if result
self.edit_mode = ... | [
"def cancel_order\n if self.status.downcase == \"pending\"\n self.status = \"Canceled\"\n self.save\n self\n else \n \"Error in Order Model\"\n end\n end",
"def cancel\n if params[:cancel_reason].blank?\n format_response({ success: false,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get details of a stored procedure | def stored_procedure(name)
get "#{base_url}/storedprocedures/#{name}"
end | [
"def inspect\n \"<#{self.class.name}/StoredProcedure name=#{@sproc_name}>\"\n end",
"def describe_procedure(procedure_name)\n __describe(procedure_name, OCI8::Metadata::Procedure, false)\n end",
"def get_procedures\n connect_db.fetch(\"SELECT RDB$PROCEDURE_NAME, RDB$PROCEDURE_SOURCE FROM RDB... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /xmt/addons/1 DELETE /xmt/addons/1.json | def destroy
@addon.drop
@addon.save(isinstall: 0)
respond_to do |format|
format.html { redirect_to xmt_addons_url, notice: '卸载成功.' }
format.json { head :no_content }
end
end | [
"def destroy\n @addon.destroy\n respond_to do |format|\n format.html { redirect_to addons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @addon = Addon.find(params[:id])\n @addon.destroy\n\n respond_to do |format|\n format.html { redirect_to addons_url }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /equipment_line_items GET /equipment_line_items.json | def index
@equipment_line_items = EquipmentLineItem.all
end | [
"def show\n @item_lines = ItemLine.find(params[:id])\n\n render json: @item_lines\n end",
"def show\n @line_items = LineItem.find(params[:id])\n render json: @line_items\n end",
"def line_item_example\n line_item_service = AtomicLti::Services::LineItems.new(@application_instance, @lti_token)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /equipment_line_items POST /equipment_line_items.json | def create
@equipment_move_buffer = current_equipment_buffer
equipment = Equipment.find(params[:equipment_id])
@equipment_line_item = @equipment_move_buffer.equipment_line_items.build(equipment_id: equipment.id)
respond_to do |format|
if @equipment_line_item.save
format.html { redirect_to... | [
"def create\n @item_lines = ItemLine.new(item_line_params)\n\n if @item_lines.save\n render json: @item_lines, status: :created, location: @item_lines\n else\n render json: @item_lines.errors, status: :unprocessable_entity\n end\n end",
"def create\n @line_item = @order.line_items.new(li... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /equipment_line_items/1 PATCH/PUT /equipment_line_items/1.json | def update
respond_to do |format|
if @equipment_line_item.update(equipment_line_item_params)
format.html { redirect_to @equipment_line_item, notice: 'Equipment line item was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
... | [
"def update\n @line_items = LineItem.find(params[:id])\n if @line_item.update(line_item_params)\n render json: {status: :ok}\n else\n render json: { status: :unprocessable_entity }\n end\n end",
"def update\n @item_line = ItemLine.find(params[:id])\n\n respond_to do |format|\n if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /equipment_line_items/1 DELETE /equipment_line_items/1.json | def destroy
@equipment_line_item.destroy
respond_to do |format|
format.html { redirect_to equipment_line_items_url }
format.json { head :no_content }
end
end | [
"def destroy\n @line_items = LineItem.find(params[:id])\n @line_item.destroy\n if @line_item.destroy\n render json: {status: :successfully}\n else\n render json: { status: error}\n end\n end",
"def destroy\n @v1_item_line = V1::ItemLine.find(params[:id])\n @v1_item_line.destroy\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the UCB::LDAP::Person for this User | def ldap_person
@person ||= UCB::LDAP::Person.find_by_uid(self.login) if self.login
end | [
"def ldap_person\r\n @person ||= UCB::LDAP::Person.find_by_uid(self.login) if self.login\r\n end",
"def find_user\n results = @ldap.search( :base => options[:ldap][:base], :filter => user_filter)\n return results.first\n end",
"def ldap_user\n LdapUser::find(:attribute => 'mail', :value => l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses the textbox list of proglangs from "c++,python" etc. to an enumerable object proglangs | def handle_proglangs(proglang_names)
return if !self.undergrad? || proglang_names.nil?
self.proglangs = [] # eliminates any previous proficiencies so as to avoid duplicates
proglang_array = []
proglang_array = proglang_names.split(',').uniq if proglang_names
proglang_array.each do |pl|
self.p... | [
"def handle_proglangs\r\n return if self.is_faculty?\r\n self.proglangs = [] # eliminates any previous proficiencies so as to avoid duplicates\r\n proglang_array = []\r\n proglang_array = proglang_names.split(',').uniq if ! proglang_names.nil?\r\n proglang_array.each do |pl|\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does its best to convert the input into a Boolean. | def convert_to_boolean(input)
case input
when false, 0, '0', 'false', 'no', nil then false
else
true
end
end | [
"def to_bool\n is_a?(::TrueClass) || self == :true || self == :yes || self == :on\n end",
"def convert_to_boolean(val)\n return val if val.is_a?(TrueClass) || val.is_a?(FalseClass)\n val = val.to_s.clean\n return nil if val.blank?\n if val.match?(/\\A(false|f|n|no)\\z/i)\n false... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /alternativas GET /alternativas.json | def index
@alternativas = Alternativa.all
end | [
"def index\n @alternativos = Alternativo.all\n end",
"def show\n @alternativa = Alternativa.find(params[:id])\n @caracteristica = @alternativa.caracteristica\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @alternativa }\n end\n end",
"def creat... | {
"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.