query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def user_params params[:user] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
GET /brands GET /brands.json
def index @shop_section = ShopSection.find_by_short_url("brands") @brands = Brand.all respond_to do |format| format.html # index.html.erb format.json { render json: @brands } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_brandings\n request :get, \"/v3/brandings.json\"\n end", "def init_brands\n response = @conn.get do |req|\n req.url \"/api/v1/brands\"\n req.headers = rest_headers\n end\n\n @brands = json(response.body)[:brands]\n end", "def index\n @brands = Brand.all\n ...
[ "0.79845434", "0.78507847", "0.75492257", "0.7380274", "0.7348523", "0.7197513", "0.7193676", "0.7181135", "0.7102809", "0.7098814", "0.7084464", "0.70393103", "0.7005633", "0.6932066", "0.6846164", "0.68381065", "0.68290555", "0.68119884", "0.6781026", "0.6742868", "0.669895...
0.7644961
2
GET /brands/1 GET /brands/1.json
def show session[:user_settings] ||= Hash.new() @user_settings = session[:user_settings] @shop_section = ShopSection.find_by_short_url("brands") @user_settings.delete("shop_section") @brand = Brand.find(params[:id]) @user_settings["brand"] = @brand.id @section = :brands condition = "products.brand_id = #{@brand.id}" unless @user_settings["sex"].nil? condition += " and products.sex_id = #{@user_settings["sex"]}" end unless @user_settings["career"].nil? condition += " and products.career_id = #{@user_settings["career"]}" end @page = (params[:page] || 1).to_i @products = Product.where(condition).valid_products.order("products.updated_at DESC").paginate(:page => @page) @more_products = Product.where(condition).valid_products.all.size() - Product.per_page * @page @more_products = nil if @more_products <= 0 respond_to do |format| format.html # show.html.erb format.json { render json: @brand } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_brandings\n request :get, \"/v3/brandings.json\"\n end", "def index\n @shop_section = ShopSection.find_by_short_url(\"brands\")\n @brands = Brand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brands }\n end\n end", "def init...
[ "0.7700306", "0.7583345", "0.75546575", "0.75084245", "0.7415763", "0.73792094", "0.73239833", "0.73105747", "0.7196419", "0.715291", "0.69859743", "0.6956179", "0.6954019", "0.69514346", "0.6899076", "0.68816453", "0.68379533", "0.68379116", "0.68306524", "0.68298864", "0.68...
0.0
-1
GET /brands/new GET /brands/new.json
def new @brand = Brand.new respond_to do |format| format.html { render layout: "editor" } format.json { render json: @brand } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @brand = Brand.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @brand }\n end\n end", "def new\r\n @brand = Brand.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @brand }\r\n ...
[ "0.79172975", "0.7865279", "0.7723669", "0.7375532", "0.73542845", "0.7344533", "0.7344505", "0.73054636", "0.73054636", "0.7293007", "0.7238698", "0.7220877", "0.72134954", "0.7212181", "0.72101307", "0.72050786", "0.7189767", "0.7188602", "0.71765625", "0.71365064", "0.7134...
0.7137619
19
POST /brands POST /brands.json
def create @brand = Brand.new(params[:brand]) respond_to do |format| if @brand.save format.html { redirect_to @brand, notice: 'Brand was successfully created.' } format.json { render json: @brand, status: :created, location: @brand } else format.html { render action: "new", layout: "editor" } format.json { render json: @brand.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @brand = Brand.new(params[:brand])\n\n respond_to do |format|\n if @brand.save\n format.html { redirect_to brands_path, notice: 'Brand was successfully created.' }\n format.json { render json: @brand, status: :created, location: @brand }\n else\n format.html { rend...
[ "0.6664932", "0.6659046", "0.65487236", "0.6504898", "0.6495391", "0.6413728", "0.63585514", "0.62862265", "0.62392527", "0.62294525", "0.61941344", "0.61870104", "0.61796385", "0.6168238", "0.6140023", "0.61304027", "0.6104583", "0.6070477", "0.60673", "0.60662967", "0.60659...
0.6216185
10
PUT /brands/1 PUT /brands/1.json
def update @brand = Brand.find(params[:id]) respond_to do |format| if @brand.update_attributes(params[:brand]) format.html { redirect_to @brand, notice: 'Успешно обновлена информация о производетеле.' } format.json { head :no_content } else format.html { render action: "edit", layout: "editor" } format.json { render json: @brand.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @brand = Brand.find(params[:id])\n\n respond_to do |format|\n if @brand.update_attributes(params[:brand])\n format.html { redirect_to brands_path, notice: 'Brand was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" ...
[ "0.68226254", "0.6747086", "0.64856046", "0.64856046", "0.63648695", "0.6328208", "0.6307355", "0.6299865", "0.62973803", "0.6255817", "0.6242385", "0.6237094", "0.6229391", "0.6216565", "0.6209823", "0.61985147", "0.618075", "0.6146235", "0.61229885", "0.61097956", "0.610469...
0.64127773
4
DELETE /brands/1 DELETE /brands/1.json
def destroy @brand = Brand.find(params[:id]) @brand.destroy respond_to do |format| format.html { redirect_to brands_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @brand = Brand.find(params[:id])\n @brand.destroy\n\n respond_to do |format|\n format.html { redirect_to brands_url }\n format.json { head :ok }\n end\n end", "def destroy\r\n @brand = Brand.find(params[:id])\r\n @brand.destroy\r\n\r\n respond_to do |format|\r\n ...
[ "0.7360671", "0.73566914", "0.7162515", "0.7158363", "0.7143138", "0.7105898", "0.70914537", "0.70715475", "0.70422506", "0.7028362", "0.696279", "0.69497985", "0.69446397", "0.69446397", "0.69446397", "0.69446397", "0.6932945", "0.692693", "0.69222414", "0.692046", "0.691728...
0.73525107
2
helper :watchers include WatchersHelper
def my_new @issue = Issue.new @issue.defaults_from(params[:related_to]) if params[:related_to] && params[:do_copy] @issue.project = @project @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) if @issue.tracker.nil? render_error l(:error_no_tracker_in_project) return end if params[:issue].is_a?(Hash) @issue.attributes = params[:issue] @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] if User.current.allowed_to?(:add_issue_watchers, @project) end @issue.author = User.current default_status = IssueStatus.default unless default_status render_error l(:error_no_default_issue_status) return end @issue.status = default_status @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq @priorities = IssuePriority.all if request.get? || request.xhr? @issue.start_date ||= Date.today render :template => 'issues/new' else requested_status = IssueStatus.find_by_id(params[:issue][:status_id]) @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) if @issue.save attach_files(@issue, params[:attachments]) flash[:notice] = l(:notice_successful_create) call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) redirect_to(params[:continue] ? { :action => 'my_new', :project_id=>@issue.project.identifier,:related_to=>params[:related_to],:do_copy=>true } : { :action => 'show', :id => @issue }) else render :template => 'issues/new' end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def watchers\n attributes.fetch(:watchers)\n end", "def watch_method; end", "def watch\n\nend", "def watchable_dirs; end", "def watched_by(watcher = nil)\n return @watched_by if watcher.nil?\n\n @watched_by ||= []\n @watched_by << watcher\n end", "def generate_watcher_wi...
[ "0.71828854", "0.64245164", "0.6347246", "0.61721164", "0.61286765", "0.61049944", "0.60550505", "0.59811825", "0.5979953", "0.5979953", "0.5947669", "0.5905763", "0.5905763", "0.5850323", "0.5817032", "0.5803103", "0.57882905", "0.5779259", "0.57619643", "0.5744881", "0.5738...
0.0
-1
Return items with a complete date same or older than from_date (formated as "2007429T10:13").
def getCompletedItemsByDate(project_id, from_date) request_url = create_url('getAllCompletedItems', {:token => @@config['todoist']['token'], :project_id => project_id, :from_date => from_date}) api_request(request_url) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def date_range(items, from, to)\n\n date_range_items = items.reject{ |item| item[\"date\"] < from }\n date_range_items.reject!{ |item| item[\"date\"] > to }\n\n return date_range_items\nend", "def items_since(date_time, opts = {})\n opts = opts.clone\n unless date_time.kind_of?(Date)\n ra...
[ "0.6576936", "0.63007635", "0.59978133", "0.5767318", "0.5766619", "0.57588387", "0.5736041", "0.5687605", "0.56770444", "0.56217295", "0.55575997", "0.5540428", "0.54951453", "0.5494607", "0.5494607", "0.54418206", "0.54342544", "0.5402746", "0.5388399", "0.53327453", "0.531...
0.6280103
2
The raw properties of the model. Most properties defined through the `property` class method will have getters/setters that will do the appropriate translation so this should in cases when you need access to the raw properties or there is not a property accessors defined.
def properties @properties ||= {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_properties\n parse_raw_map descriptor.values\n end", "def properties\n model.properties\n end", "def values_for_properties; end", "def properties\n raw.reject { |k, _| RESERVED_PROPERTIES.include? k }\n end", "def property_properties\n _property_properties\n end", "def...
[ "0.7643371", "0.76151526", "0.7023259", "0.69944996", "0.6918836", "0.6821271", "0.6753919", "0.659358", "0.65928555", "0.6590658", "0.65843415", "0.6579406", "0.65384275", "0.65044796", "0.64825994", "0.6467597", "0.6452382", "0.6401639", "0.62848336", "0.62607384", "0.62566...
0.58217925
54
Defines the subproperties defined within the property. This is to be used internally by the property method.
def _sub_property(name,options={},&block) # Use the name as the property type if one has not been provided. property_type = options[:type] || name property_class = Model::Property.property(property_type) parents = Array(options[:parents]) method_name = name if options[:prefix] method_name = (parents + [name]).join("_") end # Define a getter for the sub-property that will traverse the # parent properties, finally returning the filtered value define_method method_name do raw_value = (parents + [name]).inject(self) {|current,method| current.send(method) } property_class.new(self,options).get raw_value end # Define a setter for the sub-property that will find the parent # value and set itself on that with the filtered value. The parent # is then set. # # @TODO: If getters return dups and not instances of the original object then a very # deep setter will not be valid. # define_method "#{method_name}=" do |value| parent_value = parents.inject(self) {|current,method| current.send(method) } prepared_value = property_class.new(self,options,&block).set(value) parent_value.send("#{name}=",prepared_value) send("#{parents.last}=",parent_value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expand_properties\n @properties.each do |key,value|\n value.expand_to_element self\n end\n end", "def after_initialize(substructs)\n @subprop = Props.singular_from(key, spec, substructs)\n end", "def rdfs_sub_property_of\n end", "def properties\n super\n end...
[ "0.64515704", "0.63234204", "0.63146913", "0.61650324", "0.61326045", "0.61088467", "0.60887897", "0.5969749", "0.59515834", "0.59515834", "0.59515834", "0.59515834", "0.59515834", "0.59515834", "0.59515834", "0.59515834", "0.5947813", "0.59422886", "0.5826531", "0.5794513", ...
0.6926592
0
enum item_type: [:share, :post, :comment]
def count_likes self.likers(Profile).length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def item_type_with_status_code\n :thesis\n end", "def item_type_as_uri\n code = ITEM_TYPE_TO_URI_CODE.fetch(type.name.to_sym)\n ControlledVocabulary.era.item_type.from_value(code)\n end", "def item_type_as_uri\n code = ITEM_TYPE_TO_URI_CODE.fetch(type.name.to_sym)\n CONTROLLED_VOCABULARIES[:it...
[ "0.6680657", "0.64458567", "0.6353462", "0.63259065", "0.62961245", "0.62477463", "0.62477463", "0.6186829", "0.61459136", "0.61341035", "0.61341035", "0.6075176", "0.60631835", "0.5967191", "0.59436107", "0.58957857", "0.5860044", "0.5841655", "0.5836168", "0.58116424", "0.5...
0.0
-1
GET /contacts GET /contacts.json
def index session[:ppage] = (params[:per_page].to_i rescue 25) if (params[:per_page] && (not params[:per_page.blank?] ) ) @per_page = session[:ppage].to_s params[:ppage] = session[:ppage] if params[:member_query].present? @contacts = Contact.where("first_name LIKE ? OR last_name LIKE ? OR company LIKE ?", "%#{params[:member_query]}%", "%#{params[:member_query]}%", "%#{params[:member_query]}%") elsif params[:tag] @contacts = Contact.search(params).tagged_with(params[:tag]).page(params[:page]).per(session[:ppage]) else @contacts = Contact.search(params) end params.delete :ppage params.delete :per_page @q = params[:query].present? respond_to do |format| format.html # index.html.erb format.json { render json: @contacts.map{ |c| {id: c.id, text: c.to_label} } } # format.json { render json: @contacts.map{ |c| {id: c.id, text: {company: c.company, first_name: c.first_name, last_name: c.last_name } } } } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_contacts(options = {})\n send_request(\"get\", contacts_url, body: options.to_json)\n end", "def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end", "def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Ent...
[ "0.80651945", "0.7942857", "0.78436047", "0.7802116", "0.77277195", "0.76782286", "0.7592066", "0.74919254", "0.7467012", "0.73504406", "0.7329629", "0.73074734", "0.71978635", "0.71872765", "0.71866214", "0.7176661", "0.7168481", "0.71074116", "0.71074116", "0.7098688", "0.7...
0.0
-1
GET /contacts/1 GET /contacts/1.json
def show @contact = Contact.find(params[:id]) @contact.update_attribute(:is_active, false) if params[:deactivate].present? @contact.update_attribute(:is_active, true) if params[:activate].present? @class = @contact.is_active ? "btn" : "btn disabled" @next_contact = @contact.next_company @previous_contact = @contact.previous @members = @contact.members respond_to do |format| format.html # show.html.erb format.json { render json: @contact } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @contact = Contact.find(params[:id])\n\n render json: @contact\n end", "def index\n @contacts = Contact.all\n render json: @contacts\n end", "def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n en...
[ "0.7591177", "0.7570335", "0.75499505", "0.75394666", "0.7465594", "0.7329576", "0.73102534", "0.73102534", "0.73102534", "0.72869056", "0.72569484", "0.717351", "0.71114993", "0.7110642", "0.7110637", "0.71082646", "0.71082646", "0.7104926", "0.70934457", "0.7064881", "0.703...
0.0
-1
GET /contacts/new GET /contacts/new.json
def new if params[:member].present? && params[:member].respond_to?(:to_i) # prefill new form with member's data if @member = Member.find(params[:member]) @contact = Contact.new( company: @member.company, country: @member.country, address: @member.address, city: @member.city, postal_code: @member.postal_code, is_ceres_member: true, ) tag_list = @member.activity_list + @member.brand_list tag_list << "member" @contact.tag_list = tag_list.join(',') end end @contact ||= Contact.new @contact.emails.new respond_to do |format| format.html # new.html.erb format.json { render json: @contact } format.js { render template: 'contacts/new' } end # { render partial: "new" } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n\t\t\t\t# we are going to make a new contact yall\n\t\t\t\t# comes in like post\n\t\t\t\t# {'api_token': ..., 'contact': {}}\n\t\t\t\tcontact_params = params[:contact] # be sure to clean all the values\n\t\t\t\t# clean them up\n\t\t\t\tcontact_params = sanitize_obj(contact_params);\n\t\t\t\t# lets allow r...
[ "0.8190311", "0.8123517", "0.81170475", "0.81170475", "0.81170475", "0.81112355", "0.77553016", "0.77533853", "0.77522177", "0.76952493", "0.7669983", "0.7557285", "0.754991", "0.754585", "0.7476001", "0.7439166", "0.739486", "0.73695564", "0.73318654", "0.7313931", "0.730400...
0.6770083
96
POST /contacts POST /contacts.json
def create flash.clear begin @contact = Contact.new(params[:contact]) @contact.update_attribute(:user_id, current_user.id) rescue ActiveRecord::RecordNotUnique => e if e.message =~ /for key 'index_emails_on_address'/ email = e.message.scan(/Duplicate entry '(.*)' for key 'index_emails_on_address'.*/).flatten.first err = ["the email address <strong>'#{email.html_safe}'</strong>", "Check the emails fields"] else company = params[:contact][:company] || "ERROR" country = params[:contact][:country] || "ERROR" err = ["the company <strong>\"#{company.html_safe}\"</strong> in the country: <strong>\"#{country.html_safe}\"</strong>", "Check the company, country, address and first name fields"] end flash[:error] = <<EOL <h3>An error prevented the reccord from being saved (duplicate entry):</h3> Sorry, #{err.first.html_safe} already exists in the database. Please take one of the following action: <ul> <li>#{err.last.html_safe}</li> <li>Do not create the contact, but find and update the already existing company using the search form on the main contact page</li> </ul> EOL #flash[:error] += e.message end respond_to do |format| if @contact.save format.html { redirect_to contacts_path, notice: 'Contact was successfully created.' } format.json { render json: @contact, status: :created, location: @contact } format.js { render template: 'contacts/ajax_new_contact_success' } else @email_error = "error" if @contact.errors.full_messages.map{|m| m if(m =~ /email/i)}.size > 0 format.html { render action: "new" } format.json { render json: @contact.errors, status: :unprocessable_entity } format.js { render template: 'contacts/_form' } #format.js { render template: 'contacts/new' } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @contact = Contact.create!(contact_params)\n render json: Contact.all\n end", "def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end", "def ...
[ "0.75767535", "0.7489912", "0.73792636", "0.72857213", "0.71954143", "0.7163311", "0.71241444", "0.70903546", "0.7083217", "0.7067553", "0.7018867", "0.7013148", "0.6966274", "0.69249797", "0.69042265", "0.6890879", "0.68734777", "0.686979", "0.6859895", "0.6859895", "0.68598...
0.0
-1
PUT /contacts/1 PUT /contacts/1.json
def update flash.clear begin @contact = Contact.find(params[:id]) @contact.update_attribute(:updated_by, current_user.id) rescue ActiveRecord::RecordNotUnique => e if e.message =~ /for key 'index_emails_on_address'/ email = e.message.scan(/Duplicate entry '(.*)' for key 'index_emails_on_address'.*/).flatten.first err = ["the email address <strong>'#{h(email)}'</strong>", "Check the emails fields"] else company = params[:contact][:company] || "ERROR" country = params[:contact][:country] || "ERROR" err = ["the company <strong>\"#{h(company)}\"</strong> in the country: <strong>\"#{h(country)}\"</strong>", "Check the company, country, address and first name fields"] end flash[:error] = <<EOL <h3>An error prevented the reccord from being saved (duplicate entry):</h3> Sorry, #{h(err.first)} already exists in the database. Please take one of the following action: <ul> <li>#{h(err.last)}</li> <li>Do not create the contact, but find and update the already existing company using the search form on the main contact page</li> </ul> EOL end respond_to do |format| if @contact.update_attributes(params[:contact]) format.html { redirect_to @contact, notice: 'Contact was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @contact.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @contact.update(contact_params)\n if @contact.valid?\n render json: @contact\n end\n end", "def update\n @contact = Contact.find(params[:id])\n\n if @contact.update(contact_params)\n head :no_content\n else\n render json: @contact.errors, status: :unprocessable_enti...
[ "0.7083288", "0.6872176", "0.683562", "0.6818696", "0.6800965", "0.67988575", "0.67340034", "0.6720967", "0.66919476", "0.6639441", "0.6538753", "0.6531414", "0.6530904", "0.6530904", "0.6530904", "0.6500032", "0.64603335", "0.6456804", "0.64495784", "0.6442254", "0.6433381",...
0.0
-1
DELETE /contacts/1 DELETE /contacts/1.json
def destroy @contact = Contact.find(params[:id]) @contact.destroy #@contact.version respond_to do |format| format.html { redirect_to contacts_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @contact.destroy\n render json: {status: 204}\n end", "def delete(contactname)\n\n end", "def destroy\n @contact.destroy\n #Contact.delete(@contact.id)\n respond_to do |format|\n format.html { redirect_to contacts_path }\n format.json { head :no_content }\n end\n en...
[ "0.7692505", "0.7681699", "0.76096106", "0.75455976", "0.75426126", "0.75426126", "0.75426126", "0.75274014", "0.75274014", "0.75274014", "0.75274014", "0.7427848", "0.74231184", "0.74073875", "0.739963", "0.7388033", "0.73524195", "0.7331634", "0.7321653", "0.73016405", "0.7...
0.75637853
3
== Instance Methods =====================================================
def initialize(hostname: nil, process_name: nil, process_id: nil, config: nil) @hostname = (hostname || Skein::Support.hostname).dup.freeze @process_name = (process_name || Skein::Support.process_name).dup.freeze @process_id = process_id || Skein::Support.process_id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def initialize\n\t\t\n\tend", "def initialize\n \n end", "def initialize\n\n end", "def initialize\n\n end", "def initialize\r\n\r\n end", "def implementation; end", "def implementation; end", "def initialize\n end", "def initialize\n end", "def initialize\n ...
[ "0.84468544", "0.73226625", "0.7320286", "0.72967416", "0.72967416", "0.72934955", "0.72732323", "0.72732323", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7219184", "0.7161583", "0.71429914", "0.71429...
0.0
-1
that the Anagram class instances are initialized with.
def initialize(word) @word = word end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize() end", "def initialize #everytie an instance of the class is initialized, we should push it into the @@all class variable\n @@all << self\n end", "def init; end", "def init; end", "def init; end", "def init; end", "def initialize\n \n end", "def initialize\n\n\n\n end", "...
[ "0.6415561", "0.63226426", "0.63114786", "0.63114786", "0.63114786", "0.63114786", "0.6220704", "0.6202926", "0.61893225", "0.61893225", "0.61893225", "0.61893225", "0.61893225", "0.61893225", "0.61893225", "0.61893225", "0.61893225", "0.61893225", "0.61893225", "0.6155215", ...
0.0
-1
.match method takes as an argument.
def match(words) #iterate over the array of words that the .match method takes as an argument. words.select do |word| is_anagram?(word) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match; end", "def match; end", "def match()\n end", "def match(pattern); end", "def match(input); end", "def match(object); end", "def match\n @match\n end", "def match(p0) end", "def match(p0) end", "def match(input)\n input \n end", "def fnmatch(matcher); end", ...
[ "0.8714407", "0.8714407", "0.8371531", "0.8289826", "0.79871196", "0.7980303", "0.79598165", "0.790672", "0.790672", "0.77766216", "0.7757385", "0.7698637", "0.76869893", "0.7647631", "0.7568722", "0.74865603", "0.7474755", "0.74712574", "0.74712574", "0.74395514", "0.7331568...
0.0
-1
to determine if they are anagrams
def is_anagram?(word) #try determining if they are composed of the same letters. word.chars.sort == @word.chars.sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def are_anagrams?(word1, word2)\n #si las palabras son anagramas regresa true de lo contrario regresa false\n if canonical(word1) == canonical(word2) then true else false end\nend", "def anagrams?\n same_length? && same_letters?\n end", "def are_anagrams?\n # for all inputs, split them to an array, ...
[ "0.86278135", "0.8551276", "0.8496614", "0.8438184", "0.8392096", "0.8358835", "0.8358835", "0.8282224", "0.82696205", "0.82038707", "0.82038707", "0.82038707", "0.8197356", "0.8197356", "0.81606495", "0.8128256", "0.8106987", "0.8103522", "0.8010302", "0.79641", "0.79266214"...
0.7913934
21
Check if number is between one and one million.
def in_range? self > LOWER_BOUND && self <= UPPER_BOUND end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def divisible_by_thousand?(number)\n (number % 1000).zero?\n end", "def is_number_valid?(n)\n puts n\n # RANGE.detect {|i| !is_whole?(n.to_f / i)}.nil?\n i = 1\n i += 1 until !is_whole?(n.to_f / i)\n i >= MAX\nend", "def millionaire?\n money >= 1000000\n end", "def millionaire?\n money >=...
[ "0.69953823", "0.6470193", "0.64601094", "0.64601094", "0.6333098", "0.6333098", "0.6274078", "0.62428266", "0.61445045", "0.61111104", "0.6035338", "0.58856285", "0.5883114", "0.5868128", "0.5841467", "0.58321404", "0.57886606", "0.5753372", "0.5745058", "0.57434696", "0.572...
0.0
-1
If the number is a unique value, take directly from the WORDS hash
def in_a_word WORDS[self] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash_this(word)\n\t\tdigest = Digest::MD5.hexdigest(word) # get the hex version of the MD5 for the specified string\n\t\tdigest[@offset, @digits].to_i(16) % @max_value # offset it using the initial seed value and get a subset of the md5. then modulo it to get the bit array location\n\tend", "def addto_bloom_...
[ "0.7025198", "0.6351763", "0.6279677", "0.627818", "0.6087955", "0.60358316", "0.6002247", "0.5988607", "0.59753984", "0.5970024", "0.5955865", "0.59552854", "0.59482825", "0.5940922", "0.59222275", "0.59121495", "0.5887415", "0.5882733", "0.58773196", "0.5859284", "0.5842261...
0.0
-1
Check if the number is round a multiple of a magnitude If it is not, then
def in_many_words (self % magnitude == 0) ? multiple_of_magnitude_in_words : long_number_in_words end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def magnitude?\n self.units.reject{|d,(u,m)| m==0}.empty?\n end", "def spans_magnitudes?(base = 10)\n\t\treturn magnitudes_spanned.length > 1\n\tend", "def round_to_mag(mag)\n round(-Math.log10(mag).to_i)\n end", "def normal?\n magnitude == 1\n end", "def is_mag?(); @type == GRT_MAG; end", ...
[ "0.6814291", "0.66247165", "0.6450703", "0.63204795", "0.61712724", "0.60857534", "0.59635055", "0.5762887", "0.57513833", "0.5705745", "0.56572396", "0.5647944", "0.56410563", "0.56392175", "0.5632009", "0.5608561", "0.55770534", "0.5573868", "0.5569861", "0.5554504", "0.553...
0.0
-1
Order of magnitude followed but the magnitude word. The reason I have monkeypatched Fixnum is so that I can use in_words recursively E.g. (four thousand) (three hundred) = 2 recursions
def multiple_of_magnitude_in_words [(self / magnitude).in_words, magnitude_word].join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_many_words\n (self % magnitude == 0) ? multiple_of_magnitude_in_words : long_number_in_words\n end", "def long_number_in_words\n magnitude_part_and_remainder.map(&:in_words).join(magnitude_separator)\n end", "def determine_how_many(number, unit)\n\t(number / unit).in_words\nend", "def in_words...
[ "0.72951955", "0.7086413", "0.64792067", "0.6348274", "0.6212318", "0.61973405", "0.6161614", "0.6129737", "0.61043316", "0.6069532", "0.60280067", "0.60140646", "0.60066545", "0.5977474", "0.595645", "0.59549135", "0.58977556", "0.58915603", "0.5852429", "0.58389187", "0.579...
0.64726514
3
E.g. (four thousand) (three hundred) and (twenty) (two) = 4 recursions
def long_number_in_words magnitude_part_and_remainder.map(&:in_words).join(magnitude_separator) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_2_words(n)\n w2n = {\n 90 => \"ninety\",\n 80 => \"eighty\",\n 70 => \"seventy\",\n 60 => \"sixty\",\n 50 => \"fifty\",\n 40 => \"forty\",\n 30 => \"thirty\",\n 20 => \"twenty\",\n 19=>\"nineteen\",\n 18=>\"eighteen\",\n 17=>\"seventeen\", \n 16=>\"sixteen\",\n 15...
[ "0.6688314", "0.6649548", "0.66257864", "0.66257733", "0.6620425", "0.6537254", "0.6492264", "0.6400371", "0.63966334", "0.6374942", "0.6353154", "0.63303083", "0.63152623", "0.62785393", "0.6270775", "0.62648404", "0.62617785", "0.62433445", "0.624092", "0.6237739", "0.62325...
0.0
-1
Returns an array containing the order of magnitude and remainder.
def magnitude_part_and_remainder quotient, remainder = self.divmod(magnitude) [magnitude * quotient, remainder] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_a\n [modulus, exponent]\n end", "def magnitude\r\n data.map do |f|\r\n f.abs\r\n end\r\n end", "def toDigArray(prec = 100)\n localNum = @num.abs\n a = Array.new\n prec.times{\n a.push((localNum/@den))\n localNum = (localNum*10) % (@den*10)\n }\...
[ "0.6462871", "0.5927493", "0.5814527", "0.5564099", "0.5501972", "0.5474128", "0.5439172", "0.5424581", "0.52766985", "0.52552253", "0.52552253", "0.5253803", "0.5250525", "0.5197591", "0.5176821", "0.5137328", "0.5100174", "0.50642294", "0.50533175", "0.50530905", "0.5051025...
0.76576054
0
Lookup the magnitude if it is a unique word
def magnitude_word MAGNITUDE[magnitude] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiple_of_magnitude_in_words\n [(self / magnitude).in_words, magnitude_word].join(' ')\n end", "def in_many_words\n (self % magnitude == 0) ? multiple_of_magnitude_in_words : long_number_in_words\n end", "def magnitude\n\t\tt = 0.0\n\t\tsize.times do |k|\n\t\t\tt += __get(k).abs2\n\t\tend\n\t\tre...
[ "0.6588338", "0.6268873", "0.6069634", "0.5952392", "0.58932936", "0.58567536", "0.5839087", "0.57419765", "0.5676223", "0.5659248", "0.56214094", "0.55590844", "0.54526013", "0.5442189", "0.5427385", "0.5425869", "0.5401327", "0.5370157", "0.5344786", "0.534125", "0.5338456"...
0.78723234
0
Calculate the order of magnitude, e.g.
def magnitude return 1000 if (4..6).include?(digits) 10 ** (digits - 1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def magnitude\n\t\tt = 0.0\n\t\tsize.times do |k|\n\t\t\tt += __get(k).abs2\n\t\tend\n\t\treturn Math.sqrt(t)\n\tend", "def magnitude()\n _nrm2()\n end", "def magnitude\n Math.sqrt self.dot self\n end", "def magnitude; Math.sqrt x*x + y*y + z*z; end", "def magnitude\n Math.sqrt(@x ** 2...
[ "0.7594579", "0.75189215", "0.7459613", "0.72923094", "0.69101954", "0.6474867", "0.6327645", "0.6237148", "0.6237148", "0.60989684", "0.6074637", "0.59316695", "0.5913515", "0.58520955", "0.5815988", "0.5744043", "0.57067424", "0.5638169", "0.56250817", "0.5582605", "0.55524...
0.6853368
5
Choose the correct separator between words
def magnitude_separator (remainder(magnitude) < 100 && magnitude > 10) ? ' and ' : ' ' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_words_sep(token)\n log \"WORDS_SEP: '#{token}'\"\n super(token)\n end", "def seperate(word, seperator=\"-\")\n word.downcase.split(\"\").join(seperator)\nend", "def sep; end", "def sep; end", "def separator; end", "def default_separator; end", "def separator(text)\n puts '--%s' % ...
[ "0.7225735", "0.7151582", "0.6807083", "0.6807083", "0.67656404", "0.6759258", "0.67555016", "0.66517323", "0.65861225", "0.65599555", "0.6493759", "0.6458781", "0.63245493", "0.6202016", "0.6202016", "0.6173103", "0.614371", "0.6121153", "0.61147636", "0.60979944", "0.609490...
0.0
-1
Creates and initalizes a new instance of StringTokenProvider class.
def initialize(token, token_type = TokenCredentials::DEFAULT_SCHEME) @token = token @token_type = token_type end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @tokens = {}\n @regex_tokens = []\n @string_tokens = []\n @tokens_by_string = {}\n end", "def initialize(*args)\n if (args.size == 1)\n if args[0].respond_to? :get_authentication_header\n @token_provider = args[0]\n elsif args[0].is_a? String\n ...
[ "0.6553414", "0.6123475", "0.59777033", "0.59777033", "0.59777033", "0.59495884", "0.5924863", "0.59215087", "0.5889612", "0.5870009", "0.58653843", "0.58386046", "0.5786164", "0.5777745", "0.57513726", "0.57511866", "0.5747561", "0.57245106", "0.5705312", "0.56790423", "0.56...
0.51722085
81
Returns the string value which needs to be attached to HTTP request header in order to be authorized.
def get_authentication_header "#{token_type} #{token}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth_header\n # headers: { 'Authorization': 'Bearer <token>' }\n\n request.headers['Authorization']\n # => 'Bearer <token>'\n end", "def auth_header\n request.headers['Authorization']\n end", "def auth_header\n\t\t# { Authorization: 'Bearer <token>' }\n\t\trequest.headers['Authori...
[ "0.73940784", "0.72496825", "0.7240007", "0.72114575", "0.7171801", "0.71541965", "0.71541965", "0.71536463", "0.7013966", "0.6953349", "0.6912637", "0.68860185", "0.6785362", "0.67773914", "0.67727166", "0.67509466", "0.67461044", "0.67419046", "0.673874", "0.6724939", "0.67...
0.713994
8
Extract the filter and query information from parameters `filter` and `q` respectively, and execute query based on the information.
def search(params) filter_name, keywords, field_queries = extract params scope = filtered_by filter_name query = text_search keywords query = field_search field_queries, query scope.where query end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter\n @filter = params[:q]\n end", "def execute(filter, *command)\n Execute.new(command, options.merge(filter: filter)).execute\n end", "def run_query()\n return nil unless @query\n \n gres = @query.execute()\n if @filterClass \n fres = @filterC...
[ "0.66038334", "0.65676904", "0.65497786", "0.64555734", "0.64122593", "0.6355065", "0.6345333", "0.6283308", "0.6283308", "0.6187431", "0.6152321", "0.61311305", "0.6090849", "0.60815334", "0.60796994", "0.604885", "0.60269856", "0.597129", "0.5962209", "0.5939392", "0.588311...
0.5780555
27
Use the filter name to find out the scope in the following precedents: scope from metadata defined scope from the model unscoped
def filtered_by(filter_name) valid_filter_name = FilterUtils.filter_name_by(filter_name, @model_decorator.filters) scope = find_scope(valid_filter_name) if scope.blank? then unscoped elsif scope.is_a?(Proc) then @model_class.instance_exec(&scope) elsif @model_class.respond_to?(scope) @model_class.public_send(scope) else unscoped end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_scope(filter_name)\n @model_decorator.filters[filter_name].try(:[], :scope) || filter_name\n end", "def custom_filters(scope)\n scope\n end", "def acceptable_filter_scopes\n []\n end", "def scope_name; end", "def create_with_scope(name)\n attribute = self.attribute...
[ "0.80286807", "0.7418236", "0.686089", "0.6843585", "0.6752379", "0.66588116", "0.6551079", "0.6475828", "0.6448436", "0.64326864", "0.6420664", "0.6415839", "0.63692254", "0.63686305", "0.63255054", "0.62878114", "0.6241838", "0.62124884", "0.6146484", "0.6146484", "0.614083...
0.7530053
1
Find out the scope for given filter from filter metadata filter name itself
def find_scope(filter_name) @model_decorator.filters[filter_name].try(:[], :scope) || filter_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_filters(scope)\n scope\n end", "def scope\n parameter[:scope]\n end", "def scope_name; end", "def scope_name scope\n\t\traise \"No data-source set\" unless data_source\n\t\tdata_source.scopes.get(scope).human_name\n\tend", "def filtered_by(filter_name)\n valid_filter_nam...
[ "0.6897154", "0.6436115", "0.63479936", "0.63391876", "0.6305942", "0.6299014", "0.6224828", "0.6186677", "0.61631715", "0.6112945", "0.60791975", "0.60603124", "0.5953366", "0.5942579", "0.5861283", "0.585909", "0.58550096", "0.58421206", "0.58288914", "0.5795212", "0.577958...
0.7825267
0
Perform SQL query for the colon query (e.g. data:<20000101)
def field_search(field_queries, query) return query unless field_check? field_queries field_queries.each do |exps| sub_queries = build_sub_queries_with exps query = query.try(:and, sub_queries) || sub_queries end query end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ascii_query(sql,*values)\n sth = self.query(sql,*values)\n rows = sth.fetch_all\n col_names = sth.column_names\n sth.finish\n DBI::Utils::TableFormatter.ascii(col_names, rows)\n end", "def db2disco_parse(data)\n\t\tres = data.split(\"\\x00\")\n\t\t\"#{res[2]}_#{res[1]}\"\n\tend", ...
[ "0.5320157", "0.5265041", "0.51484454", "0.5121216", "0.5067743", "0.5026352", "0.5006725", "0.4993116", "0.49146104", "0.48950568", "0.48830947", "0.48820555", "0.48777258", "0.48658848", "0.4847628", "0.4847628", "0.48472512", "0.4846992", "0.48378566", "0.48337686", "0.481...
0.0
-1
Convert Gem to RPM. Parameter _os_ should correspond the operating system for which the _specfile_ was generated.
def gem2rpm(os, specfile, options = {}) @logger.info('Gem->RPM: Start!') begin gem = packages.detect { |package| package.type == 'gem' } raise 'Library has no gem package!' if gem.nil? build_dir = Helpers.mkdir_anonymous begin gemspec = gem.lock { Gem::Format.from_file_by_path(gem.file).spec } gemfile = "#{build_dir}/#{gemspec.file_name}" gem.lock { FileUtils.cp(gem.file, gemfile) } specfile_path = "#{build_dir}/rubygem-#{gemspec.name}.spec" File.open(specfile_path, 'w') { |f| f.write(specfile.content) } @logger.info('Gem->RPM: Success! (needs to be built now)') async_build_and_rebuild(gem, os, build_dir, options) rescue => ex FileUtils.rm_rf(build_dir) raise ex end log("Build requested. (#{os}, source)") rescue => ex @logger.error("Gem->RPM: Failure! #{ex.to_s}") raise ex end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rpm2gem(os, options = {})\n @logger.info('RPM->Gem: Start!')\n begin\n rpms = packages.select do |p|\n [Package::SRPM, Package::RPM].include?(p.type) &&\n Rpm2Gem::Rpm.os(p.file) == os\n end\n \n raise 'There are no satisfying RPM packages!' if rpms.empty...
[ "0.7607559", "0.70946497", "0.6570776", "0.62558925", "0.61680454", "0.5891139", "0.5773106", "0.5697332", "0.5679053", "0.5605558", "0.54128194", "0.51890045", "0.51535743", "0.50862855", "0.5052955", "0.5027256", "0.5006127", "0.4991754", "0.4987004", "0.4973313", "0.496292...
0.8136115
0
Convert RPMs to Gem. Parameter _os_ serves as an identification for RPMs which should be used as the source in the conversion process (as there may be RPMs present for numerous operating systems).
def rpm2gem(os, options = {}) @logger.info('RPM->Gem: Start!') begin rpms = packages.select do |p| [Package::SRPM, Package::RPM].include?(p.type) && Rpm2Gem::Rpm.os(p.file) == os end raise 'There are no satisfying RPM packages!' if rpms.empty? if rpms.select{ |p| p.type == 'rpm' }.empty? raise 'There are no binary RPM packages!' end files = rpms.map { |p| p.lock { Helpers.cp_anonymous(p.file) } } result_dir = Helpers.mkdir_anonymous begin IO.popen("cd #{result_dir} && " \ "rpm2gem --verbose #{files.join(' ')} 2>&1") { |p| p.each { |l| @logger.info("RPM->Gem: rpm2gem script: #{l.chomp}") }} raise 'Conversion failed!' if not $?.success? gemfile = Helpers.cp_anonymous(Dir.glob("#{result_dir}/*.gem").first) ensure files.each { |f| FileUtils.rm_f(f) } FileUtils.rm_rf(result_dir) end gem = Package.create(:type => 'gem', :file => gemfile, :generated => true, :force => options[:force] || false) rpms.each { |p| p.children.push(gem) } packages.push(gem) @logger.info('RPM->Gem: Success!') log("RPM->Gem conversion <g>succeeded</g>! (#{os})") rescue Repository::NameConflictError => ex @logger.error("RPM->Gem: Halted, package already exists! (#{ex.to_s})") log("RPM->Gem conversion <y>halted</y>! (#{os})") raise ex rescue => ex @logger.error("RPM->Gem: Failure! #{ex.to_s}") log("RPM->Gem conversion <r>failed</r>! (#{os})") raise ex end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gem2rpm(os, specfile, options = {})\n @logger.info('Gem->RPM: Start!')\n begin\n gem = packages.detect { |package| package.type == 'gem' }\n raise 'Library has no gem package!' if gem.nil?\n build_dir = Helpers.mkdir_anonymous\n \n begin\n gemspec = gem.loc...
[ "0.74582195", "0.6575125", "0.62877285", "0.57933027", "0.56323844", "0.5607909", "0.55365205", "0.5491153", "0.5356362", "0.5355025", "0.53310305", "0.52396554", "0.51395154", "0.5133172", "0.5128928", "0.5105103", "0.50759757", "0.5026731", "0.5024137", "0.5019028", "0.5011...
0.82049596
0
Build SRPM package using a given build directory (parameter build_dir) that contains the specfile, as well as all its source files. Parameter _gem_ is used to identify the Gem package, from which the SRPM is being built (for further reference). Parameter _os_ is the target operating system of the resulting SRPM. Possible options are: :force whether resulting package should override an existing one. :continue this should be only used if _rebuild is called immediately after (on the SRPM that results from this operation, and within the same process). The purpose of this is to avoid the need to create the same Mock environment twice, first for _build (SRPM) and then for _rebuild (binary RPMs). :arch should be used only with :continue, and should be the same as the _arch_ used on _rebuild.
def build(gem, os, build_dir, options = {}) @logger.info('Build: Start!') begin #build (Mock) specfile_path = Dir.glob("#{build_dir}/*.spec").first result_dir = Helpers.mkdir_anonymous begin @logger.info('Build: Starting Mock!') IO.popen("mock --root #{Helpers.mock_config(os)} \ --resultdir #{result_dir} \ --uniqueext #{$$} \ #{options[:continue] ? "--no-cleanup-after --arch #{options[:arch]}" : ""} \ --buildsrpm \ --spec #{specfile_path} \ --sources #{build_dir} 2>&1"){|o| o.each{|l| print l}} mock_id = incr :_mock_logs_id FileUtils.mkdir_p("#{logdir}/#{mock_id}") FileUtils.mv(Dir.glob("#{result_dir}/*.log"), "#{logdir}/#{mock_id}") raise "Mock failed! (logs id: #{mock_id})" if not $?.success? @logger.info("Build: Mock build ok! (logs id: #{mock_id})") file = Helpers.cp_anonymous(Dir.glob("#{result_dir}/*.src.rpm").first) ensure FileUtils.rm_rf(result_dir) end #update entities (database) srpm = Package.create(:type => Package::SRPM, :file => file, :generated => true, :force => options[:force] || false) gem.children.push(srpm) packages.push(srpm) @logger.info('Build: Success!') log("Build <g>succeeded</g>! (#{os}, source)") rescue Repository::NameConflictError => ex @logger.error("Build: Halted, package already exists! (#{ex.to_s})") log("Build <y>halted</y>! (#{os}, source) Package already exists!") raise ex rescue => ex @logger.error("Build: Failure! #{ex.to_s}") log("Build <r>failed</r>! (#{os}, source)") raise ex ensure FileUtils.rm_rf(build_dir) end srpm end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_and_rebuild(gem, os, build_dir, options = {})\n srpm = build(gem, os, build_dir, options.merge(:continue => true,\n :arch => ARCH.first))\n \n noarch = srpm.lock { Rpm2Gem::Rpm.noarch?(srpm.file) }\n if not noarch\n #build for...
[ "0.80240136", "0.6658952", "0.594528", "0.5889154", "0.5832288", "0.58006924", "0.5799651", "0.5762359", "0.56580913", "0.56167454", "0.5390865", "0.53607404", "0.5341759", "0.5311082", "0.5179387", "0.5170325", "0.5137394", "0.5137208", "0.5080961", "0.50595313", "0.50448924...
0.8096845
0
Rebuild the specified SRPM. This creates binary RPMs. Parameter _arch_ is the CPU architecture which the resulting RPMs should target. Possible options include :force and :continue. See _build for explanation.
def rebuild(srpm, arch, options = {}) @logger.info('Rebuild: Start!') begin file = srpm.lock { Helpers.cp_anonymous(srpm.file) } result_dir = Helpers.mkdir_anonymous begin os = Rpm2Gem::Rpm.os(file) config = Helpers.mock_config(os, arch) #rebuild (Mock) @logger.info('Rebuild: Starting Mock!') IO.popen("mock --root #{config} \ --arch #{arch} \ --resultdir #{result_dir} \ --uniqueext #{$$} \ #{options[:continue] ? '--no-clean' : ''} \ --rebuild #{file} 2>&1"){|o| o.each{|l| print l}} mock_id = incr :_mock_logs_id FileUtils.mkdir_p("#{logdir}/#{mock_id}") FileUtils.mv(Dir.glob("#{result_dir}/*.log"), "#{logdir}/#{mock_id}") raise "Mock failed! (logs id: #{mock_id})" if not $?.success? @logger.info("Rebuild: Mock build ok! (logs id: #{mock_id})") files = Dir.glob("#{result_dir}/*.rpm").select {|f| !f.end_with?('.src.rpm')} files.map! { |f| Helpers.cp_anonymous(f) } ensure FileUtils.rm_f(file) FileUtils.rm_rf(result_dir) end #update entities (database) failed = 0 files.each do |file| begin rpm = Package.create(:type => 'rpm', :file => file, :generated => true, :force => options[:force] || false) srpm.children.push(rpm) packages.push(rpm) rescue Repository::NameConflictError => ex @logger.error("Build: Warning, package already exists! #{ex.to_s}") failed += 1 end end @logger.info('Rebuild: Success!') if failed == 0 log("Build <g>succeeded</g>! (#{os}, #{arch})") else log("Build <y>succeeded</y>! (#{os}, #{arch})") end rescue => ex @logger.error("Rebuild: Failure! #{ex.to_s}") log("Build <r>failed</r>! (#{os}, #{arch})") raise ex end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_and_rebuild(gem, os, build_dir, options = {})\n srpm = build(gem, os, build_dir, options.merge(:continue => true,\n :arch => ARCH.first))\n \n noarch = srpm.lock { Rpm2Gem::Rpm.noarch?(srpm.file) }\n if not noarch\n #build for...
[ "0.63811773", "0.6308533", "0.6173001", "0.60220003", "0.6000973", "0.5942957", "0.56066334", "0.55042154", "0.5498463", "0.5481848", "0.54037386", "0.50522155", "0.5019854", "0.5008653", "0.48762834", "0.47485372", "0.4699111", "0.46984228", "0.46598303", "0.46598303", "0.46...
0.73685825
0
_Build followed by _rebuild, creating SRPM with binary RPMs for all supported architectures (unless noarch). Exists mainly for asynchronous purposes.
def build_and_rebuild(gem, os, build_dir, options = {}) srpm = build(gem, os, build_dir, options.merge(:continue => true, :arch => ARCH.first)) noarch = srpm.lock { Rpm2Gem::Rpm.noarch?(srpm.file) } if not noarch #build for all but first ARCH[1..-1].each do |arch| Resque.push('mock_build', :class => self.class.to_s, :args => ['rebuild', id, srpm.id, arch, options]) log("Build requested. (#{os}, #{arch})") end end #build for first arch (continue) log("Build requested. (#{os}, #{ARCH.first})") rebuild(srpm, ARCH.first, options.merge(:continue => true)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(chroot,dirs,task,add_to_autoreq=true,snapshot_release=false)\n validate_in_mock_group?\n _verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'\n\n # Default package metadata for reference\n default_metadata = YAML.load(File.read(\"#{@src_dir}/build/package_metadata_de...
[ "0.72713774", "0.7044943", "0.6870392", "0.6747316", "0.6735464", "0.67069924", "0.65839976", "0.6455248", "0.6409134", "0.6310248", "0.62193894", "0.60960793", "0.6091006", "0.60193765", "0.5912346", "0.5851529", "0.5844674", "0.57919675", "0.57715493", "0.5760649", "0.57598...
0.7131636
1
_Rebuild followed by _rpm2gem. Exists mainly for asynchronous purposes and is useful when the library does not have binary RPMs (yet) which are necessary for the rpm2gem conversion.
def rebuild_and_rpm2gem(srpm, options = {}) rebuild(srpm, ARCH.first, options) os = srpm.lock {Rpm2Gem::Rpm.os(srpm.file)} log("RPM->Gem conversion requested. (#{os})") rpm2gem(os, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_and_rebuild(gem, os, build_dir, options = {})\n srpm = build(gem, os, build_dir, options.merge(:continue => true,\n :arch => ARCH.first))\n \n noarch = srpm.lock { Rpm2Gem::Rpm.noarch?(srpm.file) }\n if not noarch\n #build for...
[ "0.7298516", "0.69695395", "0.6830465", "0.67637324", "0.67451835", "0.66824454", "0.63878953", "0.6368831", "0.6286194", "0.6253019", "0.62372404", "0.6218657", "0.61641735", "0.61465985", "0.6122463", "0.60373664", "0.5994468", "0.5914151", "0.58359337", "0.5812845", "0.578...
0.74302626
0
Returns library's log directory.
def logdir File.expand_path("../../../log/library/#{id}", File.dirname(__FILE__)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_directory\n @log_directory ||= begin\n Rails.root.join('log')\n rescue => e\n File.join Dir.pwd, 'log'\n end\n end", "def log_directory\n File.join(@relative_to_base, LOG_DIRECTORY_NAME)\n ...
[ "0.8447388", "0.83800954", "0.82496077", "0.7913856", "0.7860673", "0.7860673", "0.77005863", "0.7687836", "0.74350095", "0.72226346", "0.718544", "0.7163437", "0.71220464", "0.7120445", "0.70597655", "0.70591503", "0.70183164", "0.69434905", "0.68999547", "0.68754417", "0.68...
0.88541883
0
Log a message into the user log (brief.log). User log's purpose is to collect information about various manipulation operations made by users.
def log(message) open("#{logdir}/brief.log", 'a') { |f| f.puts "#{Time.now}: #{message}" } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_to_log\n user_name = self.user.name || self.user.email.split('@')[0]\n Log.create!(loggingtype: 2,user_id_1: self.user.id ,user_id_2: nil,admin_id: nil,story_id: self.story.id ,interest_id: nil,message: (user_name+\" commented on \\\"\" + self.story.title + \"\\\" with \\\"\" + self.content + \"\\\...
[ "0.67230296", "0.66648304", "0.6640765", "0.66075045", "0.6586479", "0.6428289", "0.6348655", "0.63424665", "0.63309467", "0.63185537", "0.6287588", "0.6287588", "0.6287588", "0.62865824", "0.62835616", "0.6278538", "0.6275101", "0.6245787", "0.6234159", "0.62030774", "0.6200...
0.73930764
0
Generate an RPM specfile from the Gem. Parameter _os_ specifies for which operating system the specfile is.
def generate_specfile(os) gem = packages.detect { |package| package.type == 'gem' } raise 'Library has no gem package!' if gem.nil? file = gem.lock { Helpers.cp_anonymous(gem.file) } begin Specfile.generate(file, os) #this is kinda slow ensure FileUtils.rm_f(file) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gem2rpm(os, specfile, options = {})\n @logger.info('Gem->RPM: Start!')\n begin\n gem = packages.detect { |package| package.type == 'gem' }\n raise 'Library has no gem package!' if gem.nil?\n build_dir = Helpers.mkdir_anonymous\n \n begin\n gemspec = gem.loc...
[ "0.76680535", "0.72085285", "0.66007596", "0.65519804", "0.6103706", "0.59536433", "0.59079146", "0.5907722", "0.5801065", "0.5778375", "0.5692092", "0.55921423", "0.558327", "0.5540476", "0.5510948", "0.54533154", "0.5402268", "0.5395003", "0.5366172", "0.53161687", "0.53099...
0.8171669
0
omg not working Using another formula for this, except it is computationally in 1d space, not 2d so it should be way faster
def penta(n) return n* (3*n - 1) / 2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sustitucion_regresiva(n, a, b)\n n = n - 1\n\n x = Array.new(n + 1)\n x[n] = b[n].fdiv(a[n][n])\n\n (0..n - 1).reverse_each do |i|\n sumatoria = (i + 1..n).inject(0) { |sum, k| sum + a[i][k] * x[k] }\n x[i] = (b[i] - sumatoria).fdiv(a[i][i])\n end\n\n puts \"Una solucion aproximada del sistema es X...
[ "0.5961133", "0.5919712", "0.58690745", "0.5806006", "0.5784243", "0.576807", "0.5760154", "0.5743506", "0.5728618", "0.56902117", "0.5660709", "0.5659423", "0.5644636", "0.5642293", "0.56271404", "0.56060696", "0.56024903", "0.5591314", "0.5582843", "0.5577774", "0.55704147"...
0.0
-1
Required for Active Fedora 9
def prefix(path=nil) return '' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def host_os; end", "def host_os; end", "def is_yum_platform\n node[:platform_family] == \"rhel\"\nend", "def rpm_based?(node = __getnode)\n fedora_derived?(node) || node[\"platform_family\"] == \"suse\"\n end", "def fedora?(node = __getnode)\n node[\"platform_family\"] == \"fedora\"\n ...
[ "0.6190551", "0.6190551", "0.59855247", "0.59710526", "0.59445894", "0.59132963", "0.5839115", "0.58250207", "0.5823399", "0.5810696", "0.57895446", "0.5721179", "0.5703126", "0.5676304", "0.5669401", "0.5667297", "0.5658549", "0.565073", "0.5615642", "0.56062704", "0.5574286...
0.0
-1
Create a function called assess_situation that takes three arguments danger_level, save_the_day, bad_excuse danger_level should be an integer save_the_day should be a string a hero would say once they save the day bad_excuse should be a string a hero would say if they are too afraid of the
def assess_situation(danger_level, save_the_day, bad_excuse) if danger_level > 50 puts "#{bad_excuse}" elsif danger_level >= 50 && danger_level >= 10 puts "#{save_the_day}" else puts "Meh. Hard pass." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assess_situation(danger_level, save_the_day, bad_excuse)\n danger_level = 100\n save_the_day = \"Fear not mortals I am here!\"\n bad_excuse = \"I'm sore from lifting all day bro.\"\n# Your function should include an if/else statement that meets the following criteria\n# - Danger levels that are above 50 a...
[ "0.7862342", "0.77231824", "0.76884395", "0.76097596", "0.759233", "0.7571445", "0.75169265", "0.74608225", "0.7450187", "0.7439867", "0.7439867", "0.74392426", "0.74199164", "0.7379062", "0.7329939", "0.73102605", "0.7297331", "0.720841", "0.71980757", "0.7182114", "0.674376...
0.734356
14
Issues a GET request for a page, follows any redirects, and verifies the final page load was successful. Example: visits "/"
def visits(*args) webrat_session.visits(*args) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_page(base, page, severity=:E, expectedStatus=\"200\", log=true)\n path = base + page\n response = getHTTP(path)\n code = response.code || '?'\n if code != expectedStatus\n test(severity, \"Fetched #{path} - HTTP status: #{code} expected: #{expectedStatus}\") unless severity == nil\n return nil...
[ "0.7067522", "0.6473324", "0.64233017", "0.6402704", "0.6375165", "0.6299585", "0.6150721", "0.6082927", "0.6077761", "0.6054219", "0.6051076", "0.60461676", "0.6026686", "0.5982974", "0.5977781", "0.596366", "0.59627575", "0.5954152", "0.5941981", "0.59154403", "0.59154403",...
0.0
-1
GET /eg_posts GET /eg_posts.json
def index #@pagy, @eg_posts = pagy(EgPost.all, items: 2) @pagy, @eg_posts = pagy(EgPost.published.order(created_at: "DESC"), items: 2) authorize @eg_posts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response code: #{response.code}\"\n puts \"Response cookies:\\n #{response.cookies}\\n\\n\"\n puts \"Response headers:\\n #{response.headers}\\n\\n\"\n puts \"Response...
[ "0.72363627", "0.70778954", "0.70501524", "0.70429426", "0.7037659", "0.7037659", "0.7034491", "0.69471693", "0.69252986", "0.69252986", "0.69252986", "0.6923317", "0.6909837", "0.68967676", "0.6885477", "0.6866816", "0.6849551", "0.6817131", "0.6813251", "0.68099403", "0.680...
0.6288495
74
GET /eg_posts/1 GET /eg_posts/1.json
def show @eg_post = EgPost.find(params[:id]) authorize @eg_post end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @posts = Post.find(params[:id])\n render json: @posts\n end", "def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end", "def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response cod...
[ "0.7040009", "0.6985069", "0.6958515", "0.6954932", "0.69427174", "0.69427174", "0.69225603", "0.69170094", "0.6900693", "0.6900693", "0.6900693", "0.68945754", "0.6869807", "0.68602026", "0.6846279", "0.6800523", "0.6796203", "0.6793346", "0.6753406", "0.67372274", "0.672756...
0.0
-1
Find an Event::Base subclass by it's name.
def find_by_name(name) raise TypeError, 'name must respond to #to_sym' unless name.respond_to?(:to_sym) name = name.to_sym all.find { |event_class| event_class.name == name } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(name)\n @@subclasses.fetch(name.to_s, nil)\n end", "def find_event_model(name)\n find_event(name.to_sym)\n end", "def find_by_name(name)\n find do |event|\n event.job_class_name == name.to_s\n end\n end", "def find_event(event_name)\n ...
[ "0.71451", "0.6458311", "0.64220285", "0.63923675", "0.62782264", "0.6208035", "0.62046045", "0.6163072", "0.6145593", "0.6058362", "0.6057927", "0.5993372", "0.5807081", "0.5788602", "0.5769734", "0.5723251", "0.5676853", "0.5669557", "0.56611395", "0.5623345", "0.5603583", ...
0.69379556
1
Initialize an Event::Base subclass by it's name.
def new_from_name(name, attributes={}) event_class = find_by_name(name) raise ArgumentError, "Unknown event name '#{name}'" if event_class.nil? event_class.new(attributes) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(base)\n @base = base\n @events = []\n end", "def initialize(name)\n @events = []\n @name = name\n end", "def inherited(subclass)\n super\n subclass.instance_variable_set(:@event_types, @event_types)\n end", "def inherited(subclass)\n ...
[ "0.7068805", "0.6628739", "0.6489619", "0.64149535", "0.6279002", "0.6257021", "0.6224681", "0.6161081", "0.6148373", "0.61178917", "0.6113427", "0.61070365", "0.6042165", "0.5904907", "0.5889964", "0.588244", "0.5849974", "0.58261305", "0.5824136", "0.5817688", "0.5815707", ...
0.641768
3
word "pilot" there are three 3grams: "pil", "ilo" and "lot" Note that your function will receive the following arguments: text: which is a string containing words separated by whitespaces ngramLength: which is an integer value giving the length of the ngram Data contraints The length of the text string will not exceed 200,000 characters All words are alphanumeric (they contain only English letters az, AZ and numbers 09) Efficiency contraints Your function is expected to print the result in less than 2 seconds Example. Input: text: "aaaab aOa baab c" ngramLength: 3 Output: aaa
def find_ngram(text, ngram_length) pos = 0 frequency = Hash.new(0) while pos < text.length - ngram_length temp = text.slice(pos..pos+ngram_length-1) frequency[:"#{temp}"] += 1 pos += 1 end output_key = " " output_value = 0 frequency.each do |key, value| if value > output_value output_value = value output_key = key end end puts output_key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ngram_analysis(str, n)\r\n # use a hash to store ngram - frequency mapping\r\n freq = Hash.new\r\n bigram = \"\"\r\n count = n-1\r\n i = 0\r\n\r\n # get the first ngram\r\n for i in 0..count\r\n bigram[i] = str[i]\r\n end\r\n\r\n freq[bigram] = 1\r\n\r\n str.each_char do |c...
[ "0.70740134", "0.65664154", "0.6503152", "0.64967096", "0.63414687", "0.6332621", "0.63115585", "0.6220074", "0.61928606", "0.60982215", "0.60684985", "0.60471004", "0.6032934", "0.5967931", "0.596246", "0.5961918", "0.5946147", "0.5944902", "0.5934048", "0.59143656", "0.5913...
0.67361975
1
Generates a URI to request an image from a specified CCTV camera The default options should work in most cases, but can be overridden.
def generate_uri(cctv_id, custom_opts: {}) opts = DEFAULT_OPTIONS.merge(custom_opts) uri = "http://#{cctv_host(opts[:host])}" \ "/cctv#{cctv_id}.#{opts[:img_type]}" \ "?rand=#{Random.rand}:#{opts[:port]}" URI(uri) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_url(options = {})\n query = {\n w: options[:w] || options[:width],\n h: options[:h] || options[:height],\n fm: options[:fm] || options[:format],\n q: options[:q] || options[:quality]\n }.select { |_k, value| value }\n\n query.empty? ? file.url : \"...
[ "0.6211141", "0.6211141", "0.61350274", "0.6031681", "0.59829116", "0.59050894", "0.5853166", "0.58062214", "0.5803614", "0.5718662", "0.5709959", "0.562977", "0.5615673", "0.5601223", "0.5577663", "0.5526009", "0.5482087", "0.54756516", "0.545609", "0.544328", "0.54391307", ...
0.7242577
0
Specifies the cctv_host to use. If a valid host isn't specified, the default host is returned
def cctv_host(host) return DEFAULT_CAMERA_IP if invalid_host?(host) host end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def host(value = nil)\n if value\n @host = value\n else\n @host ||= 'localhost'\n end\n end", "def set_host(v)\n @host = v\n end", "def set_host(v)\n v = \"\" if v.nil? || v == \"localhost\"\n @host = v\n end", "def host\n ENV['CA_HOST'] || DEFAULT_HO...
[ "0.7290305", "0.7250632", "0.7242043", "0.7109392", "0.7078758", "0.67911786", "0.67911786", "0.6561239", "0.65312773", "0.65000254", "0.644161", "0.6426979", "0.64075863", "0.63209337", "0.6286495", "0.62621576", "0.6260685", "0.61856616", "0.61794055", "0.61700684", "0.6137...
0.7629288
0
A host is invalid if it's not a string, or if it's empty. example: host = "google.com"
def invalid_host?(host) !host.class.to_s.eql?("String") || host.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_host(v)\n return v unless v\n\n if @opaque\n raise InvalidURIError,\n \"can not set host with registry or opaque\"\n elsif parser.regexp[:HOST] !~ v\n raise InvalidComponentError,\n \"bad component(expected host component): #{v}\"\n end\n\n return ...
[ "0.7467924", "0.7251059", "0.71052265", "0.68826246", "0.6873558", "0.6791437", "0.66289693", "0.65384775", "0.651623", "0.64804", "0.64781475", "0.6456407", "0.64321876", "0.6382885", "0.63343316", "0.6205588", "0.6195221", "0.6179974", "0.61724025", "0.61548644", "0.6146477...
0.85207033
0
Determine whether a provided cctv_id is invalid
def invalid_cctv_id?(cctv_id) invalid_host?(cctv_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_id?(id)\r\n raise CLXException, 'Id must be integer' unless id.is_a? Integer\r\n raise CLXException, 'Id must be greater than zero' unless id > 0\r\n end", "def valid_orcid_id?(id)\n if id =~ /[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9,X]{4}/\n id = id.delete('-')\n id[15] == orcid...
[ "0.6923862", "0.64885706", "0.6047873", "0.59968007", "0.5959624", "0.5954071", "0.58892584", "0.5853493", "0.5832881", "0.58149", "0.5776204", "0.57659817", "0.5745907", "0.5719668", "0.5697457", "0.5634798", "0.5624438", "0.5613505", "0.5612917", "0.5609587", "0.55863225", ...
0.8685561
0
load_and_authorize_resource :only=>[:new,:create,:destroy,:update] GET /posts GET /posts.xml
def index # @posts = Post.paginate :page => params[:page] @posts = Post.paginate :page => params[:page], :per_page => 2 respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_and_authorize_resource\n user = current_user\n user ||= User.new # guest user (not logged in)\n \n post = Post.find(params[:id])\n \n # If the post will be destroyed in the next cron job, tell the user\n # it is already gone.\n if not post.burn_after_date.nil? and p...
[ "0.690963", "0.68580925", "0.66653574", "0.6612053", "0.66117346", "0.6576126", "0.65583503", "0.65569216", "0.6519798", "0.64196885", "0.6414715", "0.6341509", "0.6322212", "0.6317954", "0.62973505", "0.6280461", "0.62634844", "0.62634844", "0.6252137", "0.6249197", "0.62477...
0.0
-1
GET /posts/1 GET /posts/1.xml
def show @post = Post.find_by_slug(params[:id]) @comment = Comment.new logger.debug "No. of comments for post #{@post.title} is #{@post.comments.size}" respond_to do |format| format.html # show.html.erb format.xml { render :xml => @post } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end", "def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => ...
[ "0.72230846", "0.7073397", "0.7073397", "0.6978713", "0.69539315", "0.69031423", "0.6797454", "0.67764527", "0.67728055", "0.6706541", "0.67029274", "0.66985327", "0.6677388", "0.66654295", "0.66654295", "0.66654295", "0.66654295", "0.66654295", "0.66654295", "0.66654295", "0...
0.0
-1
GET /posts/new GET /posts/new.xml
def new @post = Post.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @post } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n make_rss\n end", "def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n...
[ "0.78365606", "0.7708412", "0.76752806", "0.76420695", "0.76340854", "0.7567351", "0.7567351", "0.75021523", "0.7495493", "0.74472666", "0.7447242", "0.74021965", "0.7399193", "0.73932934", "0.73880976", "0.73846865", "0.7381505", "0.73672473", "0.73626494", "0.7361229", "0.7...
0.7665492
18
POST /posts POST /posts.xml
def create @post = Post.new(params[:post]) authorize! :create, @post unless params[:author].blank? @post.users << User.find(params[:author]) end logger.debug "Going to save #{Rails.logger.level} #{@post.title.inspect} #{params[:post]}" respond_to do |format| if @post.save_post? logger.debug "Saved successfully #{@post.title.inspect}" format.html { redirect_to(@post, :notice => 'Post was successfully created.') } format.xml { render :xml => @post, :status => :created, :location => @post } else logger.debug "Could not save #{@post.title.inspect}" flash[:alert] = "Slug cannot be created" format.html { render 'new' } format.xml { render :xml => @post.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def test_should_create_post_via_API_XML\r\n get \"/logout\"\r\n post \"/forum_posts.xml\", :api_key=>'testapikey',\r\n ...
[ "0.6847672", "0.6799606", "0.6638679", "0.6625985", "0.6582057", "0.63850963", "0.6320757", "0.627628", "0.62496513", "0.62292284", "0.6224684", "0.6214792", "0.62033695", "0.61848694", "0.6183795", "0.61547226", "0.61526495", "0.6142421", "0.61416507", "0.6132199", "0.61245"...
0.0
-1
PUT /posts/1 PUT /posts/1.xml
def update logger.debug "Going to update post #{params[:id]}" @post = Post.find_by_slug(params[:id]) authorize! :update, @post respond_to do |format| begin @post.update_attributes!(params[:post]) logger.debug "Updated successfully #{@post.title.inspect}" format.html { redirect_to(@post, :notice => 'Post was successfully updated.') } format.xml { head :ok } rescue Exception => e logger.debug "Update failed for #{@post.title.inspect} #{e.inspect}" flash[:alert] = "Slug not unique" format.html { render :action => "edit" } format.xml { render :xml => @post.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def upd...
[ "0.6867673", "0.66907144", "0.6294395", "0.62794256", "0.6099675", "0.6098852", "0.6035446", "0.59057415", "0.590173", "0.58895403", "0.5880021", "0.58741546", "0.5867954", "0.5849058", "0.5837317", "0.5833679", "0.58261484", "0.5825736", "0.5818691", "0.58159804", "0.5810053...
0.0
-1
DELETE /posts/1 DELETE /posts/1.xml
def destroy @post = Post.find_by_slug(params[:id]) authorize! :destroy, @post @post.destroy respond_to do |format| format.html { redirect_to(posts_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n r.delete @post\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @post = Post.find(params[:id])\n @post.deleted = 1\n ...
[ "0.7365624", "0.7322596", "0.72059286", "0.715179", "0.715179", "0.70919865", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "0.7068259", "...
0.0
-1
Retrieves latest quote for a symbol
def find(symbol) response = Request.new("/stock/#{symbol}/quote").get Models::Quote.new(response.body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_single_quote symbol, options = {}\n get_multiple_quotes([symbol], options)[0]\n end", "def latest_quote\n Quote.where(\n 'stock_id = ? and created_at = (select max(created_at) from quotes where stock_id = ?)',\n id, id).first or raise \"Could not find the latest quote for #{code}...
[ "0.7158279", "0.6862335", "0.66985035", "0.64832485", "0.645195", "0.64244974", "0.6413228", "0.6361941", "0.6224979", "0.61535007", "0.6098149", "0.60353863", "0.6033384", "0.60086316", "0.5995493", "0.5990559", "0.59702027", "0.5957124", "0.59410137", "0.591933", "0.5913518...
0.63650775
7
Returns a hash of default options for new contexts.
def context_options return { :enabled => enabled, :max_fibers => max_fibers, :tracer => tracer } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_options\n {}\n end", "def default_options\n {}\n end", "def default_options\n {}\n end", "def default_options\n {}\n end", "def default_options\n {}\n end", "def default_options\n {}\n end", "def default_options\n { }\n ...
[ "0.7564038", "0.7564038", "0.7564038", "0.75392526", "0.75392526", "0.7538957", "0.7403652", "0.7399623", "0.7361269", "0.72758263", "0.7142505", "0.7075271", "0.7065788", "0.70266813", "0.70084286", "0.695041", "0.69226444", "0.6917524", "0.6917524", "0.69024163", "0.6884597...
0.72778636
9
Given an array of predicates, a result and some static data return a single row of the download that contains just the results matching the predicates.
def as_row(result, columns) columns.map { |column| column.format_value(result) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _all_pred(opts)\n predicate = opts[:predicate]\n raise 'predicate must be provided' unless predicate\n\n visible = opts.fetch :visible, true\n %($.mainApp().getAllWithPredicate(\"#{predicate}\", #{visible});)\n end", "def generate_download\n # TODO: to support scoping by other filte...
[ "0.5246661", "0.50324833", "0.49819285", "0.4854055", "0.48475695", "0.48296937", "0.4802525", "0.47691223", "0.47610998", "0.47240302", "0.46951458", "0.46775514", "0.4648033", "0.45884943", "0.45454288", "0.45127478", "0.45127478", "0.45127374", "0.45037475", "0.4488267", "...
0.0
-1
Return truthy if the user selections include a named theme
def theme_selected? user_selections.params['thm'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_theme?(theme_name=nil)\n File.file? theme_path(theme_name)\n end", "def has_theme?(theme_tag) has_tag(:theme, theme_tag) end", "def theme_exists?(theme_name)\n File.exist?(\"#{themes_path}/#{theme_name}\")\n end", "def previewable?\n if self.root.assigned_theme_ids.include?(0)\n return...
[ "0.72266984", "0.7049707", "0.67714614", "0.65776783", "0.656833", "0.6550061", "0.63442117", "0.61306417", "0.6097872", "0.5966729", "0.5925049", "0.59241533", "0.5809383", "0.56878537", "0.56270266", "0.56244934", "0.56215245", "0.5619415", "0.55656445", "0.55502725", "0.55...
0.81035125
0
GET /chord_diagrams GET /chord_diagrams.json
def index @chord_diagrams = ChordDiagram.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_chord_diagram\n @chord_diagram = ChordDiagram.find(params[:id])\n end", "def create\n @chord_diagram = ChordDiagram.new(chord_diagram_params)\n\n respond_to do |format|\n if @chord_diagram.save\n format.html { redirect_to new_chord_diagram_url, notice: 'Chord Diagram was success...
[ "0.6137935", "0.596301", "0.5807402", "0.57998097", "0.5740774", "0.5728121", "0.5671122", "0.54945695", "0.545916", "0.5366982", "0.53260314", "0.52916074", "0.52652055", "0.5262316", "0.5176328", "0.5093561", "0.50665545", "0.506289", "0.50559", "0.50406814", "0.50229025", ...
0.77079207
0
GET /chord_diagrams/1 GET /chord_diagrams/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @chord_diagrams = ChordDiagram.all\n end", "def set_chord_diagram\n @chord_diagram = ChordDiagram.find(params[:id])\n end", "def show\n @chord = Chord.find_by_hash_ref(params[:id]) or raise ActiveRecord::RecordNotFound\n\n respond_to do |format|\n format.html # show.html.erb\...
[ "0.74701005", "0.6223068", "0.60292274", "0.60274553", "0.59593457", "0.5743951", "0.5743045", "0.56597567", "0.5455844", "0.5447076", "0.54444456", "0.54407775", "0.5416616", "0.53804195", "0.5335757", "0.5287443", "0.5260232", "0.52563465", "0.5238214", "0.5231548", "0.5204...
0.0
-1
POST /chord_diagrams POST /chord_diagrams.json
def create @chord_diagram = ChordDiagram.new(chord_diagram_params) respond_to do |format| if @chord_diagram.save format.html { redirect_to new_chord_diagram_url, notice: 'Chord Diagram was successfully created.' } format.json { render :show, status: :created, location: @chord_diagram } else format.html { render :new } format.json { render json: @chord_diagram.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chord_diagram_params\n params.require(:chord_diagram).permit(:name, :chords)\n end", "def create\n @chord = Chord.new(chord_params)\n\n respond_to do |format|\n if @chord.save\n format.html { redirect_to @chord, notice: 'Chord was successfully created.' }\n format.json { rend...
[ "0.69122237", "0.66573155", "0.6451014", "0.6307652", "0.6150083", "0.60849774", "0.5884041", "0.57101107", "0.565182", "0.55149984", "0.54372555", "0.53870916", "0.52703714", "0.52273405", "0.52008593", "0.5142563", "0.514219", "0.5100719", "0.5091912", "0.50553143", "0.5053...
0.7371507
0
PATCH/PUT /chord_diagrams/1 PATCH/PUT /chord_diagrams/1.json
def update respond_to do |format| if @chord_diagram.update(chord_diagram_params) format.html { redirect_to new_chord_diagram_url, notice: 'Chord diagram was successfully updated.' } format.json { render :show, status: :ok, location: @chord_diagram } else format.html { render :edit } format.json { render json: @chord_diagram.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @chord.update(chord_params)\n format.html { redirect_to @chord, notice: 'Chord was successfully updated.' }\n format.json { render :show, status: :ok, location: @chord }\n else\n format.html { render :edit }\n format.json { render js...
[ "0.6784826", "0.6415254", "0.6016639", "0.6003243", "0.6002493", "0.57616216", "0.57571244", "0.5724375", "0.5712917", "0.5611724", "0.55510837", "0.5524941", "0.552327", "0.55020046", "0.5495622", "0.54816616", "0.5478416", "0.54596055", "0.540871", "0.540871", "0.540871", ...
0.72628844
0
DELETE /chord_diagrams/1 DELETE /chord_diagrams/1.json
def destroy @chord_diagram.destroy respond_to do |format| format.html { redirect_to new_chord_diagram_url, notice: 'Chord diagram was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @chord.destroy\n respond_to do |format|\n format.html { redirect_to chords_url, notice: 'Chord was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @diagram = Diagram.find(params[:id])\n @diagram.destroy\n\n respond_to do |forma...
[ "0.69081736", "0.6758636", "0.6635571", "0.65923554", "0.6393665", "0.6312583", "0.6281284", "0.6233546", "0.6215284", "0.6205972", "0.6202697", "0.61386263", "0.61379457", "0.613544", "0.6127831", "0.61180735", "0.61168236", "0.610472", "0.61028373", "0.6075468", "0.6059473"...
0.74616176
0
Use callbacks to share common setup or constraints between actions.
def set_chord_diagram @chord_diagram = ChordDiagram.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def chord_diagram_params params.require(:chord_diagram).permit(:name, :chords) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
GET /gift_requests GET /gift_requests.json
def index @gift_request = GiftRequest.new if(params[:filter].nil?) @gift_requests = GiftRequest.order('gift_requests.created_at DESC').page(params[:page]).per(10) elsif params[:filter] == "popular" @gift_requests = GiftRequest.popular.page(params[:page]).per(10) elsif params[:filter] == "top" @gift_requests = GiftRequest.top.page(params[:page]).per(10) end respond_to do |format| format.html # index.html.erb format.json { render json: @gift_requests } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @gift = Gift.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gift }\n end\n end", "def friend_requests\n get(\"users/requests\").requests\n end", "def index_single_gift\n render json: @gift, include: :ages, s...
[ "0.65767413", "0.6567392", "0.65517324", "0.65230834", "0.6393312", "0.6325745", "0.6316687", "0.628358", "0.62530226", "0.62224555", "0.5963082", "0.59503204", "0.5934298", "0.593015", "0.58917564", "0.58660436", "0.58361125", "0.5823234", "0.5781584", "0.5735396", "0.571591...
0.6333549
5
GET /gift_requests/1 GET /gift_requests/1.json
def show @request = request.fullpath @gift_request = GiftRequest.find(params[:id]) if @gift_request.user_has_access?(current_user.id) == false flash[:notice] = "You are not authorized to view the gift request" redirect_to '/gift_requests' else @gift_request_comments = @gift_request.comments @gift_request_likes = @gift_request.likes @gift_request_tags = @gift_request.tags respond_to do |format| UserView.create(gift_request_id: @gift_request.id, user_id: current_user.id) format.html # show.html.erb format.json { render json: @gift_request } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @gift_request = GiftRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gift_request }\n end\n end", "def show\n @gift = Gift.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { rend...
[ "0.6840854", "0.68159384", "0.6720736", "0.652763", "0.64782596", "0.6437088", "0.6301482", "0.6280342", "0.62526876", "0.62349445", "0.6134361", "0.61301494", "0.59472036", "0.5914504", "0.5898413", "0.58796424", "0.58277804", "0.58269036", "0.5797215", "0.5747394", "0.57177...
0.6246514
9
GET /gift_requests/new GET /gift_requests/new.json
def new @gift_request = GiftRequest.new respond_to do |format| format.html # new.html.erb format.json { render json: @gift_request } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @gift = Gift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gift }\n end\n end", "def new\n @gig_request = GigRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig_request }\n ...
[ "0.7519645", "0.7465254", "0.7403624", "0.7351594", "0.7143196", "0.7143196", "0.7143196", "0.7143196", "0.7143196", "0.7134947", "0.7111061", "0.7012525", "0.68723094", "0.67591554", "0.6758979", "0.6758641", "0.67562884", "0.67443335", "0.6689935", "0.6644212", "0.6641622",...
0.81101495
0
PUT /gift_requests/1 PUT /gift_requests/1.json
def update @gift_request = GiftRequest.find(params[:id]) respond_to do |format| if @gift_request.update_attributes(params[:gift_request]) format.html { redirect_to @gift_request, notice: 'Gift request was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @gift_request.errors.full_messages.to_sentence, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @gift = Gift.find(params[:id])\n\n respond_to do |format|\n if @gift.update_attributes(params[:gift])\n format.html { redirect_to @gift, notice: 'Gift was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n ...
[ "0.67637753", "0.6641692", "0.6641692", "0.64909387", "0.63511133", "0.6349486", "0.6249055", "0.62483734", "0.6222971", "0.60211194", "0.600978", "0.600978", "0.600978", "0.600978", "0.600978", "0.600978", "0.600978", "0.600978", "0.600978", "0.60045373", "0.59928703", "0....
0.7273162
0
DELETE /gift_requests/1 DELETE /gift_requests/1.json
def destroy @gift_request = GiftRequest.find(params[:id]) @gift_request.destroy respond_to do |format| format.html { redirect_to gift_requests_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @gift = Gift.find(params[:id])\n @gift.destroy\n\n respond_to do |format|\n format.html { redirect_to gifts_url }\n format.json { head :ok }\n end\n end", "def destroy\n @gig_request = GigRequest.find(params[:id])\n @gig_request.destroy\n\n respond_to do |format|\n ...
[ "0.7434117", "0.74295974", "0.7173588", "0.71679217", "0.71679217", "0.71679217", "0.71679217", "0.7126523", "0.7071606", "0.7031558", "0.7023904", "0.7012896", "0.700059", "0.69895613", "0.6979417", "0.69621235", "0.69621235", "0.69621235", "0.69621235", "0.69621235", "0.696...
0.8034908
0
a method that computes the square of its argument (the square is the result of multiplying a number by itself).
def multiply(num1, num2) num1 * num2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def square(x) = x * x", "def square(num)\n multiply(multiply(num, num), num)\nend", "def square(num) #I calculate a simple method for calculating squares (after I will need it)\n return num * num\n end", "def square(number)\n return number*number*number\nend", "def square(num)\n multiply(num, num)...
[ "0.8687434", "0.8668761", "0.8538099", "0.85314155", "0.8518574", "0.8518574", "0.8518574", "0.8518574", "0.8518574", "0.8518574", "0.85097146", "0.84900326", "0.84649104", "0.8459585", "0.843143", "0.841938", "0.841938", "0.8401503", "0.8401503", "0.8401503", "0.8401503", ...
0.0
-1
Block until the action is finished or timeout is reached. Progress is shown with a progress bar. Offers cancellation on interrupt.
def wait_for_completion(id: nil, timeout: nil, cancel: false) id ||= @id if cancel puts "Waiting for the action to cancel (hit Ctrl+C to skip)..." else puts "Waiting for the action to complete (hit Ctrl+C to skip)..." end last_status = false can_cancel = false begin ret = HaveAPI::Client::Action.wait_for_completion( @client, id, timeout: timeout, ) do |state| last_status = state.status can_cancel = state.can_cancel? update_progress(state, cancel) end rescue Interrupt @pb && @pb.stop puts cancel_action(timeout: timeout) if can_cancel && !cancel && last_status puts print_help(id) exit(false) end if ret @pb && @pb.finish else @pb && @pb.stop end ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_done\n sleep 0.01 until done?\n end", "def eventually(label, &block)\n current_time = Time.now\n timeout_treshold = current_time + TIMEOUT\n while (block.call == false) && (current_time <= timeout_treshold) do\n sleep 5\n current_time = Time.now\n end\n if (current_time > timeout_tres...
[ "0.6089221", "0.608498", "0.60215557", "0.5868158", "0.5804231", "0.57405967", "0.5668304", "0.56557137", "0.56082183", "0.5598788", "0.5586595", "0.5578746", "0.55565655", "0.55165786", "0.55019104", "0.5496809", "0.5488717", "0.548723", "0.5465278", "0.5447464", "0.54339176...
0.7023272
0
Ask the user if he wishes to cancel the action. If so, execute cancel and call self.wait_for_completion on the cancellation, if it is blocking operation.
def cancel_action(timeout: nil) STDOUT.write("Do you wish to cancel the action? [y/N]: ") STDOUT.flush if STDIN.readline.strip.downcase == 'y' begin res = HaveAPI::Client::Action.cancel(@client, @id) rescue HaveAPI::Client::ActionFailed => e res = e.response end if res.is_a?(HaveAPI::Client::Response) && res.ok? puts "Cancelled" exit elsif res @pb.resume wait_for_completion( id: res, timeout: timeout, cancel: true, ) exit end warn "Cancel failed: #{res.message}" exit(false) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel\r\n # @todo Emit a warning for attempts to cancel an action after it's been\r\n # executed\r\n @cancelled = true\r\n end", "def cancel!\n state_guard { modify_call 'Status' => 'cancelled' }\n end", "def cancel?\n self.type == :cancel\n end", "def cancel\n ...
[ "0.7427307", "0.6826733", "0.6678281", "0.6669106", "0.65777165", "0.6533911", "0.652873", "0.6499022", "0.64855915", "0.64787143", "0.6470962", "0.64581114", "0.6380456", "0.63738465", "0.6369871", "0.63689554", "0.63689554", "0.6361809", "0.6331841", "0.63241726", "0.632022...
0.71715194
1
Remove user from station by Id Remove user from station by Id
def delete_user_by_id(id, opts = {}) data, _status_code, _headers = delete_user_by_id_with_http_info(id, opts) return data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_user_by_id(user_id)\n # ........\n end", "def removeWorkingUser user\n @workingUsers.delete user\n end", "def deleteUser(id) \n user_to_remove = getUserByID(id)\n\n if user_to_remove != nil \n @Users.delete(user_to_remove)\n else\n puts \"No such user.\"\n end \n e...
[ "0.7630822", "0.68292606", "0.6755439", "0.6743704", "0.6677033", "0.6677033", "0.66590124", "0.6650568", "0.65922314", "0.65913564", "0.6560551", "0.6559365", "0.6532358", "0.65277153", "0.65188545", "0.6512817", "0.6439246", "0.6380962", "0.6376294", "0.63733655", "0.635795...
0.0
-1
Remove user from station by Id Remove user from station by Id
def delete_user_by_id_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: UserApi.delete_user_by_id ..." end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling UserApi.delete_user_by_id" end if @api_client.config.client_side_validation && id < 0 fail ArgumentError, 'invalid value for "id" when calling UserApi.delete_user_by_id, must be greater than or equal to 0.' end # resource path local_var_path = "/users/{id}".sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['API Key'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Success') if @api_client.config.debugging @api_client.config.logger.debug "API called: UserApi#delete_user_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_user_by_id(user_id)\n # ........\n end", "def removeWorkingUser user\n @workingUsers.delete user\n end", "def deleteUser(id) \n user_to_remove = getUserByID(id)\n\n if user_to_remove != nil \n @Users.delete(user_to_remove)\n else\n puts \"No such user.\"\n end \n e...
[ "0.7630822", "0.68292606", "0.6755439", "0.6743704", "0.6677033", "0.6677033", "0.66590124", "0.6650568", "0.65922314", "0.65913564", "0.6560551", "0.6559365", "0.6532358", "0.65277153", "0.65188545", "0.6512817", "0.6439246", "0.6380962", "0.6376294", "0.63733655", "0.635795...
0.0
-1
Get user by id Get user by id
def get_user_by_id(id, opts = {}) data, _status_code, _headers = get_user_by_id_with_http_info(id, opts) return data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user(id)\n @users[id]\n end", "def get(user_id)\n User.find user_id\n end", "def get_user_by_id(id)\n $r.hgetall(\"user:#{id}\")\n end", "def get_user_byid(id)\n @user = User.find_by_id(id)\n end", "def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n e...
[ "0.8694063", "0.84904444", "0.841787", "0.8391702", "0.8356932", "0.83457094", "0.83279973", "0.8323567", "0.82876235", "0.82697755", "0.82582974", "0.8201298", "0.8178934", "0.8157825", "0.81295836", "0.8101729", "0.80936855", "0.80043906", "0.8003359", "0.7992741", "0.79800...
0.0
-1
Get user by id Get user by id
def get_user_by_id_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: UserApi.get_user_by_id ..." end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling UserApi.get_user_by_id" end if @api_client.config.client_side_validation && id < 0 fail ArgumentError, 'invalid value for "id" when calling UserApi.get_user_by_id, must be greater than or equal to 0.' end # resource path local_var_path = "/users/{id}".sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['API Key'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'UserResult') if @api_client.config.debugging @api_client.config.logger.debug "API called: UserApi#get_user_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user(id)\n @users[id]\n end", "def get(user_id)\n User.find user_id\n end", "def get_user_by_id(id)\n $r.hgetall(\"user:#{id}\")\n end", "def get_user_byid(id)\n @user = User.find_by_id(id)\n end", "def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n e...
[ "0.8694063", "0.84904444", "0.841787", "0.8391702", "0.8356932", "0.83457094", "0.83279973", "0.8323567", "0.82876235", "0.82697755", "0.82582974", "0.8201298", "0.8178934", "0.8157825", "0.81295836", "0.8101729", "0.80936855", "0.80043906", "0.8003359", "0.7992741", "0.79800...
0.0
-1
Invite user by mail Invite user by mail
def invite_user_by_mail(data, opts = {}) data, _status_code, _headers = invite_user_by_mail_with_http_info(data, opts) return data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invite_by_mail\n @user = User.find_by_id(params[:id])\n raise Kroogi::NotPermitted unless @user && @user.active? && permitted?(@user, :profile_edit) # @user is inviter\n\n begin\n invited = []\n Invite.transaction do\n params[:user_emails].split(',').each do |eml|\n eml = eml...
[ "0.77872306", "0.75820166", "0.7347593", "0.7254565", "0.72216576", "0.7196393", "0.71437204", "0.71327746", "0.70983577", "0.7090603", "0.7081546", "0.70757204", "0.7059653", "0.70463", "0.7044283", "0.70411146", "0.70166206", "0.70143944", "0.70021176", "0.69810534", "0.696...
0.6921534
24
Invite user by mail Invite user by mail
def invite_user_by_mail_with_http_info(data, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: UserApi.invite_user_by_mail ..." end # verify the required parameter 'data' is set if @api_client.config.client_side_validation && data.nil? fail ArgumentError, "Missing the required parameter 'data' when calling UserApi.invite_user_by_mail" end # resource path local_var_path = "/users/invite" # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(data) auth_names = ['API Key'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'InviteUserSuccess') if @api_client.config.debugging @api_client.config.logger.debug "API called: UserApi#invite_user_by_mail\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invite_by_mail\n @user = User.find_by_id(params[:id])\n raise Kroogi::NotPermitted unless @user && @user.active? && permitted?(@user, :profile_edit) # @user is inviter\n\n begin\n invited = []\n Invite.transaction do\n params[:user_emails].split(',').each do |eml|\n eml = eml...
[ "0.77872306", "0.75820166", "0.7347593", "0.7254565", "0.72216576", "0.7196393", "0.71437204", "0.71327746", "0.70983577", "0.7090603", "0.7081546", "0.70757204", "0.7059653", "0.70463", "0.7044283", "0.70411146", "0.70166206", "0.70143944", "0.70021176", "0.69810534", "0.696...
0.6299826
99
Get all users. List all users.
def list_users(opts = {}) data, _status_code, _headers = list_users_with_http_info(opts) return data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_users\n @users = User.find(:all)\n end", "def all\n result = Client.request(:get, 'users')\n\n if result.is_a?(Result::Success)\n result.body[:users].map { |data| User.new(data) }\n else\n []\n end\n end", "def users\n get...
[ "0.8610455", "0.8572057", "0.8394202", "0.83930814", "0.83874977", "0.8367494", "0.83344066", "0.8322802", "0.83103985", "0.83023167", "0.8296535", "0.8293392", "0.8291355", "0.82776684", "0.81759936", "0.814039", "0.8130626", "0.8095526", "0.8049441", "0.80365956", "0.802859...
0.0
-1
Get all users. List all users.
def list_users_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: UserApi.list_users ..." end if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 0 fail ArgumentError, 'invalid value for "opts[:"page"]" when calling UserApi.list_users, must be greater than or equal to 0.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 50 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling UserApi.list_users, must be smaller than or equal to 50.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling UserApi.list_users, must be greater than or equal to 1.' end if @api_client.config.client_side_validation && opts[:'order_direction'] && !['asc', 'desc'].include?(opts[:'order_direction']) fail ArgumentError, 'invalid value for "order_direction", must be one of asc, desc' end # resource path local_var_path = "/users" # query parameters query_params = {} query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'role_id'] = opts[:'role_id'] if !opts[:'role_id'].nil? query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'order-by'] = opts[:'order_by'] if !opts[:'order_by'].nil? query_params[:'order-direction'] = opts[:'order_direction'] if !opts[:'order_direction'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['API Key'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'UserResults') if @api_client.config.debugging @api_client.config.logger.debug "API called: UserApi#list_users\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_users\n @users = User.find(:all)\n end", "def all\n result = Client.request(:get, 'users')\n\n if result.is_a?(Result::Success)\n result.body[:users].map { |data| User.new(data) }\n else\n []\n end\n end", "def users\n get...
[ "0.8610455", "0.8572057", "0.8394202", "0.83930814", "0.83874977", "0.8367494", "0.83344066", "0.8322802", "0.83103985", "0.83023167", "0.8296535", "0.8293392", "0.8291355", "0.82776684", "0.81759936", "0.814039", "0.8130626", "0.8095526", "0.8049441", "0.80365956", "0.802859...
0.0
-1
Whether or not this the original request that resulted in this packet originated on the server
def from_server? @origin == :server end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def real_request?\n @real_request\n end", "def request_sent?\n !response.nil?\n end", "def request?\n self.operation == OP_REQUEST\n end", "def response_received?\n !! @status\n end", "def response_received?\n !! @status\n end", "def local_request? #:do...
[ "0.7401331", "0.7046869", "0.6924632", "0.6872971", "0.6872971", "0.6868278", "0.6868278", "0.6800996", "0.6720102", "0.6718734", "0.6718734", "0.671025", "0.6708185", "0.65668005", "0.6535127", "0.6535127", "0.6486207", "0.648453", "0.648453", "0.648453", "0.6479504", "0.6...
0.6399414
25
Whether or not this the original request that resulted in this packet originated on the client
def from_client? @origin == :client end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def real_request?\n @real_request\n end", "def request?\n self.operation == OP_REQUEST\n end", "def response_received?\n !! @status\n end", "def response_received?\n !! @status\n end", "def request_sent?\n !response.nil?\n end", "def is_request? msg\n ...
[ "0.7208449", "0.6974557", "0.68761766", "0.68761766", "0.68618417", "0.68191266", "0.6770821", "0.6770821", "0.6662868", "0.6632024", "0.65543735", "0.65543735", "0.65220296", "0.6495501", "0.64787954", "0.64693606", "0.64249295", "0.6396948", "0.6371613", "0.6333313", "0.631...
0.60797936
61
Whether or not this packet is a request
def request? @type == :request end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request?\n self.operation == OP_REQUEST\n end", "def is_request? msg\n msg && msg[:req_id]\n end", "def request?\n !!request\n end", "def real_request?\n @real_request\n end", "def inbound_request?\n requester == 'inbound'\n end", "def hasRequest?\n !req...
[ "0.8316413", "0.77361995", "0.76021594", "0.71062225", "0.6967374", "0.69544536", "0.6929902", "0.69071496", "0.67845774", "0.67788255", "0.6755745", "0.6722493", "0.6699416", "0.66659766", "0.66659766", "0.66607344", "0.66425294", "0.66171086", "0.6605745", "0.6573459", "0.6...
0.8246311
1
Whether or not this packet is a response
def response? @type == :response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def response?\n\t\treturn ((self.type == PACKET_TYPE_RESPONSE) ||\n\t\t (self.type == PACKET_TYPE_PLAIN_RESPONSE))\n\tend", "def response?\n\t\treturn ((self.type == PACKET_TYPE_RESPONSE) ||\n\t\t (self.type == PACKET_TYPE_PLAIN_RESPONSE))\n\tend", "def command_response?\n type == :command...
[ "0.89259374", "0.89259374", "0.7692029", "0.7639852", "0.7537227", "0.7537227", "0.7489489", "0.7236994", "0.7173544", "0.7122109", "0.69727784", "0.69404346", "0.6805015", "0.6764156", "0.67464525", "0.6732312", "0.6710422", "0.669741", "0.6670618", "0.66642195", "0.66508794...
0.8119925
2
If this packet is a response, return the response status, otherwise nil
def response @response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def response_status\n @response[:status]\n end", "def status\n @response && @response.status\n end", "def response?\n\t\treturn ((self.type == PACKET_TYPE_RESPONSE) ||\n\t\t (self.type == PACKET_TYPE_PLAIN_RESPONSE))\n\tend", "def response?\n\t\treturn ((self.type == PACKET_TYPE_RESPON...
[ "0.72840047", "0.711445", "0.7101135", "0.7101135", "0.6922813", "0.649361", "0.649", "0.64794207", "0.6463113", "0.6463113", "0.64630735", "0.64630735", "0.64580154", "0.63316995", "0.6275066", "0.6163588", "0.61618733", "0.6135643", "0.6117443", "0.6109082", "0.61069524", ...
0.0
-1
Resets the read index allowing the packet to be read from the very beginning
def rewind @read_index = -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n @buf.fill(0, @slices) { 0 }\n @writer = 0\n @old = @now.call\n end", "def rewind\n select_io_from_pos(0)\n end", "def rewind\n @ios.each(&:rewind)\n @index = 0\n end", "def reset\n @offset = 0\n end", "def reset_index\n io_index.clear\...
[ "0.69860804", "0.69452906", "0.6912388", "0.689239", "0.6875848", "0.68129826", "0.6761139", "0.67009974", "0.66449606", "0.66449606", "0.66173166", "0.6596159", "0.6589986", "0.65686107", "0.65556544", "0.6547274", "0.6494678", "0.6478354", "0.64025533", "0.63950396", "0.637...
0.79253834
0
Fast forward the read index by `amount` words.
def skip(amount = 1) @read_index += amount end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seek_forward(amount = opts[:seek_size])\n seek_by(amount)\n end", "def step_forward(amount = 1)\n @token_index += amount\n current_token\n end", "def seek(amount, whence=SEEK_SET)\n #This is a stub, used for indexing\n end", "def index_from_start(index); end", "def index(key, size)...
[ "0.62066877", "0.61898315", "0.5368759", "0.53165835", "0.5213334", "0.51748836", "0.5170526", "0.51571715", "0.5113481", "0.51002574", "0.51002574", "0.51002574", "0.51002574", "0.51002574", "0.51002574", "0.51002574", "0.51002574", "0.51002574", "0.51002574", "0.51002574", ...
0.6386082
0