query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
GET /connpasses GET /connpasses.json
def index @connpasses = Connpass.all end
[ "def passes\n command = RequestPasses.call(@current_user, serialNumbers)\n if command.success?\n @passes = command.result\n render 'passes.json.jbuilder', status: :ok\n else\n render json: {error: command.errors}, status: :bad_request\n end\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /connpasses POST /connpasses.json
def create @connpass = Connpass.new(connpass_params) respond_to do |format| if @connpass.save format.html { redirect_to @connpass, notice: 'Connpass was successfully created.' } format.json { render :show, status: :created, location: @connpass } else format.html { render :ne...
[ "def passes\n command = RequestPasses.call(@current_user, serialNumbers)\n if command.success?\n @passes = command.result\n render 'passes.json.jbuilder', status: :ok\n else\n render json: {error: command.errors}, status: :bad_request\n end\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /connpasses/1 DELETE /connpasses/1.json
def destroy @connpass.destroy respond_to do |format| format.html { redirect_to connpasses_url, notice: 'Connpass was successfully destroyed.' } format.json { head :no_content } end end
[ "def delete_guest_access_portal(args = {}) \n delete(\"/guestaccess.json/gap/#{args[:portalId]}\", args)\nend", "def destroy\n @pass.destroy\n respond_to do |format|\n format.html { redirect_to passes_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {})...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Description: This method process get lastest roadmap
def get_lastest_roadmaps(user_id) UserCategory.where(user_id: user_id).order_by(created_at: -1).limit(ITEM_PER_PAGE) end
[ "def last_location\n waypoints.order(sent_at: :desc).first\n end", "def find_new_road\n return nil if finding_new_road?\n return nil if Params::NEW_ROOT_FIND_PERCENTAGE < rand(Params::PERCENT_DENOMINATOR)\n\n found_mini_map_ids = mini_map_roads.collect{|r| r.end_mini_map_id}\n found_mini_map_ids <...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
::: bp_class ::: 31/05/2012 ................................................................................................... Format and clean class strings
def bp_class class_param class_param.blank? ? '' : class_param.strip().html_safe end
[ "def sanitize_class_name(name)\n name.gsub(/[^_0-9A-Za-z:]/, '')\n end", "def sanitize_classname(klass_name)\n klass_name.gsub(\":\",\"\")\n end", "def modify_string_class(opts)\n opts = check_params(opts,[:classes])\n super(opts)\n end", "def full_class_name\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
::: bp_html_print ::: 31/05/2012 ................................................................................................... Format and print final HTML code Supports: crude html code Returns: Safe html without spaces
def bp_html_print html if html.blank? out = 'The helper <b>bp_html_print</b> received <b>empty</b> or <b>null</b>.' else out = html.gsub(/ /, ' ') out = out.gsub('id=""', '') out = out.gsub('class=""', '') out = out.gsub('style=""', '') end out.try(:html_safe) end
[ "def lstrip_html\n return if self.blank?\n\n m = self.match(/\\A(\\s*?[^<]|(.*?)>\\s*[^<])/) #Find first printing character\n return self unless m\n \n ldr = m[0]\n ldr_last = ldr.slice(ldr.size-1, ldr.size)\n ldr = ldr.slice(0,ldr.size-1) # portion up to the first printing character\n bdy =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
::: bp_group :: (ANTES group_inputs_form) ................................................................................................... Agrupar elementos Admite: Label, ID y Class
def bp_group options, &block label = options[:label].blank? ? "" : options[:label] id = options[:id].blank? ? "" : options[:id] style = options[:style].blank? ? "" : options[:style] out = content_tag :li, :class => bp_class("group #{options[:class]}"), :id => "#{id}", :style => style do content_t...
[ "def input_text_group(name, values = [])\n field = field_content(name)\n field_name = prop(field, 'name') || name\n group = {}\n unless field.nil?\n group[:legend] = prop(field, 'label')\n group[:description] = prop(field, 'description')\n group[:description_id] = \"label-description-#{na...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
::: bp_inline :: (ANTES inline_inputs_form) ................................................................................................... Campos en linea Admite: Label, ID y Class
def bp_inline options, &block label = options[:label].blank? ? "" : options[:label] not_label = label.blank? ? "not-label" : "" id = options[:id].blank? ? "" : "id='#{options[:id]}'" cols = options[:cols].blank? ? "" : "cols-#{options[:cols]}" msgerr = cols.blank? ? "No se ha definido el numero de...
[ "def labeled_input_fields(*attrs)\n attrs.collect {|a| labeled_input_field(a) }.join(\"\\n\").html_safe\n end", "def input(wrapper_options)\n @builder.text_field(attribute_name, input_html_options) + \\\n @builder.hidden_field(attribute_name, value: input_html_options[:value], class: attribute_name.to_s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
::: action_button ::: ................................................................................................... Boton de estilo Accion (accion positiva) Muestra un enlace A con estilo Accion Admite: Label, URL y clases adicionales
def action_button_form options label = options[:label] ? options[:label] : "Boton" url = options[:url] ? options[:url] : "#" myclass = options[:class] ? "btn-action #{options[:class]}" : "btn-action" "<li><div class='#{myclass}'>#{link_to(label, url)}</div></li>".html_safe end
[ "def aide2()\n indice = IndiceMoyen.create(@map)\n res = indice.envoyerIndice.indice.split(\"-\")\n\n x=res[0].to_i\n y=res[1].to_i\n if res[2]==\"0\"\n @map.putAt!(x,y,Case.create(2))\n changeImage(@buttonTab[x][y],\"../images/cases/croix.png\")\n else\n @map.putAt!(x,y,Case.create...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
::: custom_item ::: ................................................................................................... Elemento personalizado: texto, link,... Admite: ID, label, hint, HTML Ejemplo: custom_item_form :label => 'Visita mi web', :html => link_to('miweb.es','
def custom_item_form options group_html = "<li id='#{options[:id]}' class='p'>" group_html += options[:label] ? "<label for='#{options[:id]}'>#{options[:label]}</label>" : "" group_html += "<div class='wrap-custom-html'>#{options[:html]}</div>" group_html += options[:hint] ? "<p class='inline-hints'>#{o...
[ "def trasform_item_to_html(item)\n return super unless self.class.right_items.include?(item.id)\n\n html_list_item(item) do\n link = html_link(item) { item.label(@inject[item.id]) }\n\n <<-HTML\n <span class=\"right_border\">&nbsp;</span>\n <span cla...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
::: bp_directory_index ::: Muestra un arbol de carpetas y vistas en funcion del path del request
def bp_directory_index tree_hash = BP.same_level_views("/base_project#{request.env['PATH_INFO']}") p tree_hash out = "<ul>" tree_hash.keys.each do |tree_hash_key| thk = tree_hash_key.gsub(".html.erb", "") thk = thk.gsub("/mocks", "") out += content_tag :li, thk.gsub("/", "") out += "<ul>" ...
[ "def index\n @directory = find_directory params[:path]\n end", "def path(*) end", "def bp_mock_directory_index\n\n tree_hash = BP.same_level_views(\"/mocks\")\n\n out = \"<ul>\"\n\n tree_hash.keys.each do |tree_hash_key|\n thk = tree_hash_key.gsub(\".html.erb\", \"\")\n thk = thk.gsub(\"/mocks\", \...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
::: bp_mock_directory_index ::: Muestra un arbol de carpetas y vistas dentro de la carpeta mocks
def bp_mock_directory_index tree_hash = BP.same_level_views("/mocks") out = "<ul>" tree_hash.keys.each do |tree_hash_key| thk = tree_hash_key.gsub(".html.erb", "") thk = thk.gsub("/mocks", "") out += content_tag :li, thk.gsub("/", "") out += "<ul>" tree_hash[tree_hash_key].each do |tree_h...
[ "def bp_directory_index\n tree_hash = BP.same_level_views(\"/base_project#{request.env['PATH_INFO']}\")\n\n p tree_hash\n\n out = \"<ul>\"\n\n tree_hash.keys.each do |tree_hash_key|\n thk = tree_hash_key.gsub(\".html.erb\", \"\")\n thk = thk.gsub(\"/mocks\", \"\")\n\n out += content_tag :li, thk.gsub(\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
::: bp_meta_tags ::: 31/05/2012 ................................................................................................... Add baseproject meta tags
def bp_meta_tags "<meta name='base-project-version' content='#{bp_version}'>".html_safe end
[ "def set_meta_tags_title\n set_meta_tags site: 'benradler.com'\n end", "def default_meta_tags\r\n # set main site title\r\n set_meta_tags :site => I18n.t('meta_tags.defaults.site', :default => '')\r\n\r\n # set keywords\r\n c = I18n.t \"meta_tags.#{controller_name}.#{action_name}.keywords\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
filter by post type. TODO
def by_type filter(:type) do |post, type| post.post_type.casecmp(type).zero? end end
[ "def list_by_post_type\n list :conditions => ['post_type = ?', params[:type]]\n end", "def get_post_types(args = {}, output = 'names', operator = 'and')\n field = ( 'names' == output ) ? 'name' : false\n\n wp_filter_object_list(Railspress.GLOBAL.wp_post_types, args, operator, field)\n end", "def filt...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /schmos POST /schmos.json
def create @schmo = Schmo.new(schmo_params) respond_to do |format| if @schmo.save format.html { redirect_to @schmo, notice: 'Schmo was successfully created.' } format.json { render :show, status: :created, location: @schmo } else format.html { render :new } format.js...
[ "def create\n @microcosm = Microcosm.new(microcosm_params)\n\n respond_to do |format|\n if @microcosm.save\n format.html { redirect_to @microcosm, notice: 'Microcosm was successfully created.' }\n format.json { render :show, status: :created, location: @microcosm }\n else\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /schmos/1 PATCH/PUT /schmos/1.json
def update respond_to do |format| if @schmo.update(schmo_params) format.html { redirect_to @schmo, notice: 'Schmo was successfully updated.' } format.json { render :show, status: :ok, location: @schmo } else format.html { render :edit } format.json { render json: @schmo.e...
[ "def update\n respond_to do |format|\n if @microcosm_changeset.update(microcosm_changeset_params)\n format.html { redirect_to @microcosm_changeset, notice: 'Microcosm changeset was successfully updated.' }\n format.json { render :show, status: :ok, location: @microcosm_changeset }\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /schmos/1 DELETE /schmos/1.json
def destroy @schmo.destroy respond_to do |format| format.html { redirect_to schmos_url, notice: 'Schmo was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @sms_client = SmsClient.find(params[:id])\n @sms_client.destroy\n\n respond_to do |format|\n format.html { redirect_to sms_clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @scrim.destroy\n respond_to do |format|\n format.html { redirect...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
write chain index to file. The file is a binary file, and payload of +block_list+ and +newest_block+ are stored.
def write_to_file File.open(config.block_list_path, 'a') do |f| block_count = old_newest_block ? (block_list.size - old_newest_block.height - 1) : block_list.size block_list = self.block_list.sort{|(k1, v1), (k2, v2)| v1.height <=> v2.height} block_list = block_list[(old_newest_blo...
[ "def write_block file, block\n payload = block.to_payload\n file.write Bitcoin.network[:magic_head]\n file.write [payload.bytesize].pack(\"L\")\n file.write payload\n end", "def write_index\n open(@index_filename, \"w\") do |index|\n index.write Marshal.dump(@data)\n end\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /spells, GET /
def spells get_schools get_classes respond_to do |format| format.json { get_all_spells render json: @spells.sort_by {|k, v| v['name']}.to_json } format.html {} end end
[ "def index\n\t\t@spells = Spell.all\n\tend", "def index\n @spells = Spell.all\n end", "def index\n @spells = Spell.all\n\n render json: @spells\n end", "def index\n\t\t@player_spells = PlayerSpell.all\n\tend", "def spell\n fetch('harry_potter.spells')\n end", "def index\n @cl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
update /etc/instancecontroller/logs.json for uploading presto logs to s3
def s3LogJsonUpdate(presto_log_dir) println "presto log dir : #{presto_log_dir}" logs_json_path = "/etc/instance-controller/logs.json" println "Updating #{logs_json_path}" json_obj=JSON.parse(File.read("#{logs_json_path}")); sections = json_obj["logFileTypes"] sections.each { |section| if ...
[ "def s3LogJsonUpdate\n logs_json_path = \"/etc/instance-controller/logs.json\"\n println \"Updating #{logs_json_path}\"\n json_obj=JSON.parse(File.read(\"#{logs_json_path}\"));\n sections = json_obj[\"logFileTypes\"]\n sections.each { |section|\n if section['typeName'] == 'USER_LOG' then\n user_log = s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
write /etc/init.d/prestolauncher & /etc/servicenanny/presto.conf for servicenanny to monitor
def writePrestoFilesForServiceNanny println "Making /etc/init.d/presto-launcher" File.open('/tmp/presto-launcher', 'w') do |f| f.write(<<EOF /home/hadoop/presto-server/bin/launcher $@ EOF ) end sudo "mv /tmp/presto-launcher /etc/init.d/presto-launcher && chmod a+x /etc/init.d/presto-launcher" println...
[ "def writePrestoFilesForServiceNanny\n println \"Making /etc/init.d/presto-launcher\"\n File.open('/tmp/presto-launcher', 'w') do |f|\n f.write(<<EOF\n/home/hadoop/presto-server/bin/launcher $@\nEOF\n )\n end\n sudo \"mv /tmp/presto-launcher /etc/init.d/presto-launcher && chmod a+x /etc/init.d/pres...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Turns query results into a hash keyed by event name, values are a set of unique user IDs for that event
def data @data ||= begin event_users = Hash.new do |h, uuid| h[uuid] = Set.new end # IDEA: maybe there's a block form if this we can do that yields results as it loads them # to go slightly faster fetch_results.each do |row| event_users[row['name']] << ...
[ "def data\n @data ||= begin\n event_users = Hash.new do |h, event_name|\n h[event_name] = Set.new\n end\n\n # IDEA: maybe there's a block form if this we can do that yields results as it loads them\n # to go slightly faster\n fetch_results.each do |row|\n ev...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the user ID, if authentication was successful.
def user_id return nil unless success? @user_id end
[ "def authenticate_user\n return if user_id\n\n @user_id =\n cookies.signed.permanent[:user_id] =\n request.headers[\"HTTP_X_FINGERPRINT\"] || SecureRandom.hex\n end", "def auth_user_id\n auth[:user_id]\n end", "def hubssolib_get_user_id\n user = self.hubssolib_current_user\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the meta data, if authentication was successful.
def meta_data return nil unless success? @meta_data end
[ "def fetch_metadata\n data = JSON.parse(@object.headers[:x_optidash_metadata] || @object.body)\n\n if data[\"success\"]\n @metadata = data\n else\n @error = data[\"message\"]\n end\n rescue JSON::ParserError\n @error = \"Una...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates a notched path that flows between the outer edge of the box (outside_line) and inner (inside_line). Relative location of these lines also defines the direction and orientation of the box, and hence the notches. We always want to create a symmetric path that has a notch in the middle (for center_out = true) o...
def path(edge) shifts = define_shifts(edge) path = NotchedPath.new if fill_corners r1 = Geometry::Rect.new(edge.inside.p1, edge.outside.p1) r2 = Geometry::Rect.new(edge.inside.p2, edge.outside.p2) path.corner_boxes << r1 path.corner_boxes <...
[ "def to_path\n nodes = []\n angle = 2 * Math::PI / @sides\n theta = angle / 2 + Math::PI / 2\n @sides.times do |n|\n nodes[n] = []\n nodes[n][0] = @radius * Math.cos(angle * n + theta) + @x\n nodes[n][1] = @radius * Math.sin(angle * n + theta) + @y\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the Dot label for the object.
def dot_label x @dot_label[x] ||= _dot_label x end
[ "def label\n dotted_item.to_s\n end", "def label o\n o.to_s\n end", "def dot\n RGL::DOT::Graph.new('elements' => dot_edges).to_s\n end", "def dot_header\n result = \"digraph #{@diagram_type.downcase}_diagram {\\n\" +\n \"\\tgraph[overlap=false, splines=true]\\n\"\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Renders the StateMachine as Dot syntax.
def render_StateMachine sm, dot_opts = nil return if @rendered[sm] @rendered[sm] = true dot_opts ||= { } hide_decomposition = dot_opts.delete(:hide_decomposition) stream.puts "\n// {#{sm.inspect}" name = dot_opts.delete(:_node_name) || dot_name(sm) type = "subgraph #{name}" ...
[ "def print_state_machine_dot opts={}\n io = opts[:io] || StringIO.new\n graph_options = opts[:graph_options] || ''\n message_name_transform = opts[:message_name_transform] || proc {|x| x}\n state_name_transform = opts[:state_name_transform] || proc {|x| x}\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Renders the State object as Dot syntax.
def render_State s return if @rendered[s] @rendered[s] = true stream.puts "\n// #{s.inspect}" sequence = [ ] if options[:history] options[:history].each_with_index do | hist, i | if hist[:new_state] && s.is_a_superstate_of?(hist[:new_state]) seq...
[ "def to_dot(options = {})\r\n Dot::Digraph.new(:fontsize => 10, :shape => :box, :size => 5) do |g|\r\n states.each do |state|\r\n g.node(state, :label => state.items.values.collect{|item| item.to_s(options)}.join(\"\\n\"))\r\n @transitions[state].each do |symbol, dest_state|\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns SVG data of the graph, using a temporary file.
def render_graph_svg_data machine, opts = { } require 'tempfile' tmp = Tempfile.new("red_steak_dot") self.file_dot = tmp.path + ".dot" self.file_svg = nil render_graph(machine, opts) result = File.open(self.file_svg, "r") { | fh | fh.read } if opts[:xml_header] == false || opti...
[ "def svg\n # Only recompile the SVG if it doesn't already exist\n unless File.exist? self.svg_name\n File.open(\"#{@name}.tex\", 'w') { |f| f.write document }\n # TODO Catch pdflatex errors\n system \"lib/latex2svg #{@name}\"\n end\n # Unless latex2svg was successful, use a placeholder SV...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instructions for selecting the PCR program template
def select_program_template(program:) file = program_template_file(program: program) "Choose the program template <b>#{file}</b>" end
[ "def select_program_template(program:)\n file = program_template_file(program: program)\n \"Choose the protocol <b>#{file}</b>\"\n end", "def select_program_template(program:)\n file = program_template_file(program: program)\n \"Select the #{file} protocol from the Library\"\n end", "def choose_te...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Image Methods These probably should NOT be overridden in the concrete classes Image for opening the lid
def open_lid_image image_path(image_name: params[:open_lid_image]) end
[ "def image\n end", "def image\n\n end", "def open_lid\n format_show_array([\n 'Open the lid by pinching the side tabs on the front plate of the miniPCR',\n 'Use your thumb and index fingers to pinch, and lift the lid with your other hand'\n ])\n end", "def lnbPicture _obj, _args\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Image for closing the lid
def close_lid_image image_path(image_name: params[:close_lid_image]) end
[ "def close_image\n @p.close_image(self)\n end", "def unload_image(image_handle)\n end", "def delete_mirage(img)\n img.dispose\n end", "def destroy\n\t @image = Gosu::Image.new(\"media/earth_destroyed.png\")\n\tend", "def exit_image\nputs \" \"\nputs\" ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Image for starting the run
def start_run_image image_path(image_name: params[:start_run_image]) end
[ "def S(args)\n puts \"\\n=>\\n\"\n @image.show\n end", "def display_image\n system(\"#{imgcat} #{screenshot_path}\") unless imgcat.nil?\n end", "def startcmd\n [initscript, :start]\n end", "def run_lucian_image(image=Lucian.image)\n raise \"Image can not be nil\" if image.nil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instructions for selecting the plate layout template in the software
def select_layout_template(program:) file = layout_template_file(program: program) "Choose the layout template <b>#{file}</b>" end
[ "def choose_template(title_string, template_file, container)\n show do\n title \"Select #{title_string}\"\n check 'Open the BD Accuri software BD CSampler if not already open'\n check 'If the program is open and displaying <b>DONE!</b>, press <b>CLOSE RUN DISPLAY</b>'\n check 'Go to...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instructions for saving an experiment file
def save_experiment_file(filename:) "Save the experiment as #{filename} in #{params[:experiment_filepath]}" end
[ "def cmd_save argv\n setup argv\n e = @hash['elements']\n filepath = @hash['filepath'] || \"config.json\"\n response = @api.save(e, filepath)\n msg response\n return response\n end", "def save\n save_file :timers\n save_file :shortcuts\n save_file :hops\n save_file :userpoin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Image for setting up the software workspace
def setup_workspace_image image_path(image_name: params[:setup_workspace_image]) end
[ "def show_prepare_workspace\n show do\n title 'Prepare workspace'\n\n note \"All tasks in this protocol occur in the #{RNA_FREE_WORKSPACE}.\"\n note 'As you retrieve reagents, place them on ice or in a cold-block.'\n end\n end", "def build_vm_image\n options.verbose? ? log.level = Logge...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Image for selecting the plate layout template in the software
def setup_plate_layout_image image_path(image_name: params[:setup_plate_layout_image]) end
[ "def plate_preheating \r\n show do \r\n title \"Pre-heat plates\"\r\n note \"Retrieve the following plates, and place into still #{operations[0].input(\"Plasmid\").sample.properties[\"Transformation Temperature\"].to_i} C incubator.\" \r\n grouped_by_marker = operations.running.group_by { |op|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Getter Methods These should NOT be overridden in the concrete classes The name of the software that controls the thermocycler
def software_name self.class.const_get(:SOFTWARE_NAME) end
[ "def name; termid;end", "def getClienObjName\r\n\t\t\treturn \"mfiforce__Client__c\"\r\n\t\tend", "def strategy_name; end", "def carrier_name\r\n self.class.carrier_name\r\n end", "def getProcessorName; self.class.name; end", "def classname\n @data['driver-class-name']\n end", "def logical_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run block with spinner by default if all, or when using verbose. Do not use spinner if silent.
def maybe_spinner(msg, &block) if (all? || verbose?) && !silent? spinner(msg, &block) else yield end end
[ "def vspinner(msg, &block)\n return vfakespinner(msg) unless block_given?\n\n if running_verbose? && $stdout.tty?\n spinner(msg, &block)\n else\n logger.debug { msg }\n yield\n end\n end", "def spin(options={}, &block)\n options = Base.build_confi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /absences/new GET /absences/new.json
def new @absence = Absence.new @title = "New Absence" respond_to do |format| format.html # new.html.erb format.json { render json: @absence } end end
[ "def new\n @absence = Absence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @absence }\n end\n end", "def new\n @absence = Absence.new\n @member = Member.find(params[:member_id])\n \n respond_to do |format|\n format.html # new.html.er...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /absences/1 PUT /absences/1.json
def update @absence = Absence.find(params[:id]) respond_to do |format| if @absence.update_attributes(params[:absence]) format.html { redirect_to @absence, notice: 'Absence was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" ...
[ "def update\n respond_to do |format|\n if @absence.update(absence_params)\n format.html { redirect_to @absence, notice: 'Absence was successfully updated.' }\n format.json { render :show, status: :ok, location: @absence }\n else\n format.html { render :edit }\n format.json {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /absences/1 DELETE /absences/1.json
def destroy @absence = Absence.find(params[:id]) @absence.destroy respond_to do |format| format.html { redirect_to absences_url } format.json { head :no_content } end end
[ "def destroy\n @absence.destroy\n respond_to do |format|\n format.html { redirect_to absences_url, notice: 'Отсутствие успешно удалено.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @absence = Absence.find(params[:id])\n @absence.destroy\n\n respond_to do |format|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /bandas/new GET /bandas/new.xml
def new @banda = Banda.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @banda } end end
[ "def new\n @band = Band.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @band }\n end\n end", "def new\n @band = Band.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @band }\n end\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
psuedocode define method that remoces item from list remove item from groceries list output update list
def remove_item(items, groceries_list) groceries_list.delete(items) end
[ "def remove_item(new_list, item_name)\r\n new_list.delete(item_name)\r\nend", "def remove_item(item)\n\tadd_item_to_grocery_list_hash = add_item(\"cake\", 5)\n\tadd_item_to_grocery_list_hash.delete(item)\n#\tp add_item_to_grocery_list_hash\n\titem_removed_hash = add_item_to_grocery_list_hash\n#\tp item_removed...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
pseudocode define a method that updates the quantities for items in groceries_list update quantity output updated groceries_list
def update_quantity(item, quantity, groceries_list) groceries_list[item] = quantity end
[ "def update_grocery_list_quantity(list, category, item, quantity)\n list[category][item] = quantity\n list\nend", "def update_qty(shopping_list, item, quantity)\n\n\tadd_item(shopping_list, item, quantity)\n\nend", "def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
given a user_id, return a count of unviewed photos
def num_new_photos user_id = params[:user_id] # if request.format != :json # render :status=>406, :json=>{:message=>"The request must be json"} # return # end if user_id.nil? render :status=>400, :json=>{:message=>"The request must contain a user_id."} return end ...
[ "def number_of_unviewed_notifications(user)\n Notification.where(:userID => user.id).where(:viewed => false).count\n\tend", "def albums_user_photo_count\n count = 0\n albums.each do |a|\n vk_client.photos.get(owner_id: a.owner_id, album_id: a.aid).each do |p|\n count += 1 if p.user...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function finds refining parameters via ConstraintBlocks/ConstraintElements from the given VerificationElement. It highlights elements that have no expressions for constraints and missing units. Params: +requirement+:: A Requirement element to look for refining parameters.
def findRefinedParameters(element) for relation in element.get_relationshipOfRelatedElement() if StereotypesHelper.hasStereotype(relation, $veRelationshipStereotype) req = ModelHelper.getSupplierElement(relation) for relation in req.get_relationshipOfRelatedElement() ...
[ "def findRefinedParameters(requirement)\n for relation in requirement.get_relationshipOfRelatedElement()\n if StereotypesHelper.hasStereotype(relation, $refineStereotype)\n ce = ModelHelper.getClientElement(relation)\n if StereotypesHelper.hasStereotype(ce, $ceStereotype)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function executes the function looking for all refining parameters for a VerficationElement and then parses through all owned elements from the given one. Params: +element+:: SysML element from the containment tree.
def recursiveTreeTraversal(element) if StereotypesHelper.hasStereotype(element, $veStereotype) findRefinedParameters(element) end for child in element.getOwnedElement() recursiveTreeTraversal(child) end end
[ "def findRefinedParameters(element)\n for relation in element.get_relationshipOfRelatedElement()\n if StereotypesHelper.hasStereotype(relation, $veRelationshipStereotype)\n req = ModelHelper.getSupplierElement(relation)\n for relation in req.get_relationshipOfRelatedElement()\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
encoding: utf8 Function creates a paragraph from string p and writes them out to file f
def paragraph(p,f) # Replaces everything that has <b>, </b>, etc. value = p.gsub(/<b>|<\/b>|<a>|<\/a>/, "") arr = value.split(/</) # Gets rid of anything else from .* to > # and fixes spaces between numbers arr.each {|x| x.gsub!(/.*>\d*/, ""); x.gsub!(/\&\#\d*\;/, " "); } arr.each {|x| if x == a...
[ "def paragraph(p,f)\n\t\n\t# Replaces everything that has <b>, </b>, etc.\n\tvalue = p.gsub(/<b>|<\\/b>|<a>|<\\/a>/, \"\")\n \tvalue.gsub!(/[\\[\\]]/, \"\")\n \tarr = value.split(/</)\n\n \t# Gets rid of anything else from .* to > \n \t# and fixes spaces between numbers\n\tarr.each {|x| x.gsub!(/.*>\\d*/, \"\");\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This function keeps loop going until "DONE" is seen Otherwise, function get_info will be called to use To extract first two paragraphs from Wikipedia
def get_info_loop file loop do line = file.gets if line == nil then break end words = line.scan(/\S+/) words.each{ |word| case word when /DONE/ return else get_info(word) end } end end
[ "def get_detailed_info(html)\n result = {}\n page = Nokogiri::HTML(html)\n result[:img] = extract_image(page)\n # No easy identifiers, so get where the section starts, where the next section starts, and look at all tables in between\n # TODO: Use XPath to use less code\n start_elem = page.css('spa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a Transaction ready to be signed. Returns an Array of signature dictionaries.
def signatures(transaction, names: [:primary]) transaction.inputs.map do |input| path = input.output.metadata[:wallet_path] node = self.path(path) sig_hash = transaction.sig_hash(input, node.script) node.signatures(sig_hash, names: names) end end
[ "def sign(transaction)\n raise TypeError \"transaction must be a Transaction, but #{transaction.class} given.\" unless transaction.is_a? Transaction\n raise NotMyTransactionError.new 'tx not yours!' unless transaction.wallet == self\n raise Transaction::TransactionAlreadyLockedError.new 'locked transaction...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a Transaction and any number of Arrays of signature dictionaries. Each sig_dict in an Array corresponds to the Input with the same index. Uses the combined signatures from all the signers to generate and set the script_sig for each Input. Returns the transaction.
def authorize(transaction, *signers) transaction.set_script_sigs *signers do |input, *sig_dicts| node = self.path(input.output.metadata[:wallet_path]) signatures = combine_signatures(*sig_dicts) node.script_sig(signatures) end transaction end
[ "def apply_multisignatures(tx, i, script, *sigs)\r\n\t\t#txobj = deserialize(tx)\r\n\t\tscriptSig = \"00\" # Push byte 0x0 due to bug in multisig\r\n\t\tpushdata = '' # In case transaction > 150 bytes.\r\n\r\n\t\t# In case sigs is an array * puts it inside another array\r\n\t\t# so that outter array size is 1.\r\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes any number of "signature dictionaries", which are Hashes where the keys are tree names, and the values are base58encoded signatures for a single input. Returns an Array of the signatures in binary, sorted by their tree names.
def combine_signatures(*sig_dicts) combined = {} sig_dicts.each do |sig_dict| sig_dict.each do |tree, signature| decoded_sig = decode_base58(signature) low_s_der_sig = Bitcoin::Script.is_low_der_signature?(decoded_sig) ? decoded_sig : Bitcoin::OpenSSL_EC.signature_to_...
[ "def signatures(transaction, names: [:primary])\n transaction.inputs.map do |input|\n path = input.output.metadata[:wallet_path]\n node = self.path(path)\n sig_hash = transaction.sig_hash(input, node.script)\n node.signatures(sig_hash, names: names)\n end\n end", "def sign...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /percentual_gorduras GET /percentual_gorduras.json
def index @percentual_gorduras = PercentualGordura.all end
[ "def index\n @percent_ranges = PercentRange.all\n render :json => @percent_ranges, :status=>:ok\n end", "def index\n @grados = Grado.order(\"nivel, grado\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @grados }\n end\n end", "def index\n @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /percentual_gorduras/1 GET /percentual_gorduras/1.json GET /percentual_gorduras/new
def new @percentual_gordura = PercentualGordura.new end
[ "def create\n @percentual_gordura = PercentualGordura.new(percentual_gordura_params)\n\n respond_to do |format|\n if @percentual_gordura.save\n format.html { redirect_to @percentual_gordura, notice: 'Percentual gordura was successfully created.' }\n format.json { render action: 'show', stat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /percentual_gorduras POST /percentual_gorduras.json
def create @percentual_gordura = PercentualGordura.new(percentual_gordura_params) respond_to do |format| if @percentual_gordura.save format.html { redirect_to @percentual_gordura, notice: 'Percentual gordura was successfully created.' } format.json { render action: 'show', status: :create...
[ "def create\n @percentage = Percentage.new(percentage_params)\n\n respond_to do |format|\n if @percentage.save\n format.html { redirect_to @percentage, notice: 'Percentage was successfully created.' }\n format.json { render :show, status: :created, location: @percentage }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /percentual_gorduras/1 PATCH/PUT /percentual_gorduras/1.json
def update respond_to do |format| if @percentual_gordura.update(percentual_gordura_params) format.html { redirect_to @percentual_gordura, notice: 'Percentual gordura was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } f...
[ "def update\n @pelicula = Pelicula.find(params[:id])\n @pelicula.update(update_params)\n render json: @pelicula, status: :ok\n end", "def update\n respond_to do |format|\n if @percentage.update(percentage_params)\n format.html { redirect_to @percentage, notice: 'Percentage was successfull...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /percentual_gorduras/1 DELETE /percentual_gorduras/1.json
def destroy @percentual_gordura.destroy respond_to do |format| format.html { redirect_to percentual_gorduras_url } format.json { head :no_content } end end
[ "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @gran_unidad.destroy\n respond_to do |format|\n format.html { redirect_to gran_unidad_index_url }...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /producers POST /producers.json
def create @producer = Pusher.create_producer(params[:producer]) if @producer.valid? render json: @producer, status: :created, location: @producer else render json: @producer.errors, status: :unprocessable_entity end end
[ "def create\n @producer = Producer.new(producer_params)\n\n if @producer.save\n render :show, status: :created, location: @producer\n else\n render json: @producer.errors, status: :unprocessable_entity\n end\n end", "def create\n @producer = Producer.new(producer_params)\n\n respond_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
propose a new item with quantity
def propose_item_with_quantity(name, price, quantity, selling_mode, increment, end_time, description = "", log = true) item = self.propose_item(name,price,selling_mode,increment,end_time, quantity, description,log) item end
[ "def test_create_item_with_quantity\n me = Trader.named(\"Me\", :credits => 100)\n you = Trader.named(\"You\", :credits => 100)\n (my_item = me.propose_item_with_quantity(\"One\", 7, 1, :fixed, nil, nil)).activate\n (your_item = you.propose_item_with_quantity(\"Four\", 11, 4, :fixed, nil, nil)).activate...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
propose a new item
def propose_item(name, price, selling_mode, increment, end_time, quantity = 1, description = "", log = true) if selling_mode == :fixed item = Item.fixed(name, price, self, description) elsif selling_mode == :auction item = Item.auction(name, price, self, increment.to_i, end_time, descrip...
[ "def add_item(new_item)\n item = Item.new(new_item)\n @items.push(item)\n end", "def add_item(new_item)\n item = Item.new(new_item)\n items.push(item)\n end", "def add_item(new_item)\n item = Item.new(new_item)\n @items.push(item)\n end", "def add_item(new_item_desc)\n item ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
sell item matching an offer
def sell_to_offer(offer,item) active = item.active? item.activate if !active #offer.from.credits +=offer.price*offer.quantity purchase = Purchase.create(item,offer.quantity,item.owner,offer.from) purchase.adapt_price_to_offer(offer) purchase.prepare PurchaseActivity.succ...
[ "def sell_item\n play_decision_se\n item_id = @item_list[@index]\n return action_b if item_id == nil\n price = GameData::Item[item_id].price / 2\n PFM::Text.set_item_name(GameData::Item[item_id].exact_name)\n if price > 0\n $game_temp.num_input_variable_id = ::Yuki::Var::Entered...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get a list of all active items of a user
def get_active_items self.items.select { |i| i.active? } #TODO only fixed or only auction end
[ "def fetch_all_active_items\r\n self.items.values.select{|item| item.active}\r\n end", "def fetch_all_active_items\n @items.values.select{|item| item.active}\n end", "def all_active\n all_users = self.all\n all_users.select {|a| a.state == :active}\n end", "def list_authenti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
attach a bought item to the user. If the bought item matches an already owned item, items will be composed, i.e their respective quantities will be added
def attach_item(item) equal_item = self.check_for_equal_item(item.name,item.price,item.description) if equal_item == nil self.items << item item.owner = self item.deactivate else equal_item.quantity += item.quantity equal_item.deactivate item.de...
[ "def buy_item(item)\n self.decrease_credit(item.price)\n item.owner.increase_credit(item.price)\n item.owner.remove_from_user(item)\n item.owner = self\n item.inactivate\n self.items << item\n end", "def buy_item(user, item)\r\n if(self.has_enough_money(item) and user.has_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
releases a certain quantity of an item
def release_quantity_of_item(item, quantity) if self.items.include?(item) item.quantity -= quantity end end
[ "def release_holding_quantity\n product.change_available_quantity -(self.quantity)\n end", "def doPurchase(item)\n item.quantity = Integer(item.quantity)\n\t if item.quantity > 0\n\t item.quantity = item.quantity - 1\n\t puts \"Removed 1 \" + item.format + \" of \" + item.title + \" by \" + item.artis...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
deletes the owner of an item to release it
def release_item(item) if self.items.include?(item) item.owner = nil self.items.delete(item) end end
[ "def release_item(item)\n if self.items.include?(item)\n item.owner = nil\n self.items.delete(item)\n end\n end", "def remove_item(item)\r\n items.delete(item)\r\n item.owner = nil\r\n end", "def remove_from_agent(item)\n item.owner = nil\n end", "def remove_fro...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
confirm a previously prepared purchase
def confirm_purchase(purchase) purchase.confirm end
[ "def confirmPurchase\n EZPaypal::Request.ConfirmPurchase(self[\"TOKEN\"], self[\"PAYERID\"])\n end", "def confirm\r\n self.buyer.attach_item(self.item)\r\n\r\n TradingAuthority.settle_item_purchase(self.seller, self.item, self.quantity)\r\n\r\n self.buyer.delete_pending(self)\r\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
confirms all pending purchases
def confirm_all_pending_purchases self.pending_purchases.each{|purchase| purchase.confirm} end
[ "def confirm\r\n self.buyer.attach_item(self.item)\r\n\r\n TradingAuthority.settle_item_purchase(self.seller, self.item, self.quantity)\r\n\r\n self.buyer.delete_pending(self)\r\n end", "def confirm!\n self.pending = false\n self.save\n self.createDebts\n end", "def con...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add purchase to user's pending purchases list
def add_to_pending(purchase) self.pending_purchases.push(purchase) end
[ "def create\n @purchase = Purchase.create(purchase_params)\n # render text: params.inspect\n @product = Product.find(params[:purchase][:product_id].to_i)\n @product.purchases << @purchase\n current_user.purchases << @purchase\n @new_qty = @product.qty - params[:purchase][:qty].to_i\n @product.u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
delete purchase from user's pending purchases list
def delete_pending(purchase) self.pending_purchases.delete(purchase) end
[ "def destroy\n @purchase_list.destroy\n end", "def decrement_purchases_count\n self.decrement!(:purchases_count)\n\n if self.purchases_count.zero? && self.source == ShoppingSource::Purchase\n self.destroy\n end\n end", "def destroy\n @purchase = @customer.purchases.find(params[:id])\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns true if user is allowed to buy item
def can_buy?(item) item.buyable_by?(self) end
[ "def can_buy?(item)\n item.buyable_by?(self)\n end", "def buy_item?(item)\n return true unless item == nil || item.owner == nil || self.credit < item.price || !item.active\n return false\n end", "def test_user_can_buy_own_item\n user = Trader.named(\"Hans\")\n item = user.propose_item...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns true if user is allowed to activate an item
def can_activate?(item) item.activatable_by?(self) end
[ "def can_activate?(item)\n item.activatable_by?(self)\n end", "def can_user_start?\n item.can_user_start?(user)\n end", "def activated?\n true\n end", "def user_activated?(current_user)\n current_user.activated\n end", "def can_authorize?(user, a)\n user != self and ma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /moneyboxes GET /moneyboxes.json
def index @moneyboxes = Moneybox.all end
[ "def index\n @cashboxes = Cashbox.all\n end", "def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend", "def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend", "def get_coi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /moneyboxes POST /moneyboxes.json
def create @account = Account.new # data = params[:moneybox] @account.name = params[:name] respond_to do |format| if @moneybox.save format.html { redirect_to @moneybox, notice: 'Moneybox was successfully created.' } format.json { render action...
[ "def index\n @moneyboxes = Moneybox.all\n end", "def create\n @postbox = current_user.postboxes.new(postbox_params)\n\n respond_to do |format|\n if @postbox.save\n format.html { redirect_to @postbox, notice: 'Postbox was successfully created.' }\n format.json { render :show, sta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /moneyboxes/1 PATCH/PUT /moneyboxes/1.json
def update respond_to do |format| if @moneybox.update(moneybox_params) format.html { redirect_to @moneybox, notice: 'Moneybox was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } ...
[ "def update\n @box = Box.find(params[:id])\n\n respond_to do |format|\n if @box.update_attributes(params[:box])\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /moneyboxes/1 DELETE /moneyboxes/1.json
def destroy @moneybox.destroy respond_to do |format| format.html { redirect_to moneyboxes_url } format.json { head :no_content } end end
[ "def delete_aos_version_box(args = {}) \n delete(\"/aosversions.json/aosversionbox/#{args[:aosVersionBoxId]}\", args)\nend", "def destroy\n @cashbox.destroy\n respond_to do |format|\n format.html { redirect_to cashbox_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /suggested_ages GET /suggested_ages.json
def index @suggested_ages = SuggestedAge.all end
[ "def gender_ages\n resp = @conn.get 'genderAndAges.json'\n resp.body\n end", "def index\n @luggages = luggages.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @luggages }\n end\n end", "def popular_guesses\n about_user = User.find_by...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /suggested_ages POST /suggested_ages.json
def create @suggested_age = SuggestedAge.new(suggested_age_params) respond_to do |format| if @suggested_age.save format.html { flash[:notice] = 'La edad sugerida se creó satisfactoriamente.' redirect_to suggested_ages_path } format.json { render :show, status:...
[ "def index\n @suggested_ages = SuggestedAge.all\n end", "def update\n respond_to do |format|\n if @suggested_age.update(suggested_age_params)\n format.html { \n flash[:notice] = 'La edad sugerida se actualizó satisfactoriamente.'\n redirect_to suggested_ages_path\n }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /suggested_ages/1 PATCH/PUT /suggested_ages/1.json
def update respond_to do |format| if @suggested_age.update(suggested_age_params) format.html { flash[:notice] = 'La edad sugerida se actualizó satisfactoriamente.' redirect_to suggested_ages_path } format.json { render :show, status: :ok, location: @suggested_age }...
[ "def update\n @luggage = luggages.find(params[:id])\n\n respond_to do |format|\n if @luggage.update_attributes(params[:luggage])\n format.html { redirect_to @luggage, notice: 'Luggage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /suggested_ages/1 DELETE /suggested_ages/1.json
def destroy @suggested_age.destroy respond_to do |format| format.html { flash[:notice] = 'La edad sugerida se eliminó satisfactoriamente.' redirect_to suggested_ages_path } format.json { head :no_content } end end
[ "def destroy\n @gage = Gage.find(params[:id])\n @gage.destroy\n\n respond_to do |format|\n format.html { redirect_to gages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @luggage = luggages.find(params[:id])\n @luggage.destroy\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
See comments for base_url in lib/pact_broker/doc/controllers/app.rb
def ui_base_url request.env["pactbroker.base_url"] || "" end
[ "def base_url\n context[:base_url] || '/'\n end", "def base_url\n context[:base_url] || \"/\"\n end", "def base_url\n context[:base_url] || '/'\n end", "def base_url_path; end", "def base_url\n return url\n end", "def base_url\n \"#{config['protocol']}://#{config['host']...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Ensure we have valid JSON if a JSON body is required OR if a body has been provided
def content_type_is_json_but_invalid_json_provided? content_type_json? && ((request_body_required? || any_request_body?) && invalid_json?) end
[ "def format_body(body, json)\n if json && !body.is_a?(String) && !body.nil?\n body.to_json\n elsif body.is_a?(String) || body.nil?\n body\n else\n raise TaskHelper::Error.new(\n 'body must be a String when json_endpoint is false',\n 'http_request/body-type-error'\n )\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
TODO rename to put_to_create_supported, otherwise it sounds like it's a policy issue Not a Webmachine method. This is used by security policy code to identify whether a PUT to a non existing resource can create a new object.
def put_can_create? false end
[ "def patch_can_create?\n false\n end", "def allow_create?\n allow_create == true\n end", "def has_create_action?\n %i{create create_if_missing}.any? { |action| resource.performed_action?(action) }\n end", "def put?\n request_method == :put\n end", "def can_change?...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
TODO rename to patch_to_create_supported, otherwise it sounds like it's a policy issue Not a Webmachine method. This is used by security policy code to identify whether a PATCH to a non existing resource can create a new object.
def patch_can_create? false end
[ "def can_patch?(document)\n\t\t!next_patch(document).nil?\n\tend", "def put_can_create?\n false\n end", "def allow_create?\n allow_create == true\n end", "def patch?\n method == 'PATCH'\n end", "def patch?\n method == :put || method == :patch\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Repo branches repo String Returns Array of String
def branches(repo) api.branches(repo).index_by(&:name) end
[ "def branches\n git.capturing.branch({:contains => true}, rev).split(\"\\n\").map do |name|\n name.tr('*', '').strip\n end\n end", "def branches(ctx)\n output, status = ctx.capture2e('git', 'branch', '--list', '--format=%(refname:short)')\n ctx.abort(ctx.message('core.git.error.n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Repo default branch repo String Returns String
def default_branch(repo) api.repository(repo).default_branch end
[ "def default_branch\n @client.repo(repo_slug).default_branch\n end", "def repository_default_branch\n repository[:default_branch]\n end", "def default_branch\n @default_branch ||= Nokogiri::HTML(open(branches_url)).at_css('tr.base td.name h3').text.strip.chomp\n rescue OpenURI::HTTPError => ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create repo hooks repo String endpoint String Yields hook_id Integer
def add_hooks(repo, endpoint) hook = api.create_hook( repo, 'web', { url: endpoint, secret: ENV['GITHUB_SECRET_TOKEN'] }, { events: %w(push pull_request), active: true, } ) yield hook.id rescue Octokit::UnprocessableEntity => error raise unl...
[ "def hooks\n @hooks ||= ApiFactory.new 'Repos::Hooks'\n end", "def create_hook!\n hook = client.create_hook(\n full_name,\n 'web',\n {\n url: Constants::HOOK_URL,\n content_type: 'json'\n },\n {\n events: ['release'],\n active: true\n }...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove repo hooks repo String hook_id Integer
def remove_hooks(repo, hook_id) api.remove_hook(repo, hook_id) end
[ "def remove_hook!\n client.remove_hook(full_name, github_hook_id)\n\n self.github_hook_id = nil\n end", "def cleanup_for_removal\n github_client.remove_hook(repository_id, project.webhook_id) if project.webhook_id\n end", "def clear_hooks(repo)\n\t path = Golem::Config.repository_path(repo)\n\t ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
All repos for access_token Returns Array of Hash
def repos api.repos.map(&:to_hash) end
[ "def fetch_all_repos\n access_token = User.first.oauth_token\n url = \"https://api.github.com/orgs/zense/repos?access_token=#{access_token}\"\n all_repos = parse_json(url)\n return all_repos\n end", "def collect_github_repositories(github_token, org_name)\n require 'octokit'\n github = Octokit::Cli...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns organizations where user is admin
def own_organizations api.org_memberships.select { |org| org[:role] == "admin"} end
[ "def organizations_by_user(user)\n @organizations.values.select { |org| org.is_member?(user) }\n end", "def active_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper).flatten\n end", "def admins\n contributors.where(admin: true)\n end", "def active_admins\n a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Computes the total value of all Bitcoin inputs
def total_input @inputs.inject(:+) end
[ "def total_value\n coins.reduce(0) do |sum, (coin_name, quantity)|\n sum + coin_value(coin_name) * quantity\n end\n end", "def calculate_coins_value\n @amount = 0\n\n @coins.each do |coin|\n @amount += COINS[coin.weight]\n end\n end", "def total(input)\n\tinput.inject(0) {|sum...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Computes the total value of all Bitcoin outputs
def total_output @outputs.inject(:+) end
[ "def output_value\n total = 0\n @outputs.each do |output|\n total += output.value\n end\n\n total\n end", "def total_value\n coins.reduce(0) do |sum, (coin_name, quantity)|\n sum + coin_value(coin_name) * quantity\n end\n end", "def calculate_coins_value\n @a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Computes the fees paid for the transaction
def fees total_input - total_output end
[ "def total_fee\n fee + fee2 + fee3 + fee4\n end", "def fees\n @fees ||= {\n \"insurance_fee\" => (commission * ASSURANCE_SHARE).round(0),\n \"assistance_fee\" => (ASSISTANCE_COST * rental.duration).round(0)\n }.tap { |fees| fees[\"drivy_fee\"] = commission - fees.values.inject(:+) }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
rubocop: enable MethodLength, UnderscorePrefixedVariableName Public: Checks whether one word or phrase is an anagram of another. === Parameter(s) +phrase_one+ +String+: A word or phrase. +phrase_two+ +String+: A word or phrase that may be an anagram of +phrase_one+. === Return Value +Boolean+: True if one phrase is an ...
def anagram?(phrase_one, phrase_two) phrase_one.split('').sort == phrase_two.split('').sort end
[ "def anagram_checker\n word_1_split = @input_word_1.split('').sort\n word_2_split = @input_word_2.split('').sort\n shared_letters = antigram_checker(word_1_split, word_2_split)\n\n if shared_letters.length == 0 \n return \"These are antigrams\"\n end\n\n if word_1_split == word_2_split\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Performs frequency analysis on the provided text. === Parameter(s) +text+ +String+: The text to analyze. === Return Value +Hash+: A hash representing the letter frequencies.
def frequency(text) text = text.downcase.gsub(/\s*/, '') chars = text.split('') freqs = Hash[('a'..'z').to_a.zip([0] * 26)] chars.each { |c| freqs[c] += 1 } freqs end
[ "def analyze(text)\n words_in(text).each_cons(@order) { |slice| @frequency[slice] += 1 }\n end", "def letter_frequency(text)\n\n #create blank hash\n character_hash = Hash.new\n character_hash.default = 0\n\n #delete other characters\n text.delete! \"^a-zA-Z\"\n\n #all lower case\n text = text.downcase\n\n #t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Calculates the percentage of text composed of vowels. (Y is not included as a vowel.) === Parameter(s) +text+ +String+: The text to analyze. === Return Value +Float+: The percentage comprising vowels.
def vowels(text) vowels = %w(A E I O U) chars = text.upcase.split('') vowel_count = 0 chars.each { |c| vowel_count += 1 if vowels.include? c } vowel_count.to_f / text.length end
[ "def vowels(text)\n return 0 if @emphasis[:vowels] == 0\n \n percent = text.vowels.length / text.length.to_f\n percent * @emphasis[:vowels]\n end", "def vowels(text)\n percent = text.vowels.length / text.length.to_f\n percent * @emphasis[:vowels]\n end", "def percent2PercentV...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The inline worker to migrate the data report
def report_worker @report_worker ||= DataReportWorker.new end
[ "def worker\n\t\t\t@worker\n\t\tend", "def run\n schedule_data_reports\n end", "def start_worker!\n @engine = ::Ruote::Dashboard.new(\n ::Ruote::Worker.new(\n storage\n )\n )\n @engine.join\n end", "def worker\n @worker\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Offset Polygon Functions Get the orientation of a polygon Pick "bottom left" corner vertex (and adjacent oes) determine orientation matrix of this subpolygon (which is guaranteed to be convex)
def orientation p1, p2, p3 = *convex_sub_polygon det = (p2[0]-p1[0])*(p3[1]-p1[1]) - (p3[0]-p1[0])*(p2[1]-p1[1]) @orientation ||= (det < 0)? 1 : -1 end
[ "def polygonize\n postgis_calculate(:polygonize, self)\n end", "def mill_polygon(mill, cent_x, cent_y, diam, \r\n no_sides, depth=nil, cutter_comp=false)\r\n#############################################\r\n if cutter_comp == true\r\n diam -= mill.bit_radius\r\n end #if\r\n #mill.retract()\r\n side_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a set of 3 points along a convex subsection of the polygon
def convex_sub_polygon subsets = [] vertices.each_cons(3) do |p1, p2, p3| subsets << [p2, [p1, p2, p3]] end subsets.sort.first.last end
[ "def polygon_vertices(sides, size)\n return [CP::Vec2.new(-size, size), CP::Vec2.new(size, size), CP::Vec2.new(size, -size), CP::Vec2.new(-size, -size)]\n end", "def points\n\t\tpolygon.flatten\n\tend", "def convex_hull\n postgis_calculate(:convexhull, self)\n end", "def polygon\n\t\t@path.collect ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
cost is stored in cents
def cost_in_dollars self.cost / 100.to_f end
[ "def actual_cost\n self.cost/1000.to_f\n end", "def calculate_total_cost\n self.total_cost = victuals.sum(\"price\")\n end", "def cost_in_dollars\n return (self.cost.to_f / 100).round(2)\n end", "def cost\n @beverage.cost + 0.15\n end", "def cents\n @cents\n end", "def calc_cost(in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }