query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
GET /reunion_participantes GET /reunion_participantes.json
def index @reunion_participantes = ReunionParticipante.all end
[ "def getParticipantes\r\n @rifa = Rifa.find(rifa_params)\r\n if @rifa.limit.nil?\r\n if ParticipanteRifa.all.empty?\r\n @participantes = Participante.all\r\n else\r\n @participantes = Participante.where('id not in (?)', ParticipanteRifa.all.map(&:participante_id) )\r\n end\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /reunion_participantes/1 DELETE /reunion_participantes/1.json
def destroy @reunion_participante.destroy respond_to do |format| format.html { redirect_to reunion_participantes_url, notice: 'Reunion participante was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @participant = Participant__c.find(params[:id])\n @participant.delete\n\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :ok }\n end\n end", "def destroy\n @reunion = Reunion.find(params[:id])\n @reunion.destroy\n\n respond...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Notifies everyone who has commented on the video as well as the video owner that someone has commented on that video
def notify_all_users_in_the_conversation(current_user, video, video_owner) # send e-mail to the video owner unless the person commented on their own video # or their notification settings say not to unless (video.user_id == self.user_id) # for whatever reason, delayed_job won't send the email unless y...
[ "def notify_commenters_of_edit\n action = \"edited a proof that you have commented on for\"\n @commenters = (@proof.comments.map { |c| c.user }).uniq \n (@commenters - (@editors + [@actor, @proof.user].uniq)).each do |commenter|\n Notification.create(recipient: commenter, actor...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
p sum_of_range([1, 4]) => 10 p sum_of_range([4, 1]) => 10
def sum_of_range(arr) arr[0] < arr[1] ? (arr[0]..arr[1]).reduce(:+) : arr[0].downto(arr[1]).reduce(:+) end
[ "def sum_of_range(range)\n if range[0] == range[1]\n range[0]\n elsif range[0] < range[1]\n (range[0]..range[1]).reduce(:+)\n else\n (range[1]..range[0]).reduce(:+)\n end\nend", "def sum_of_range(range)\n range.sort! # easiest way to max sure it's in min max order\n # range = [range[1], range[0]] i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
if ( str.length() ==0 ) puts s; return end ch = str[0,1] ros = str[1,str.length()1] print_Subsequence(ros,s) print_Subsequence(ros,s+ch) end print_Subsequence("abc","")
def print_Subsequence(str) if(str.length() == 0 ) base = []; base.push(".") return base; end ch = str[0,1]; ros = str[1,str.length()-1] recResult = print_Subsequence(ros) res=[] for i in (0..recResult.length-1) res.push(recResult[i]) end for i in (0..r...
[ "def substrings(string)\n substrings = []\n string.length.times do\n 1.upto(string.length) do |letters|\n substrings << string[0, letters]\n end\n string = string[1..-1]\n end\n p substrings\nend", "def substrings2(str)\n result = []\n counter = 0\n p str\n loop do\n break if counter == s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create new status change record on status change
def check_status_change if self.status_id != @current_status sc = StatusChange.new sc.submission_id = self.id sc.status_id = self.status_id sc.changed_at = @current_time sc.comments = status_comments sc.save #give sub a global id if approved ...
[ "def check_status_change\n if self.status_id != @current_status\n sc = StatusChange.new\n sc.submission_id = self.id\n sc.status_id = self.status_id\n sc.changed_at = @current_time \n sc.comments = status_comments\n sc.save\n #give sub a global id if approved\n if self.sta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
mainmenu(companyname,user,client_hash) Returns option selected by user
def main_menu(companyname="Unknown",username="Unknown",client_hash) prompt = TTY::Prompt.new(symbols: {marker: ">"}) input = "" while input != "Exit" system('clear') Debug.show "Debug ON\ninput: #{input} | company_name: #{companyname} | username: #{username}" menuoptions = ["Add new ...
[ "def client_menu prompt = nil, clients = Rumai.clients\n choices = []\n\n clients.each_with_index do |c, i|\n choices << \"%d. [%s] %s\" % [i, c[:tags].read, c[:label].read.downcase]\n end\n\n if target = key_menu(choices, prompt)\n clients[target.scan(/\\d+/).first.to_i]\n end\nend", "def menu\n ([[0...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add_new_client(client_hash) prompts for new client information, adds to client_hash, then returns the updated hash. Also updates the clients.json file
def add_new_client(client_hash) prompt = TTY::Prompt.new(symbols: {marker: ">"}) totalclients = client_hash[:clients].length system('clear') Debug.show("Debug ON") puts "Create new client: \n\n\n" name = prompt.ask("Name:") do |q| q.validate(/^[\w ]+$/) q.messages[:valid?] = "Inv...
[ "def add_client\n name = get_answer_to(\"What is the client\\'s name?\")\n age = get_answer_to(\"What is the client\\'s age?\")\n new_client = Clients.new(name, age)\n @clients << new_client\n end", "def add_client(client)\n keys.add(client, @secret)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
searches the client hash to match a string input from the user, then goes to clientselect menu
def clientsearch(client_hash,username) prompt = TTY::Prompt.new(symbols: {marker: ">"}) input = "" while input != "Exit" system('clear') Debug.show("Debug ON") input = prompt.select("Client lookup\n\n\n",["Fulltext search","ID search","Exit"]) string = nil if input ==...
[ "def main_menu(companyname=\"Unknown\",username=\"Unknown\",client_hash)\n prompt = TTY::Prompt.new(symbols: {marker: \">\"})\n input = \"\"\n while input != \"Exit\"\n system('clear')\n Debug.show \"Debug ON\\ninput: #{input} | company_name: #{companyname} | username: #{username}\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Construct an XML fragment representing the assertion id request
def to_xml(xml=Builder::XmlMarkup.new) xml.tag!('samlp:AssertionIDRequest') { assertion_id_refs.each { |assertion_id_ref| xml << assertion_id_ref.to_xml } } end
[ "def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('saml:AssertionIDRef', id)\n end", "def build_assertion\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.Assertion xmlns: Saml::XML::Namespaces::ASSERTION,\n ID: reference_string,\n IssueInstant: now_iso,\n Vers...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
symbols_for() returns an array of symbols, one for each name in a group returns an array of the input symbol if not a group
def symbols_for( symbol ) return @group_members.member?(symbol.name) ? @group_members[symbol.name] : [symbol] end
[ "def each_namespaced_symbol\n self.nested_symbols.inject([]) do |name, symbol|\n name << symbol\n yield name.join('::').to_sym\n name\n end\n end", "def symbols() @symbols end", "def each() @symbols.each {|s| yield s if block_given? } end", "def find_symbol name\n if !(s=get_symbol(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
syntactic_determinants_for() given a syntactic production name, returns a list of token symbols that can start it
def syntactic_determinants_for( symbols, into = nil, trail_marker = nil ) if symbols.is_an?(Array) then trail_marker = Util::TrailMarker.new() if trail_marker.nil? determinants = into.nil? ? {} : into symbols.each do |symbol| syntactic_determinant...
[ "def lexical_determinants_for( symbols, visited = {} )\n if symbols.is_an?(Array) then\n determinants = CharacterRange.new()\n symbols.each do |symbol|\n determinants.add( lexical_determinants_for(symbol) )\n end\n return determinants\n \n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
lexical_determinants_for() given a lexical production name, returns a CharacterRange of codes that can start it
def lexical_determinants_for( symbols, visited = {} ) if symbols.is_an?(Array) then determinants = CharacterRange.new() symbols.each do |symbol| determinants.add( lexical_determinants_for(symbol) ) end return determinants else...
[ "def reduce_lowercase_from_to(_production, _range, _tokens, theChildren)\n raw_range = [theChildren[2].token.lexeme, theChildren[4].token.lexeme]\n range_sorted = raw_range.sort\n ch_range = char_range(range_sorted[0], range_sorted[1])\n char_class(false, ch_range)\n end", "def reduce_any_l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Operations compile_parser_plan() generates a ParserPlan for a specific start rule
def compile_parser_plan( name ) case name when Model::Markers::Reference, Plan::Symbol name = name.name end assert( @production_sets.member?(name), "not a valid start rule name" ) state_table = StateTable.build( self, name ) return ParserPlan.new( self...
[ "def compile_plan()\n return Plan::ParserPlan.build( self )\n end", "def __parse__\r\n match start_rule\r\n end", "def start!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 20 )\n\n\n\n type = START\n channel = ANTLR3::DEFAULT_CH...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PAGE BLOCK / UNBLOCK
def unblock! BlockedObject.unblock_page!(self) end
[ "def remove_block\r\n block = params[:block]\r\n # remove block in all groups\r\n %w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }\r\n render :nothing => true\r\n end", "def remove_block\n block = params[:block].to_s.underscore\n @user = User.current\n # remove b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /invites/new GET /invites/new.json
def new @invite = Invite.new respond_to do |format| format.html # new.html.erb format.json { render json: @invite } end end
[ "def new\n @invite_list = InviteList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite_list }\n end\n end", "def new\n @invite_status = InviteStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
log a message, and increment future messages in this thread. useful for nesting logic
def log_incr(*args) log(*args) unless args.empty? @log_indents[Thread.current] += 1 end
[ "def log_incr(*args)\n\t\tlog(*args) unless args.empty?\n\t\t@log_indents[Thread.current] += 1\n\tend", "def increment\n @attempt += 1\n log\n end", "def work(message)\n if message.is_a?(Message)\n self.count = count + 1\n\n Concurrent::IVar.new(:ok)\n else\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /heading_bg_images GET /heading_bg_images.json
def index @heading_bg_images = HeadingBgImage.all end
[ "def index\n authenticate\n @background_images = BackgroundImage.all\n end", "def show\n @bgimage = Bgimage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bgimage }\n end\n end", "def index\n @admin_bg_images = BgImage.al...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /heading_bg_images POST /heading_bg_images.json
def create @heading_bg_image = HeadingBgImage.new(heading_bg_image_params) respond_to do |format| if @heading_bg_image.save format.html { redirect_to @heading_bg_image, notice: 'Heading bg image was successfully created.' } format.json { render :show, status: :created, location: @heading_...
[ "def create\n @bgimage = Bgimage.new(params[:bgimage])\n\n respond_to do |format|\n if @bgimage.save\n format.html { redirect_to @bgimage, :notice => 'Bgimage was successfully created.' }\n format.json { render :json => @bgimage, :status => :created, :location => @bgimage }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /heading_bg_images/1 PATCH/PUT /heading_bg_images/1.json
def update respond_to do |format| if @heading_bg_image.update(heading_bg_image_params) format.html { redirect_to @heading_bg_image, notice: 'Heading bg image was successfully updated.' } format.json { render :show, status: :ok, location: @heading_bg_image } else format.html { ren...
[ "def update\n @bgimage = Bgimage.find(params[:id])\n\n respond_to do |format|\n if @bgimage.update_attributes(params[:bgimage])\n format.html { redirect_to @bgimage, :notice => 'Bgimage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /heading_bg_images/1 DELETE /heading_bg_images/1.json
def destroy @heading_bg_image.destroy respond_to do |format| format.html { redirect_to heading_bg_images_url, notice: 'Heading bg image was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @bgimage = Bgimage.find(params[:id])\n @bgimage.destroy\n\n respond_to do |format|\n format.html { redirect_to bgimages_url }\n format.json { head :no_content }\n end\n end", "def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend", "def des...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Assign a callback to enable _password authentication_. As soon as an callback is assigned here, _password authentication_ is enabled for the service. The assigned `Proc`instance will get two arguments: 1. The username of the authentication request, 2. The password received from the client. The return value of the callb...
def password(&blk) @authentication_methods ||= {} @authentication_methods[:password] = blk self end
[ "def authentication_callback=(block)\n self.callback do |property|\n case property\n when Gsasl::GSASL_PASSWORD\n handle_password_authentication(&block)\n when Gsasl::GSASL_VALIDATE_SECURID\n handle_secureid_authentication(&block)\n when Gsasl::GSASL_DIGEST_MD5_HAS...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test +has_content+ method to return false if a post have no content
def test_has_content assert(!@contentless_post.has_content?) end
[ "def has_content?\n !content.nil?\n end", "def content?\n !content.nil? && !content.empty?\n end", "def has_content; end", "def article_content?\n !article.nil?\n end", "def has_content?\n empty_token_sort.nil?\n end", "def manage_content?(posttype = nil)\n get_option('h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Scarica dal sito FTP il file associato al tipo di flusso Parameters : file => "MGP_Prezzi" (Tipo di flusso che deve scaricate) Return : "K:/.../esiti_xml/20141009/20141010MGPPrezzi.xml" (path del flusso scaricato)
def download_file(file) #name_file = "20141010MGPPrezzi.xml" name_file = parse_name_file file path_xml = crea_dir_per_xml full_path = path_xml+name_file #entro dentro la directory nel server ftp @ftp.chdir("/MercatiElettrici/#{file}") #scarico nella directory corren...
[ "def parse_name_file file\r\n #name_file = \"#{@giorno_flusso}\" + \"#{file.gsub \"MGP_\",\"MGP\"}\" + \".xml\" \r\n name_file = case file\r\n when /OffertePubbliche/ then \"#{@giorno}\" + \"#{file.gsub \"MGP_\",\"MGP\"}\" + \".zip\" \r\n when /MGP/ then \"#{@giorno}\" + \"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fa il parse dal tipo di flusso, mi crea il nome del file da scaricare Parameters : file => "MGP_Prezzi" (Tipo di flusso che deve scaricate) Return : "20141010MGPPrezzi.xml" (nome del file da scaricare)
def parse_name_file file #name_file = "#{@giorno_flusso}" + "#{file.gsub "MGP_","MGP"}" + ".xml" name_file = case file when /OffertePubbliche/ then "#{@giorno}" + "#{file.gsub "MGP_","MGP"}" + ".zip" when /MGP/ then "#{@giorno}" + "#{file.gsub "MGP_","MGP"}" + ".xml...
[ "def get_raw_filename (file)\n\t\n\t\t# convert to string\n\t\tfile = get_filename(file)\n\t\t# remove extension\n\t\tfile.sub(get_ext(file), \"\")\n\t\t\n\tend", "def parse_fnt_xml_file(xml_string)\n xml_string.match(/file=\"(.*)\"/)[1]\n end", "def parsed_file_name\n data_file_name.split('.')[0]\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Crea la directory che contiene il flusso e si posiziona al suo interno Parameters : nil Return : "K:/.../esiti_xml/20141009" (path della directory che contiene il flusso scaricato)
def crea_dir_per_xml path_xml = (Pathname.new(__dir__).parent)+"esiti_xml"+@giorno path_xml.mkdir(0700) unless path_xml.exist? return path_xml end
[ "def generatedReportFolder\n currentData, currentTime = DateTime.now.strftime(\"%Y_%m_%d %H_%M\").split(' ')\n path = \"#{$ROOT}/../output\"\n creatFolder(path)\n path += \"/#{currentData}\"\n creatFolder(path)\n path += \"/#{currentTime}\"\n creatFolder(path)\n path\n end", "def createWo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns an array of the answers sorted by their vote score in descending order
def highest_voted_answers answers.sort_by {|answer| answer.vote_score}.reverse end
[ "def get_sorted_scores_for_learners(learners)\n scores = learners.pluck(:assessment_score).sort\n return scores\n end", "def answers_by_votes(options={})\n parse_answers(request(singular(id) + \"answers/votes\", options))\n end", "def sort_by_rank\n\t\tsorted = @candidates.sort{ |x,y| y.votes <=>...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A definition of a term
def termdef(name) element(name, {:name => name, :class=>:term}, 'a') end
[ "def term\n term_p(factor)\n end", "def term!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 34 )\n\n type = TERM\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 173:8: 'term'\n match( \"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A reference to a defined term (excluding role adjectives)
def termref(name, role_name = nil) role_name ||= name element(role_name, {:href=>'#'+name, :class=>:term}, 'a') end
[ "def target_term; @terms[@target]; end", "def term\n return @term\n end", "def current_term\n term\n end", "def termdef(name)\n element(name, {:name => name, :class=>:term}, 'a')\n end", "def source_term; @terms[@source]; end", "def term(name, uri = nil)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a log event to indicate a scope change (e.g. sprint started, issue closed).
def log_activity(issue, type, change) activities.build(:issue_id => issue.id, :type_of_change => type, :scope_change => change) end
[ "def record_scope_entry(scope_node, scope_context_entry, scope_context_before)\n dict = (@scope_entries[scope_node] ||= {})\n (dict[scope_context_entry] ||= Set.new).add(scope_context_before)\n #puts \"Recording scope entry:\"\n #puts \" scope node: #{scope_node}\"\n #puts \" scope context entry: #{s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /tapiocas POST /tapiocas.json
def create @tapioca = Tapioca.new(tapioca_params) respond_to do |format| if @tapioca.save format.html { redirect_to @tapioca, notice: 'Tapioca was successfully created.' } format.json { render action: 'show', status: :created, location: @tapioca } else format.html { render a...
[ "def create\n @taco = Taco.new(taco_params)\n\n if @taco.save\n render json: @taco, status: :created, location: @taco\n else\n render json: @taco.errors, status: :unprocessable_entity\n end\n end", "def create\n @taco = Taco.new(taco_params)\n if @taco.save\n render status: :ok, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /tapiocas/1 PATCH/PUT /tapiocas/1.json
def update respond_to do |format| if @tapioca.update(tapioca_params) format.html { redirect_to @tapioca, notice: 'Tapioca was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @tapioca.errors, s...
[ "def update\n @taco = Taco.find(params[:id])\n\n if @taco.update(taco_params)\n head :no_content\n else\n render json: @taco.errors, status: :unprocessable_entity\n end\n end", "def update\n @taco = Taco.find(params[:id])\n\n respond_to do |format|\n if @taco.update_attributes(pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /tapiocas/1 DELETE /tapiocas/1.json
def destroy @tapioca.destroy respond_to do |format| format.html { redirect_to tapiocas_url } format.json { head :no_content } end end
[ "def destroy\n @taco.destroy\n render json: @taco, status: :ok\n end", "def destroy\n @taco = Taco.find(params[:id])\n @taco.destroy\n\n respond_to do |format|\n format.html { redirect_to tacos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tccapi.destro...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
:nodoc: Return a expanded path to repository mirror build with information from configuration for repository. Replace keywords (:keyword) with value matched by it pattern.
def mirror_path(repository_owner, repository_name) mirror_path = repository_info(repository_owner, repository_name).path || raise(GithubMirrorError, "Path for repository '#{repository_owner}/#{repository_name}' doesn\'t exist in config") mirror_patterns = repository_info(repository_owner, repository_name).patte...
[ "def repository\n {repo: %r{[^/]+}}\n end", "def repositories\n return self.uri self.path(@keywords[:repositories])\n end", "def package_url\n format(\"#{node['kong']['mirror']}#{package_name}\", substitutions)\n end", "def url_for_fetching\n if @settings.mirror.present?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Handle request from Github, return always success response, but write an error message in body if an error raised
def handle_request raise GithubMirrorError, 'Only POST request allowed' unless @request.post? # return fail message if request is not a POST raise GithubMirrorError, 'Token not match' if config['token'] && !@request.path_info.end_with?('/' + config['token']) payload = JSON.parse(@request[:payload]) rescue ...
[ "def github_check\n github_legit = false\n begin\n RestClient.get \"github.com/#{params[:member][:github]}\"\n github_legit = true\n rescue\n # 404\n github_legit = false\n end\n \n respond_with(github_legit)\n end", "def travis_github_request(path, body = nil,\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
helper method to get image from url
def image_from_url io = open(URI.parse(image_url)) def io.original_filename; base_uri.path.split('/').last; end self.image = io.original_filename.blank? ? nil : io rescue # catch url errors with validations instead of exceptions (Errno::ENOENT, OpenURI::HTTPError, etc...) end
[ "def get_url\n img.url\n end", "def image_url(path); end", "def getStockImage(link)\n dog_page = HTTParty.get(link, :verify => false)\n parsed_dog_page = Nokogiri::HTML(dog_page)\n\n info_table = parsed_dog_page.css(\".biota\")[0]\n \n image = info_table.css(\"img\")[0]\n pic = image != nil ? \"https:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
action for when payment is successful. finding the correct product listing my the eventid, assigning the buyer to the current user, creating a new sale and then making the item unapproved by changing the boolean value from true to false.
def success # using find to find exact result that matches the conditions(params with correct eventId) @product_listing = ProductListing.find(params["eventId"]) @sale = Payment.create(user_id: current_user.id, buyer_email: current_user.email, seller_email: @product_listing.user.email, product_listing_id: @p...
[ "def execute_buy\n \n # Product ID validity would have been verified during the execution of the method process_buy\n # product should not be nil \n if self.user && self.user.active\n @listing = Listing.new(:product_id => @response[\"product_id\"], :user_id => self.user.id, :quantity => @response[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /garbages/new GET /garbages/new.xml
def new @garbage = Garbage.new(params[:garbage]) end
[ "def new\n @garbage = Garbage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @garbage }\n end\n end", "def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @monkey }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
prepare an UpdateRequest that will be displayed if the user entered a search that has no nearby_hits
def prepare_location_unavailable @update_request = UpdateRequest.new( search_location: @search_form.search_location # TODO: set by JS ) end
[ "def test_location_unavailable\n # See if area is covered and if not instantiate an UpdateRequest\n unless @search_cache.nearby?\n @update_request = UpdateRequest.new(\n search_location: @search_cache.search_location\n )\n end\n\n # Alert user when we used default location because they ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def product_params params.permit(:roomname, :image, :text) end
def product_params params.require(:product).permit(:roomname, :text, :image) end
[ "def product_params\n params.require(:product).permit(:name, :description, :stockCount, :pricePence, :image, :section_id)\n end", "def room_params(my_params)\n my_params.permit(:id,:name, :rent, :months_free, :status, :preferences, :bonus, :tenant_pet_info, :room_size, :room_notes, :tenant_info, :renting...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the string prefix for tagging versions of this package. Only makes any sense if the package is in a recognized repo, and will error out if that's not the case. The most basic prefix is "v" for packages located at the root of the repository.
def version_tag_prefix if root_path == repo.root_path 'v' else (repo_rel_path / 'v').to_s end end
[ "def set_prefix\n @prefix ||= Octopolo::SemverTagScrubber.scrub_prefix(git.semver_tags.last)\n end", "def current_git_version_tag\n\t\treturn [ self.release_tag_prefix, self.version ].join\n\tend", "def version_prefix\n '/v2'\n end", "def tag_string\n config[:tag_prefix] ? \"#{config[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /gig_rosters GET /gig_rosters.json
def index @gig_rosters = GigRoster.all end
[ "def index\n @draft_rosters = @team.draft_rosters.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @draft_rosters }\n end\n end", "def show\n @gig = Gig.find(params[:id])\n\n render json: @gig\n end", "def show\n @gig = Gig.find(params[:id]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /gig_rosters POST /gig_rosters.json
def create @gig_roster = GigRoster.new(gig_roster_params) respond_to do |format| if @gig_roster.save format.html { redirect_to @gig_roster, notice: 'Gig roster was successfully created.' } format.json { render :show, status: :created, location: @gig_roster } else format.html...
[ "def create\n @gig = Gig.new(params[:gig])\n\n if @gig.save\n render json: @gig, status: :created, location: @gig\n else\n render json: @gig.errors, status: :unprocessable_entity\n end\n end", "def create\n @rigging = Rigging.new(rigging_params)\n\n respond_to do |format|\n if @r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /operating_hours GET /operating_hours.json
def index @operating_hours = OperatingHour.all end
[ "def index\n @operatinghours = Operatinghour.all\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @office_hours }\n end\n end", "def show\n @office_hour = OfficeHour.find(params[:id])\n\n respond_to do |format|\n format.html ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /operating_hours POST /operating_hours.json
def create @operating_hour = OperatingHour.new(operating_hour_params) respond_to do |format| if @operating_hour.save format.html { redirect_to @operating_hour, notice: 'Operating hour was successfully created.' } format.json { render :show, status: :created, location: @operating_hour } ...
[ "def create\n @operatinghour = Operatinghour.new(operatinghour_params)\n\n respond_to do |format|\n if @operatinghour.save\n format.html { redirect_to @operatinghour, notice: 'Operatinghour was successfully created.' }\n format.json { render :show, status: :created, location: @operatinghour...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /operating_hours/1 PATCH/PUT /operating_hours/1.json
def update respond_to do |format| if @operating_hour.update(operating_hour_params) format.html { redirect_to @operating_hour, notice: 'Operating hour was successfully updated.' } format.json { render :show, status: :ok, location: @operating_hour } else format.html { render :edit ...
[ "def update\n respond_to do |format|\n if @operatinghour.update(operatinghour_params)\n format.html { redirect_to @operatinghour, notice: 'Operatinghour was successfully updated.' }\n format.json { render :show, status: :ok, location: @operatinghour }\n else\n format.html { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /operating_hours/1 DELETE /operating_hours/1.json
def destroy @operating_hour.destroy respond_to do |format| format.html { redirect_to operating_hours_url, notice: 'Operating hour was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @operationhour = Operationhour.find(params[:id])\n @operationhour.destroy\n\n respond_to do |format|\n format.html { redirect_to operationhours_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @operatinghour.destroy\n respond_to do |format|\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Show the window and start the main loop. Also starts the window given in parameters. (Used for VimWindow)
def start(start_window) gtk_window.show_all start_window.start Gtk.main_with_queue end
[ "def start!\n @window = Window.new width, height, fullscreen?\n window.caption = name\n window.scene = Scenes.generate(first_scene)\n window.show\n end", "def start(*args)\n self.setup\n self.show_all(*args)\n Nyle.main\n end", "def start(options={})\n in_xterm_state(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a number and checks to see if it is in any of the ranges given
def in_ranges?(num, ranges) result = false ranges.each do |range| if range.include?(num) result = true end end return result end
[ "def all_in_ranges?(nums, ranges)\n if nums.empty?\n return false\n end\n nums.each do |num|\n if !in_ranges?(num, ranges)\n return false\n end\n end\n true\nend", "def isInrange?(a, b, c)\n a.range?(b, c)\nend", "def check_range(a,b)\n if (20..30).include?(a)\n puts \"a is in the rang...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks to see if every num in nums is in the ranges given
def all_in_ranges?(nums, ranges) if nums.empty? return false end nums.each do |num| if !in_ranges?(num, ranges) return false end end true end
[ "def in_ranges?(num, ranges)\n result = false\n ranges.each do |range|\n if range.include?(num)\n result = true\n end\n end\n return result\nend", "def in_ranged_array?(ranged_ary, num)\n !!ranged_ary.find {|n| n === num }\n end", "def OverlappingRanges(arr)\n first_num = arr[0]\n secon...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a map of fields to ranges and an array of numbers and returns a set of fields are possible candidates for the numbers
def possible_fields(map, nums) result = Set.new() map.each do |field, ranges| if all_in_ranges?(nums, ranges) result << field end end result end
[ "def find_valid_numbers(fields)\n bounds = fields.map { |line| line.scan(/\\d+/).map(&:to_i) }\n valid_numbers = []\n bounds.each do |set|\n pair = []\n (0..set.length - 1).step(2) { |ind| pair += (set[ind]..set[ind + 1]).to_a }\n valid_numbers << pair\n end\n valid_numbers\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a 2D matrix and returns the transpose
def transpose(matrix) if matrix.empty? || matrix.first.empty? raise ArgumentError end result = Array.new(matrix.first.length) { Array.new(matrix.length, 0) } matrix.each_with_index do |row, x| row.each_with_index do |val, y| result[y][x] = val end end result end
[ "def transpose_of_matrix matrix\n\treturn Matrix.new(matrix.line, matrix.col, matrix.values.transpose)\nend", "def transpose\n transposed_matrix=[]\n 0.upto(@matrix[0].size-1) do |col_num| \n transposed_matrix[col_num] ||= []\n 0.upto(@matrix.size-1) do |row_num|\n transposed_matrix[col_num...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Schreiben der aktuellen Connection in last logins, wenn neue dabei
def write_connection_to_last_logins database = read_from_client_info_store(:current_database) last_logins = read_last_logins min_id = nil last_logins.each do |value| last_logins.delete(value) if value && value[:sid] == database[:sid] && value[:host] == database[:host] && value[:user] == databas...
[ "def connection_completed\r\n end", "def checkin_connection(*)\n conn = super\n @connection_timestamps[conn] = Sequel.start_timer\n conn\n end", "def connection_completed\n\t\t\tdispatch_event :init_bot\n\t\t\t@state = :login\n\t\tend", "def connection_completed\n @connected_at = Tim...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
repeat last called menu action
def repeat_last_menu_action controller_name = read_from_client_info_store(:last_used_menu_controller) action_name = read_from_client_info_store(:last_used_menu_action) # Suchen des div im Menü-ul und simulieren eines clicks auf den Menü-Eintrag respond_to do |format| format.js {render :js => ...
[ "def main_menu_return\n puts \"Returning to main menu...\"\n sleep(1)\n main_menu\n end", "def repeat\n self.send(@state.last_command[:method], *@state.last_command[:args]) unless @state.last_command.nil?\n end", "def run_menu_and_call_next(menu)\n user_wants = run_menu(menu)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /graphics/1 GET /graphics/1.json
def show @graphic = Graphic.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @graphic } end end
[ "def index\n @graphics = Graphic.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @graphics }\n end\n end", "def index\n @graphics = Graphic.all\n end", "def show\n @graphic_datum = GraphicDatum.find(params[:id])\n\n respond_to do ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return to the patient dashboard if patient lab test has been ordered within 1 hour
def patient_should_proceed_after_lab_order? test_type = concept 'Test type' tb_concept = concept 'Tuberculous' observation = Observation.joins(:encounter).where( 'person_id = ? AND concept_id = ? AND value_coded = ? AND encounter.encounter_type = ?', @patient.patient_id, test_type.conc...
[ "def due_lab_order? (patient:)\n program_start_date = find_patient_date_enrolled(patient)\n return false unless program_start_date\n\n days = (Date.today - program_start_date).to_i\n falls_within_ordering_period?(days: days, tolerance: 5) && no_orders_done?(patient: patient, time...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /size_groups/1 GET /size_groups/1.xml
def show @size_group = SizeGroup.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @size_group } end end
[ "def new\n @size_group = SizeGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @size_group }\n end\n end", "def create\n @size_group = SizeGroup.new(params[:size_group])\n result = @size_group.save\n if result\n for size in params[:s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /size_groups/new GET /size_groups/new.xml
def new @size_group = SizeGroup.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @size_group } end end
[ "def create\n @size_group = SizeGroup.new(params[:size_group])\n result = @size_group.save\n if result\n for size in params[:size]\n new_size = Size.new(size)\n new_size.save\n @size_group.sizes << new_size\n end\n end\n respond_to do |format|\n if result\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /size_groups POST /size_groups.xml
def create @size_group = SizeGroup.new(params[:size_group]) result = @size_group.save if result for size in params[:size] new_size = Size.new(size) new_size.save @size_group.sizes << new_size end end respond_to do |format| if result flash[:notice] = ...
[ "def update\n @size_group = SizeGroup.find(params[:id])\n result = @size_group.update_attributes(params[:size_group])\n if result\n for size in params[:size]\n new_size = Size.new(size)\n new_size.save\n @size_group.sizes << new_size\n end\n for id,size in params[:existi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /size_groups/1 PUT /size_groups/1.xml
def update @size_group = SizeGroup.find(params[:id]) result = @size_group.update_attributes(params[:size_group]) if result for size in params[:size] new_size = Size.new(size) new_size.save @size_group.sizes << new_size end for id,size in params[:existing_size] ...
[ "def update\n\n if @size_group.update_attributes(params[:size_group])\n flash[:notice] = 'SizeGroup was successfully updated.'\n render :partial => 'show', :object => @size_group\n else\n render :partial => 'edit', :object => @size_group, :status => 409\n end\n end", "def create\n @siz...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /size_groups/1 DELETE /size_groups/1.xml
def destroy @size_group = SizeGroup.find(params[:id]) @size_group.destroy respond_to do |format| format.html { redirect_to(admin_size_groups_url) } format.xml { head :ok } end end
[ "def destroy\n @size_group.destroy\n\n render :nothing => true\n end", "def destroy\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get API URL for projects
def project_url project_id server = lookup_server_from_project(project_id) pivotal_url = server[:url] { :url => "#{pivotal_url}/projects/#{project_id}", :token => server[:token] } end
[ "def getProjectsUrl\r\n\t\t\t\treturn getBaseURL+'projects/'\r\n\t\t\tend", "def getProjectUrl(projectId)\r\n\t\t\t\treturn getBaseURL+'projects/'+String(projectId)+'/'\r\n\t\t\tend", "def api_url\n \"#{@@base_url}/#{format}/#{resource}?apikey=#{@@api_key}#{parameters}\"\n end", "def api_url\n \"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get API URL for stories
def stories_url project_id server = lookup_server_from_project(project_id) pivotal_url = server[:url] { :url => "#{pivotal_url}/projects/#{project_id}/stories", :token => server[:token] } end
[ "def story_url(story_id)\n \"https://www.pivotaltracker.com/story/show/#{story_id}\"\n end", "def article_endpoint\n File.join api_url, \"article\"\n end", "def api_url\n api_mode + api_interface\n end", "def person_url(id)\n \"https://swapi.dev/api/people/#{id}/\"\nend", "def api_url\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given a project id, get the server's information
def lookup_server_from_project pid PT2TODO_CONFIG.each do |token, p| if p[:project_ids].include? pid return {:token => token, :url => p[:url], :project_ids => p[:project_ids], :append => p[:append]} end end return nil end
[ "def get_project_info()\n GitBox::base_uri @server\n GitBox::basic_auth @user, @pass\n GitBox::get(\"/projects/#{@project}.json\")\n end", "def project_details(project_id)\n return get(\"/projects/#{project_id}\")\n end", "def server_by_id(server_id)\n get(\"Server/#{server_id}\")\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Call the Pivotal Tracker API with the given `url`. This method provides the API Token as a HTTP Header.
def pivotal_tracker(server) clnt = HTTPClient.new clnt.get(server[:url], nil, { "X-TrackerToken" => server[:token] }) end
[ "def api_token\n api_token = @options[:api_token] || Git.get_config(KEY_API_TOKEN, :inherited)\n\n if api_token.blank?\n api_token = ask('Pivotal API Token (found at https://www.pivotaltracker.com/profile): ').strip\n Git.set_config(KEY_API_TOKEN, api_token, :local) unless api_token.blank?\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given a project's id (`pid`), get the project's name.
def project_name(pid) Nokogiri::HTML(pivotal_tracker(project_url(pid)).content).css('project > name').text.split(' ').join end
[ "def getProjectName()\n\t\tsrc = getPage()\n\t\tif(src.include? \"/project/\")\n\t\t\ttmp = src.split(\"/\")\n\t\t\t#Fix redirect to make shure we are in right virtual folder for project\t\n\t\t\tif(src.ends_with?(\"/\") == false && src.ends_with?(\"save\") == false && src.ends_with?(\"edit\") == false)\n\t\t\t\tre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Formats a Pivotal Tracker story in the todo.txt format. Letterbased priorities are given to it depending on what the story's current status is. The story's labels and story type are todo.txt's contexts, while the story's project name is the todo's story. The URL of the story is also added to the
def format_todotxt(project_id, priority_group, story) task_priority = case priority_group when :today then "(A)" when :next then "(B)" when :someday then "(C)" end done = task_priority.nil? # TODO: escape newlines... title = story.css('name').text url = s...
[ "def print_file\n new_file = File.new(\"todolist.txt\", \"w+\")\n new_file.puts \"-\" * 30\n new_file.puts \"#{@title.upcase}\"\n new_file.puts\"-\" * 30\n new_file.puts \"TO DOs\".ljust(45) + \"Completed?\".ljust(15) + \"Priority\"\n @items.each_with_index do |task, index|\n new_file.write(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /extrainfos POST /extrainfos.json
def create @extrainfo = Extrainfo.new(extrainfo_params) respond_to do |format| if @extrainfo.save format.html { redirect_to @extrainfo, notice: 'Extrainfo was successfully created.' } format.json { render :show, status: :created, location: @extrainfo } else format.html { ren...
[ "def create\n @ex = Ex.new(ex_params)\n\n respond_to do |format|\n if @ex.save\n format.html { redirect_to ex_url(@ex), notice: \"Ex was successfully created.\" }\n format.json { render :show, status: :created, location: @ex }\n else\n format.html { render :new, status: :unproce...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /extrainfos/1 PATCH/PUT /extrainfos/1.json
def update respond_to do |format| if @extrainfo.update(extrainfo_params) format.html { redirect_to @extrainfo, notice: 'Extrainfo was successfully updated.' } format.json { render :show, status: :ok, location: @extrainfo } else format.html { render :edit } format.json { r...
[ "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n @exco = Exco.find(params[:id])\n\n respond_to do |format|\n if @exco.update_attributes(params[:exco])\n format.html { redirect_to @exco, notice: 'Exco was successfully updated.' }\n fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /extrainfos/1 DELETE /extrainfos/1.json
def destroy @extrainfo.destroy respond_to do |format| format.html { redirect_to extrainfos_url, notice: 'Extrainfo was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @exercise = Exercise.find(params[:id])\n File.unlink(@exercise.path)\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n\n head :no_content\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
genera la secuencia sugerida para la nueva cuenta a crear, dependiendo del nivel, grupo y antesosor(padre)
def secuenciasugerida #recupera los hijos del padre de la cuenta a crear hijos = Catalogo.where("padre_id = ? AND activo = ?", idcuenta, true) #configuracion del nivel a crear idnivel = Catalogo.find_by(id: idcuenta).nivel_id nivelh = Nivel.find_by(id: idnivel).numnivel + 1 nivel...
[ "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_observador\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [21]\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
only considers quickerydefined attributes that has corresponding _is_synced attribute
def autoload_unsynced_quickery_attributes! model = self.class new_values = {}.with_indifferent_access defined_quickery_attribute_names = model.quickery_builders.keys defined_quickery_attribute_names.each do |defined_quickery_attribute_name| if has_attribute?(:"#{def...
[ "def _synced?(foreign_key)\n !!_synced[foreign_key]\n end", "def insync?(is)\n synced = true\n provider.attributes_to_update = Hash.new\n @should[0].each do |k, v|\n unless is[k] == v\n synced = false\n provider.attributes_to_update[k] = v\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: resolves a template file by looking in the template path. template the template name. extension the extension of the desired template. Returns a string with the full path of the template file, or nil if it is not found.
def which(template, extension) template_with_extension = with_extension(template, extension) path = absolute_paths.find do |path| File.exists?(File.join(path, template_with_extension)) end if path File.join(path, template_with_extension) end end
[ "def template_file\n @template_file || \"#{path}/#{template_name}.#{template_extension}\"\n end", "def find_template_file(parts, possible_exts = [], possible_paths = default_search_paths)\n possible_paths.each do |base|\n (possible_exts + [\"\"]).each do |ext|\n filename = fil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Internal: parses the SNP_PATH environment variable, if it is set. The format of this variable follows the same convention of the shell's PATH variable: a series of directories separated by a collon.
def path_from_env ENV['SNP_PATH'] && ENV['SNP_PATH'].split(':') end
[ "def path_components\n ENV[\"PATH\"].split(File::PATH_SEPARATOR)\n end", "def search_paths\n if Facter::Util::Config.is_windows?\n ENV['PATH'].split(File::PATH_SEPARATOR)\n else\n # Make sure facter is usable even for non-root users. Most commands\n # in /sbin ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Internal: The default path to be used when the SNP_PATH environment variable is not set.
def default_path ['~/.snp'] end
[ "def default_path\n Pathname.pwd.join(*base_config_path, self.class.config_folder)\n end", "def default_path\n [ (std_path || key).to_s ]\n end", "def default_config_path\n @default_config_path ||= root.join('config').freeze\n end", "def conf_default\n File.join(dir_cases, @@d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Internal: checks if the given name ends with the passed `extension`. template the template file name.
def has_extension?(template, extension) comparison_length = extension.size + 1 # account for the separator `.` template[-comparison_length, comparison_length] == ".#{extension}" end
[ "def template_extension\n @_extension ||= begin\n match_data = template_name.match(/.+(\\..+)/)\n\n # set it to the empty string in case there is no extension to allow for\n # proper memoization of its value\n match_data ? match_data[1] : \"\"\n end\n end", "def with_exten...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Internal: appends a given extension to the template file name, unless it is already present. template the template name. extension the extension to be appended. Examples with_extension('template', 'erb') => 'template.erb' with_extension('template.erb', 'erb') => 'template.erb'
def with_extension(template, extension) if has_extension?(template, extension) template else [template, extension].join(".") end end
[ "def _conditionally_append_extension(template, type)\n type && !template.match(/\\.#{type.to_s.escape_regexp}$/) ? \"#{template}.#{type}\" : template\n end", "def template_extension\n @_extension ||= begin\n match_data = template_name.match(/.+(\\..+)/)\n\n # set it to the empty string in c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
We need to sign the customer in ourselves, since iVeri is not sending the relevant data back to us to do so.
def sign_the_customer_in transaction = ::Refinery::Transactions::Transaction.find_by_unique_guid(params['REFERENCE']) sign_in(:customer, ::Refinery::Customers::Customer.find(transaction.order.customer_id)) @current_cart = get_cart # get the cart again now that the customer is signed in. ...
[ "def signing_input; end", "def sign_key; end", "def authenticate_customer \n label = request_label(:authenticate_customer, customer_id)\n \n @http_request_bundler.add(\n label, \n @url + \"/authenticate_customer\", \n :get,\n head: headers,\n query: { provider_id: provid...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
TODO: Dynamically get all rows rather than pass 'range'
def rows(range = 'Sheet1!A1:E') get_spreadsheet_data('1eu1Dk67gKnrIgQQ9Fm0Y-RCMzRfZf1UaTQzEt7hjWp0', range) end
[ "def getRowRange(range)\n end", "def get_range table, start_row_inclusive, end_row_exclusive, columns=nil, batch_size=1000\n start_bytes = table._row_obj_to_bytes(start_row_inclusive)\n end_bytes = table._row_obj_to_bytes(end_row_exclusive)\n RowRange.new(@connection, @transaction_adapter, table...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns array with hospital id, medication_id, number of times medication_id was used at hospital [42, 16765295]=>111
def specific_type_of_medication_per_hospital self.group(:hospital_id, :medication_id).count end
[ "def total_people_recording\n recorded_hours.select(:person_id).map(&:person_id).uniq.count\n end", "def getPatientCount\n return @patientList.size\n end", "def attendance_counts\n\t\tresults = {}\n\t\tstudents = @redis.smembers('StudentPersonal')\n\t\tstudents.each do |s|\n\t\t\tabsences = @redis.s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /driver_records/1 GET /driver_records/1.json
def show @driver_record = DriverRecord.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @driver_record } end end
[ "def show\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end", "def index\n @drivers = Driver.all\n render json: @drivers\n end", "def index\n @drivers = Driver.all\n\n respond_to do |f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /driver_records/new GET /driver_records/new.json
def new @driver_record = DriverRecord.new respond_to do |format| format.html # new.html.erb format.json { render json: @driver_record } end end
[ "def new\n @driver = Driver.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @driver }\n end\n end", "def new\n @record = Record.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @record }\n end\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /driver_records POST /driver_records.json
def create @driver_record = DriverRecord.new(params[:driver_record]) respond_to do |format| if @driver_record.save format.html { redirect_to @driver_record, notice: 'Driver record was successfully created.' } format.json { render json: @driver_record, status: :created, location: @driver_re...
[ "def create\n # Logic to create a driver and submit to DB\n @driver = Driver.new(params[:driver])\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Driver was successfully created.' }\n format.json { render json: @driver, status: :created, locatio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /driver_records/1 PUT /driver_records/1.json
def update @driver_record = DriverRecord.find(params[:id]) respond_to do |format| if @driver_record.update_attributes(params[:driver_record]) format.html { redirect_to @driver_record, notice: 'Driver record was successfully updated.' } format.json { head :no_content } else f...
[ "def update\n\t\t\t\trespond_with Driver.update(params[:id],params[:driver])\n\t\t\tend", "def update\n #@driver = Driver.find(params[:id])\n @driver = @event.drivers.find(params[:id])\n\n respond_to do |format|\n if @driver.update_attributes(params[:driver])\n format.html { redirect_to [@eve...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /driver_records/1 DELETE /driver_records/1.json
def destroy @driver_record = DriverRecord.find(params[:id]) @driver_record.destroy respond_to do |format| format.html { redirect_to driver_records_url } format.json { head :no_content } end end
[ "def destroy\n\t\t\t\trespond_with Driver.destroy(params[:id])\n end", "def destroy\n @driver = Driver.find(params[:id])\n @driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n driver.de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetch the size of an url
def fetch_filesize(url) uri = URI.parse(url) header = { 'User-Agent' => "A tiny script in ruby to analyse your videos :) - But don't worry a user is also there.", } h = Net::HTTP.new uri.host, uri.port getfile = uri.path getfile << '?' << uri.query if not uri.query.nil? res = h.request_head(getfile...
[ "def download_size\n download_url_response['s']\n end", "def content_size(url)\n Rails.cache.fetch(\"/content_size/#{url}\", expires_in: 10.minutes) do\n begin\n meta = meta_file(url)\n size_text = meta.xpath(\"//m:metalink//m:file//m:size[1]//text()\", 'm' => 'urn:ietf:params:xml:ns:met...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Transform amount of bytes in humanreadable format
def transform_byte(byte) byte = byte.to_f return two_digits(byte / 1073741824).to_s << " GB" if byte > 1073741824 return two_digits(byte / 1048576).to_s << " MB" if byte > 1048576 return two_digits(byte / 1024).to_s << " KB" if byte > 1024 return two_digits(byte).to_s << " B" end
[ "def human_bytes(bytes)\n s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];\n #indicates if thousands, millions ...\n place = (Math.log(bytes)/Math.log(1024)).floor\n (bytes/(1024 ** place.floor)).to_s+\" \"+s[place];\n end", "def convert_bytes (bytes)\n if bytes < 1024\n sprintf(\"%6dB\", byt...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Wheter this user is a super admin. Short for has_permission(:is_super_admin)
def is_super_admin? ((!user_group_id.nil?) && has_permission(:is_super_admin)) end
[ "def is_superadmin?\n\t\tno_permission_redirection unless self.current_user && self.current_user.has_system_role('superadmin')\n\tend", "def is_superuser?\n \n superuser == true\n \n end", "def super_admin?(user)\n user.organizations.exists?(name: 'admins')\n end", "def superadmin_re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Print the version of iTunes
def show_version puts "iTunes version: #{@iTunes.version}" @logger.info "iTunes version: #{@iTunes.version}" end
[ "def print_version(name, vd)\n puts \"*\" * 79\n puts \"Latest #{name} version: #{vd.version}\"\n puts \"Latest #{name} build date: \" + Time.at(vd.timestamp / 1000).to_datetime.to_s\n puts \"Latest #{name} download URL: #{vd.url}\"\n puts \"Latest #{name} filename: #{vd.filename}\"\nend", "def sh...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get a list of all possible iTunes sources
def sources @iTunes.sources.each do |source| @sources << source end end
[ "def list_sources\n log_message( \"Listing sources...\" ) unless @logging == false\n source_list = @connection.get( \"source\" )\n return source_list\n end", "def hulu_sources\n [\n source_obj(\"free_web_sources\", \"hulu_free\"),\n source_obj(\"subscription_web_sources\", \"hulu_pl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find a playlist by its name
def find_playlist_by_name name @playlists.each do |playlist| return playlist.index if name == playlist.name end end
[ "def playlist( playlist_name )\n play_list = @playlists.select { |playlist| playlist.name == playlist_name }\n if play_list.count == 1\n return play_list[0]\n else\n raise \"ERROR: #{play_list.count} playlists with name #{playlist_name}\"\n end\n end", "def test_find_by_name\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the number of dead tracks
def count_dead_tracks @dead_track_list.length end
[ "def track_count\n return @tracks.length\n end", "def track_count\n return @track_count\n end", "def track_count\n\t\t@result['Tracks'].each do\n\t\t\t@song_count +=1\n\t\tend\n\t\t@song_count\n\tend", "def numUnplayedPieces()\n return @unplayedPieces.length()\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove tracks from the track_list from the iTunes database
def rem_dead_tracks playlist begin playlist.fileTracks.each do |track| #puts "#{track.index}: #{track.location}" next unless track.location == nil puts "Deleting dead track: #{track.artist} - #{track.album} - #{track.name}" @logger.info "Deleting dead track: #{track.artist} - #{tra...
[ "def remove_track()\n @track_list.pop\n end", "def clear_itunes\n log\n while (tracks = tracks_in_playlist(\"Music\")).any?\n tracks.each do |location, track| \n itunes.delete(track)\n end\n end\n end", "def clear\n tracks.each do |track|\n tracks.delete(track)\n trac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gem Dependency API methods Declare a dependency on a gem. Ignores every option except :group.
def gem( name, *requirements, **options ) if options[:group] == :development || options[:groups]&.include?( :development ) || self.current_groups.include?( :development ) requirements.push( :development ) end dependency = Gem::Dependency.new( name, *requirements ) self.dependencies.add( dependency )...
[ "def gem(name, *reqs)\n if dep = @dependency_names[name]\n dep.requirement.concat reqs\n else\n dep = Gem::Dependency.new name, *reqs\n @dependency_names[name] = dep\n @dependencies << dep\n end\n end", "def util_gem(name, *args) args.last.is_a?(Hash) && args.last.merge!(:require => ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Callback to filter backtrace lines. One use for this is to make additional [PROJECT_ROOT] or [GEM_ROOT] substitutions, which are used by Honeybadger when grouping errors and displaying application traces. block A block which can be used to modify the Backtrace lines sent to Honeybadger. The block expects one ar...
def backtrace_filter(&block) Agent.backtrace_filter(&block) end
[ "def backtrace_filter(*args, &block); end", "def filter_backtrace &block\n self.backtrace_filters << block\n end", "def filter_backtrace(lines)\n filtered = []\n lines.each do |line|\n unless line.match(self.backtrace_filter)\n filtered.push(line)\n end\n end\n filtered = li...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Populate the prejoined fact table.
def populate(options={}) populate_prejoined_fact_table(options) end
[ "def populate_prejoined_fact_table(options={})\r\n fact_columns_string = columns.collect {|c|\r\n \"#{table_name}.\" + c.name unless excluded_foreign_key_names.include?(c.name)\r\n }.compact.join(\",\\n\") \r\n \r\n prejoined_columns = []\r\n \r\n tables_and_joins = \"#{table_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get foreign key names that are excluded.
def excluded_foreign_key_names excluded_dimension_relations = prejoined_fields.keys.collect {|k| dimension_relationships[k]} excluded_dimension_relations.collect {|r| r.foreign_key} end
[ "def foreign_keys\n self.reflect_on_all_associations.inject([]) do |r, e|\n r << e.foreign_key\n r\n end.uniq\n end", "def foreign_keys\n self.reflect_on_all_associations.inject([]) do |r, e|\n r << e.foreign_key\n r\n end\n end", "def fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Construct the prejoined fact table.
def create_prejoined_fact_table(options={}) connection.transaction { drop_prejoin_fact_table connection.create_table(prejoined_table_name, :id => false) do |t| # get all columns except the foreign_key columns for prejoined dimensions columns.each do |c| t.co...
[ "def populate_prejoined_fact_table(options={})\r\n fact_columns_string = columns.collect {|c|\r\n \"#{table_name}.\" + c.name unless excluded_foreign_key_names.include?(c.name)\r\n }.compact.join(\",\\n\") \r\n \r\n prejoined_columns = []\r\n \r\n tables_and_joins = \"#{table_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Populate the prejoined fact table.
def populate_prejoined_fact_table(options={}) fact_columns_string = columns.collect {|c| "#{table_name}." + c.name unless excluded_foreign_key_names.include?(c.name) }.compact.join(",\n") prejoined_columns = [] tables_and_joins = "#{table_name}" prej...
[ "def populate(options={})\r\n populate_prejoined_fact_table(options)\r\n end", "def create_prejoined_fact_table(options={})\r\n connection.transaction {\r\n drop_prejoin_fact_table\r\n\r\n connection.create_table(prejoined_table_name, :id => false) do |t|\r\n # get all columns ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
this page allows you to add food items to a participant
def edit @food_item = @participant.food_items.new end
[ "def add_food(food)\n food_meals.create(food_id: food.id)\n end", "def create\n @food_item_add_on = FoodItemAddOn.new(food_item_add_on_params)\n\n\n\n#Todo: can select multiple items for a sinfle addons\n respond_to do |format|\n if @food_item_add_on.save\n format.html { redirect_to :control...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }