query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
POST /alternativas POST /alternativas.json
def create @alternativa = Alternativa.new(alternativa_params) respond_to do |format| if @alternativa.save format.html { redirect_to @alternativa, notice: 'Alternativa was successfully created.' } format.json { render :show, status: :created, location: @alternativa } else for...
[ "def create\n @alternativo = Alternativo.new(alternativo_params)\n\n respond_to do |format|\n if @alternativo.save\n format.html { redirect_to @alternativo, notice: 'Alternativo was successfully created.' }\n format.json { render :show, status: :created, location: @alternativo }\n else...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /alternativas/1 PATCH/PUT /alternativas/1.json
def update respond_to do |format| if @alternativa.update(alternativa_params) format.html { redirect_to @alternativa, notice: 'Alternativa was successfully updated.' } format.json { render :show, status: :ok, location: @alternativa } else format.html { render :edit } forma...
[ "def update\n respond_to do |format|\n if @alternativo.update(alternativo_params)\n format.html { redirect_to @alternativo, notice: 'Alternativo was successfully updated.' }\n format.json { render :show, status: :ok, location: @alternativo }\n else\n format.html { render :edit }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /alternativas/1 DELETE /alternativas/1.json
def destroy @alternativa.destroy respond_to do |format| format.html { redirect_to alternativas_url, notice: 'Alternativa was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @alternativo.destroy\n respond_to do |format|\n format.html { redirect_to alternativos_url, notice: 'Alternativo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pregunta_alternativa.destroy\n respond_to do |format|\n for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
operation a +Roomorama::Client::Operations::Diff+ instance client a +Roomorama::Client+ instance properly configured
def initialize(operation, client) @operation = operation @roomorama_client = client end
[ "def diff(from, to=head)\n scm authentication, :diff2, \"-u -db\", \"//#{p4client}/...#{rev_no(from)}\", \"//#{p4client}/...#{rev_no(to)}\"\n end", "def extract_diff\n diff = Roomorama::Diff.new(original.identifier)\n\n extract_metadata_diff(original, new, diff)\n Workers::Compariso...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
calendar a +Roomorama::Calendar+ instance representing the changes to be applied to a property's availability calendar. Returns a +Result+ that, when successful, wraps the given calendar instance.
def perform(calendar) result = roomorama_client.perform(operation) return result unless result.success? Result.new(calendar) end
[ "def v_availability=(vcalendar)\n @vavailability = vcalendar\n end", "def calendar=(value)\n @calendar = value\n end", "def sync_calendar(property_id, seasons)\n calendar_sync.start(property_id) do\n result = fetch_availabilities(property_id)\n next resul...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build an instance of BrandRegistrationOtpInstance
def get_instance(payload) BrandRegistrationOtpInstance.new(@version, payload, brand_registration_sid: @solution[:brand_registration_sid]) end
[ "def register_device\n Urbanairship.register_device(self.device_token, :alias => self.email)\n end", "def create_bank_token\n @btok = Stripe::Token.create(\n bank_account: { \n country: \"US\",\n currency: \"usd\",\n routing_number: \"110000000\",\n account_number: \"000123...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create a session for the messaging user and try to authenticate them with the password
def auth(m, password) user = Justbot::Models::User.first(:name => m.user.nick) if user.nil? or not user.authenticates? password sleep 1 # prevent timing attacks? m.reply(INVALID_USER_OR_PASSWORD, true) return end s = Justbot::Session.new(user, m.u...
[ "def connect_login(global = true)\n pop2sock = connect(global)\n\n\n if !(user and pass)\n print_status(\"No username and password were supplied, unable to login\")\n return false\n end\n\n print_status(\"Authenticating as #{user} with password #{pass}...\")\n res = raw_send_recv(\"HELO #{u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
start a session and set up a timer to stop it, too
def start_session(s) # callback to remove the session from play end_session_timer = Timer( Justbot::Session::DURATION, :stop_automatically => false, :shots => 1, :threaded => true ) do s.stop! end end_session_t...
[ "def start_timer\n Thread.new do\n loop {\n sleep @session_ttl\n reap_old_sessions\n } \n end \n end", "def start_timer\n Thread.new do\n loop {\n sleep @session_ttl\n reap_expired_sessions\n } \n end \n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Reads file from a folder and returns array of content lines. Strips leading and trailing whitespace, including newlines.
def read_file(file) lines = [] IO.foreach(find(file)) do |line| lines << line.strip unless line.strip == '' end lines end
[ "def read_simple_file file\n arr = []\n File.foreach(file) do |line|\n arr << line.delete(\"\\n\")\n end\n return arr\nend", "def readlines(src_path)\n if File.exist?(src_path) && !File.directory?(src_path)\n File.readlines(src_path)\n else\n []\n end\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /prioridades/1 GET /prioridades/1.json
def show @prioridade = Prioridade.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @prioridade } end end
[ "def index\n @prioridades = Prioridade.all\n end", "def priorities\n Sifter.\n get(\"/api/priorities\").\n parsed_response[\"priorities\"]\n end", "def index\n @prioridads = Prioridad.all\n end", "def new\n @prioridade = Prioridade.new\n\n respond_to do |format|\n format.html ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /prioridades/new GET /prioridades/new.json
def new @prioridade = Prioridade.new respond_to do |format| format.html # new.html.erb format.json { render json: @prioridade } end end
[ "def create\n @prioridade = Prioridade.new(params[:prioridade])\n\n respond_to do |format|\n if @prioridade.save\n format.html { redirect_to @prioridade, notice: 'Prioridade was successfully created.' }\n format.json { render json: @prioridade, status: :created, location: @prioridade }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /prioridades POST /prioridades.json
def create @prioridade = Prioridade.new(params[:prioridade]) respond_to do |format| if @prioridade.save format.html { redirect_to @prioridade, notice: 'Prioridade was successfully created.' } format.json { render json: @prioridade, status: :created, location: @prioridade } else ...
[ "def create\n @prioridade = Prioridade.new(prioridade_params)\n\n respond_to do |format|\n if @prioridade.save\n format.html { redirect_to @prioridade, notice: 'Prioridade was successfully created.' }\n format.json { render :show, status: :created, location: @prioridade }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /prioridades/1 PUT /prioridades/1.json
def update @prioridade = Prioridade.find(params[:id]) respond_to do |format| if @prioridade.update_attributes(params[:prioridade]) format.html { redirect_to @prioridade, notice: 'Prioridade was successfully updated.' } format.json { head :no_content } else format.html { rend...
[ "def update\n respond_to do |format|\n if @prioridade.update(prioridade_params)\n format.html { redirect_to @prioridade, notice: 'Prioridade was successfully updated.' }\n format.json { render :show, status: :ok, location: @prioridade }\n else\n format.html { render :edit }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /prioridades/1 DELETE /prioridades/1.json
def destroy @prioridade = Prioridade.find(params[:id]) @prioridade.destroy respond_to do |format| format.html { redirect_to prioridades_url } format.json { head :no_content } end end
[ "def destroy\n @prioridade.destroy\n respond_to do |format|\n format.html { redirect_to prioridades_url, notice: 'Prioridade was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @prioridade_adocao = PrioridadeAdocao.find(params[:id])\n @prioridad...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a pointer from a certain position.
def get_pointer_at(index) IO.binread(@path, POINTER_SIZE, HEADER_SIZE + POINTER_SIZE * index).unpack("N").first end
[ "def position\n @cursor[0]\n end", "def pointer_to_offset(pointer)\n Bytestream.from_bytes(pointer.reverse).to_i\n end", "def read_pointer(buffer, offset = 0)\n unpack_pointer(buffer[offset, (offset + pointer_size)])\n end", "def _pointer_to_index(pointer)\n return [pointer - offset, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
generate upper quartile value
def upper_quartile return nil if self.empty? sorted_array = self.sort u = (0.25*(3*sorted_array.length)) if (u-u.truncate).is_a?(Integer) return sorted_array[(u-u.truncate)-1] else sample = sorted_array[u.truncate.abs-1] sample1 = sorted_array[(u.truncate.abs)] return sample+...
[ "def upper_quartile\n sorted = self.sort\n midpoint = if sorted.length.even?\n sorted.length/2\n else\n sorted.length/2 + 1\n end\n sorted[midpoint..-1].median\n end", "def lower_quartile\n return nil if self.empty?\n sorted_array = self.sort\n u = 0.25*sorted_array.length + 1\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
generate lower quartile value
def lower_quartile return nil if self.empty? sorted_array = self.sort u = 0.25*sorted_array.length + 1 if (u-u.truncate).is_a?(Integer) return sorted_array[(u-u.truncate)-1] else sample = sorted_array[u.truncate.abs-1] sample1 = sorted_array[(u.truncate.abs)] return sample+((...
[ "def upper_quartile\n return nil if self.empty?\n sorted_array = self.sort\n u = (0.25*(3*sorted_array.length))\n if (u-u.truncate).is_a?(Integer)\n return sorted_array[(u-u.truncate)-1]\n else\n sample = sorted_array[u.truncate.abs-1]\n sample1 = sorted_array[(u.truncate.abs)]\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
tabulate elements and frequencies of an Enumerable return [Hash] return a hash of :element => :freq_count
def count_freq hash = Hash.new(0) self.each do |element| hash[element] +=1 end return hash end
[ "def compute_frequencies(list)\n dict = {}\n list.each do |token|\n unless dict.has_key?(token)\n dict[token] = list.count(token)\n end\n end\n dict\nend", "def count_freq(array)\n array.each_with_object(Hash.new(0)) { |obj, counts| counts[obj] += 1 }\n end", "def count_elements(array)\n cou...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Process for moving any binders
def moveitem errors = [] @binder = Binder.find(params[:id]) if params[:target] != params[:id] src = Mongo.log(current_teacher.id.to_s, __method__.to_s, params[:controller].to_s, @binder.id.to_s, params) @binder.sift_siblings() @inherited = inherit_from(params[:target]) ...
[ "def process_move_route\n command = @move_route.list[@move_route_index]\n if command\n process_move_command(command)\n advance_move_route_index\n end\n end", "def move(*args)\n move = Move.new(*args)\n move.bind(self)\n move.execute\n end", "def process_movement\n # Dele...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Because named_binder_route can accept an id or object, so can this check
def binder_routing_ok?(binder, action) return request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action) end
[ "def has_named_route?(name); end", "def has_named_route?(name)\n @set.named_routes.key?(name)\n end", "def valid_route?(route)\n route.respond_to?(:url_for) && route.respond_to?(:name)\n end", "def routing_params?\n routing_params.any?\n end", "def additive_object...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Function that returns routing given a binder object and action Only works for routes in the format of: /username/portfolio(/root)/title/id/action(s) Binder objects preferred over ids
def named_binder_route(binder, action = "show") if binder.class == Binder retstr = "/#{binder.handle}/portfolio" if binder.parents.length != 1 retstr += "/#{CGI.escape(binder.root.gsub(" ", "-"))}" end retstr += "/#{CGI.escape(binder.title.gsub(" ", "-"))}/#{binder.id}" if action != "show" ...
[ "def binder_routing_ok?(binder, action)\n\n\t\treturn request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action)\n\n\tend", "def action_routes action\n request_methods, route = HTTP__REQUEST_METHODS, action.to_s\n HTTP__REQUEST_METHODS.each do |m|\n regex = /\\A#...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a task that uses the various template wrappers to make a wrapped output file. There is some extra complexity because Dojo and YUI use different final locations.
def templated_build(name, opts={}) short = name.downcase source = File.join("wrappers", short) dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*") target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js" CLEAN.include(opts[:location] ? opts[:location] : target_js) desc "Pack...
[ "def templated_build(name, opts={})\n short = name.downcase\n source = File.join(\"wrappers\", short)\n dependencies = [\"mustache.js\"] + Dir.glob(\"#{source}/*.tpl.*\")\n target_js = opts[:location] ? \"mustache.js\" : \"#{short}.mustache.js\"\n\n CLEAN.include(opts[:location] ? opts[:location] : target_js)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Provides either the passed in HTML, or uses the doc to generate the HTML
def html @html ||= args.dig(:html) || doc.to_html end
[ "def html_markup_rdoc(text); end", "def html_markup_asciidoc(text); end", "def documentation_html\n @documentation_html ||= generate_documentation_html\n end", "def doc\n # get_html beforehand for good output messages\n html = get_html\n print \"Parsing doc...\"\n doc = Nokogiri::H...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /file_list_items GET /file_list_items.xml
def index @file_list = UploadedFileList.find(params[:uploaded_file_list_id]) @file_list_items = @file_list.file_list_items.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @file_list_items } end end
[ "def show\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end", "def index\n @file_lists...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /file_list_items/1 GET /file_list_items/1.xml
def show @file_list = UploadedFileList.find(params[:uploaded_file_list_id]) @file_list_item = @file_list.file_list_items.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @file_list_item } end end
[ "def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end", "def index\n @file_lists = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
start random generator threads and writer thread
def start @running = true gen_threads = start_generators writer = start_writer gen_threads.each(&:join) kill_proccess writer.join end
[ "def start_generators\n threads = []\n 5.times do |idx|\n thread = Thread.new { contious_generation }\n thread[:id] = idx\n threads << thread\n end\n threads\n end", "def start_new_generator_thread generator = @generator\n Jarvis.log.debug \"Starting a new generator thread.\"\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns frequency for last hundred outputs
def get_freq #instantiate with values to ensure consistent ordering freq = { 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0 } #sum up freqencies of each number last_100 = get_last_100 last_100.each do |item| freq[item.to_i] += 1 end # convert to percentage freq.each do |key, val| #di...
[ "def frequency\n growth_rate = 2 ** (1.0 / 12)\n frequency = 440 * (growth_rate ** semitones_from_A4)\n frequency.round(3)\n end", "def get_frequency()\n return(get_cmd('FA;',0.1,0.5,3).gsub(/^FA/,'').gsub(/;$/,'').to_i)\nend", "def frequency\n FREQUENCY\n end", "def mtf_freq; end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
helper method to return last 100 outputs
def get_last_100 last_100 = [] lines = File.readlines('./output.txt').reverse[0...100] lines.each do |line| last_100 << line.chomp.split(", ")[0] end last_100 end
[ "def get_LastPage()\n \t return @outputs[\"LastPage\"]\n \tend", "def last_output\n return @last_output\n end", "def get_last_result( )\n #This is a stub, used for indexing\n end", "def get_last count = 20\n\t\t\t\tModel::ChainBlock.where(:chain_id => @chain_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ensure all queues remain filled until the generators are done generating and and the output queue has been emmptied
def fill_queues while @thread_queues.any?(&:empty?) && (@running || !@output_queue.empty?) el = @output_queue.shift @thread_queues[el[:thread]] << el if el end end
[ "def fill_queue(reps, combos, should_buffer=true)\n puts \"Approximately #{sets_remaining} items found in queue\"\n configurations = reps.map { |r| combos.map { |c| \"#{r}:#{c}\" } }\n .flatten.shuffle\n configurations += configurations[-20..-1] if should_buffer\n configurations....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
uses a minheap to ensure ordered data output before writing to disc
def ensure_order_and_write fill_queues unless @heap.empty? #extract the minimum element from the heap extracted_el = @heap.extract write_to_disk(extracted_el) #add the next element from the same thread to the heap from_queue = extracted_el[:thread] fill_queues next_el ...
[ "def build_minheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tminheapify(i)\n\t\t\ti -= 1\n\t\tend\n\tend", "def build_minheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tn_heapify(@min, i)\n\t\t\ti -= 1\n\t\tend\n\tend", "def asc_heap_sort(arr)\n ordered_arr = []\n #build a heap with the array pas...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generator Methods Creats 5 seperate writer generator threads
def start_generators threads = [] 5.times do |idx| thread = Thread.new { contious_generation } thread[:id] = idx threads << thread end threads end
[ "def create_intelligent_generator(jobs)\n jobs_gen = jobs.lazy.each\n Fiber.new do\n (jobs.length-1).times do\n Fiber.yield jobs_gen.next\n end\n jobs_gen.next\n end\n end", "def generate_workers\n return if self.anthill.queens.count > 1\n worker = self.anthill.workers.new do...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /children/1 DELETE /children/1.json
def destroy @child.destroy respond_to do |format| format.html { redirect_to children_url } format.json { head :no_content } end end
[ "def delete\n @child = Child.find(params[:id])\n @child.delete\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :ok }\n end\n end", "def destroy\n @children = Children.find(params[:id])\n @children.destroy\n\n respond_to do |format|\n fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates a random query
def random_query # Use a fake query # TODO: better random queries 'query ' + (rand*5000).to_i.to_s end
[ "def random_clause\n case connection.adapter_name\n when /mysql/i\n 'RAND()'\n when /sqlite|postgres/i\n 'RANDOM()'\n else\n raise \"Rand::Orders Error: Unknown adapter!\"\n end\n end", "def get_random_quick_queries(types)\n allType...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates a random (category, action) pair for an event
def random_category_action category = (QuickSearch::Engine::APP_CONFIG['searchers'] + ['spelling-suggestion', 'result-types', 'doi-trap', 'more-options']).sample.dasherize # Default action is a click action = 'click' # Typically, serves only happen for these categories if category == 'best-bets' || category ...
[ "def random_action(target)\n \n valid_actions = actions.fetch(target) { Kernel::raise(RuntimeError.new(\"No actions found for object type '#{target}'.\"))}\n\n Kernel::raise(TDMonkeyNoActionsError.new(\"No actions found for object type '#{target}'.\")) if valid_actions.empty?\n\n chosen_action = va...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates a random item for an event, based on the category
def random_item(category) if category == 'best-bets' # Sample a random Best Bet type from a static list ['webofscience', 'googlescholar', 'ieee', 'pubmed', 'morningstar', 'wgsn', 'standards', 'dissertation', 'refworks', 'ibis', 'proquest', 'psychinfo', 'sciencemagazine', 'sciencedirect', 'petition', 'com...
[ "def random_event\n clear\n center \"Random Event\"\n new_line\n display_event(Event.all.sample)\n wait_and_clear\n end", "def get_random_act\n KindAct.all.sample\n end", "def fetch_recipe(meal_category, event)\n @recipies = search_mealdb_category(meal_category) # fetch array of rec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Raise error if no such block
def check_block name raise "No such block: #{name}" unless @source.key? name end
[ "def has_block(blk_hash)\n raise \"Not implemented\"\n end", "def raise_if_block(obj, name, has_block, type)\n return unless has_block\n\n puts \"Type passed in: #{type}\"\n puts \"#{obj.class}##{name} does not accept blocks\"\n\n raise Appom::UnsupportedBlockError\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Save pem encoded content to a file. If the file doesn't exist, it will be created. Otherwise, the file will be overwritten. In both cases the contents will be overwritten atomically so other processes don't see a partially written file.
def save_pem(pem, path, owner: nil, group: nil, mode: 0644) Puppet::FileSystem.replace_file(path, mode) do |f| f.set_encoding('UTF-8') f.write(pem.encode('UTF-8')) end if !Puppet::Util::Platform.windows? && Puppet.features.root? && (owner || group) FileUtils.chown(owner, group, path) ...
[ "def save(file)\n File.open(file, \"w\") do |f|\n f.write(@raw_key.to_pem)\n end\n end", "def write_to(path)\n File.open(path, 'w') { |file| file.write(@certificate.to_pem) }\n end", "def write_to(path)\n File.open(path, 'w') { |file| file.write(@private_key.to_pem) }\n Fil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete a pem encoded object, if it exists.
def delete_pem(path) Puppet::FileSystem.unlink(path) true rescue Errno::ENOENT false end
[ "def delete\n result = exists\n raise RubyAem::Error.new('Certificate not found', result) if result.data == false\n\n @call_params[:cert_alias] = @cert_alias\n @client.call(self.class, __callee__.to_s, @call_params)\n end", "def destroy\n @pem = Pem.find(params[:id])\n @pem....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /academic_informations GET /academic_informations.json
def index @academic_informations = AcademicInformation.all end
[ "def show\r\n @academic_work = AcademicWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end", "def index\n @educations = Education.all\n render json: @educations\n end", "def show\n @an...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /academic_informations/1 PATCH/PUT /academic_informations/1.json
def update respond_to do |format| if @academic_information.update(academic_information_params) format.html { redirect_to @academic_information, notice: 'Academic information was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } ...
[ "def update\n\n respond_to do |format|\n if @manual_laboratory.update_attributes(params[:manual_laboratory])\n format.html { redirect_to manual_subject_laboratories_path, notice: 'Laboratory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /academic_informations/1 DELETE /academic_informations/1.json
def destroy @academic_information.destroy respond_to do |format| format.html { redirect_to academic_informations_url } format.json { head :no_content } end end
[ "def destroy\n @academic.destroy\n\n respond_to do |format|\n format.html { redirect_to academics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @academic_detail.destroy\n respond_to do |format|\n format.html { redirect_to academic_details_url, notice: 'Academ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /repondres GET /repondres.json
def index @repondres = Repondre.all end
[ "def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end", "def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /repondres POST /repondres.json
def create @repondre = Repondre.new(repondre_params) respond_to do |format| if @repondre.save format.html { redirect_to @repondre, notice: 'Repondre was successfully created.' } format.json { render :show, status: :created, location: @repondre } else format.html { render :ne...
[ "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def create\n @repuesto = Repuesto.new(repuesto_param...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /repondres/1 PATCH/PUT /repondres/1.json
def update respond_to do |format| if @repondre.update(repondre_params) format.html { redirect_to @repondre, notice: 'Repondre was successfully updated.' } format.json { render :show, status: :ok, location: @repondre } else format.html { render :edit } format.json { render...
[ "def update\n @receipe = Receipe.find(params[:id])\n\n if @receipe.update(receipe_params)\n head :no_content\n else\n render json: @receipe.errors, status: :unprocessable_entity\n end\n end", "def patch *args\n make_request :patch, *args\n end", "def api_patch(path, data = {})\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /repondres/1 DELETE /repondres/1.json
def destroy @repondre.destroy respond_to do |format| format.html { redirect_to repondres_url, notice: 'Repondre was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @rond = Rond.find(params[:id])\n @rond.destroy\n\n respond_to do |format|\n format.html { redirect_to ronds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Trains the ANN with the training data (Don't forget to call prepare first) The desired error is divided by the normalizaion factor to respect data normalization.
def train(options = {}) options.reverse_merge!({ :max_epochs => 100000, :epochs_between_reports => 500, :desired_error => 0.0001 }) #fann.train_on_data(train_data, 10000, 100, 0.00001) fann.train_on_data(train_data, options[:max_epochs], options[:epochs_between_reports], options[:desired_error] * normalizat...
[ "def train\r\n\t\t@trainer \t= RubyFann::TrainData.new(\r\n\t\t\tinputs: \t\t\ttrainingData, \r\n\t\t\tdesired_outputs: \ttrainingTarget\r\n\t\t)\r\n\t\t@lr\t\t\t= RubyFann::Standard.new(\r\n\t\t\tnum_inputs:\t\t\t@parameters[:num_inputs],\r\n\t\t\thidden_neurons: \t@parameters[:hidden_neurons], \r\n\t\t\tnum_outpu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Reinits the ANN and forgets learned stuff
def reset init_fann end
[ "def reset\n if config.isRecurrent\n @nn.resetRecurrentStates\n else\n puts \"Warning not a recurrent network. This does nothing\"\n end\n end", "def reset_all_nodes\n NeuralNet.find(id).nodes.each do |node|\n unless node.bias\n node.output = 0.0\n node.total_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Runs fann on real inputs
def run(inputs, normalize_outputs = true) outputs = fann.run(inputs) if normalize_outputs return outputs.map { |value| value / normalization_factor } else return outputs end end
[ "def train(options = {})\n options.reverse_merge!({ :max_epochs => 100000, :epochs_between_reports => 500, :desired_error => 0.0001 })\n #fann.train_on_data(train_data, 10000, 100, 0.00001)\n fann.train_on_data(train_data, options[:max_epochs], options[:epochs_between_reports], options[:desired_error] * no...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a train data object
def train_data ::RubyFann::TrainData.new( :inputs => inputs, :desired_outputs=> desired_outputs) end
[ "def create_train(train_type)\n Train.new(\n @train_types.find do |type|\n type.to_s.eql? \"#{train_type.fetch('type')}T\"\n end\n )\n end", "def create_learners dataset\n \n end", "def train\r\n\t\t#Do data splitting\r\n\t\tdata = trainingData\r\n\t\ttrainData\t= data.se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /post_parts GET /post_parts.json
def index @post_parts = PostPart.all end
[ "def index\n @parts = Part.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @parts }\n end\n end", "def parts\n @audio_file = AudioFile.find(params[:id])\n @parts = @audio_file.parts\n\n respond_to do |format|\n format.html # parts.html.e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /post_parts POST /post_parts.json
def create @post_part = PostPart.new(post_part_params) respond_to do |format| if @post_part.save format.html { redirect_to @post_part, notice: 'Post part was successfully created.' } format.json { render :show, status: :created, location: @post_part } else format.html { rend...
[ "def create\n @part = Part.new(params[:part])\n\n if @part.save\n render json: @part, status: :created, location: @part\n else\n render json: @part.errors, status: :unprocessable_entity\n end\n end", "def create\n @part = Part.new(params[:part])\n\n respond_to do |format|\n if @p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /post_parts/1 PATCH/PUT /post_parts/1.json
def update respond_to do |format| if @post_part.update(post_part_params) format.html { redirect_to @post_part, notice: 'Post part was successfully updated.' } format.json { render :show, status: :ok, location: @post_part } else format.html { render :edit } format.json { r...
[ "def update\n @part = Part.find(params[:id])\n\n if @part.update(params[:part])\n head :no_content\n else\n render json: @part.errors, status: :unprocessable_entity\n end\n end", "def update\n @part = Part.find(params[:id])\n\n respond_to do |format|\n if @part.update_attributes(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /post_parts/1 DELETE /post_parts/1.json
def destroy @post_part.destroy respond_to do |format| format.html { redirect_to post_parts_url, notice: 'Post part was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @part.destroy\n respond_to do |format|\n format.html { redirect_to parts_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @bodypart = Bodypart.find(params[:id])\r\n @bodypart.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /pricing_sections or /pricing_sections.json
def index @pricing_sections = PricingSection.all end
[ "def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end", "def sell_shop_sections (params={})\r\n url = api_url \"/sell/shop/sec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /pricing_sections or /pricing_sections.json
def create @pricing_section = PricingSection.new(pricing_section_params) respond_to do |format| if @pricing_section.save format.html { redirect_to @pricing_section, notice: "Pricing section was successfully created." } format.json { render :show, status: :created, location: @pricing_secti...
[ "def update\n respond_to do |format|\n if @pricing_section.update(pricing_section_params)\n format.html { redirect_to @pricing_section, notice: \"Pricing section was successfully updated.\" }\n format.json { render :show, status: :ok, location: @pricing_section }\n else\n format.ht...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /pricing_sections/1 or /pricing_sections/1.json
def update respond_to do |format| if @pricing_section.update(pricing_section_params) format.html { redirect_to @pricing_section, notice: "Pricing section was successfully updated." } format.json { render :show, status: :ok, location: @pricing_section } else format.html { render :...
[ "def update\n @miscellaneous_pricing = MiscellaneousPricing.find(params[:id])\n\n if @miscellaneous_pricing.update(miscellaneous_pricing_params)\n head :no_content\n else\n render json: @miscellaneous_pricing.errors, status: :unprocessable_entity\n end\n end", "def update(options: {}, **dat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /pricing_sections/1 or /pricing_sections/1.json
def destroy @pricing_section.destroy respond_to do |format| format.html { redirect_to pricing_sections_url, notice: "Pricing section was successfully destroyed." } format.json { head :no_content } end end
[ "def destroy\n @page_section = Admin::PageSection.find(params[:id])\n @page_section.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_page_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section = Section.find(params[:id])\n @section....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
projects:delete PROJECTNAME Delete the Mortar project PROJECTNAME.
def delete name = shift_argument unless name error("Usage: mortar projects:delete PROJECTNAME\nMust specify PROJECTNAME.") end validate_arguments! projects = api.get_projects().body['projects'] project_id = nil if projects.any? projects.each do |project| if project['name'...
[ "def delete_project(name)\n @projects.delete(name)\n end", "def delete project_id\n service.delete_project project_id\n true\n end", "def delete(projects)\n project_ids = projects.collect { |project| project.id } \n args = {ids: project_ids.to_json}\n retu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
projects:create PROJECTNAME Used when you want to start a new Mortar project using Mortar generated code. embedded Create a Mortar project that is not its own git repo. Your code will still be synced with a git repo in the cloud. public Register a public project, which can be viewed and forked by anyone.
def create name = shift_argument unless name error("Usage: mortar projects:create PROJECTNAME\nMust specify PROJECTNAME") end args = [name,] is_public = false if options[:public] is_public= true ask_public(is_public) end validate_project_name(name) project_id = r...
[ "def create\n name = shift_argument\n unless name\n error(\"Usage: mortar projects:create PROJECT\\nMust specify PROJECT.\")\n end\n validate_arguments!\n \n unless git.has_dot_git?\n error(\"Can only create a mortar project for an existing git project. Please run:\\n\\ngit init\\ngit a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
projects:register PROJECTNAME Used when you want to start a new Mortar project using your existing code in the current directory. embedded Register code that is not its own git repo as a Mortar project. Your code will still be synced with a git repo in the cloud. public Register a public project, which can be viewed an...
def register name = shift_argument unless name error("Usage: mortar projects:register PROJECT\nMust specify PROJECT.") end validate_arguments! ask_public(options[:public]) #nil is non existant project_id because it hasn't been posted yet register_do(name, options[:public], options[:emb...
[ "def register_project(project, dictionary, version, locale, syn_list)\n select_project.select project\n edit_project.click\n add_icon.click\n select_dictionary_name.click\n select_from_dropdown(:dictionary_name, dictionary)\n select_dictionary_version.click\n select_from_dropdown(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
projects:set_remote PROJECTNAME Used after you checkout code for an existing Mortar project from a nonMortar git repository. Adds a remote to your local git repository to the Mortar git repository. For example if a coworker creates a Mortar project from an internal repository you would clone the internal repository and...
def set_remote project_name = shift_argument unless project_name error("Usage: mortar projects:set_remote PROJECT\nMust specify PROJECT.") end unless options[:embedded] unless git.has_dot_git? error("Can only set the remote for an existing git project. Please run:\n\ngit init\ngit...
[ "def set_remote\n project_name = shift_argument\n\n unless project_name\n error(\"Usage: mortar projects:set_remote PROJECT\\nMust specify PROJECT.\")\n end\n\n unless git.has_dot_git?\n error(\"Can only set the remote for an existing git project. Please run:\\n\\ngit init\\ngit add .\\ngit c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
projects:clone PROJECTNAME Used when you want to clone an existing Mortar project into the current directory.
def clone name = shift_argument unless name error("Usage: mortar projects:clone PROJECT\nMust specify PROJECT.") end validate_arguments! projects = api.get_projects().body["projects"] project = projects.find{|p| p['name'] == name} unless project error("No project named: #{name} e...
[ "def git_clone(project)\n git 'clone', '--quiet', address(project)\n end", "def clone_new_repositories\n clone_repositories.each do |name, clone_url|\n if File.exist?(name)\n puts(\"Skipping existing project '%s'\" % name) unless quiet\n next \n end\n execute_cmd \"git ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
projects:fork GIT_URL PROJECT_NAME Used when you want to fork an existing Git repository into your own Mortar project. public Register a public project, which can be viewed and forked by anyone.
def fork git_url = shift_argument name = shift_argument unless git_url and name error("Usage: mortar projects:fork GIT_URL PROJECT\nMust specify GIT_URL and PROJECT.") end validate_arguments! validate_project_name(name) if git.has_dot_git? begin error("Currently in git r...
[ "def add_forked_from_project(project, forked_from_id, options = {}) \n post \"#{Project.path(project)}/fork/#{forked_from_id}\", options\n end", "def fork\n @forked = Curricula.find_by_id(params[:id])\n\n @fork = Curricula.new\n @fork.attributes = { cur_name: @forked.cur_name, cur_description...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints the best plan for the selected features. Shows the total price of the plan selected.
def to_s if match? "Best Plan: " + @plans_name + "for $" + '%.2f' % [(@cost * 100).round / 100.0] else "No matching plan for your features" end end
[ "def best_plan()\n # best_plan = nil\n # lowest_cost = 9999999999\n#\n # each_plan do |plan|\n # cost = plan.cost\n # if (cost < lowest_cost)\n # lowest_cost = cost\n # best_plan = plan\n # end\n # end\n best_plan = @complete_plans....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
is there at least one matching plan(s) for requested features
def match? @plans and @plans.size > 0 end
[ "def has_features?\n return ! features.nil?\n end", "def has_plans?; not [@program].any?{|e|e.nil?} and @groups.all?{|grp| grp.has_plan?}; end", "def has_feature?(*features)\n has?(:feature_f, *features)\n end", "def cheaper?(plan)\n cost = plan.inject(0) {|sum,plan| sum + plan['cost']}\n fe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns an array of all combinations of plans where the selected feature exist Example F1 selected feature existing in following plans [[P1],[P1,P2]...]
def matching_combinations(plans, selected_features) a = {} # array of plan indexed by feature # Example F1 => [P1, P2], F2 => [P2, P3] ... plans.each do |plan| plan['features'].each do |f| a[f] ||= [] a[f] << plan end end # Returns an array of all combinatio...
[ "def feature_value_combinations(feat_inst_list)\n values = values_by_feature(feat_inst_list)\n if values.empty?\n [[]]\n else\n # Compute the cartesian product of the lists of possible values\n # of the features.\n values[0].product(*values[1..-1])\n end\n end", "def allowed_combi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
set lowest plan and compute global name/feature_count/cost
def optimal_plan=(plans) @plans = plans @cost = 0.00 @plans_name = "" @features_count = 0 @plans.each do |plan| @cost += plan['cost'] @plans_name += plan['name'] + " " @features_count += plan['features'].size end end
[ "def best_plan()\n # best_plan = nil\n # lowest_cost = 9999999999\n#\n # each_plan do |plan|\n # cost = plan.cost\n # if (cost < lowest_cost)\n # lowest_cost = cost\n # best_plan = plan\n # end\n # end\n best_plan = @complete_plans....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is the matching plan cheaper? We make two assumptions here: 1. If cost are equal, return the plan with more features as cheaper plan 2. If cost are equal, feature count is same and feature belongs to both plan, the first plan retrieved is selected. This behavior can be easily changed. Based on business need both plan c...
def cheaper?(plan) cost = plan.inject(0) {|sum,plan| sum + plan['cost']} features_count = plan.inject(0) {|sum,plan| sum + plan['features'].size} @cost.nil? or cost < @cost or (cost == @cost && features_count > @features_count) end
[ "def best_plan()\n # best_plan = nil\n # lowest_cost = 9999999999\n#\n # each_plan do |plan|\n # cost = plan.cost\n # if (cost < lowest_cost)\n # lowest_cost = cost\n # best_plan = plan\n # end\n # end\n best_plan = @complete_plans....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
adds the necessary javascript include tags, stylesheet tags, and load event with necessary javascript to activate wym editor(s)
def wym_editor_initialize(*dom_ids) editor_ids = (@wym_editor_ids || []) + wym_extract_dom_ids(*dom_ids) output = [] output << stylesheet_link_tag('/wymeditor/wymeditor/skins/default/screen') output << javascript_include_tag('/wymeditor/jquery/jquery') output << javascript_include_tag('/wymeditor/wy...
[ "def include_javascript_for_catalog_edit\n # This _would_ include the fluid infusion javascripts, but we don't want them\n # javascript_includes << infusion_javascripts(:default_no_jquery, :extras=>[:inline_editor_integrations], :debug=>true, :render_html=>false)\n \n javascript_includes << [\"jquery.je...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the token value for the current session and returns it in a masked form that's safe to send to the client. See section 3.4 of "BREACH: Reviving the CRIME attack".
def masked_authenticity_token(session) one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN_LENGTH) encrypted_csrf_token = xor_byte_strings(one_time_pad, real_csrf_token(session)) masked_token = one_time_pad + encrypted_csrf_token Base64.strict_encode64(masked_token) end
[ "def masked_authenticity_token(session)\n one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN_LENGTH)\n encrypted_csrf_token = xor_byte_strings(one_time_pad, real_csrf_token(session))\n masked_token = one_time_pad + encrypted_csrf_token\n Base64.strict_encode64(masked_tok...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks the client's masked token to see if it matches the session token. Essentially the inverse of +masked_authenticity_token+.
def valid_authenticity_token?(session, encoded_masked_token) return false if encoded_masked_token.nil? || encoded_masked_token.empty? masked_token = Base64.strict_decode64(encoded_masked_token) return false if masked_token.length != AUTHENTICITY_TOKEN_LENGTH * 2 # Split the token into...
[ "def valid_authenticity_token?(session, encoded_masked_token); end", "def valid_authenticity_token?(session, encoded_masked_token)\n return false if encoded_masked_token.nil? || encoded_masked_token.empty?\n\n masked_token = Base64.strict_decode64(encoded_masked_token)\n\n # See if it's actua...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Destroy all records and stop Daemon script on logout
def destroy system "ruby streaming_script.rb stop" session[:username] = nil User.all.each do |user| user.destroy end User.reset_pk_sequence Tweet.all.each do |tweet| tweet.destroy end Tweet.reset_pk_sequence reset_session redirect_to root_path end
[ "def stop_daemon\n if self.running?\n lc = RMB::ListenerClient.new(daemon_properties)\n lc.stop\n delete_old_user\n end\n end", "def daemon_clean_up\n TaskQueue.where(id: $daemon[:heartbeat_task_queue_id]).destroy_all\n File.delete($daemon[:pid_file])\nend", "def destroy\n stop\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /restaurants/1/tables GET /restaurants/1/tables.json
def index @tables = @restaurant.tables end
[ "def show\n @restaurant_table = RestaurantTable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant_table }\n end\n end", "def index\n @restaurant_tables = RestaurantTable.all\n end", "def index\n @restaurants = Restauran...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /restaurants//tables POST /restaurants/1/tables.json
def create @table = @restaurant.tables.build(table_params) respond_to do |format| if @table.save format.html { redirect_to restaurant_tables_path(@restaurant), notice: 'Table was successfully created.' } format.json { render :show, status: :created, location: @table } else f...
[ "def create\n @dinner_table = @restaurant.dinner_tables.new(dinner_table_params)\n\n respond_to do |format|\n if @dinner_table.save\n format.html { redirect_to @dinner_table, notice: 'Dinner table was successfully created.' }\n format.json { render action: 'show', status: :created, location...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /restaurants/1/tables/1 PATCH/PUT /restaurants/1/tables/1.json
def update respond_to do |format| if @table.update(table_params) format.html { redirect_to restaurant_tables_path(@restaurant), notice: 'Table was successfully updated.' } format.json { render :show, status: :ok, location: @table } else format.html { render :edit } format...
[ "def update\n @restaurant_table = RestaurantTable.find(params[:id])\n\n respond_to do |format|\n if @restaurant_table.update_attributes(params[:restaurant_table])\n format.html { redirect_to @restaurant_table, notice: 'Restaurant table was successfully updated.' }\n format.json { head :no_c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Stamps all files matching DIR_PATTERNS and the +includepaths+ option unless they have already been stamped
def run!(options={}) options[:exclude_paths] ||= [] options[:include_paths].each do |path| DIR_PATTERS << path end if options[:include_paths] DIR_PATTERS.each do |main_dir| Dir.glob(main_dir).each do |path| # skip to the next file if this file matches exclude_paths next ...
[ "def merge_directives(target, dirs); end", "def files_scheduled_for_add\n Dir[temp_plugin_name+\"/**/*\"].collect {|fn| fn.gsub(temp_plugin_name, '.')} -\n Dir[plugin.name+\"/**/*\"].collect{|fn| fn.gsub(plugin.name, '.')}\n end", "def timestamp_files\n all_files.each {|path| set_file_timest...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Read a CSV string into an array of CSVEntries.
def read(string) lines = string.split("\n") header = lines[0] attributes = header.split(',').map! { |v| v.to_sym } # Struct.new('CSVEntry', *attributes) ret = [] lines.drop(1).each do |line| values = line.split(',') opts = {} values.each_with_index do |val, idx| opts[at...
[ "def parse_csv(csv)\n # Return a list of rows\n # First row is header data\n data = []\n lines = csv.split(\"\\n\")\n\n for l in lines\n data.append(l.split(','))\n end\n\n return data\n end", "def csv_to_array(csv_name)\n\tCSV.read(csv_name)\nend", "def init_rows(csv_str)\n array ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Try ping three times. Return true if at least one time responds. def ping3
def update_ping result = false 3.times do command = "ping -c 1 -W #{PING_MIN_INTERVAL} #{@hostname} 2> /dev/null 1> /dev/null" if system(command) result = true break end end write_cache("ping", result) end
[ "def ping target, attempts = 5\n try = 0\n while try < attempts\n result = exec(Beaker::Command.new(\"ping -c 1 #{target}\"), :accept_all_exit_codes => true)\n return true if result.exit_code == 0\n\n try += 1\n end\n result.exit_code == 0\n end", "def ping target, attempts = 5\n tr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /districts POST /districts.json
def create @district = District.new(district_params) respond_to do |format| if @district.save format.html { redirect_to @district, notice: 'District was successfully created.' } format.json { render :show, status: :created, location: @district } else format.html { render :ne...
[ "def create\n @district = District.new(params[:district])\n\n respond_to do |format|\n if @district.save\n format.html { redirect_to @district, :notice => 'District was successfully created.' }\n format.json { render :json => @district, :status => :created, :location => @district }\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /districts/1 PATCH/PUT /districts/1.json
def update respond_to do |format| if @district.update(district_params) format.html { redirect_to @district, notice: 'District was successfully updated.' } format.json { render :show, status: :ok, location: @district } else format.html { render :edit } format.json { render...
[ "def update\n @district = District.find(params[:id])\n\n respond_to do |format|\n if @district.update_attributes(params[:district])\n format.html { redirect_to @district, notice: 'District was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
fetches the product referenced by the id.
def fetch_product @product = Product.visible.find(params[:id]) if params[:id] end
[ "def find_by_id(id)\n get_product_by_id(id)\n end", "def get_product(id)\n prod = Product.where(:id => id)\n end", "def get_product_by_id(product_id)\n return Product.find(product_id)\n end", "def getProduct(id)\n @products.find {|prod| prod.productId.to_i == id.to_i}\n end", "def pr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
creates a cookie that will store the products this user viewed.
def store_visited_product id = @product.id unless cookies[:user_visited_products] cookies[:user_visited_products] = id else cookies_array = cookies[:user_visited_products].to_s.split(',') if cookies_array.size < 20 cookies_array << id unless cookies_array.include?("#{id}") ...
[ "def cookies\n @_cookies ||= {}\n @_cookies[@_current_user] ||= []\n end", "def cookie\n @cookie ||= Coca::AuthCookie.new(cookies, scope)\n end", "def install_offers_cookie \n if @lead_was_created\n if tracking_cookie.user.blank? && resource.effective_user\n tracking_cookie.upd...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a node to the project graph.
def add_node(node) @nodes.add node end
[ "def add_node node\n GraphNode.new(node)\n @nodes.push(node)\n end", "def add_node(node)\r\n @nodes << node\r\n end", "def add(node)\r\n @nodes << node\r\n end", "def add_node( node )\n\t\tnode.id = node.object_id\n\t\t@nodes[ node.object_id ] = node\n\tend", "def add_node(node)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add multiple nodes at once.
def add_nodes(*nodes) @nodes.merge nodes end
[ "def add(*nodes)\n @nodes.push(*nodes)\n end", "def add_nodes(*args)\n args.each{|n| add_node(n)}\n args\n end", "def add_nodes(node_array)\n @nodes += node_array\n end", "def add_nodes( *nodes )\n\t\t\t@current_branch.push( *nodes )\n\t\t\t@current_node = @current_branch.last\n\t\t\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set maximum project duration by adding an edge with negative duration as weight.
def max_duration=(duration) nodes = @nodes.to_a add_edge(nodes.last, nodes.first, -duration) duration end
[ "def duration= duration\n super\n @duration = -@duration unless @duration.rest? # force to be a rest\n end", "def maximum_duration=(value)\n @maximum_duration = value\n end", "def max_duration=(max_duration)\n max_duration = nil unless max_duration.present?\n s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
inserting a new row into the database contact
def save if self.id self.update else sql = <<-SQL INSERT INTO contacts (name, phone_number, address, email) VALUES (?, ?, ?, ?) SQL DB[:conn].execute(sql, name, phone_number, address, email) @id = DB[:conn].execute("SELECT last_insert_rowid() FROM contacts"...
[ "def insert_contact(contact)\n method = @mirror.contacts.insert\n\n if contact.kind_of?(Hash)\n contact = method.request_schema.new(contact)\n end\n\n @client.execute!(\n api_method: method,\n body_object: contact\n ).data\n end", "def post_contact\n\t\tcontact = Contact.new\n\t\tco...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
updating the database row mapped to the Contact instance.
def update sql = "UPDATE contacts SET name = ?, phone_number = ?, address = ?, email = ? WHERE id = ?" DB[:conn].execute(sql, name, phone_number, address, email, id) end
[ "def update_contact(id, data)\n update(\"contacts\", id, data).first\n end", "def contact_update(handle, fields)\n # fields = contact_prepare(fields)\n fields[:handle] = handle\n query 'contact-modify', fields\n end", "def contact_update(handle, fields)\n fields = contact_prepare(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A URI describing where we are listening
def listener_uri(addr = datastore['ReverseListenerBindAddress']) addr = datastore['LHOST'] if addr.nil? || addr.empty? uri_host = Rex::Socket.is_ipv6?(addr) ? "[#{addr}]" : addr "tcp://#{uri_host}:#{bind_port}" end
[ "def uri(location, options={})\n ops = resolve_defaults(options)\n @listener.register(location, ops[:handler], ops[:in_front])\n end", "def listener_uri(addr=datastore['ReverseListenerBindAddress'])\n addr = datastore['LHOST'] if addr.nil? || addr.empty?\n uri_host = Rex::Socket.is_ipv6?(addr) ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Save record that user visited this country
def visit_country self.user_countries.create!(user_id: self.visitor_id) end
[ "def visited\n self.visited_at = Time.now\n self.save!\n end", "def visited\n set_cors_headers\n geo = check_geo(request.remote_ip)\n location = geo['city']+', '+geo['region_code']\n referer = URI(request.referer)\n if !params[:visitor]\n params[:visitor] = \"Anon User\"\n end\n @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /enrolled_scores/1 GET /enrolled_scores/1.json
def show @enrolled_score = EnrolledScore.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render :json => @enrolled_score } end end
[ "def index\n @scores = @user.scores.all\n\n render json: @scores\n end", "def new\n @enrolled_score = EnrolledScore.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @enrolled_score }\n end\n end", "def index\n @games_le...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /enrolled_scores/new GET /enrolled_scores/new.json
def new @enrolled_score = EnrolledScore.new respond_to do |format| format.html # new.html.erb format.json { render :json => @enrolled_score } end end
[ "def new\n @score = Score.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @score }\n end\n end", "def new\n @enrolled = Enrolled.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @enrol...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /enrolled_scores POST /enrolled_scores.json
def create @enrolled_score = EnrolledScore.new(params[:enrolled_score]) respond_to do |format| if @enrolled_score.save format.html { redirect_to @enrolled_score, :notice => t('selecao_admin.flash_messages.successfully_created', :model => @enrolled_score.class.model_name.human) } ...
[ "def create\n @games_leaderboards_score = Games::Leaderboards::Score.new(games_leaderboards_score_params)\n\n if @games_leaderboards_score.save\n render json: @games_leaderboards_score, status: :created, location: @games_leaderboards_score\n else\n render json: @games_leaderboards_score.errors, s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /enrolled_scores/1 PUT /enrolled_scores/1.json
def update @enrolled_score = EnrolledScore.find(params[:id]) respond_to do |format| if @enrolled_score.update_attributes(params[:enrolled_score]) format.html { redirect_to @enrolled_score, :notice => t('selecao_admin.flash_messages.successfully_updated', :model => @enrolled_score.class....
[ "def update\n @score = Score.find(params[:id])\n\n respond_to do |format|\n if @score.update_attributes(params[:score])\n format.json { head :ok }\n else\n format.json { render :json => @score.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @g...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /enrolled_scores/1 DELETE /enrolled_scores/1.json
def destroy @enrolled_score = EnrolledScore.find(params[:id]) @enrolled_score.destroy respond_to do |format| format.html { redirect_to enrolled_scores_url } format.json { head :no_content } end end
[ "def destroy\n @score.destroy\n respond_to do |format|\n format.html { redirect_to scores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_line_score.destroy\n respond_to do |format|\n format.html { redirect_to test_line_scores_url }\n format.json { h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the offset that was given in the request
def offset @offset ||= raw_response['response']['start'] end
[ "def get_offset\n @offset\n end", "def query_offset\n if params[:offset]\n params[:offset].to_i # defaults to 0\n else\n nil\n end\n end", "def offset\n sanitize search_params['offset']\n end", "def find_offset\n return self.offset if self.respond_to? :offse...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper for displaying a given field (first tries the highlight, then the stored value)
def display_for(doc, field) highlights_for(doc['unique_id'], field) || doc[field] end
[ "def highlight(field_name)\n highlights(field_name).first\n end", "def render_field(label, value)\n render_field_content(label, (h value))\n end", "def display_field\n current_field_values_with_field_type_id(field_types.first.id).first.try(:value) || 'no display field available'\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the highlights for a given id for a given field
def highlights_for(unique_id, field) raw_response['highlighting'] ||= {} raw_response['highlighting'][unique_id] ||= {} raw_response['highlighting'][unique_id][field] end
[ "def highlights(field_name = nil)\n if field_name.nil?\n highlights_cache.values.flatten \n else\n highlights_cache[field_name.to_sym]\n end || []\n end", "def highlight(field_name)\n highlights(field_name).first\n end", "def add_highlight(fields=[], optio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns all of the facet queries
def facet_queries @facet_queries ||= facets['facet_queries'] || {} end
[ "def query_facets\n @query.query_facets\n end", "def facet_queries\n @facet_queries ||= facet_counts['facet_queries'] || {}\n end", "def facets\n self.facet_list.any? ? SearchFacet.where(:identifier.in => self.facet_list) : SearchFacet.visible\n end", "def active_facets\n return [] if o...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the count for the given field/value pair
def facet_field_count(field, value) facet_fields_by_hash[field.to_s][value.to_s] if facet_fields_by_hash[field.to_s] end
[ "def count(field, value)\n return generate_hash(send_request('count %s \"%s\"' % [field, value]))\n end", "def value_count(hash, value)\n count = 0\n hash.each { |elem| count += 1 if elem[1]==value }\n count\nend", "def hash_count(hash, value)\n\nend", "def field_count\n end", "def tally(fie...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the counts for a given facet_query_name
def facet_query_count_by_key(facet_query_key) facet_queries[facet_query_key.to_s] end
[ "def count(query)\n count_results(make_query(query))\n end", "def count(query)\n count_results(make_query(query)) \n end", "def count(query = \"\", facets: {}, **params)\n params[:query] = query\n converted_params = turn_into_query(params)\n facets = turn_into_facets(facets)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }