query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Is the brewed Python installed | def brewed?
@brewed ||= begin
require 'formula'
Formula.factory(@name).linked_keg.exist?
end
end | [
"def have_brew?\n have_command? :brew\n end",
"def installed?\n result = current_shell.exec \"#{@bin_path}/brew info #{@package_name}\"\n\n if current_shell.last_exit_status.zero?\n !result.match %r[Not installed]\n else\n false\n end\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is the python the one from OS X? | def from_osx?
@from_osx ||= begin
p = `#{binary} -c "import sys; print(sys.prefix)"`.strip
p.start_with?("/System/Library/Frameworks/Python.framework")
end
end | [
"def os_x?\n RUBY_PLATFORM.match(/darwin/)\n end",
"def mac? ; RUBY_PLATFORM =~ /.*(sal|86).*-darwin1/i end",
"def applescript?\n osx? && begin\n run('osalang', quietly: true).include? 'AppleScript'\n end\n end",
"def installed?\n MacOS.dev_tools_path == Pathname.new(\"/usr/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is the `python` a PyPy? | def pypy?
@pypy ||= !(`#{binary} -c "import sys; print(sys.version)"`.downcase =~ /.*pypy.*/).nil?
end | [
"def function_or_method?\n check = RubyPython::Macros.PyObject_TypeCheck(@pointer, [\n RubyPython::Python.PyFunction_Type.to_ptr,\n RubyPython::Python.PyCFunction_Type.to_ptr,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Refresh the object with the new response. This happens when a new access token is requested using a request token. | def refresh(response)
@access_token = response[:access_token]
@expires_at = Time.now + response[:expires_in]
end | [
"def refresh\n set_access_token\n\n logger.info(\"Successfully refreshed/created access token.\")\n head :ok\n end",
"def refresh!\n response = request_token_from_google\n data = JSON.parse(response.body)\n update_attributes(\n access_token: data['access_token'],\n expires_at: Time.now + ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /sport_categories POST /sport_categories.json | def create
@sport_category = SportCategory.new(sport_category_params)
respond_to do |format|
if @sport_category.save
format.html { redirect_to @sport_category, notice: 'Sport category was successfully created.' }
format.json { render :show, status: :created, location: @sport_category }
... | [
"def categories(sport_id)\n get(\"sports/en/sports/sr:sport:#{sport_id}/categories.xml\")\n end",
"def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend",
"def create\n @sportgoods_category = SportgoodsCategory.new(sportgood... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /sport_categories/1 DELETE /sport_categories/1.json | def destroy
@sport_category.destroy
respond_to do |format|
format.html { redirect_to sport_categories_url, notice: 'Sport category was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @sportgoods_category.destroy\n respond_to do |format|\n format.html { redirect_to sportgoods_categories_url, notice: 'Sportgoods category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n render json: @catego... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Called when entering this state. | def enter_state
end | [
"def enter_in_sinking_state\n @update_callback = :update_enter_sinking_state\n @update_callback_count = 0\n end",
"def on_enter\n ## Form has already set this, and set modified to false\n @state = :HIGHLIGHTED # duplicating since often these are inside containers\n #@focussed = true\n if @ha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reset timeout when granting vote to candidate. | def handle_vote_request(payload)
response = super(payload)
timeout.reset if response[:vote_granted]
response
end | [
"def reset_timeout!\n @timeout_at = Time.now + @timeout\n end",
"def vote(candidates) sleep(1) end",
"def election_timeout\n options[:election_timeout] || ELECTION_TIMEOUT\n end",
"def set_election_timeout(timeout)\n cfg = get_rs_config\n cfg['settings']['electionTimeoutMillis'] = timeout * 1000... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reset timeout when receiving valid AppendEntries RPC. FIXME: This is pseudocode. | def handle_append_entries(payload)
response = super(payload)
if response[:success]
timeout.reset
end
response
end | [
"def handle_timeout\n pop_outstanding_request\n nil\n end",
"def set_pending_connect_timeout(value); end",
"def read_timeout=(timeout); end",
"def adjust timeout\n if :blocking == timeout || -1 == timeout\n -1\n else\n timeout.to_i\n end\n end",
"def return_to_qu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /standard_measurements/1 GET /standard_measurements/1.json | def show
@standard_measurement = StandardMeasurement.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @standard_measurement }
end
end | [
"def new\n @standard_measurement = StandardMeasurement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @standard_measurement }\n end\n end",
"def show\n @measurement = Measurement.find(params[:id])\n\n respond_to do |format|\n format.json { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /standard_measurements/new GET /standard_measurements/new.json | def new
@standard_measurement = StandardMeasurement.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @standard_measurement }
end
end | [
"def create\n @standard_measurement = StandardMeasurement.new(params[:standard_measurement])\n\n respond_to do |format|\n if @standard_measurement.save\n format.html { redirect_to @standard_measurement, notice: 'Standard measurement was successfully created.' }\n format.json { render json: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /standard_measurements POST /standard_measurements.json | def create
@standard_measurement = StandardMeasurement.new(params[:standard_measurement])
respond_to do |format|
if @standard_measurement.save
format.html { redirect_to @standard_measurement, notice: 'Standard measurement was successfully created.' }
format.json { render json: @standard_m... | [
"def create\n data = reload(get_series('body'), str(Date.strptime(params[:measurement].values.join(\"-\"))))\n saved = false\n get_series('body').each do |s|\n # get variable name from last part of series\n data[s].each do |day|\n @measurement = find_for(day['dateTime'])\n @measurem... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /standard_measurements/1 PUT /standard_measurements/1.json | def update
@standard_measurement = StandardMeasurement.find(params[:id])
respond_to do |format|
if @standard_measurement.update_attributes(params[:standard_measurement])
format.html { redirect_to @standard_measurement, notice: 'Standard measurement was successfully updated.' }
format.json... | [
"def update\n if @measure.update(measure_params)\n head :no_content, status: 204\n else\n render json: @measure.errors, status: 422\n end \n end",
"def update\n if @measure.update(measure_params)\n head :no_content\n else\n render json: @measure.errors, status: :unprocessable_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /standard_measurements/1 DELETE /standard_measurements/1.json | def destroy
@standard_measurement = StandardMeasurement.find(params[:id])
@standard_measurement.destroy
respond_to do |format|
format.html { redirect_to standard_measurements_url }
format.json { head :no_content }
end
end | [
"def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measurement = Measurement.find(params[:id])\n @measurement.destroy\n\n respond_to do |format|\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /many_alumnos_has_many_asignaturas GET /many_alumnos_has_many_asignaturas.json | def index
@many_alumnos_has_many_asignaturas = ManyAlumnosHasManyAsignatura.all
end | [
"def destroy\n @many_alumnos_has_many_asignatura.destroy\n respond_to do |format|\n format.html { redirect_to many_alumnos_has_many_asignaturas_url, notice: 'Many alumnos has many asignatura was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def update\n respon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /many_alumnos_has_many_asignaturas/1 PATCH/PUT /many_alumnos_has_many_asignaturas/1.json | def update
respond_to do |format|
if @many_alumnos_has_many_asignatura.update(many_alumnos_has_many_asignatura_params)
format.html { redirect_to @many_alumnos_has_many_asignatura, notice: 'Many alumnos has many asignatura was successfully updated.' }
format.json { render :show, status: :ok, lo... | [
"def update\n @factura = Factura.find(params[:factura_id])\n @renglon_factdetalle = @factura.renglon_factdetalles.find(params[:id])\n\n if (params[:renglon_factdetalle][:impuesto_ids] == nil)\n params[:renglon_factdetalle][:impuesto_ids] = []\n end\n\n respond_to do |format|\n if @renglon_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /many_alumnos_has_many_asignaturas/1 DELETE /many_alumnos_has_many_asignaturas/1.json | def destroy
@many_alumnos_has_many_asignatura.destroy
respond_to do |format|
format.html { redirect_to many_alumnos_has_many_asignaturas_url, notice: 'Many alumnos has many asignatura was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @motivo_consulta = MotivoConsulta.find(params[:motivo_consulta_id])\n @asignacion = @motivo_consulta.asignaciones.find(params[:id]) \n @asignacion.destroy\n\n respond_to do |format|\n format.html { redirect_to @motivo_consulta }\n format.json { head :no_content }\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /employeer_photos/1 GET /employeer_photos/1.xml | def show
@employeer_photo = EmployeerPhoto.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @employeer_photo }
end
end | [
"def index\n @photos = @place.photos\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @photos.to_xml }\n end\n end",
"def index\n @photos = @album.photos\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /employeer_photos/new GET /employeer_photos/new.xml | def new
@employeer_photo = EmployeerPhoto.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @employeer_photo }
end
end | [
"def new\n @photos = interesting\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @flickr_photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @photo }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /employeer_photos POST /employeer_photos.xml | def create
params.permit!
@employeer_photo = EmployeerPhoto.new(params[:employeer_photo])
respond_to do |format|
if @employeer_photo.save
format.html { redirect_to(@employeer_photo, :notice => 'Employeer photo was successfully created.') }
format.xml { render :xml => @employeer_photo... | [
"def create_photos\n end",
"def create\n @employer_photo = EmployerPhoto.new(params[:employer_photo])\n\n respond_to do |format|\n if @employer_photo.save\n format.html { redirect_to @employer_photo, notice: 'Employer photo was successfully created.' }\n format.json { render json: @emplo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /employeer_photos/1 PUT /employeer_photos/1.xml | def update
params.permit!
@employeer_photo = EmployeerPhoto.find(params[:id])
respond_to do |format|
if @employeer_photo.update_attributes(params[:employeer_photo])
format.html { redirect_to(@employeer_photo, :notice => 'Employeer photo was successfully updated.') }
format.xml { head... | [
"def picasa_update!\n resp, data = client.update_photo picasa_id, description, file\n \n if resp.code != \"200\" or resp.message != \"OK\"\n raise Picasa::Exception, \"Error updating photo: #{resp.message}.\"\n end\n \n populate_attributes_from_xml data\n end",
"def update\n @external_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /employeer_photos/1 DELETE /employeer_photos/1.xml | def destroy
@employeer_photo = EmployeerPhoto.find(params[:id])
@employeer_photo.destroy
respond_to do |format|
format.html { redirect_to(employeer_photos_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @external_photo = ExternalPhoto.find(params[:id])\n @external_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to(external_photos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @scrap_photo = ScrapPhoto.find(params[:id])\n @scrap_photo.d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Displays changelogs. If specified a `append` or `prepend` option, updates CHANGELOG.md with generated changelog. | def call
if append
changelog_editor.append!(content: changelog)
elsif prepend
changelog_editor.prepend!(content: changelog)
end
changelog
end | [
"def changelog\n # Add a changelog file to the project\n template 'CHANGELOG.md.tt', 'CHANGELOG.md'\n end",
"def compound_changelog\n @options.load_custom_ruby_files\n fetch_and_filter_tags\n fetch_issues_and_pr\n\n log = \"\"\n log += @options[:frontmatter] if @options[:fron... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a changelog. The result is memoized. | def changelog
@changelog ||= Generator.call(version: version)
end | [
"def make_changelog\n\tsh('git fetch --unshallow') if travis?\n\tlog = git_changelog\n\n\tlimit = 4_000\n\tending = '…'\n\n\tif log.length <= limit\n\t\tlog\n\telse\n\t\tlog[0, log.rindex(/\\s/, limit - ending.length)].rstrip + ending\n\tend\nend",
"def make_changelog\n @hg_opener.open \"00changelog.i\",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
numb The number to be checked. Examples even(2) => true Returns the apropriate boolean. | def even(numb)
return true if numb % 2 == 0
return false
end | [
"def check_cond(num)\n \tif num < 1000000\n\t\t\ttrue\n\t\telse\n\t\t\tputs \"Number not less than billion. Try again...\"\n\t\t\tfalse\n\t\tend\n end",
"def cmake_bool(b)\n return true if b.is_a? String and [\"true\", \"yes\", \"1\"].include?(b.downcase)\n return true if b.is_a? Integer and b > 0\n return f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return this string's note at fretNumber | def [](fretNum)
raise NoSuchFretError, E__M[:no_such_fret_error] unless (0..@length-1).include? fretNum
@notes[fretNum]
end | [
"def note_name\n name.split(/-?\\d\\z/).first\n end",
"def get_note_at_offset(note, offset)\n note = note.to_s\n # If the note ends with a number, increase it by offset and add it on again.\n if note.end_with?(\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\")\n octave = n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates an object and saves it to the MLS. The resulting object is returned whether or no the object was saved successfully to the MLS or not. ==== Examples !ruby Create a single new object User.create(:first_name => 'Jamie') Create a single object and pass it into a block to set other attributes. User.create(:first_na... | def create(attributes={}, &block) # TODO: testme
model = self.new(attributes)
yield(model) if block_given?
model.save
model
end | [
"def make_object(**attributes, &block)\n obj = new_object(**attributes, &block)\n _write(obj)\n obj\n end",
"def make_object(**attributes, &block)\n obj = new_object(**attributes, &block)\n _write(obj)\n obj\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ballots GET /ballots.json | def index
@ballots = Ballot.all
end | [
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def index\n @boats = Boat.all\n render :json => @boats.as_json\n end",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /configuration_files GET /configuration_files.json | def index
@configuration_files = ConfigurationFile.all
end | [
"def config_files\n @config_files\n end",
"def get_configurations(opts={})\n query_params = self.merge_query_options(opts)\n path = self.api_root + \"/api/configurations#{query_params}\"\n process_firecloud_request(:get, path)\n end",
"def configuration_files\n @configuration_files ||= []... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /configuration_files POST /configuration_files.json | def create
@configuration_file = ConfigurationFile.new(configuration_file_params)
respond_to do |format|
if @configuration_file.save
format.html { redirect_to @configuration_file, notice: 'Configuration file was successfully created.' }
format.json { render :show, status: :created, locati... | [
"def create\n @config_file = ConfigFile.new(params[:config_file])\n\n respond_to do |format|\n if @config_file.save\n format.html { redirect_to @config_file, notice: 'Config file was successfully created.' }\n format.json { render json: @config_file, status: :created, location: @config_file... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /configuration_files/1 PATCH/PUT /configuration_files/1.json | def update
respond_to do |format|
if @configuration_file.update(configuration_file_params)
format.html { redirect_to @configuration_file, notice: 'Configuration file was successfully updated.' }
format.json { render :show, status: :ok, location: @configuration_file }
else
format.... | [
"def update\n @config_file = ConfigFile.find(params[:id])\n\n respond_to do |format|\n if @config_file.update_attributes(params[:config_file])\n format.html { redirect_to @config_file, notice: 'Config file was successfully updated.' }\n format.json { head :no_content }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /configuration_files/1 DELETE /configuration_files/1.json | def destroy
@configuration_file.destroy
respond_to do |format|
format.html { redirect_to configuration_files_url, notice: 'Configuration file was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @config_file.destroy\n respond_to do |format|\n format.html { redirect_to config_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @config_file = ConfigFile.find(params[:id])\n @config_file.destroy\n\n respond_to do |format|\n format.html ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
initializes the Validation object on given +project+ | def initialize(project)
@project = project
@errors = []
end | [
"def run_on_project\n @errors = []\n\n # run validations against it\n # TODO: Move validation classes to class level definition\n @validations.each do |val_clazz|\n (@errors << run_validation(@project, val_clazz)).flatten!\n end\n\n if @errors.size == 0\n outputs 'VALIDAT... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ensures that objects of given +type_as_string+ (i.e. networks) are attached to zones | def objects_attached_to_zones?(type_as_string)
zones = @project.get_element('zones')
@project.get_element(type_as_string).each do |name, data|
zone = data[:zone] # assume that this object contains ref to a zone
if !zone
mark("#{type_as_string} is not attached to a zone", type_as... | [
"def networks_attached_to_zones?\n objects_attached_to_zones? 'networks'\n end",
"def uplink_has_network_of_type?(uplink, type)\n uplink_networks(uplink).map do |network|\n network[\"type\"].downcase\n end.include?(type.downcase)\n end",
"def objects_in_zone(type_name... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ask the player to enter the row and column of their next move TODO: Handle bad user input here. Q: Should we handle the case when the row and column are already taken in the UserInterface class? | def ask_player_for_move(player)
print "#{player} - enter your next move (row, column): "
row_col = gets.chomp
row, col = row_col.split(",").map {|row_or_col| row_or_col.to_i }
end | [
"def input_row_column\n puts \"Input row and Column Seprated by spaces:press q to quit\"\n input1 = gets.chomp\n if input1 == \"q\"\n return input1\n end\n input = input1.split(\" \")\n player_row = input[0].to_i - 1\n player_col = input[1].to_i - 1\n unless(row_col_validated(player_row... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is simplified from examples/h2o/h2o.conf upstream. | def conf_example(port = 8080)
<<~EOS
listen: #{port}
hosts:
"127.0.0.1.xip.io:#{port}":
paths:
/:
file.dir: #{var}/h2o/
EOS
end | [
"def database_type\n :h2\n end",
"def chain_config; end",
"def h_2!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 6 )\n\n type = H2\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at li... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deactivates a client changeing `is_active` to false. | def deactivate
@client = Client.find(params[:client_id])
@client.is_active = false
if @client.save
redirect_to client_path(@client), notice: 'El cliente fue desactivado'
else
redirect_to client_path(@client), notice: 'No pudimos deactivar este cliente'
end
end | [
"def deactivate\n @client.delete(\"paypal_accounts/#{id}\")\n @attributes['active'] = false\n true\n end",
"def deactivate\n @account_status = :deactivated\n end",
"def deactivate\n @is_active_lock.with_write_lock do\n @is_active = false\n end\n logger.info \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The capybara current session | def page
Capybara.current_session
end | [
"def current_session\n session_pool[\"#{current_driver}:#{session_name}:#{app.object_id}\"] ||= Capybara::Session.new(current_driver, app)\n end",
"def session\n if Thread.current['capybara_session'].nil?\n Thread.current['capybara_session'] = Capybara::Session.new(config[:default_driver])... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hovers over the root node of this component | def hover
root_node.hover
end | [
"def hover(*args)\n if args.empty?\n root.hover\n else\n widget(*args).hover\n end\n end",
"def hover(&blk)\n @__app__.current_slot.hover(&blk)\n end",
"def hover\n synchronize { base.hover }\n self\n end",
"def hover(&blk)\n @__a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clicks on the root node of this component | def click
root_node.click
end | [
"def click(*args)\n if args.empty?\n root.click\n else\n widget(*args).click\n end\n end",
"def click\n @_node.click\n @_node.getPage.getWebClient.waitForBackgroundJavaScriptStartingBefore(3000)\n end",
"def click(id)\n h = child(id).handle\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split a single Word Document DOCX into Separate Documents by Page Split a Word DOCX Document, comprised of multiple pages into separate Word DOCX document files, with each containing exactly one page. | def split_document_docx(input_file, opts = {})
data, _status_code, _headers = split_document_docx_with_http_info(input_file, opts)
data
end | [
"def split_document_docx_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SplitDocumentApi.split_document_docx ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_valida... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split a single Word Document DOCX into Separate Documents by Page Split a Word DOCX Document, comprised of multiple pages into separate Word DOCX document files, with each containing exactly one page. | def split_document_docx_with_http_info(input_file, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SplitDocumentApi.split_document_docx ...'
end
# verify the required parameter 'input_file' is set
if @api_client.config.client_side_validation && in... | [
"def split_document_docx(input_file, opts = {})\n data, _status_code, _headers = split_document_docx_with_http_info(input_file, opts)\n data\n end",
"def split_document_pdf_by_page(input_file, opts = {})\n data, _status_code, _headers = split_document_pdf_by_page_with_http_info(input_file, opts)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split a PDF file into separate PDF files, one per page Split an input PDF file into separate pages, comprised of one PDF file per page. | def split_document_pdf_by_page(input_file, opts = {})
data, _status_code, _headers = split_document_pdf_by_page_with_http_info(input_file, opts)
data
end | [
"def split_pdf(filename, density=300, format=:jpg)\n\n #If this isn't a PDF, return the unmodified filename.\n return filename unless File.extname(filename) == '.pdf'\n\n #Get the length of the PDF...\n length = Docsplit.extract_length(filename)\n\n #If we don't have a multi-page document, abort.\n return fil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split a single PowerPoint Presentation PPTX into Separate Slides Split an PowerPoint PPTX Presentation, comprised of multiple slides into separate PowerPoint PPTX presentation files, with each containing exactly one slide. | def split_document_pptx(input_file, opts = {})
data, _status_code, _headers = split_document_pptx_with_http_info(input_file, opts)
data
end | [
"def rebuild_pptx\n Zip::File.open(@files.to_s, Zip::File::CREATE) { |zipfile|\n @slides.each do |f|\n if f.changed\n # Temporary file to store the manipulated xml\n temp_file = Tempfile.new(f.slide_file_name)\n # Store the manipulated xml inside the file\n temp_fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split a single Text file (txt) into lines Split a Text (txt) Document by line, returning each line separately in order. Supports multiple types of newlines. | def split_document_txt_by_line(input_file, opts = {})
data, _status_code, _headers = split_document_txt_by_line_with_http_info(input_file, opts)
data
end | [
"def split_lines\n text.split(/\\n/)\n end",
"def lines\n text.split(/(?<=[\\n\\f])/)\n end",
"def lines(text)\n # Remove any trailing separators, and then split based on them\n # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]\n x = text.sub(/#{self.line_separator}\\Q/,'')... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split a single Text file (txt) by a string delimiter Split a Text (txt) Document by a string delimiter, returning each component of the string as an array of strings. | def split_document_txt_by_string(input_file, split_delimiter, opts = {})
data, _status_code, _headers = split_document_txt_by_string_with_http_info(input_file, split_delimiter, opts)
data
end | [
"def extractFromTextSplit(regex, text)\n\textract = Array.new\n\ttext.each_line do |s|\t\n\t\t\tif s.match(regex)\n\t\t\t\text=s.split(\"|\")\n\t\t\t\textract.push(ext[2])\n\n\t\t\tend\n\n\tend\n\n\treturn extract\n\nend",
"def get_array_from_text unparsed\n return unparsed.split(\"\\n\").map{|s| s.chomp}\nend",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split a single Excel XLSX into Separate Worksheets Split an Excel XLSX Spreadsheet, comprised of multiple Worksheets (or Tabs) into separate Excel XLSX spreadsheet files, with each containing exactly one Worksheet. | def split_document_xlsx(input_file, opts = {})
data, _status_code, _headers = split_document_xlsx_with_http_info(input_file, opts)
data
end | [
"def split( header )\n wb = Workbook.new\n ch( header ).each_wh.to_a.uniq.each { |name| wb.add( name ).load( data.headers ) }\n rows( header_rows+1 ) do |row|\n wb.sheets( row.val( header ) ) << row\n end\n wb\n end",
"def worksheets\n @worksheets ||= (1..number_of_worksheets... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /adresses/1 DELETE /adresses/1.json | def destroy
@adress = Adresse.find(params[:id])
@adress.destroy
respond_to do |format|
format.html { redirect_to adresses_url }
format.json { head :no_content }
end
end | [
"def destroy\n @adress = Adress.find(params[:id])\n @adress.destroy\n\n respond_to do |format|\n format.html { redirect_to adresses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @api_v1_address.destroy\n render json: 'deletado'\n end\n end",
"def des... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
given a sorted array of integers as method argument return a new array that includes all the missing integers in order between first argument and last. (only include missing integers) Requirements method that takes array of integers returns new array contains only the intergers that are not included in given array that... | def missing(array)
full_array_set = (array.first..array.last).to_a
missing_numbers = []
full_array_set.each do |number|
if array.include?(number)
next
else
missing_numbers << number
end
end
missing_numbers
end | [
"def missing(array)\n result = []\n (array.first).upto(array.last) do |num|\n result << num if !array.include?(num)\n end\n result\nend",
"def missing(sorted_arr)\n number_range = (sorted_arr[0]..sorted_arr[-1])\n result_arr = []\n\n sorted_arr.each_cons(2) do |first, second|\n result_arr += ((first ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns this organization's pricing setup that is effective on a given date. | def effective_pricing_setup_for_date(date=Date.today)
if self.pricing_setups.blank?
raise ArgumentError, "Organization has no pricing setups" if self.parent.nil?
return self.parent.effective_pricing_setup_for_date(date)
end
current_setups = self.pricing_setups.select { |x| x.effective_date.to_d... | [
"def pricing_setup_for_date(date)\n if self.pricing_setups.blank?\n raise ArgumentError, \"Organization has no pricing setups\" if self.parent.nil?\n return self.parent.pricing_setup_for_date(date)\n end\n\n current_setups = self.pricing_setups.select { |x| x.display_date.to_date <= date.to_date ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
unpublish this message so it is not displayed in user/messages | def unpublish
MessagePublish.new(@message).unpublish
if params[:redirect] == 'index'
return_url = admin_messages_path
else
return_url = admin_message_path(@message)
end
redirect_to return_url, notice: t(:message_unpublishing_successful)
end | [
"def unpublish!\r\n unpublish\r\n save!\r\n end",
"def unpublish!\n unpublish\n save!\n end",
"def unpublish!\n unpublish\n save!\n end",
"def unpublish\n set_pages\n authorize @pages\n\n unless @pages.map(&:unpublish).include?(false)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Decode the message body with URLsafe Base64. | def decode_body(body)
body += '=' * (4 - body.length.modulo(4))
Base64.decode64(body.tr('-_','+/'))
end | [
"def decode_message(message_body)\n JSON.parse(Base64.decode64(message_body))\n end",
"def decode\n raise TypeError, \"Can not decode a multipart message.\" if multipart?\n case header.fetch('content-transfer-encoding', '7bit').strip.downcase\n when 'quoted-printable'\n Utils.quoted_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /cache_flags GET /cache_flags.json | def index
@cache_flags = CacheFlag.all
end | [
"def refresh_feature_cache \n get(\"/globalsettings.json/cache/refresh\")\nend",
"def list_flags(options={})\n connection.get(\"/flags\").body.flags\n end",
"def index\n @flags = Flag.search(params[:search]).order(\"id\").page(params[:page]).per(10)\n respond_to do |format|\n format.html # in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /cache_flags POST /cache_flags.json | def create
@cache_flag = CacheFlag.new(cache_flag_params)
respond_to do |format|
if @cache_flag.save
format.html { redirect_to @cache_flag, notice: 'Cache flag was successfully created.' }
format.json { render :show, status: :created, location: @cache_flag }
else
format.html... | [
"def update\n respond_to do |format|\n if @cache_flag.update(cache_flag_params)\n format.html { redirect_to @cache_flag, notice: 'Cache flag was successfully updated.' }\n format.json { render :show, status: :ok, location: @cache_flag }\n else\n format.html { render :edit }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /cache_flags/1 PATCH/PUT /cache_flags/1.json | def update
respond_to do |format|
if @cache_flag.update(cache_flag_params)
format.html { redirect_to @cache_flag, notice: 'Cache flag was successfully updated.' }
format.json { render :show, status: :ok, location: @cache_flag }
else
format.html { render :edit }
format.jso... | [
"def update\n respond_to do |format|\n if @flag.update(flag_params)\n format.html { redirect_to @flag, notice: 'Flag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @flag.errors, stat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /cache_flags/1 DELETE /cache_flags/1.json | def destroy
@cache_flag.destroy
respond_to do |format|
format.html { redirect_to cache_flags_url, notice: 'Cache flag was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @flag.destroy\n respond_to do |format|\n format.html { redirect_to flags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flag = Flag.find(params[:id])\n @flag.destroy\n\n respond_to do |format|\n format.html { redirect_to flags_url }\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create's a new PomodoroTimer with a count of Time.secsIn25Mins | def initialize
@count = Time.secsIn25Mins
end | [
"def start_new_pomodoro_timer\n self.pomodoro_timer = PomodoroTimer.new\n pomodoro_timer.delegate = self\n pomodoro_timer.start\n end",
"def start\n invalidate if ns_timer\n self.ns_timer = NSTimer.timerWithTimeInterval(1, target: self, selector: 'decrement', userInfo: nil, repeats: true)\n NSR... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set's the delegate property as a weak reference object The Object to act as this PomodoroTimer's delegate | def delegate=(object)
@delegate = WeakRef.new(object)
end | [
"def delegate=(delegate)\n @delegate = WeakRef.new(delegate)\n end",
"def invalidate\n ns_timer.invalidate\n delegate.pomodoro_timer_did_invalidate(self) if delegate\n end",
"def start_new_pomodoro_timer\n self.pomodoro_timer = PomodoroTimer.new\n pomodoro_timer.delegate = self\n pomodoro_ti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Start this PomodoroTimer counting down to zero | def start
invalidate if ns_timer
self.ns_timer = NSTimer.timerWithTimeInterval(1, target: self, selector: 'decrement', userInfo: nil, repeats: true)
NSRunLoop.currentRunLoop.addTimer(ns_timer, forMode: NSDefaultRunLoopMode)
delegate.pomodoro_timer_did_start(self) if delegate
end | [
"def start_new_pomodoro_timer\n self.pomodoro_timer = PomodoroTimer.new\n pomodoro_timer.delegate = self\n pomodoro_timer.start\n end",
"def start(&block)\n begin\n yield(current_pomodoro) if block_given?\n\n display_countdown\n\n @pomodoros -= 1\n\n start(&block) unless... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Invalidate this PomodoroTimer (via ns_timer) and stop the countdown | def invalidate
ns_timer.invalidate
delegate.pomodoro_timer_did_invalidate(self) if delegate
end | [
"def pomodoro_timer_did_invalidate(pomodoro_timer)\n timer_button.selected = false \n update_timer_label \n end",
"def start\n invalidate if ns_timer\n self.ns_timer = NSTimer.timerWithTimeInterval(1, target: self, selector: 'decrement', userInfo: nil, repeats: true)\n NSRunLoop.currentRunLoop... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Default the flash error key to Rails' default :alert. | def flash_error_key
:alert
end | [
"def flash_error_key\n :alert\n end",
"def error(message, name=:notice_error)\r\n flash[name] = {:message => message}\r\n end",
"def flash_keys\n [:error, :notice, :warning]\n end",
"def unobtrusive_flash_keys\n [:notice, :alert, :error, :success, :warning]\n end",
"def set_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evaluates the block in context of a Rodauth controller instance. | def rails_controller_eval(&block)
rails_controller_instance.instance_exec(&block)
end | [
"def rails_controller_eval(&block)\n rails_controller_instance.instance_exec(&block)\n end",
"def run(block)\n case block\n when Proc\n controller.instance_eval(&block)\n else\n controller.send(block)\n end\n end",
"def run_builder_block(block, controller, *a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Runs any (before|around|after)_action controller callbacks. | def rails_controller_callbacks
# don't verify CSRF token as part of callbacks, Rodauth will do that
rails_controller_forgery_protection { false }
rails_controller_instance.run_callbacks(:process_action) do
# turn the setting back to default so that form tags generate CSRF tags
rails_c... | [
"def rails_controller_callbacks(&block)\n rails_controller_instance.run_callbacks(:process_action, &block)\n end",
"def pre_registered_callbacks\n callback_args = Smash.new(\n :params => params,\n :request => request,\n :current_user => current_user\n )\n Rails.application.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Runs any registered rescue_from controller handlers. | def rails_controller_rescue
yield
rescue Exception => exception
rails_controller_instance.rescue_with_handler(exception) || raise
unless rails_controller_instance.performed?
raise Rodauth::Rails::Error, "rescue_from handler didn't write any response"
end
end | [
"def rails_controller_rescue\n yield\n rescue Exception => exception\n rails_controller_instance.rescue_with_handler(exception) || raise\n\n unless rails_controller_instance.performed?\n raise Rodauth::Rails::Error, \"rescue_from handler didn't write any response\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls the Rails renderer, returning nil if a template is missing. | def rails_render(*args)
return if rails_api_controller?
rails_controller_instance.render_to_string(*args)
rescue ActionView::MissingTemplate
nil
end | [
"def rails_render(*args)\n rails_controller_instance.render_to_string(*args)\n rescue ActionView::MissingTemplate\n nil\n end",
"def rails_render(*args)\n return if rails_api_controller?\n\n rails_controller_instance.render_to_string(*args)\n rescue ActionView::MissingTemp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hidden tag with Rails CSRF token inserted into Rodauth templates. | def rails_csrf_tag
%(<input type="hidden" name="#{rails_csrf_param}" value="#{rails_csrf_token}">)
end | [
"def rails_csrf_tag\n %(<input type=\"hidden\" name=\"#{rails_csrf_param}\" value=\"#{rails_csrf_token}\">)\n end",
"def csrf_metatag\n \"<meta name=\\\"#{csrf_field}\\\" content=\\\"#{csrf_token}\\\" \\/>\"\n end",
"def csrf_meta_tags; end",
"def csrf_meta_tags\n return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The request parameter under which to send the Rails CSRF token. | def rails_csrf_param
rails_controller.request_forgery_protection_token
end | [
"def rails_csrf_param\n rails_controller.request_forgery_protection_token\n end",
"def csrf_param\n defined?(settings) && settings.respond_to?(:csrf_param) ? settings.csrf_param : :authenticity_token\n end",
"def csrf_token\n CSRF.token(env)\n end",
"def csrftok... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /work_flow_transition_conditions GET /work_flow_transition_conditions.json | def index
@work_flow_transition_conditions = WorkFlowTransitionCondition.all
end | [
"def create\n @work_flow_transition_condition = WorkFlowTransitionCondition.new(work_flow_transition_condition_params)\n\n respond_to do |format|\n if @work_flow_transition_condition.save\n format.html { redirect_to @work_flow_transition_condition, notice: 'Work flow transition condition was succe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /work_flow_transition_conditions POST /work_flow_transition_conditions.json | def create
@work_flow_transition_condition = WorkFlowTransitionCondition.new(work_flow_transition_condition_params)
respond_to do |format|
if @work_flow_transition_condition.save
format.html { redirect_to @work_flow_transition_condition, notice: 'Work flow transition condition was successfully cr... | [
"def index\n @work_flow_transition_conditions = WorkFlowTransitionCondition.all\n end",
"def update\n respond_to do |format|\n if @work_flow_transition_condition.update(work_flow_transition_condition_params)\n format.html { redirect_to @work_flow_transition_condition, notice: 'Work flow transit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /work_flow_transition_conditions/1 PATCH/PUT /work_flow_transition_conditions/1.json | def update
respond_to do |format|
if @work_flow_transition_condition.update(work_flow_transition_condition_params)
format.html { redirect_to @work_flow_transition_condition, notice: 'Work flow transition condition was successfully updated.' }
format.json { render :show, status: :ok, location: ... | [
"def update\n respond_to do |format|\n if @flowwork.update(flowwork_params)\n format.html { redirect_to flowitem_url(@flowwork.flowdeal.flowitem_id), notice: 'Flowwork was successfully updated.' }\n format.json { render :show, status: :ok, location: @flowwork }\n else\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /work_flow_transition_conditions/1 DELETE /work_flow_transition_conditions/1.json | def destroy
@work_flow_transition_condition.destroy
respond_to do |format|
format.html { redirect_to work_flow_transition_conditions_url, notice: 'Work flow transition condition was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @work_flow_activity_definition.destroy\n respond_to do |format|\n format.html { redirect_to work_flow_activity_definitions_url, notice: 'Work flow activity definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @workflow_tran... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method expects an array of certnames to get facts for | def facts_for_node(certnames)
return {} if certnames.empty? || certnames.nil?
certnames.uniq!
name_query = certnames.map { |c| ["=", "certname", c] }
name_query.insert(0, "or")
@logger.debug("Querying certnames")
result = make_query(name_query, 'inventory')
res... | [
"def facts_for_node(certnames)\n return {} if certnames.empty? || certnames.nil?\n\n certnames.uniq!\n name_query = certnames.map { |c| [\"=\", \"certname\", c] }\n name_query.insert(0, \"or\")\n result = make_query(name_query, 'inventory')\n\n result&.each_with_object({}) ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sends a command to PuppetDB using version 1 of the commands API. | def send_command(command, version, payload)
command = command.dup.force_encoding('utf-8')
body = JSON.generate(payload)
# PDB requires the following query parameters to the POST request.
# Error early if there's no certname, as PDB does not return a
# message indicating it's ... | [
"def send_command(command)\n @client.write \"#{command}\\r\\n\"\n end",
"def send_command cmd\n raise \"Must be a command object\" unless cmd.is_a? NEAT::Daemon::Command\n @amqp[:exchange].publish Oj.dump(cmd),\n routing_key: @amqp[:routing],\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /docs/1 GET /docs/1.json | def show
@doc = Doc.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @doc }
end
end | [
"def index\n @docs = Doc.all\n\n render json: @docs\n end",
"def get(params = {})\n response = client.get \"/{index}/{type}/{id}\", update_params(params, action: \"docs.get\", rest_api: \"get\")\n response.body\n end",
"def documents(params={})\n server.get(\"#{name}/_all_docs\", ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /docs/1 DELETE /docs/1.json | def destroy
@doc = Doc.find(params[:id])
@doc.destroy
respond_to do |format|
format.html { redirect_to docs_url }
format.json { head :ok }
end
end | [
"def destroy\n @doc = Doc.find(params[:id])\n @doc.destroy\n\n respond_to do |format|\n format.html { redirect_to docs_url }\n format.json { head :no_content }\n end\n end",
"def delete doc\n slug = CGI.escape(doc['_id'])\n CouchRest.delete \"#{@root}/#{slug}?rev=#{doc['_rev']}\"\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
provides access to tokens, through token identifier | def token(tokenname)
@tokens[tokenname.to_sym]
end | [
"def identifier\n return @token[:identifier]\n end",
"def token\n end",
"def do_token(token)\n end",
"def token_get()\n\t\tputs \"Here is the token \" + @token\n\tend",
"def token_string\n @token\n end",
"def token(content, kind); end",
"def current_token\n @tokens[@token_index]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
tries to find matching tokenklass for token i.e. Token::Token::ParamToken for :param then calls matching tokenhandler (if exists) with data in `this`context | def process_token(tokenline)
begin
camelcased = tokenline.token.to_s.capitalize.gsub(/_\w/){|w| w[1].capitalize}
tokenklass = Token.const_get "#{camelcased}Token"
instance_exec(tokenklass, tokenline.content, &(tokenklass.handler))
rescue Exception => error
raise NoTokenHa... | [
"def do_token(token)\n end",
"def process_token(token)\n # Create a ProcessedToken to make sure we don't process the same thing twice\n processed_token = ProcessedToken.new(token.name, token.parent)\n \n unless @processed_tokens.include?(processed_token)\n # Add to the right array of t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
disk.seek(find_inode_offset(1126)) inode = MinixInode.read(disk) pp(get_zones(disk, inode.i_zone)) disk.seek(35668 1024) data = disk.read(1024) pp data | def cat(disk, path)
inode_num = find_inode_num(disk, path)
disk.seek(find_inode_offset(inode_num))
inode = MinixInode.read(disk)
data = ""
size = inode.i_size
zones = get_zones(disk, inode.i_zone)
for zone in zones do
disk.seek(zone * 1024)
if size <= 1024 then
da... | [
"def test_multi_8gb_seek_and_read\n filename = FILE_MLTD_8GB\n return unless File.exist?(filename)\n\n # Disk format: 1st and 3rd disks have only the first and last blocks\n # filled with 1 and 3, respectively; 2nd and 4th disks are completely\n # filled with 2 and 4, respectively.\n d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
You have an array of integers, and for each index you want to find the product of every integer except the integer at that index. Write a function get_products_of_all_ints_except_at_index() that takes an array of integers and returns an array of the products. Solution 1: Brute Force O(n^2) | def get_products_of_all_ints_except_at_index_brute(arr)
result = []
arr.each_with_index do |el, i|
arr.delete_at(i)
product = arr.inject(1) {|product, int| product*int}
arr.insert(i, el)
result << product
end
result
end | [
"def get_products_of_all_ints_except_at_index(array)\n\t# Make sure there are atleast two integers in the array\n\tif array.length < 2\n\t\traise IndexError, \"Two or more integers are required\"\n\tend\n\n\tproducts_of_all_ints_except_at_index = []\n\n\t# For each integer we find the product of all the integers be... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /dotsmembers/1 GET /dotsmembers/1.json | def show
@dotsmember = Dotsmember.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @dotsmember }
end
end | [
"def list_members\n HTTP.headers(:accept => @@accept, \"content-type\" => @@content_type).basic_auth(:user => ENV[\"API_USERNAME\"], :pass => ENV[\"API_PASSWORD\"])\n .get(\"#{@@base_url}/users/#{self.guid}/members\").parse[\"members\"]\n end",
"def get_members\n @user = User.find_by(user_para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /dotsmembers/new GET /dotsmembers/new.json | def new
@dotsmember = Dotsmember.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @dotsmember }
end
end | [
"def new\n @member = Member.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @member }\n end\n end",
"def new\n new_url = \"#{ENV['KPASS_ENDPOINT']}/members/new?app_id=#{ENV['KPASS_APP_ID']}\"\n redirect_to new_url\n end",
"def new\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /dotsmembers POST /dotsmembers.json | def create
@dotsmember = Dotsmember.new(params[:dotsmember])
respond_to do |format|
if @dotsmember.save
format.html { redirect_to @dotsmember, notice: 'Dotsmember was successfully created.' }
format.json { render json: @dotsmember, status: :created, location: @dotsmember }
else
... | [
"def new\n @dotsmember = Dotsmember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dotsmember }\n end\n end",
"def add_member_to_list(user, list, member_id, options={})\n post(\"/#{user}/#{list}/members.json\", options.merge(:id => member_id))\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /dotsmembers/1 PUT /dotsmembers/1.json | def update
@dotsmember = Dotsmember.find(params[:id])
respond_to do |format|
if @dotsmember.update_attributes(params[:dotsmember])
format.html { redirect_to @dotsmember, notice: 'Dotsmember was successfully updated.' }
format.json { head :no_content }
else
format.html { rend... | [
"def update\n expose Member.update(@oauth_token, params[:membername], params)\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n puts params[:fields]\n expose Participant.update(@oauth_token, params[:membername].strip,\n para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /dotsmembers/1 DELETE /dotsmembers/1.json | def destroy
@dotsmember = Dotsmember.find(params[:id])
@dotsmember.destroy
respond_to do |format|
format.html { redirect_to dotsmembers_url }
format.json { head :no_content }
end
end | [
"def delete_member(url)\n delete url\n assert last_response.ok?, \"deleting extant member\"\n check_error_response(last_response)\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete_member\n connection.call_method('lists.dele... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Call a named Esgob API function. | def call(function_name, args = {})
uri = URI(config.endpoint + function_name)
uri.query = build_query(default_arguments.merge(args))
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
req = Net::HTTP::Get.new(uri.request_uri)
req['Accept'] = 'application/json... | [
"def use_function(name)\n call \"_#{name}\"\n end",
"def call_subroutine(name, options = {})\n options = { jump: false }.merge(options)\n @called_subroutines << name.to_s.chomp unless @called_subroutines.include?(name.to_s.chomp)\n local_microcode = ''\n if options[:jump]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all hosted domains | def domains_list
call('domains.list')[:domains]
end | [
"def domains\n @_domains ||= mxers.map { |m| Host.new(m.first).domain_name }.sort.uniq\n end",
"def domains\n []\n end",
"def domains\n collect { |a| a.domain }\n end",
"def domains\n @domains || []\n end",
"def domains\n domains = []\n nextToken = n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all hosted slave domains as a hash | def domains_slaves_list
Hash[
call('domains.slaves.list')[:domains].map do |item|
[item[:domain], item[:masterip]]
end
]
end | [
"def domains_hash\n return @domains\n end",
"def domains\n @_domains ||= mxers.map { |m| Host.new(m.first).domain_name }.sort.uniq\n end",
"def get_all_hosts\n @raw[\"servers\"].keys\n end",
"def db_slaves\n data['instances'].select { |i| i['role'] == 'db_slave' }.map { |i| i['publi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a new slave domain. | def domains_slaves_add(domain, masterip)
result = call('domains.slaves.add', :domain => domain, :masterip => masterip)
result[:domain] ||= domain
result
end | [
"def add_slave(slave)\n RRRSpec.redis.rpush(RRRSpec.make_key(key, 'slave'),\n slave.key)\n end",
"def add_domain(domain)\n @server.connect do \n display_ \"Adding '#{domain}'\" do\n @server.exec! \"touch #{@home}/domains/#{domain}\", sudo: true, error_msg: \"C... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deletes a slave domain. | def domains_slaves_delete(domain)
result = call('domains.slaves.delete', :domain => domain)
result[:domain] ||= domain
result
end | [
"def delete_slave(options)\n date = instance_date(options)\n puts \"Deleting slave instance of TokyoTyrant for #{date.strftime('%m/%Y')}\"\n\n begin\n TokyoManager.delete_slave_for_date(date)\n rescue => e\n puts e.message\n end\n end",
"def delete_slave_d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Force AXFR / transfer from master of a slave domain | def domains_slaves_forcetransfer(domain)
result = call('domains.slaves.forcetransfer', :domain => domain)
result[:domain] ||= domain
result
end | [
"def force_master!\n @forced_to_master = true\n end",
"def switch_master_to(master, slaves)\n\n slaves = Array(slaves)\n \n # Step 1. Make sure all slaves have completely processed their\n # Relay Log.\n slaves.each do |s|\n puts \"Draining relay log for slave instance #{s}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the master IP of a slave domain | def domains_slaves_updatemasterip(domain, masterip)
result = call('domains.slaves.updatemasterip', :domain => domain, :masterip => masterip)
result[:domain] ||= domain
result
end | [
"def domains_slaves_add(domain, masterip)\n result = call('domains.slaves.add', :domain => domain, :masterip => masterip)\n result[:domain] ||= domain\n result\n end",
"def switch_master_to(master, slaves)\n\n slaves = Array(slaves)\n \n # Step 1. Make sure all slaves have completely proc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a list of domains and a master IP, add and delete domains so that the Esgob account matches the local list | def domains_slaves_sync(domains, masterip)
existing_domains = domains_slaves_list
# Add any missing domains
responses = []
domains.each do |domain|
unless existing_domains.include?(domain)
response = domains_slaves_add(domain, masterip)
response[:domain] ||= domain
respons... | [
"def add_domain_list(name)\n configure \"ip domain-list #{name}\"\n end",
"def domains_slaves_add(domain, masterip)\n result = call('domains.slaves.add', :domain => domain, :masterip => masterip)\n result[:domain] ||= domain\n result\n end",
"def bulk_delete(list)\n\t\tputs \"Delete entrie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clear all expectations with the given request | def clear(request)
request = camelized_hash(HTTP_REQUEST => Request.new(symbolize_keys(request)))
logger.debug("Clearing expectation with request: #{request}")
logger.debug("URL: #{CLEAR_ENDPOINT}. Payload: #{request.to_hash}")
response = @base[CLEAR_ENDPOINT].put(request.to_json, content_type... | [
"def clear!\n @requests.clear\n end",
"def clear\n self.request = nil\n end",
"def clear_request\n @url = nil\n @options = nil\n end",
"def clear_all\n Response.where( :test_id => self.id ).each do |response|\n response.delete\n end\n \n self.complete ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reset the mock server clearing all expectations previously registered | def reset
request = {}
logger.debug('Resetting mockserver')
logger.debug("URL: #{RESET_ENDPOINT}. Payload: #{request.to_hash}")
response = @base[RESET_ENDPOINT].put(request.to_json)
logger.debug("Got reset response: #{response.code}")
parse_string_to_json(response)
end | [
"def clear\n FakeWeb.clean_registry\n @@responses = []\n end",
"def stub_reset\n @stub_urls = []\n @stub_data = []\n end",
"def reset!\n @server.clear_data\n end",
"def reset!\n @handlers = {}\n @client_handler = nil\n end",
"def reset!\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Verify that the given request is called the number of times expected | def verify(request, times = exactly(1))
logger.debug('Sending query for verify to mockserver')
results = retrieve(request)
# Reusing the times model here so interpreting values here
times = Times.new(symbolize_keys(times))
num_times = times.remaining_times
is_exact = !times.u... | [
"def method_called? method, options={}\n target_count = options[:count] || options[:exactly] || 1\n\n count = method_call_count method, options\n\n options[:exactly] ? count == target_count : count >= target_count\n end",
"def expected_received_count=(_arg0); end",
"def number_requests\r\n return @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /student_interests POST /student_interests.json | def create
@student_interest = StudentInterest.new(student_interest_params)
respond_to do |format|
if @student_interest.save
format.html { redirect_to @student_interest, notice: 'Student interest was successfully created.' }
format.json { render action: 'show', status: :created, location:... | [
"def create\n @interest = Interest.new(params[:interest])\n \n respond_to do |format|\n if @interest.save\n format.json { render :json => @interest,\n :status => :created, :location => @interest }\n else\n format.json { render :json => @interest.errors,\n :status => :u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /student_interests/1 PATCH/PUT /student_interests/1.json | def update
respond_to do |format|
if @student_interest.update(student_interest_params)
format.html { redirect_to @student_interest, notice: 'Student interest was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.js... | [
"def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /student_interests/1 DELETE /student_interests/1.json | def destroy
@student_interest.destroy
respond_to do |format|
format.html { redirect_to student_interests_url }
format.json { head :no_content }
end
end | [
"def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end \n end",
"def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.html { redirect_to interests_u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /review_images/1 GET /review_images/1.json | def show
@review_image = ReviewImage.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @review_image }
end
end | [
"def show\n @shop_review_image = ShopReviewImage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shop_review_image }\n end\n end",
"def new\n @review_image = ReviewImage.new\n\n respond_to do |format|\n format.html # new.html.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /review_images/new GET /review_images/new.json | def new
@review_image = ReviewImage.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @review_image }
end
end | [
"def new\n @shop_review_image = ShopReviewImage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shop_review_image }\n end\n end",
"def new\n @title = t('view.images.new_title')\n @image = Image.new\n\n respond_to do |format|\n format.html... | {
"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.