query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
PUT /outlet_goods_receive_note_items/1 PUT /outlet_goods_receive_note_items/1.xml | def update
@outlet_goods_receive_note_item = OutletGoodsReceiveNoteItem.find(params[:id])
respond_to do |format|
if @outlet_goods_receive_note_item.update_attributes(params[:outlet_goods_receive_note_item])
flash[:notice] = 'OutletGoodsReceiveNoteItem was successfully updated.'
format.htm... | [
"def update\n @outlet_goods_receive_note = OutletGoodsReceiveNote.find(params[:id])\n\n respond_to do |format|\n if @outlet_goods_receive_note.update_attributes(params[:outlet_goods_receive_note])\n flash[:notice] = 'OutletGoodsReceiveNote was successfully updated.'\n format.html { redirect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /outlet_goods_receive_note_items/1 DELETE /outlet_goods_receive_note_items/1.xml | def destroy
@outlet_goods_receive_note_item = OutletGoodsReceiveNoteItem.find(params[:id])
@outlet_goods_receive_note_item.destroy
respond_to do |format|
format.html { redirect_to(outlet_goods_receive_note_items_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @outlet_goods_receive_note = OutletGoodsReceiveNote.find(params[:id])\n @outlet_goods_receive_note.destroy\n\n respond_to do |format|\n format.html { redirect_to(outlet_goods_receive_notes_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n api_xml(category(targe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Realiza calculos de liquidacion, sumas | def salvar_calculados
self.cif_dolares = fob_dolares.to_f + seguro.to_f + flete_I.to_f + flete_II.to_f + otros_gastos.to_f
self.cif_bolivianos = 7.07 * cif_dolares.to_f
self.ga = cif_bolivianos * 0.10
self.iva = (cif_bolivianos.to_f + ga.to_f) * 0.1494
self.ice = (cif_bolivianos.to_f + ga.to_f) * 0.... | [
"def sum_totals\n @total = Lote.where(:programacion_id => @programacion.first).sum(:precio_t)\n @total = Money.new(\"#{@total}00\", \"USD\").format\n @cantidades = Lote.where(:programacion_id => @programacion.first).sum(:cantidad)\n end",
"def calcular_stock(estados = [1,2])\n items = self.solicitud_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if the logged user has rights on the given comment | def authorized_user? comment
comment.user_id == current_user.id || comment.post.user_id == current_user.id
end | [
"def can_edit?(comment)\n if has_permission?('account_holder || administrator') || current_user.id == comment.user_id\n true\n else\n false\n end\n end",
"def edit_comment_allowed?(comment = @comment)\n # User needs to be logged in\n return false unless logged_in?\n # User can only ed... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the percentile value for percentile _p_; nil if array is empty. _p_ should be expressed as an integer; percentile(90) returns the 90th percentile of the array. Algorithm from NIST[ Implementation from | def percentile(p)
sorted_array = self.sort
rank = (p.to_f / 100) * (self.length + 1)
return nil if self.length == 0
if rank.truncate > 0 && rank.truncate < self.length
sample_0 = sorted_array[rank.truncate - 1]
sample_1 = sorted_array[rank.truncate]
# Returns the fractional part of ... | [
"def percentile(p)\n self.sort[(p * self.length).ceil - 1]\n end",
"def percentile p\n sorted_array = self.sort\n rank = (p.to_f / 100) * (self.length + 1)\n\n return nil if self.length == 0\n\n if rank.truncate > 0 && rank.truncate < self.length\n sample_0 = sorted_array[rank.truncate - 1]\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete a Space security policy definition | def delete_space_security_policy_definition(name, headers=default_headers)
@logger.info("Deleting Space Security Policy Definition \"#{name}\".")
# Delete the space security policy definition
delete("#{@api_url}/securityPolicyDefinitions/#{encode(name)}", headers)
end | [
"def delete_security_policy_definition(kapp_slug, name, headers=default_headers)\n @logger.info(\"Deleting Security Policy Definition \\\"#{name}\\\" from the \\\"#{kapp_slug}\\\" kapp.\")\n # Delete the kapp security policy definition\n delete(\"#{@api_url}/kapps/#{kapp_slug}/securityPolicyDefinitio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete all Space security policy definitions | def delete_space_security_policy_definitions(headers=default_headers)
(find_space_security_policy_definitions({}, headers).content["securityPolicyDefinitions"] || []).each do |s|
delete_space_security_policy_definition(s['name'], headers)
end
end | [
"def delete_security_policy_definitions(kapp_slug, headers=default_headers)\n (find_security_policy_definitions(kapp_slug, {}, headers).content[\"securityPolicyDefinitions\"] || []).each do |s|\n delete_security_policy_definition(kapp_slug, s['name'], headers)\n end\n end",
"def delete_space_s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find all Space security policy definitions | def find_space_security_policy_definitions(params={}, headers=default_headers)
@logger.info("Finding Space Security Policy Definitions.")
get("#{@api_url}/securityPolicyDefinitions", params, headers)
end | [
"def find_security_policy_definitions(kapp_slug, params={}, headers=default_headers)\n @logger.info(\"Listing Security Policy Definitions on the \\\"#{kapp_slug}\\\" kapp.\")\n get(\"#{@api_url}/kapps/#{kapp_slug}/securityPolicyDefinitions\", params, headers)\n end",
"def find_space_security_policy_d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find a single Space security policy definition | def find_space_security_policy_definition(name, params={}, headers=default_headers)
@logger.info("Finding Space Security Policy Definition \"#{name}\"")
get("#{@api_url}/securityPolicyDefinitions/#{encode(name)}", params, headers)
end | [
"def find_space_security_policy_definitions(params={}, headers=default_headers)\n @logger.info(\"Finding Space Security Policy Definitions.\")\n get(\"#{@api_url}/securityPolicyDefinitions\", params, headers)\n end",
"def find_security_policy_definition(kapp_slug, name, params={}, headers=default_hea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update a Space security policy definition | def update_space_security_policy_definition(name, body, headers=default_headers)
@logger.info("Updating Space Security Policy Definition \"#{name}\"")
put("#{@api_url}/securityPolicyDefinitions/#{encode(name)}", body, headers)
end | [
"def update_security_policy_definition(kapp_slug, name, body, headers=default_headers)\n @logger.info(\"Updating Security Policy Definition \\\"#{name}\\\" on the \\\"#{kapp_slug}\\\" kapp.\")\n put(\"#{@api_url}/kapps/#{kapp_slug}/securityPolicyDefinitions/#{encode(name)}\", body, headers)\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a Kapp security policy definition | def add_security_policy_definition(kapp_slug, body, headers=default_headers)
@logger.info("Adding Security Policy Definition \"#{body['name']}\" to the \"#{kapp_slug}\" kapp.")
# Create the kapp security policy definition
post("#{@api_url}/kapps/#{kapp_slug}/securityPolicyDefinitions", body, headers)
... | [
"def add_policy(_sec, _ptype, _rule); end",
"def update_security_policy_definition(kapp_slug, name, body, headers=default_headers)\n @logger.info(\"Updating Security Policy Definition \\\"#{name}\\\" on the \\\"#{kapp_slug}\\\" kapp.\")\n put(\"#{@api_url}/kapps/#{kapp_slug}/securityPolicyDefinitions/#{... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete a Kapp security policy definition | def delete_security_policy_definition(kapp_slug, name, headers=default_headers)
@logger.info("Deleting Security Policy Definition \"#{name}\" from the \"#{kapp_slug}\" kapp.")
# Delete the kapp security policy definition
delete("#{@api_url}/kapps/#{kapp_slug}/securityPolicyDefinitions/#{encode(name)}"... | [
"def delete_space_security_policy_definition(name, headers=default_headers)\n @logger.info(\"Deleting Space Security Policy Definition \\\"#{name}\\\".\")\n # Delete the space security policy definition\n delete(\"#{@api_url}/securityPolicyDefinitions/#{encode(name)}\", headers)\n end",
"def del... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete all Kapp security policy definitions | def delete_security_policy_definitions(kapp_slug, headers=default_headers)
(find_security_policy_definitions(kapp_slug, {}, headers).content["securityPolicyDefinitions"] || []).each do |s|
delete_security_policy_definition(kapp_slug, s['name'], headers)
end
end | [
"def delete_space_security_policy_definitions(headers=default_headers)\n (find_space_security_policy_definitions({}, headers).content[\"securityPolicyDefinitions\"] || []).each do |s|\n delete_space_security_policy_definition(s['name'], headers)\n end\n end",
"def delete_security_policy_defini... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find all Kapp security policy definitions | def find_security_policy_definitions(kapp_slug, params={}, headers=default_headers)
@logger.info("Listing Security Policy Definitions on the \"#{kapp_slug}\" kapp.")
get("#{@api_url}/kapps/#{kapp_slug}/securityPolicyDefinitions", params, headers)
end | [
"def find_space_security_policy_definitions(params={}, headers=default_headers)\n @logger.info(\"Finding Space Security Policy Definitions.\")\n get(\"#{@api_url}/securityPolicyDefinitions\", params, headers)\n end",
"def find_security_policy_definition(kapp_slug, name, params={}, headers=default_hea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find a single Kapp security policy definition | def find_security_policy_definition(kapp_slug, name, params={}, headers=default_headers)
@logger.info("Finding Security Policy Definition \"#{name}\" on the \"#{kapp_slug}\" kapp.")
get("#{@api_url}/kapps/#{kapp_slug}/securityPolicyDefinitions/#{encode(name)}", params, headers)
end | [
"def find_space_security_policy_definition(name, params={}, headers=default_headers)\n @logger.info(\"Finding Space Security Policy Definition \\\"#{name}\\\"\")\n get(\"#{@api_url}/securityPolicyDefinitions/#{encode(name)}\", params, headers)\n end",
"def searchpolicy\n eval @policy_key\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update a Kapp security policy definition | def update_security_policy_definition(kapp_slug, name, body, headers=default_headers)
@logger.info("Updating Security Policy Definition \"#{name}\" on the \"#{kapp_slug}\" kapp.")
put("#{@api_url}/kapps/#{kapp_slug}/securityPolicyDefinitions/#{encode(name)}", body, headers)
end | [
"def update_policy(resource, name, config)\n puts Colors.blue(\"\\tupdating policy #{name}...\")\n policy = resource.policy(name)\n if config.empty?\n policy.delete()\n else\n policy.put({\n :policy_document => config.as_pretty_json\n })\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the reactionType property value. Supported values are like, angry, sad, laugh, heart, surprised. | def reaction_type
return @reaction_type
end | [
"def reaction_type=(value)\n @reaction_type = value\n end",
"def reaction\n return @reaction\n end",
"def reaction=(value)\n @reaction = value\n end",
"def relief_type_class\n return if @relief_type.blank?\n\n @relief_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the reactionType property value. Supported values are like, angry, sad, laugh, heart, surprised. | def reaction_type=(value)
@reaction_type = value
end | [
"def reaction=(value)\n @reaction = value\n end",
"def reaction_type\n return @reaction_type\n end",
"def set_type(v)\n self.type = v\n self\n end",
"def set_RelationshipType(value)\n set_input(\"RelationshipType\", value)\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the user property value. The user property | def user=(value)
@user = value
end | [
"def user_property=(value)\n @user_property = value\n end",
"def user=(value)\n @user = value\n end",
"def set_user(props={})\n send_people_request(\"$set\", props)\n end",
"def user_attribute=(value)\n @user_attribute = value\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /pmplayers POST /pmplayers.json | def create
@pmplayer = Pmplayer.new(pmplayer_params)
respond_to do |format|
if @pmplayer.save
format.html { redirect_to @pmplayer, notice: 'Pmplayer was successfully created.' }
format.json { render :show, status: :created, location: @pmplayer }
else
format.html { render :ne... | [
"def create\n @layer = @map.layers.build(params[:layer])\n\n respond_to do |format|\n if @layer.save\n format.html { redirect_to([@layer.map, @layer], :notice => 'Layer was successfully created.') }\n format.json { render :json => @layer, :status => :created, :location => [@layer.map, @laye... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /pmplayers/1 PATCH/PUT /pmplayers/1.json | def update
respond_to do |format|
if @pmplayer.update(pmplayer_params)
format.html { redirect_to @pmplayer, notice: 'Pmplayer was successfully updated.' }
format.json { render :show, status: :ok, location: @pmplayer }
else
format.html { render :edit }
format.json { render... | [
"def update\n @layer = @map.layers.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n format.html { redirect_to([@layer.map, @layer], :notice => 'Layer was successfully updated.') }\n format.json { head :ok }\n else\n format.html { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /pmplayers/1 DELETE /pmplayers/1.json | def destroy
@pmplayer.destroy
respond_to do |format|
format.html { redirect_to pmplayers_url, notice: 'Pmplayer was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @layer = @map.layers.find(params[:id])\n @layer.destroy\n\n respond_to do |format|\n format.html { redirect_to map_layers_url(@map) }\n format.json { head :ok }\n end\n end",
"def destroy\n @layer = Layer.find(params[:id])\n @layer.destroy\n\n respond_to do |format|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
logout fails flakely on CI. To further pinpoint problem we start storing more screenshots if this fails. | def logout_using_menu
screenshots_for_debugging = []
find_button("user-menu").click
assert has_text?("Abmelden")
screenshots_for_debugging << page.save_screenshot(Rails.root.join("tmp/screenshots/after-opening-menu.png"))
list_of_user_menu_items = find("#user-menu-list")
logout_link = list_of_user_menu_ite... | [
"def take_failed_screenshot\n return unless failed? && supports_screenshot? && Capybara::Session.instance_created?\n\n take_screenshot\n metadata[:failure_screenshot_path] = relative_image_path if Minitest::Runnable.method_defined?(:metadata)\n end",
"def take_failed_screenshot\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is the media item valid? A media item must have a show title, season number and episode number. | def valid?
return !(self.show.empty? or self.season.zero? or self.episode.zero?)
end | [
"def emma_item?(item)\n return true if item.is_a?(Upload) && item.repository.nil?\n digits_only?(item) || Upload.valid_sid?(item) || Upload.emma_native?(item)\n end",
"def valid?\n @errors = []\n \n if !item_id.nil? && item_id !~ GUID_REGEX\n @errors << ['line_item_id', 'must be blank... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Where did the file come from? Example: /origin/some/path/ | def origin
# Split the full path of the video file by /
# and then exclude the last part (whic is the filename)
# and join the path back together
paths = self.fullpath.split('/')
if paths.length > 1 then
res = Helpers::trailingslash(Helpers::trailingslash($config[:origin_dir]) + paths.slice(0, paths.length... | [
"def get_origin\n\t\treturn @transport.get_path(\"meta\",\"origin\")\n\tend",
"def file_path\n @local_path\n end",
"def remote_path(path = '')\n \"/good/remote#{get_file_path(path)}/path\"\n end",
"def file() = pathname.relative_path_from(Cnfs.config.paths.definitions)",
"def file_path\n file.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write a method that will take a short line of text, and print it within a box. Example: print_in_box('To boldly go where no one has gone before.') ++ | | | To boldly go where no one has gone before. | | | ++ print_in_box('') ++ | | | | | | ++ You may assume that the input will always fit in your terminal window. | def print_in_box(text)
width = text.size
result = <<EOS
+-#{'-' * width}-+
| #{' ' * width} |
| #{text} |
| #{' ' * width} |
+-#{'-' * width}-+
EOS
result
end | [
"def print_in_box(text)\n whole_line = \"+-\" + \"-\" * text.length + \"-+\"\n empty_line = \"| \" + \" \" * text.length + \" |\"\n\n puts whole_line\n puts empty_line\n puts \"| \" + text + \" |\"\n puts empty_line\n puts whole_line\nend",
"def print_in_box(string)\r\n box_length = string.length\r\n box... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns all sorted alpha matches | def all_alpha_matches(input)
where(alpha: sort_letters(input)).pluck :text
end | [
"def match(possible)\n answer = []\n possible.each do |i|\n new = i.split(\"\")\n compare = new.sort\n compare_ana = @anagram.sort \n if compare == compare_ana\n answer << i \n end \n end \n answer \n end",
"def sorted_with_scores( search, actuals, score_threshold=1.0 ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get or check current session secure token | def secure_token token=nil
generated = Crypt.sha1(request.ip)
return generated == token if token
generated
end | [
"def session_token\n obtain_credentials\n @session_token\n end",
"def secure_token token = nil\n generated = Crypt.sha1(self.ip)\n token ? (generated == token) : generated\n end",
"def secure_token?\n secure == true\n end",
"def token?\n @session_token\n end",
"def session_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Empty out the build directory | def clean_build_directory
FileUtils.rm_rf Dir.glob(File.join(@project.build_path, '*'))
end | [
"def cleanup_build_dir\n FileUtils.rm_rf(build_dir, secure: true)\n end",
"def clean_directories!\n all_build_files = File.join(@app.config[:build_dir], '**', '*')\n\n empty_directories = Dir[all_build_files].select do |d|\n File.directory?(d)\n end\n\n empty_directories.each do... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write an .erb from source to destination, catching and reporting errors along the way | def write_erb(source, destination)
begin
@task.shell.mute do
@task.create_file(destination) do
@project.parse_erb(source)
end
end
rescue Exception => e
@task.say "Error while building #{File.basename(source)}:"
@task.say e.message + "\n", Thor:... | [
"def write_from_erb_template(erbfile, outfile, config = {},\n options = {\n :no_interaction => false\n })\n erbfiles = (erbfile.is_a?(Array)) ? erbfile : [ erbfile ]\n content = \"\"\n erbfiles.each do |f|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Join the underlying thread. This is a blocking call. | def join
@thread.join
end | [
"def join\n\n @run_thread.join rescue nil\n end",
"def join_thread\n @thread.join if @thread\n @thread = nil\n end",
"def join\n @run_thread.join if @run_thread\n end",
"def join\n threads.each { |t| t.join }\n end",
"def join\n threads.list.each {|t| t.join if t.aliv... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /datos_usuarios POST /datos_usuarios.json | def create
@datos_usuario = DatosUsuario.new(datos_usuario_params)
respond_to do |format|
if @datos_usuario.save
format.html { redirect_to "/inicio/success", success: 'Datos usuario was successfully created.' }
else
format.html { render action: 'new' }
format.json {... | [
"def create\n @usuario = Usuario.new(usuario_params)\n\n if @usuario.save\n render json: @usuario, status: :created, location: @usuario\n else\n render json: @usuario.errors, status: :unprocessable_entity\n end\n end",
"def create\n @apodos_usuario = ApodosUsuario.new(params[:apodos_usua... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /datos_usuarios/1 DELETE /datos_usuarios/1.json | def destroy
@datos_usuario.destroy
respond_to do |format|
format.html { redirect_to datos_usuarios_url }
format.json { head :no_content }
end
end | [
"def destroy\n @usuario.destroy\n respond_to do |format|\n format.html { redirect_to usuarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @direccionusuario = Direccionusuario.find(params[:id])\n @direccionusuario.destroy\n\n respond_to do |format|\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Increase the dogs position values by 5 using Array.map!. | def chasing_squirrels(dogs)
dogs.map! do |individual_dog|
individual_dog[:position] += 5
individual_dog
end
return dogs
end | [
"def chase_squirrel(dogs_array)\n dogs_array.map! do |dog|\n dog[:position] += 5\n p dog\n end\nend",
"def return_dogs(dogs_array)\n dogs_array.map! do |dog|\n dog[:position] = 0\n p dog\n end\nend",
"def return_dogs(dogs)\n dogs.map! do |individual_dogs|\n indi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write a new method called return_dogs that takes an array of dogs as an argument. It should reset all of the dogs' positions back to 0. | def return_dogs(dogs)
dogs.map! do |individual_dogs|
individual_dogs[:position] = 0
individual_dogs
end
return dogs
end | [
"def return_dogs(get_over_here_dogs)\n # get_over_here_dogs.map do |dogs|\n dogs[:position] = 0\n end",
"def return_dogs(dogs_array)\n dogs_array.map! do |dog|\n dog[:position] = 0\n p dog\n end\nend",
"def return_dogs(my_dogs)\n my_dogs.map! do |dog|\n dog[:position] = 0\n end\nen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method takes three parameters: (1) An input file object containing the log messages that need to be translated (2) An output file object to write the translated messages to (3) The depth of the translations The input file object should be open for reading, while the output file object should be open for writing. T... | def reverse_translate(input_file, output_file, depth)
LogParser.parse(input_file).each do |log_message|
@tables[0].reverse_translate(log_message, depth)
output_file.puts(log_message)
end
end | [
"def process_file(filename, locale, output_locale)\n\n def assemble(templ, local)\n # If already assembling the string\n return local unless templ.is_a?(Hash)\n\n # If templ is a hash but local is nil, it means that the entire current \n # branch is not yet translated. Therefore cre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pause for one second before each vote Pass in array of candidates to vote from | def vote(candidates) sleep(1) end | [
"def do_voting()\n @submitting = false\n say \"Pencils down, time is up!\"\n if @answers.keys.length < 2\n say \"Not enough submissions, stopping.\"\n stop(nil, nil)\n return\n end\n say \"Vote for one of the following and send it to \" +\n \"me via #{Hi}/msg #{@bot.nick} vote <... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
toggle status of a chain_task to be active/inactive | def toggle_status
@chain_task.toggle_status!
render :text => :ok and return
end | [
"def switch_task_status()\n @status = !@status\n end",
"def toggle(task_number)\r\n all_tasks[task_number.to_i - 1].toggle_status\r\n end",
"def make_inactive\n self.status = \"I\"\n end",
"def ignore_inactive?(_task)\n !active?\n end",
"def make_active\n self.status = \"A\"\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
It is used for define an xml handler's task. It does 1) locking, 2) authenticating, 3) executing a task, and 4)returning a result to a client. +task_name+ name of task +session+ a string that represents a user session +lock_mode+ a mode flag for exclusive access :rd for read lock and :wt for write lock. +admin_auth+ it... | def task(task_name, session, lock_mode, admin_auth=false, &block)
begin
# lock
if lock_mode == :wt
@lock.write_lock
else
@lock.read_lock
end
begin
rc = authenticate(session, admin_auth, &block)
log_msg = rc
... | [
"def task(&block) \n task = TaskRunnable.new\n task.proc = Proc.new(block)\n task\n end",
"def task(name, &block)\n name = name.to_s\n\n unless task = @tasks.find{|t| t.name == name}\n task = Salticid::Task.new(name, :salticid => self)\n @tasks << task\n end\n \n if block_giv... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
It log rpc call result. +task_name+ name of called method +user+ name of user who executes this rpc call +result[0]+ true or false +result[1]+ a string representing error if result[0] is false, otherwise undefined | def log_result(task_name, user, result)
if result[0]
log_success(user, task_name)
else
log_fail(user, task_name, result[1])
end
end | [
"def log_result(result, cmd, timeout)\n return if result.results[:data].blank?\n\n Astute.logger.debug(\n \"#{@ctx.task_id}: #{details_for_log(cmd, timeout)}\\n\" \\\n \"stdout: #{result.results[:data][:stdout]}\\n\" \\\n \"stderr: #{result.results[:data][:stderr]}\\n\" \\\n \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fin de def showUserList Permet d'afficher la liste des users non sportif voulant faire du sport | def showNonSportifList
@users = User.where(isSportif: false, wantDoSport: true)
@titre = "Liste des utilisateurs non sportifs"
generatePDFnonSportif(@users)
render 'showUserList'
end | [
"def list \n @users = User.all\n \n render \"list\"\n end",
"def user_list\n @room = current_user.room\n @user_list = @room.users\n @status = [\"Not in any room\", \"Answering\", \"Confirmed\", \"Ready\"]\n render partial: \"user_list\"\n end",
"def user_list\n @room = current_user.roo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fin de def generatePDFsportif Genere un PDF de la liste des users non sportif voulant faire du sport | def generatePDFnonSportif(all_users)
Prawn::Document.generate("public/listUsers.pdf", :page_layout => :landscape) do |pdf|
table_data = [["Nom", "Email", "Date de naissance", "Poids actuel", "Poids Idéal", "Taille", "IMC"]]
all_users.each do |u|
table_data += [["#{u.nom}", "#{u.... | [
"def showNonSportifList\n @users = User.where(isSportif: false, wantDoSport: true)\n @titre = \"Liste des utilisateurs non sportifs\"\n generatePDFnonSportif(@users)\n render 'showUserList'\n end",
"def users\n @users = User.all.order(:name)\n html = render_to_string(layout: 'pdf')\n kit = P... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:nodoc: Google Calendar does not have a category concept. Instead a feed consists of multiple calendars. We've chosen to map the category into the calendar concept. This function, category, returns an array of calendar objects which match the requested category(ies). categories can be a single string/symbol or an array... | def category categories
categories = categories.to_a if !categories.is_a? Array
categories.collect { |i| calendars.find_by_title i.to_s }.compact
end | [
"def categories\n nodes = @doc.xpath(\"atom:feed/atom:category\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomCategory.new(node) }\n end",
"def categories\n if !is_a_number?(params[:category])\n c = Category.find_by_name(params[:category])\n cat = c.id\n else\n cat = params[:c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sessions are opened to the google api using a google username and password. This implemented so that only one session is used per feed. You probably won't need to use this, but if you do, you can access the session for a feed object by: feed = GCalendar::Feed.first feed.login assigns session feed.session => returns the... | def session
@@session ||= []
if @@session[self.id].nil?
session = GData::Client::Calendar.new
token = session.clientlogin(username,password)
@@session[self.id] = session
end
@@session[self.id]
end | [
"def get_session\n \n unless @session\n @session = GoogleDrive.login(@account.username, @account.password)\n end\n \n @session\n \n end",
"def get_session\n\t\trefresh_token = get_refresh_token\n\n\t\tclient = OAuth2::Client.new(\n\t\t CLIENT_ID,\n\t\t CLIENT_SECR... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create a new calendar object for this feed. name name or title of the calendar opts hash of fields for creating the calendar object. TODO, move or add function to the calendars association | def create_calendar(name, opts={})
opts[:name] = name
cal = GCalendar::Calendar.new(:opts=>opts)
calendars << cal
cal.sync
save
end | [
"def create_google_calendar\n unless self.apps_cal_id\n result = Gandalf::GoogleApiClient.insert_google_calendar({\n \"summary\" => self.name\n })\n self.apps_cal_id = result.data.id\n self.save!\n end\n end",
"def create_calendar_object(calendar_id, object_uri, calendar_data)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Uses session to get the calendar feed for the user | def get_user_calendar_xml # :nodoc:
response = session.get(USER_FEED)
Nokogiri::XML(response.body)
end | [
"def todays_calendar\n current_user.calendars.each do |calendar|\n calendar.posts.where(date: Date.current)\n end\n end",
"def get_calendars\r\n http = Net::HTTP.new(@google_url, 80)\r\n response, data = http.get(\"http://#{@google_url}/calendar/feeds/\" + @user_id, @headers)\r\n case r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
As stated, the goal of this library is to manipulate the google calendar, using ActiveRecord as a cache. This means that synchronization needs to follow these rules: a) data exists in gcal and not in local > create local objects note that deletion of a local event must either immediately delete the google object, or ma... | def sync_calendars(opts={})
# why does the primary calendar feed change every time?
feed_xml = get_user_calendar_xml
xml_ts = Time.zone.parse(feed_xml.xpath('/ns:feed/ns:updated', 'ns'=>'http://www.w3.org/2005/Atom').text)
self.body = feed_xml.to_s if xml_ts != synced_at
feed_xml.css('ent... | [
"def sync_events!(source_event_list)\n event_mappings = unique_events_array(source_event_list).sort do |a, b| # sort required for correct first and last at ***\n a.start.to_datetime <=> b.start.to_datetime\n end.map do |source_event|\n { source_event: source_event, gcal_event: nil }\n end\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
compare the results of "working solution" with "optimized solution" | def compare_solutions(count = 5, n_min = 1, n_max = 300)
arr = generate(count, n_min, n_max)
if solve(arr) != solve_opt(arr)
puts "\nFAILED"
puts 'data: ' + arr.to_s
puts 'solution: ' + solve(arr).to_s
puts 'optimized solution: ' + solve_opt(arr).to_s
end
end | [
"def optimal?\n end",
"def objective_function(solution)\n offset = 5\n actual_position = @start.dup\n\n performance = Array.new(@m) { Array.new(@n) { offset } }\n performance[@start.x][@start.y] = 0\n performance[@final.x][@final.y] = 0\n\n solution.each_with_index do |movement, index|\n p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
prompt asks us to create a list of directors with their names only using source as an argument. pping source indicates that source is the entire nds | def list_of_directors(source)
dir_list = []
dir_index =0
while dir_index<source.length do
dir_list << source[dir_index][:name]
dir_index +=1
end
dir_list
end | [
"def list_of_directors(source)\r\n director_index = 0\r\n director_list = Array.new\r\n \r\n while director_index < source.size do\r\n director_list.push(source[director_index][:name])\r\n director_index += 1\r\n end\r\n director_list\r\nend",
"def list_of_directors(source)\n director_index = 0\n di... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cscope egrep is pretty bad very few character classes | def generate_cscope_pattern(base)
pattern = base.downcase #in order to do case insensitive matching cscope requires lower case
return "^(.* )?#{pattern}" if pattern.length <= 2
return "^(.* )?#{pattern}"
#return '^(.* )?p[a-zA-Z0-9]*a'
end | [
"def regexp_source; end",
"def filter_chars\n # In Python we apply a string to a regexp,\n # but in Ruby we apply a regexp to a string, that's why we don't have to append\n $stack.push($stack.pop().gsub(Regexp.compile('[\\W_]+'), ' ').downcase)\nend",
"def start_re; end",
"def lex_en_regexp_modifiers; end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
turn compression on or off | def compression=(bool); @store.compression = bool; end | [
"def default_compression; end",
"def compression(value = true)\n options[:compression] = value\n end",
"def compression\n configuration[:copy_compression] || :gzip\n end",
"def compression_method; end",
"def gzip_enabled; end",
"def compression\n unless defined?(@compres... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /legalissues GET /legalissues.json | def index
@legalissues = Legalissue.all
end | [
"def index\n a = URI.parse(\"https://api.github.com/repos/nnluukhtn/employment_bot/issues?state=all\").read\n @gitissue = JSON.parse(a)\n end",
"def getorgissues\n self.class.get(\"/orgs/TIY-ATL-ROR-2015-Sep/issues\", headers: @headers, \n query... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /legalissues POST /legalissues.json | def create
@legalissue = Legalissue.new(legalissue_params)
respond_to do |format|
if @legalissue.save
format.html { redirect_to @legalissue, notice: 'Legalissue was successfully created.' }
format.json { render :show, status: :created, location: @legalissue }
else
format.htm... | [
"def create(issue)\n fetch({:method => :post, :body => issue})\n end",
"def create\n begin\n params.permit!\n 100.times do |index|\n claim_issue = {:claim_issue => {\"description\" => params[\"description\"][0], \"contact_id\" => params[\"contact_id\"][0], \"user_id\" => params[\"user_id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /legalissues/1 PATCH/PUT /legalissues/1.json | def update
respond_to do |format|
if @legalissue.update(legalissue_params)
format.html { redirect_to @legalissue, notice: 'Legalissue was successfully updated.' }
format.json { render :show, status: :ok, location: @legalissue }
else
format.html { render :edit }
format.jso... | [
"def update\n update_resource_response(@issue, issue_params)\n end",
"def edit_issue(issue_num,params)\n RestClient.proxy = @proxy\n\n url = @github_api_url + \"/repos\" + @github_repo + \"/issues/#{issue_num}\"\n headers = {:accept => :json, :content_type => :json, :authorization => \"Bearer #... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /legalissues/1 DELETE /legalissues/1.json | def destroy
@legalissue.destroy
respond_to do |format|
format.html { redirect_to legalissues_url, notice: 'Legalissue was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n response = RestClient.delete $api_service+\"/claim_issues/\"+params['id']\n redirect_to :action => \"index\"\n end",
"def destroy\n @normal_issue = NormalIssue.find(params[:id])\n @normal_issue.destroy\n\n respond_to do |format|\n format.html { redirect_to normal_issues_url }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
REQUIRED. FluidFeatures will call this to determine if your user is logged in, what the unique id of this user is and any additional attributes you wish to use for selecting users. | def fluidfeatures_current_user(verbose=false)
if current_user
if verbose
{
:id => @current_user[:id],
:name => @current_user[:name],
:uniques => {
:twitter => @current_user[:twitter_id]
},
:cohorts => {
# Example attributes for ... | [
"def user?\n get_mode == :user\n end",
"def user_id; config[:user_id]; end",
"def parametrizr_user\n current_user\n end",
"def userid\n user_id\n end",
"def current_user\n @current_user = fel_id if authenticated? \n end",
"def load_user\n\t\t\tUser.find_by_id(session[:user_id]) # r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
OPTIONAL Set default for any new features. These are only used for the first time that FluidFeatures sees a feature. This happens when this feature is deployed for the first time. | def fluidfeatures_defaults
{
# By default unknown features are disabled.
:enabled => false, # no visible to any users
# You can also use these values...
#:enabled => true, # visible to all users (use for depreciating old features)
#:enabled => 10, # 10 percent of user will see it
... | [
"def default_feature_value() nil end",
"def default_feature\n @default ||= find_feature(name, :main=>true)\n end",
"def set_default\n end",
"def default_feature_value() [] end",
"def feature_flags_with_defaults\n FeatureFlag.default_flag_hash.merge(feature_flags ? feature_flags : {})\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
each "number" card scores as its value | def score_numbers(cards_numbers)
cards_numbers.sum { |card| card.value.to_i }
end | [
"def possible_scores\n card_values.inject([0]) do |memo, item|\n if ace_value?(item)\n added_one = memo.map { |score| score + 1 }\n added_one << (added_one.last + 10)\n else\n memo.map { |number| number + item.first }\n end\n end\n end",
"def card_value... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
each "picture" card scores as 10 | def score_pictures(cards_pictures)
cards_pictures.count * 10
end | [
"def total_score\n total = 0\n @cards.each do |card|\n total += card.value\n end\n\n sorted_cards = @cards.sort\n\n straights = get_straight(sorted_cards).reverse\n straights.each do |straight|\n total += 40\n sorted_cards.slice!(straight[0]..straight[1])\n end\n\n three_cards... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
each "ace" card can score 11 or 1, depending on what is closer to 21, but not exceeding 21 | def score_aces(cards_aces, score_without_aces)
# first, assume all "ace" cards score as 1
aces_count = cards_aces.count
return 0 if aces_count.zero?
# check if we can convert one ace card to 11
if (score_without_aces + aces_count <= 11)
11 + (aces_count - 1)
else
# all ace cards sti... | [
"def aces_points(hand, current_score)\n\n number_of_aces = hand.count(\"Ace\")\n\n if number_of_aces == 1 && current_score <= 10\n aces_score = 11\n elsif number_of_aces == 2 && current_score <= 9\n aces_score = 12\n elsif number_of_aces == 3 && current_score <= 8\n aces_score = 13\n elsif number_of_a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /dvds/new GET /dvds/new.xml | def new
@dvd = Dvd.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @dvd }
end
end | [
"def new\n @vdig = Vdig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vdig }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @dnas... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /dvds/1 DELETE /dvds/1.xml | def destroy
@dvd = Dvd.find(params[:id])
@dvd.destroy
respond_to do |format|
format.html { redirect_to(dvds_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @vdig = Vdig.find(params[:id])\n @vdig.destroy\n\n respond_to do |format|\n format.html { redirect_to(vdigs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @rdv = Rdv.find(params[:id])\n @rdv.destroy\n\n respond_to do |format|\n format.html { redi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Here we want to make a method add_song that takes in an argument of a song and associates that song with the artist by telling the song that it belongs to that artist. | def add_song(song)
# We want to tell the song_name passed in that it belongs to the instance
# of Artist for which this method is called on aka self.
song.artist = self
end | [
"def add_song(song)\n @songs << song if @songs.include?(song) == false #adds the song to the artist's collection if it doesn't already exist\n song.artist = self if song.artist == nil #assigns the artist to the song if the song doesn't already have an artist\n end",
"def add_song(song)\n song.artist = s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Here we make a method add_song_by_name that takes in an argument of a song name, creates a new song with it, and associates the song and artist. | def add_song_by_name(song_name)
# Create a new song called "song" with argument passed in.
song = Song.new(song_name)
# Associate it with the artist
song.artist = self
end | [
"def add_song_by_name(song_name)\n song = Song.new(song_name)\n add_song(song)\n end",
"def add_song_by_name(name)\n song = Song.new(name)\n song.artist = self\n end",
"def add_song_by_name(song_name)\n song_name = Song.new(song_name) \n song_name.artist = self \n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns true if current_user has a facebook profile | def facebook_profile?
@network = current_user.network ||= Network.new
!(@network.facebook.nil? || @network.facebook.blank?)
end | [
"def is_facebook_user?\n @current_user.fb_id != nil \n end",
"def has_profile?\n return self.profile.present?\n end",
"def connected_to_facebook?\n fb_uid && fb_access_token\n end",
"def fb_connected?\n fb_user_id.present?\n end",
"def profile_owned_by_current_user?(profile)\n user = curr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns current frame's `location.href`. | def url
evaluate("document.location.href")
end | [
"def current_url\n evaluate(\"window.top.location.href\")\n end",
"def get_current_url\n @browser.current_url\n end",
"def actual_url\n @browser.current_url\n end",
"def current_url\n URI.parse(driver.current_url)\n end",
"def path\n `window.location.pathname`\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /drug_stores GET /drug_stores.json | def index
@drug_stores = DrugStore.all
end | [
"def index\n @stores = Store.all\n\n render json: @stores\n end",
"def index\n @stores = Store.all\n render json: @stores\n end",
"def index\n @api_v1_stores = Store.all\n json_response(@api_v1_stores)\n end",
"def index\n @store = Store.find(params[:store_id])\n @dish_discoun... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /drug_stores POST /drug_stores.json | def create
@drug_store = DrugStore.new(drug_store_params)
respond_to do |format|
if @drug_store.save
format.html { redirect_to @drug_store, notice: 'Drug store was successfully created.' }
format.json { render :show, status: :created, location: @drug_store }
else
format.html... | [
"def create\n @drugstore = current_user.drugstores.build(drugstore_params)\n\n respond_to do |format|\n if @drugstore.save\n format.html { redirect_to drugstores_url, notice: 'Farmacia creata exitosamente' }\n format.json { render :show, status: :created, location: @drugstore }\n else\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /drug_stores/1 PATCH/PUT /drug_stores/1.json | def update
respond_to do |format|
if @drug_store.update(drug_store_params)
format.html { redirect_to @drug_store, notice: 'Drug store was successfully updated.' }
format.json { render :show, status: :ok, location: @drug_store }
else
format.html { render :edit }
format.jso... | [
"def update\n respond_to do |format|\n if @drugstore.update(drugstore_params)\n format.html { redirect_to drugstores_url, notice: 'Actualización existosa' }\n format.json { render :show, status: :ok, location: @drugstore }\n else\n format.html { render :edit }\n format.json ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /drug_stores/1 DELETE /drug_stores/1.json | def destroy
@drug_store.destroy
respond_to do |format|
format.html { redirect_to drug_stores_url, notice: 'Drug store was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @drugstore.destroy\n respond_to do |format|\n format.html { redirect_to drugstores_url, notice: 'Elimninado exitosamente' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datastore = Datastore.find(params[:id])\n @datastore.destroy\n\n respond_to do |f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /user_game_levels GET /user_game_levels.json | def index
@user_game_levels = UserGameLevel.all
end | [
"def levels\n response = JSON.parse(@client.get(\"/api/v1/levels\").body)\n return response[\"levels\"] || response\n end",
"def index\n @userlevels = Userlevel.all\n end",
"def levels\n grant_id = params[:id]\n grant = Grant.find(grant_id)\n if grant == nil\n render :json => {}\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /user_game_levels POST /user_game_levels.json | def create
@user_game_level = UserGameLevel.new(user_game_level_params)
respond_to do |format|
if @user_game_level.save
format.html { redirect_to @user_game_level, notice: 'User game level was successfully created.' }
format.json { render :show, status: :created, location: @user_game_leve... | [
"def create\n @game_level = @game.game_levels.new(game_level_params)\n\n respond_to do |format|\n if @game_level.save\n format.html { redirect_to game_game_levels_path(@game), notice: 'Game level was successfully created.' }\n format.json { render :show, status: :created, location: @game_le... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /user_game_levels/1 PATCH/PUT /user_game_levels/1.json | def update
respond_to do |format|
if @user_game_level.update(user_game_level_params)
format.html { redirect_to @user_game_level, notice: 'User game level was successfully updated.' }
format.json { render :show, status: :ok, location: @user_game_level }
else
format.html { render :... | [
"def update\n authorize @game_level\n respond_to do |format|\n if @game_level.update(game_level_params)\n format.html { redirect_to game_game_levels_path(@game), notice: 'Game level was successfully updated.' }\n format.json { render :show, status: :ok, location: @game_level }\n else\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /user_game_levels/1 DELETE /user_game_levels/1.json | def destroy
@user_game_level.destroy
respond_to do |format|
format.html { redirect_to user_game_levels_url }
format.json { head :no_content }
end
end | [
"def destroy\n @level.destroy\n respond_to do |format|\n format.html { redirect_to game_levels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @game_level.destroy\n respond_to do |format|\n format.html { redirect_to game_levels_url }\n format.json { head :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /glass_store_links GET /glass_store_links.json | def index
@glass_store_links = GlassStoreLink.all
@glass_store_links.each do |glass_store_link|
@glass = Glass.find(glass_store_link.glass_id)
end
end | [
"def get_links(service)\n\t\treturn @transport.get_path(\"links\",service)\n\tend",
"def index\n @links = Link.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @links }\n end\n end",
"def index\n @links = Link.all\n\n respond_to d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /glass_store_links/1 PATCH/PUT /glass_store_links/1.json | def update
respond_to do |format|
if @glass_store_link.update(glass_store_link_params)
format.html { redirect_to @glass_store_link, notice: 'Glass store link was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.js... | [
"def update\n @link = Link.find(params[:id])\n if @link.update_attributes(params[:link])\n render json: @link\n else\n render json: @link.errors, status: :unprocessable_entity\n end\n end",
"def update\n update_and_respond(@link, link_params)\n end",
"def update\n respond_to do |fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /glass_store_links/1 DELETE /glass_store_links/1.json | def destroy
@glass_store_link.destroy
respond_to do |format|
format.html { redirect_to glass_store_links_url }
format.json { head :no_content }
end
end | [
"def destroy\n @slink.destroy\n respond_to do |format|\n format.html { redirect_to slinks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format.json { head :ok }\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test comment ^^^ meta.function.method.withoutarguments.ruby keyword.control.def.ruby ^^^^^^ meta.function.method.withoutarguments.ruby entity.name.function.ruby ^ punctuation.separator.statement.ruby ^^^^^ variable.other.ruby ^ punctuation.separator.object.ruby ^^^^^ variable.other.ruby ^ keyword.operator.assignment.ru... | def method # test comment
# ^^^ meta.function.method.without-arguments.ruby keyword.control.def.ruby
# ^^^^^^ meta.function.method.without-arguments.ruby entity.name.function.ruby
# ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby
# ^^^^^^^^^^^^^ comment.line.number-sign.ru... | [
"def method_with_parentheses(a, b, c = [foo,bar,baz]) # test comment\n# ^^^ meta.function.method.with-arguments.ruby keyword.control.def.ruby\n# ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.method.with-arguments.ruby entity.name.function.ruby\n# ^ meta.function.method.with-arguments.ruby pun... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test comment ^^^ meta.function.method.witharguments.ruby keyword.control.def.ruby ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.method.witharguments.ruby entity.name.function.ruby ^ meta.function.method.witharguments.ruby punctuation.definition.parameters.ruby ^ meta.function.method.witharguments.ruby variable.parameter.functi... | def method_with_parentheses(a, b, c = [foo,bar,baz]) # test comment
# ^^^ meta.function.method.with-arguments.ruby keyword.control.def.ruby
# ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.method.with-arguments.ruby entity.name.function.ruby
# ^ meta.function.method.with-arguments.ruby punctuation... | [
"def method # test comment\n# ^^^ meta.function.method.without-arguments.ruby keyword.control.def.ruby\n# ^^^^^^ meta.function.method.without-arguments.ruby entity.name.function.ruby\n# ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby\n# ^^^^^^^^^^^^^ comment.line.numbe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reverse the IP address for the inaddr.arpa zone | def reverse_ip(ipaddress)
reverse_ip = IPAddr.new ipaddress
reverse_ip.reverse
end | [
"def reverse\n @octets.reverse.join(\".\") + \".in-addr.arpa\"\n end",
"def reverse\n \"#{to_a.reverse.join('.')}.in-addr.arpa\"\n end",
"def reversed_ip\n return nil if reverse_name.nil?\n\n @reverse_ip ||= @dns.getaddress(reverse_name)\n @reverse_ip.to_s\n end",
"def to_arp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /police_units GET /police_units.json | def index
@police_units = PoliceUnit.all
end | [
"def foods_units\n get('/foods/units.json')\n end",
"def food_units\n get('foods/units.json')\n end",
"def units\n Units.names\n end",
"def units\n @units = Item.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units += Detail.select(\"DI... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /police_units POST /police_units.json | def create
@police_unit = PoliceUnit.new(police_unit_params)
respond_to do |format|
if @police_unit.save
format.html { redirect_to @police_unit, notice: 'Police unit was successfully created.' }
format.json { render :show, status: :created, location: @police_unit }
else
form... | [
"def create\n x = PoliceUnit.all.pluck(:id).sort[-1] + 1\n @police_unit = PoliceUnit.new(id: x, name: admin_police_unit_params[\"name\"], police_station_id: admin_police_unit_params[\"police_station_id\"].to_i, local_prosecution_id:admin_police_unit_params[\"local_prosecution_id\"].to_i)\n\n respond_to do ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /police_units/1 PATCH/PUT /police_units/1.json | def update
respond_to do |format|
if @police_unit.update(police_unit_params)
format.html { redirect_to @police_unit, notice: 'Police unit was successfully updated.' }
format.json { render :show, status: :ok, location: @police_unit }
else
format.html { render :edit }
forma... | [
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /police_units/1 DELETE /police_units/1.json | def destroy
@police_unit.destroy
respond_to do |format|
format.html { redirect_to police_units_url, notice: 'Police unit was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n response = HTTParty.delete(url, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n redirect_to units_url, notice: 'Unit was successfully deleted.'\n end",
"def destroy\n @base_unit.destroy\n respond_to do ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /team_years POST /team_years.json | def create
@team_year = TeamYear.new(team_year_params)
respond_to do |format|
if @team_year.save
format.html { redirect_to @team_year, notice: 'Team year was successfully created.' }
format.json { render :show, status: :created, location: @team_year }
else
format.html { rend... | [
"def create\n @team_year = TeamYear.new(team_year_params)\n\n respond_to do |format|\n if @team_year.save\n format.html { redirect_to @team_year, notice: 'Team year was successfully created.' }\n format.json { render action: 'show', status: :created, location: @team_year }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /team_years/1 PATCH/PUT /team_years/1.json | def update
respond_to do |format|
if @team_year.update(team_year_params)
format.html { redirect_to @team_year, notice: 'Team year was successfully updated.' }
format.json { render :show, status: :ok, location: @team_year }
else
format.html { render :edit }
format.json { r... | [
"def update\n respond_to do |format|\n if @team_year.update(team_year_params)\n format.html { redirect_to @team_year, notice: 'Team year was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /team_years/1 DELETE /team_years/1.json | def destroy
@team_year.destroy
respond_to do |format|
format.html { redirect_to team_years_url, notice: 'Team year was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @team_year.destroy\n respond_to do |format|\n format.html { redirect_to team_years_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @yearly_detail_year = YearlyDetailYear.find(params[:id])\n @yearly_detail_year.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializes Configuration instance with nil values unless config file was created previously | def initialize
@config = config_from_file || empty_config
end | [
"def initialize_config_file\n @config = HashWithIndifferentAccess.new\n write_config_file\n end",
"def create_config\n self.config = {} if !self.config\n end",
"def initialize\n self.reset\n\n if File.exist? SETTING_FILE\n\n # Sometimes on the _development_ environment\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resets configuration instance to initial values | def reset
@config = empty_config
end | [
"def reset_configuration!\n set_default_configuration\n end",
"def reset_config!\n @config = nil\n end",
"def reset_configs\n @configs = nil\n end",
"def clear\n self.configuration = {}\n end",
"def reset\n reset_adapters\n reset_config\n reset_handlers\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets absolute path of cloud path | def cloud_path=(path)
raise Error::InvalidCloudPath unless File.directory?(path)
@config[:cloud_path] = File.expand_path(path)
config_to_file
end | [
"def path_set(path)\n absolute_path = (Pathname.new(uri.path) + path).to_s\n rebuild_uri :path => absolute_path\n end",
"def set_path\n @file_path = @s3_local_object.body.path\n end",
"def path\n File.join(Dir.pwd, \"Cloudfile\")\n end",
"def absolute_path(options = {})\n if !@ab... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /oauth_tokens/new GET /oauth_tokens/new.xml | def new
@oauth_token = OauthToken.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @oauth_token }
end
end | [
"def new\n @access_token = ServiceProvider.find(params[:service_provider_id]).access_tokens.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @access_token }\n end\n end",
"def new\n @access_token = AccessToken.new\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /oauth_tokens/1 PUT /oauth_tokens/1.xml | def update
@oauth_token = OauthToken.find(params[:id])
respond_to do |format|
if @oauth_token.update_attributes(params[:oauth_token])
format.html { redirect_to([:scaffold, @oauth_token], :notice => 'Oauth token was successfully updated.') }
format.xml { head :ok }
else
form... | [
"def exchange_oauth_tokens\n end",
"def oauth_update(path, params=nil)\n raise 'OAuth access token required!' unless @oauth_token\n path = \"#{path}?#{params.map{|k,v|\"#{k}=#{v}\"}.join('&')}\" if params\n resp = @oauth_token.post(path, {'Accept'=>'application/xml'})\n\n case resp\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /oauth_tokens/1 DELETE /oauth_tokens/1.xml | def destroy
@oauth_token = OauthToken.find(params[:id])
@oauth_token.destroy
respond_to do |format|
format.html { redirect_to(scaffold_oauth_tokens_url) }
format.xml { head :ok }
end
end | [
"def delete_access_token(token)\n delete(\"/oauth2/accesstokens/#{token}\")\n end",
"def destroy\n @access_token = ServiceProvider.find(params[:service_provider_id]).access_tokens.find(params[:id])\n @access_token.destroy\n\n respond_to do |format|\n format.html { redirect_to(access_toke... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the data of a widget GET widget_data | def widget_data
widget = Widget.find(params[:widget_id])
data = widget.get_filtered_dataset false, 10000
render json: {id: widget.id,
visualization: widget.visualization,
name: widget.name,
description: widget.description,
data: data['d... | [
"def widget_data\n widget = WidgetService.widget(params[:widget_id])\n render json: {\n id: widget.id,\n dataset: widget.dataset,\n visualization: widget.widget_config,\n name: widget.name,\n description: widget.description,\n metadata: widget.metadata\n }\n end",
"def widg... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get hash of all active root level campuses/ORUs, sorted by ordering in unit_hier table | def getActiveCampuses
return Unit.join(:unit_hier, :unit_id=>:id).
filter(:ancestor_unit=>'root', :is_direct=>1).exclude(:status=>["hidden", "archived"]).
order_by(:ordering).to_hash(:id)
end | [
"def getActiveCampuses\n return Unit.join(:unit_hier, :unit_id=>:id).\n filter(:ancestor_unit=>'root', :is_direct=>1).exclude(:status=>\"hidden\").\n order_by(:ordering).to_hash(:id)\nend",
"def keys\n hierarchy.flat_map{ |lspace| lspace.hash.keys }.uniq\n end",
"def roothash\n root_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Move pending PDF files to their published location | def movePendingFiles(itemID)
noSplashKey = calcNoSplashKey(itemID)
pvwPfx = getEnv("S3_PREVIEW_PREFIX")
pvwLin = $s3Bucket.object("#{pvwPfx}/#{itemID}/#{itemID}_noSplash_#{noSplashKey}.pdf")
pvwSplash = $s3Bucket.object("#{pvwPfx}/#{itemID}/#{itemID}.pdf")
# If there's no preview file to move, we have nothi... | [
"def send_pdfs\n package(\"#{package_name('original_documents')}.zip\") do |zip|\n @documents.each do |doc|\n zip.get_output_stream(\"#{doc.slug}.pdf\") {|f| f.write(asset_store.read_pdf(doc)) }\n end\n end\n end",
"def movepdfs\n ignore_exception { puts \"Ignoring Exception\"; raise Ex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Uses the same Logger instance as ActiveRecord. | def logger
::ActiveRecord::Base.logger
end | [
"def log_to(stream)\n ActiveRecord::Base.logger = Logger.new(stream)\n ActiveRecord::Base.clear_active_connections!\n end",
"def apply_logger!(rack_env)\n logger = rack_env['captivity.logger']\n ActiveRecord::Base.logger = logger if logger\n end",
"def change_log(stream)\n ActiveRecord:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Getter (reader) for the job of the person | def job
@job
end | [
"def getJobName()\n return @jobName\n end",
"def job=(person_job)\n @job = person_job\n end",
"def job\n @job ||= Job.where(\"exam_id = ?\", self.id).order(\"modified_date DESC\").first\n end",
"def job\n fetch('games.final_fantasy_xiv.jobs')\n end",
"def job_resource(job)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a pattern to the grammar. | def add_pattern(pattern)
@patterns << pattern
end | [
"def add_pattern(pattern)\n patterns << pattern\n end",
"def add_pattern( pattern )\n type_check( pattern, Elements::Pattern )\n assert( !name_defined?(name), \"name [#{name}] is already in use\" )\n \n @patterns[pattern.name] = pattern\n end",
"def <<(patter... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete all images for a preset | def delete_preset_items(preset)
only_provides(*graphics_mime_types)
raise NotFound unless preset_exists?(preset)
files = Dir.glob(preset_request_path / "**" / "*.{#{graphics_mime_types.join(',')}}")
success = files.all? { |file| FileUtils.rm(file) rescue nil }
cleanup_empty_dirs!(preset_re... | [
"def delete_images\n FileUtils.rm_rf(Dir.glob('./lib/images/*'))\n end",
"def remove_all_pictures\n end",
"def clear_images\n\t\t\tfiles = EntityFile.where(entity: controller_name.classify, entity_id: 0, user: current_user )\n\t\t\tfiles.try(:destroy_all)\n\t\tend",
"def remove_all_images\n self... | {
"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.