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
GET /post_parts/1 GET /post_parts/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @post_parts = PostPart.all\n end", "def show\n @part = @product.parts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @part }\n end\n end", "def parts\n @audio_file = AudioFile.find(params[:id])\n @parts = @audio_...
[ "0.68984956", "0.65087146", "0.63962877", "0.6380265", "0.63696945", "0.623836", "0.62131286", "0.60302943", "0.6027642", "0.59151167", "0.59129286", "0.59075886", "0.5878882", "0.58508", "0.5835164", "0.58065295", "0.58054554", "0.5793242", "0.57920194", "0.578543", "0.57146...
0.0
-1
POST /post_parts POST /post_parts.json
def create @post_part = PostPart.new(post_part_params) respond_to do |format| if @post_part.save format.html { redirect_to @post_part, notice: 'Post part was successfully created.' } format.json { render :show, status: :created, location: @post_part } else format.html { render :new } format.json { render json: @post_part.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_part_params\n params.require(:post_part).permit(:heading, :body, :price, :neighborhood, :external_url, :timestamp)\n end", "def create\n @part = Part.new(params[:part])\n\n respond_to do |format|\n if @part.save\n format.html { redirect_to @part, :notice => 'Part was successful...
[ "0.65953344", "0.6349316", "0.6316498", "0.62887037", "0.6256853", "0.6085176", "0.6083", "0.5998084", "0.59869564", "0.5984582", "0.5923192", "0.5888448", "0.58645827", "0.58626896", "0.5847761", "0.5845177", "0.5843476", "0.57635933", "0.5706779", "0.56969863", "0.56921834"...
0.7007685
0
PATCH/PUT /post_parts/1 PATCH/PUT /post_parts/1.json
def update respond_to do |format| if @post_part.update(post_part_params) format.html { redirect_to @post_part, notice: 'Post part was successfully updated.' } format.json { render :show, status: :ok, location: @post_part } else format.html { render :edit } format.json { render json: @post_part.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @part = Part.find(params[:id])\n\n respond_to do |format|\n if @part.update_attributes(params[:part])\n format.html { redirect_to @part, :notice => 'Part was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n ...
[ "0.63045335", "0.62945646", "0.62745637", "0.6199231", "0.6176063", "0.614541", "0.6142998", "0.6119238", "0.6098641", "0.6059295", "0.60423285", "0.6035777", "0.5911059", "0.59043455", "0.5902983", "0.5900299", "0.5880431", "0.58686185", "0.58664715", "0.5860878", "0.5857453...
0.68431634
0
DELETE /post_parts/1 DELETE /post_parts/1.json
def destroy @post_part.destroy respond_to do |format| format.html { redirect_to post_parts_url, notice: 'Post part was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @medium_body_part = MediumBodyPart.find(params[:id])\n @medium_body_part.destroy\n\n respond_to do |format|\n format.html { redirect_to medium_body_parts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @part = Part.find(params[:id])\n @part.destroy...
[ "0.7135184", "0.7089026", "0.7049856", "0.7041977", "0.69963825", "0.69424635", "0.6924231", "0.689641", "0.6895302", "0.6895302", "0.6882251", "0.6858963", "0.6845252", "0.6836659", "0.6821784", "0.675517", "0.6708233", "0.6667735", "0.66397136", "0.6577632", "0.6572953", ...
0.75699514
0
Use callbacks to share common setup or constraints between actions.
def set_post_part @post_part = PostPart.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 post_part_params params.require(:post_part).permit(:heading, :body, :price, :neighborhood, :external_url, :timestamp) 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
Convert the string returned by the server into Date class
def due_date if @values[:due_date] != nil && @values[:due_date] != "" @date_due_date ||= Date.parse(@values[:due_date]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_date(string)\n Date.parse(string)\n rescue\n nil\n end", "def convert_to_date(str_date)\n Date.parse(str_date) if str_date\n end", "def string_to_date(string)\n super(handle_date_parse_input(string))\n end", "def d(date_string)\n Date.parse(date_string)\nen...
[ "0.7291145", "0.72274095", "0.7181739", "0.71117675", "0.69330734", "0.6898816", "0.68822765", "0.6876746", "0.6817308", "0.6772966", "0.6750544", "0.67447513", "0.6712245", "0.6660963", "0.6608982", "0.6604013", "0.6586998", "0.65821093", "0.6576907", "0.6576907", "0.6562331...
0.0
-1
check if user is last active admin user
def before_destory if User.count(:all, :conditions => ["is_superuser = 1 and active = 1"]) <= 1 errors.add_to_base "Cannot delete #{self.username.upcase} because it is the last admin user" return false else return true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_last_admin?(user)\r\n fail \"Missing user\" if (user == nil)\r\n\r\n is_admin?(user) && self.admin_count == 1\r\n end", "def last_admin?\n admin_was && self.class.count(:all, :conditions => { :admin => true }) == 1\n end", "def last_admin?\n num_admins = Person.count(:conditions => [...
[ "0.81331223", "0.8098282", "0.79163855", "0.7865159", "0.74681765", "0.7453188", "0.7423883", "0.73102945", "0.7305622", "0.7300194", "0.728531", "0.72675323", "0.7251611", "0.7251168", "0.7213384", "0.72081536", "0.7194273", "0.71564114", "0.7153468", "0.7147708", "0.7146410...
0.0
-1
Create a new account Creates a new account
def create_account(budget_id, data, opts = {}) data, _status_code, _headers = create_account_with_http_info(budget_id, data, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_account\n\n end", "def create(body = {})\n @client.account.create(body)\n end", "def create_account\n set_user\n set_payer\n set_user_sport\n save_account\n end", "def create_account\n if new_record? && !self.account_id\n account = Account.new\n account...
[ "0.8257312", "0.82239836", "0.80831707", "0.8010991", "0.79454243", "0.77753085", "0.7699585", "0.7690828", "0.76399446", "0.7629188", "0.76224715", "0.7622097", "0.7615733", "0.7614438", "0.76122206", "0.7606574", "0.7590418", "0.7589648", "0.7586393", "0.75724083", "0.75717...
0.0
-1
Create a new account Creates a new account
def create_account_with_http_info(budget_id, data, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AccountsApi.create_account ...' end # verify the required parameter 'budget_id' is set if @api_client.config.client_side_validation && budget_id.nil? fail ArgumentError, "Missing the required parameter 'budget_id' when calling AccountsApi.create_account" 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 AccountsApi.create_account" end # resource path local_var_path = '/budgets/{budget_id}/accounts'.sub('{' + 'budget_id' + '}', budget_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']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(data) auth_names = ['bearer'] 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 => 'AccountResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: AccountsApi#create_account\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_account\n\n end", "def create(body = {})\n @client.account.create(body)\n end", "def create_account\n set_user\n set_payer\n set_user_sport\n save_account\n end", "def create_account\n if new_record? && !self.account_id\n account = Account.new\n account...
[ "0.8257312", "0.82239836", "0.80831707", "0.8010991", "0.79454243", "0.77753085", "0.7699585", "0.7690828", "0.76399446", "0.7629188", "0.76224715", "0.7622097", "0.7615733", "0.7614438", "0.76122206", "0.7606574", "0.7590418", "0.7589648", "0.7586393", "0.75724083", "0.75717...
0.0
-1
Single account Returns a single account
def get_account_by_id(budget_id, account_id, opts = {}) data, _status_code, _headers = get_account_by_id_with_http_info(budget_id, account_id, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def...
[ "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.79495734", "0.7806883", "0.7634226", "0.758146", "0.758146", "0.7475047", "0.7367855", "0.7353887", "0.7311101", "0.73054814", "0.7285499", "...
0.0
-1
Single account Returns a single account
def get_account_by_id_with_http_info(budget_id, account_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AccountsApi.get_account_by_id ...' end # verify the required parameter 'budget_id' is set if @api_client.config.client_side_validation && budget_id.nil? fail ArgumentError, "Missing the required parameter 'budget_id' when calling AccountsApi.get_account_by_id" end # verify the required parameter 'account_id' is set if @api_client.config.client_side_validation && account_id.nil? fail ArgumentError, "Missing the required parameter 'account_id' when calling AccountsApi.get_account_by_id" end # resource path local_var_path = '/budgets/{budget_id}/accounts/{account_id}'.sub('{' + 'budget_id' + '}', budget_id.to_s).sub('{' + 'account_id' + '}', account_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']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['bearer'] 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 => 'AccountResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: AccountsApi#get_account_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 account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def account; Account.get(self.account_id); end", "def...
[ "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.7991588", "0.79495734", "0.7806883", "0.7634226", "0.758146", "0.758146", "0.7475047", "0.7367855", "0.7353887", "0.7311101", "0.73054814", "0.7285499", "...
0.0
-1
Account list Returns all accounts
def get_accounts(budget_id, opts = {}) data, _status_code, _headers = get_accounts_with_http_info(budget_id, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accounts\n account_data = request('listaccounts')\n account_data.map do |account_name, account_value|\n Account.new(self, account_name, account_value, false)\n end\n end", "def get_accounts\n @accounts = Account.all\n end", "def all\n @dealing_platform.gather 'accounts',...
[ "0.8230852", "0.80566627", "0.79811406", "0.7957752", "0.78999263", "0.78936106", "0.78550804", "0.78464746", "0.77886575", "0.7787846", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", ...
0.0
-1
Account list Returns all accounts
def get_accounts_with_http_info(budget_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AccountsApi.get_accounts ...' end # verify the required parameter 'budget_id' is set if @api_client.config.client_side_validation && budget_id.nil? fail ArgumentError, "Missing the required parameter 'budget_id' when calling AccountsApi.get_accounts" end # resource path local_var_path = '/budgets/{budget_id}/accounts'.sub('{' + 'budget_id' + '}', budget_id.to_s) # query parameters query_params = {} query_params[:'last_knowledge_of_server'] = opts[:'last_knowledge_of_server'] if !opts[:'last_knowledge_of_server'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['bearer'] 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 => 'AccountsResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: AccountsApi#get_accounts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accounts\n account_data = request('listaccounts')\n account_data.map do |account_name, account_value|\n Account.new(self, account_name, account_value, false)\n end\n end", "def get_accounts\n @accounts = Account.all\n end", "def all\n @dealing_platform.gather 'accounts',...
[ "0.8230852", "0.80566627", "0.79811406", "0.7957752", "0.78999263", "0.78936106", "0.78550804", "0.78464746", "0.77886575", "0.7787846", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", "0.77548766", ...
0.0
-1
GET /pricing_sections or /pricing_sections.json
def index @pricing_sections = PricingSection.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end", "def pricing\n request('pricing', :get)\n end", "def sell_shop_se...
[ "0.650615", "0.64592797", "0.6401837", "0.63283855", "0.6098201", "0.6098201", "0.60506755", "0.6044163", "0.59810024", "0.59753543", "0.58807594", "0.58678555", "0.57875943", "0.57875943", "0.57875943", "0.5787582", "0.57462263", "0.5741422", "0.56877404", "0.56698936", "0.5...
0.709728
0
GET /pricing_sections/1 or /pricing_sections/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @pricing_sections = PricingSection.all\n end", "def pricing\n request('pricing', :get)\n end", "def show\n render json: @pricing\n end", "def set_pricing_section\n @pricing_section = PricingSection.find(params[:id])\n end", "def show\n @pricing_structure = PricingStru...
[ "0.7129712", "0.6749928", "0.66061246", "0.6418318", "0.62437844", "0.62264353", "0.6179155", "0.609767", "0.593823", "0.5931946", "0.5931946", "0.5931946", "0.5893725", "0.5858189", "0.5815258", "0.5803959", "0.57934517", "0.57934517", "0.5759789", "0.57518184", "0.5701516",...
0.0
-1
POST /pricing_sections or /pricing_sections.json
def create @pricing_section = PricingSection.new(pricing_section_params) respond_to do |format| if @pricing_section.save format.html { redirect_to @pricing_section, notice: "Pricing section was successfully created." } format.json { render :show, status: :created, location: @pricing_section } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @pricing_section.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pricing_section_params\n params.require(:pricing_section).permit(:section_id, :description)\n end", "def set_pricing_section\n @pricing_section = PricingSection.find(params[:id])\n end", "def update\n respond_to do |format|\n if @pricing_section.update(pricing_section_params)\n ...
[ "0.6557482", "0.6444953", "0.6319671", "0.6223495", "0.6102098", "0.6065209", "0.59367275", "0.59097797", "0.57917225", "0.5772799", "0.5720925", "0.5674241", "0.5656817", "0.5643312", "0.5618706", "0.5611128", "0.55987465", "0.55884993", "0.55769545", "0.5563262", "0.5562858...
0.7201398
0
PATCH/PUT /pricing_sections/1 or /pricing_sections/1.json
def update respond_to do |format| if @pricing_section.update(pricing_section_params) format.html { redirect_to @pricing_section, notice: "Pricing section was successfully updated." } format.json { render :show, status: :ok, location: @pricing_section } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @pricing_section.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_pricing_section\n @pricing_section = PricingSection.find(params[:id])\n end", "def update\n respond_to do |format|\n if @pricing.update(pricing_params)\n format.html { redirect_to @pricing, notice: 'Pricing was successfully updated.' }\n format.json { render :show, status: :...
[ "0.70158684", "0.67984235", "0.6566068", "0.6531886", "0.6475", "0.6372816", "0.63443524", "0.6183952", "0.6149243", "0.6140965", "0.6136654", "0.6130516", "0.61077875", "0.60778105", "0.6011418", "0.59976536", "0.59958106", "0.599171", "0.59874487", "0.5952463", "0.5949511",...
0.7647509
0
DELETE /pricing_sections/1 or /pricing_sections/1.json
def destroy @pricing_section.destroy respond_to do |format| format.html { redirect_to pricing_sections_url, notice: "Pricing section was successfully destroyed." } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @pricing.destroy\n\n head :no_content\n end", "def destroy\n @section = Section.find(params[:id])\n @section.destroy\n\n respond_to do |format|\n format.html { redirect_to sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section = Se...
[ "0.6980797", "0.67241883", "0.67241883", "0.6705014", "0.6673571", "0.667", "0.66619635", "0.66590655", "0.66590655", "0.6596321", "0.6587576", "0.6576339", "0.6574573", "0.64880896", "0.64826775", "0.64783835", "0.64728045", "0.6459528", "0.6452271", "0.6452271", "0.6437279"...
0.7631115
0
Use callbacks to share common setup or constraints between actions.
def set_pricing_section @pricing_section = PricingSection.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
Only allow a list of trusted parameters through.
def pricing_section_params params.require(:pricing_section).permit(:section_id, :description) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.63264...
0.0
-1
projects:list Display the available set of Mortar projects.
def list index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_projects # :nologin:\n query = create_query(:Project, :all, :by => :title)\n show_selected_projects(query)\n end", "def listprojects\n get('listprojects.json')['projects']\n end", "def list_all\n query = create_query(:Project, :all, by: default_sort_order)\n show_selected_projects(que...
[ "0.8321108", "0.81430775", "0.8031821", "0.78649247", "0.77635694", "0.77293485", "0.76331955", "0.76331955", "0.76258874", "0.76119924", "0.75845623", "0.75328326", "0.7458737", "0.73593843", "0.7344323", "0.7305017", "0.7255085", "0.7253378", "0.72194785", "0.7215072", "0.7...
0.0
-1
projects:delete PROJECTNAME Delete the Mortar project PROJECTNAME.
def delete name = shift_argument unless name error("Usage: mortar projects:delete PROJECTNAME\nMust specify PROJECTNAME.") end validate_arguments! projects = api.get_projects().body['projects'] project_id = nil if projects.any? projects.each do |project| if project['name'] == name project_id = project['project_id'] end end end if project_id.nil? display "\nNo project with name: #{name}" else # delete embedded project mirror if one exists mirror_dir = "#{git.mortar_mirrors_dir()}/#{name}" if File.directory? mirror_dir FileUtils.rm_r mirror_dir end # delete Mortar remote action("Sending request to delete project: #{name}") do api.delete_project(project_id).body['project_id'] end display "\nYour project has been deleted." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(projects)\n project_ids = projects.collect { |project| project.id } \n args = {ids: project_ids.to_json}\n return @client.api_helper.command(args, \"project_delete\")\n end", "def delete_project(project)\n handle_action_exceptions(__method__) do\n cmd_line = [\"dele...
[ "0.7917102", "0.78557205", "0.7784202", "0.7671753", "0.76519525", "0.7615767", "0.76097095", "0.75473964", "0.75473964", "0.75473964", "0.75473964", "0.75473964", "0.7539417", "0.7506018", "0.74974936", "0.7480534", "0.7477606", "0.74680436", "0.7467646", "0.7435846", "0.743...
0.86508876
0
projects:create PROJECTNAME Used when you want to start a new Mortar project using Mortar generated code. embedded Create a Mortar project that is not its own git repo. Your code will still be synced with a git repo in the cloud. public Register a public project, which can be viewed and forked by anyone.
def create name = shift_argument unless name error("Usage: mortar projects:create PROJECTNAME\nMust specify PROJECTNAME") end args = [name,] is_public = false if options[:public] is_public= true ask_public(is_public) end validate_project_name(name) project_id = register_api_call(name,is_public) Mortar::Command::run("generate:project", [name]) FileUtils.cd(name) is_embedded = false if options[:embedded] is_embedded = true register_do(name, is_public, is_embedded, project_id) else git.git_init git.git("add .") git.git("commit -m \"Mortar project scaffolding\"") register_do(name, is_public, is_embedded, project_id) display "NOTE: You'll need to change to the new directory to use your project:\n cd #{name}\n\n" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n name = shift_argument\n unless name\n error(\"Usage: mortar projects:create PROJECT\\nMust specify PROJECT.\")\n end\n validate_arguments!\n \n unless git.has_dot_git?\n error(\"Can only create a mortar project for an existing git project. Please run:\\n\\ngit init\\ngit a...
[ "0.82168484", "0.7927701", "0.777378", "0.7650788", "0.75814563", "0.7567293", "0.7528929", "0.7468335", "0.74408036", "0.73494047", "0.72913575", "0.72911626", "0.7288899", "0.72506505", "0.7239542", "0.72060895", "0.71818537", "0.71660745", "0.7132836", "0.70833194", "0.707...
0.8602962
0
projects:register PROJECTNAME Used when you want to start a new Mortar project using your existing code in the current directory. embedded Register code that is not its own git repo as a Mortar project. Your code will still be synced with a git repo in the cloud. public Register a public project, which can be viewed and forked by anyone.
def register name = shift_argument unless name error("Usage: mortar projects:register PROJECT\nMust specify PROJECT.") end validate_arguments! ask_public(options[:public]) #nil is non existant project_id because it hasn't been posted yet register_do(name, options[:public], options[:embedded], nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_do(name, is_public, is_embedded, project_id)\n if is_embedded\n validate_project_structure()\n\n register_project(name, is_public, project_id) do |project_result|\n initialize_embedded_project(project_result)\n end\n else\n unless git.has_dot_git?\n # check if we'...
[ "0.78097445", "0.66672343", "0.6485799", "0.6364393", "0.6080523", "0.6046141", "0.6040116", "0.601036", "0.5999332", "0.5999332", "0.59859055", "0.59563434", "0.59516287", "0.59289443", "0.58608466", "0.58344203", "0.5823962", "0.57886815", "0.57801175", "0.5723978", "0.5723...
0.831978
0
projects:set_remote PROJECTNAME Used after you checkout code for an existing Mortar project from a nonMortar git repository. Adds a remote to your local git repository to the Mortar git repository. For example if a coworker creates a Mortar project from an internal repository you would clone the internal repository and then after cloning call mortar projects:set_remote. embedded make this a embedded project tied to the specified remote
def set_remote project_name = shift_argument unless project_name error("Usage: mortar projects:set_remote PROJECT\nMust specify PROJECT.") end unless options[:embedded] unless git.has_dot_git? error("Can only set the remote for an existing git project. Please run:\n\ngit init\ngit add .\ngit commit -a -m \"first commit\"\n\nto initialize your project in git.") end if git.remotes(git_organization).include?("mortar") display("The remote has already been set for project: #{project_name}") return end end projects = api.get_projects().body["projects"] project = projects.find { |p| p['name'] == project_name} unless project error("No project named: #{project_name} exists. You can create this project using:\n\n mortar projects:create") end if options[:embedded] File.open(".mortar-project-remote", "w") do |f| f.puts project["git_url"] end git.sync_embedded_project(project, embedded_project_user_branch, git_organization) else git.remote_add("mortar", project["git_url"]) end display("Successfully added the mortar remote to the #{project_name} project") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_remote\n project_name = shift_argument\n\n unless project_name\n error(\"Usage: mortar projects:set_remote PROJECT\\nMust specify PROJECT.\")\n end\n\n unless git.has_dot_git?\n error(\"Can only set the remote for an existing git project. Please run:\\n\\ngit init\\ngit add .\\ngit c...
[ "0.87974554", "0.67510116", "0.6679692", "0.6569934", "0.6522725", "0.64648604", "0.6442583", "0.6284816", "0.62839985", "0.62839985", "0.62299085", "0.6183519", "0.61738694", "0.6101672", "0.59710914", "0.5843516", "0.58231604", "0.58125013", "0.58071613", "0.5791443", "0.57...
0.896468
0
projects:clone PROJECTNAME Used when you want to clone an existing Mortar project into the current directory.
def clone name = shift_argument unless name error("Usage: mortar projects:clone PROJECT\nMust specify PROJECT.") end validate_arguments! projects = api.get_projects().body["projects"] project = projects.find{|p| p['name'] == name} unless project error("No project named: #{name} exists. Your valid projects are:\n#{projects.collect{ |x| x["name"]}.join("\n")}") end project_dir = File.join(Dir.pwd, project['name']) unless !File.exists?(project_dir) error("Can't clone project: #{project['name']} since directory with that name already exists.") end git.clone(project['git_url'], project['name']) display "\nYour project is ready for use. Type 'mortar help' to see the commands you can perform on the project.\n\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clone\n\t\t did_clone = system \"git clone #{remote_path} projects/#{name}\"\n\t\t\tsystem \"cd projects/#{name} && git pull origin\" if !did_clone\n\t\tend", "def copy\n project_to_clone = Project.find(params[:id])\n @project = project_to_clone.clone\n\n # FIXME add copying of project team members...
[ "0.7456945", "0.67859703", "0.65468585", "0.64820933", "0.64382607", "0.63885105", "0.6360722", "0.6315655", "0.60633355", "0.60182697", "0.5974519", "0.5917901", "0.5908996", "0.5905753", "0.5873216", "0.58126414", "0.5793599", "0.5777473", "0.5745835", "0.5742597", "0.57370...
0.8546274
1
projects:fork GIT_URL PROJECT_NAME Used when you want to fork an existing Git repository into your own Mortar project. public Register a public project, which can be viewed and forked by anyone.
def fork git_url = shift_argument name = shift_argument unless git_url and name error("Usage: mortar projects:fork GIT_URL PROJECT\nMust specify GIT_URL and PROJECT.") end validate_arguments! validate_project_name(name) if git.has_dot_git? begin error("Currently in git repo. You can not fork a new project inside of an existing git repository.") rescue Mortar::Command::CommandFailed => cf error("Currently in git repo. You can not fork a new project inside of an existing git repository.") end end is_public = options[:public] ask_public(is_public) git.clone(git_url, name, git.fork_base_remote_name) Dir.chdir(name) # register a nil project id because it hasn't been created yet register_project(name, is_public, nil) do |project_result| git.remote_add("mortar", project_result['git_url']) git.push_master # We want the default remote to be the Mortar managed repo. git.git("fetch --all") git.set_upstream('mortar/master') display "Your project is ready for use. Type 'mortar help' to see the commands you can perform on the project.\n\n" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def admin_fork_repo(dst, src)\n response = HTTParty.post(\n GIT_BASE_URL + 'projects/' + dst.to_s + '/fork/' + src.to_s,\n :headers => {\n 'PRIVATE-TOKEN' => GIT_TOKEN\n }\n )\n Rails.logger.info \"Git server response (fork repo): #{response}\"\n end", "def create_repo_f...
[ "0.7000899", "0.6796955", "0.6410218", "0.6164391", "0.6145727", "0.6117099", "0.61133814", "0.6104223", "0.60817224", "0.60664755", "0.6032076", "0.59603673", "0.59322625", "0.5931203", "0.5917447", "0.5913743", "0.5909714", "0.58901495", "0.5862971", "0.58540183", "0.585145...
0.8252669
0
GET /users GET /users.json def index
def index authorize! :index, User @datatable = UsersDatatable.new view_context end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n users = User.all\n json_response(users)\n end", "def index\n @users = User.all\n logger.debug(\"user index\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end", "def index\n if params[:single]\n\t url =...
[ "0.85333496", "0.85263276", "0.8451336", "0.83828354", "0.8381708", "0.83795655", "0.83712995", "0.8360554", "0.8356165", "0.8350339", "0.8280744", "0.8264254", "0.8264254", "0.82625717", "0.82575315", "0.82527727", "0.82527727", "0.82527727", "0.82527727", "0.82527727", "0.8...
0.0
-1
GET /users/1 GET /users/1.json
def show authorize! :show, @user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.81046426", "0.7703556", "0.77011716", "0.76262826", "0.7582106", "0.74818", "0.7461394", "0.7446168", "0.730656", "0.7300699", "0.72902125", "0.72781444", "0.72358584", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.722...
0.0
-1
POST /users POST /users.json
def create authorize! :create, User @user = User.new(user_params) if @user.save flash[:notice] = 'User is created successfully. ' else flash.now[:alert] = @user.errors.full_messages.first end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end", "def post b...
[ "0.77179813", "0.75206673", "0.73831296", "0.72405374", "0.719841", "0.7140812", "0.71038526", "0.7058827", "0.7041636", "0.70236504", "0.7003128", "0.70021695", "0.70021695", "0.70021695", "0.69936967", "0.6990463", "0.6980393", "0.6979075", "0.69788617", "0.69788617", "0.69...
0.0
-1
PATCH/PUT /users/1 PATCH/PUT /users/1.json
def update authorize! :update, @user if @user.update(user_params) flash.now[:notice] = '@user was successfully updated.' else flash.now[:alert] = @user.errors.full_messages.first end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "de...
[ "0.7225568", "0.7129473", "0.70036036", "0.6903525", "0.6821961", "0.68157715", "0.6708618", "0.66936064", "0.66810983", "0.6673763", "0.6672601", "0.6664346", "0.6664346", "0.6659468", "0.6659468", "0.6654875", "0.66486204", "0.66436917", "0.6641295", "0.6635214", "0.6618464...
0.0
-1
DELETE /users/1 DELETE /users/1.json
def destroy authorize! :destroy, @user @user.destroy respond_to do |format| format.html { redirect_to users_url, notice: 'User was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def delete\n render json: Users.delete(params[\"id\...
[ "0.78750724", "0.77518034", "0.7713981", "0.7610077", "0.747295", "0.74073994", "0.74073994", "0.7369968", "0.7346072", "0.7340465", "0.7328618", "0.7309635", "0.73095363", "0.7306841", "0.7297868", "0.72917855", "0.7291585", "0.7289111", "0.7284347", "0.7250935", "0.7250935"...
0.0
-1
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
Only allow a list of trusted parameters through.
def user_params params.require(:user).permit(:email, :password, :password_confirmation, :mobile, :name, :admin) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.63264...
0.0
-1
just return a number does not return a rank, just sort all the users to have a rank type is either :cash or :tourney
def virtual_rank(type, group) return chips(group.id) if type == :cash return tourney_rank(group) if type == :tourney raise "invalid type for rankings (#{type.to_s}})" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rank() User.withVerifiedWeighins.paid.sort_by {|u| u.percentWeightChange }.index(self)+1 end", "def f2p_clues_rank(clue_type)\n f2p_rank [[\"clues_#{clue_type}\", :DESC],\n [\"id\", :ASC]]\n end", "def sort_using_rank\n score[1]\n end", "def rank\n BetaUser.where(selected: false)....
[ "0.67329633", "0.6563013", "0.6537982", "0.64468825", "0.6280818", "0.6235899", "0.62220144", "0.6175744", "0.6169046", "0.6165289", "0.61638117", "0.615843", "0.614226", "0.6095294", "0.60907006", "0.60687727", "0.60665387", "0.60665387", "0.6041314", "0.5996539", "0.596579"...
0.64397794
4
Write a method named xor that takes two arguments, and returns true if exactly one of its arguments is truthy, false otherwise.
def xor?(x, y) return true if x && !y return true if y && !x false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xor?(arg1, arg2)\n if arg1 && !arg2\n true\n elsif !arg1 && arg2\n true\n else \n false\n end\nend", "def xor?(first_arg, second_arg)\n return true if first_arg == false && second_arg == true\n return true if first_arg == true && second_arg == false\nend", "def xor?(arg1, arg2)\n if arg1 &&...
[ "0.8717416", "0.8666821", "0.86460924", "0.86209816", "0.86036307", "0.8595236", "0.858767", "0.8576675", "0.85737514", "0.85692316", "0.8515411", "0.8457522", "0.8388781", "0.8323613", "0.82958066", "0.82783943", "0.82055634", "0.8176512", "0.8133452", "0.81316817", "0.81065...
0.8088864
23
Write a method that takes a single String argument and returns a new string that contains the original value of the argument, but the first letter of every word is now capitalized. You may assume that words are any sequence of nonblank characters, and that only the first character of each word must be considered. Examples
def word_cap(strs) strs.split.map do |str| str.capitalize end.join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_cap2(str) # Without Using .capitalize method\n str.split.each { |word| word[0] = word[0].upcase }.join(\" \")\nend", "def capitalized string\n little_words = [\"a\", \"an\", \"the\", \"and\", \"in\", \"of\"]\n string = string.downcase\n string = string.split(\" \")\n if str...
[ "0.82596326", "0.821193", "0.80596143", "0.8053398", "0.80417114", "0.8025429", "0.8023036", "0.80071825", "0.8003106", "0.79722494", "0.79678386", "0.79623693", "0.7956512", "0.7938355", "0.7935863", "0.79354143", "0.7928802", "0.79246914", "0.7901144", "0.7880979", "0.78769...
0.76632994
76
Code blocks are anonymous functions that provide closure like functionality. The execution flow passes to the code block, due to yield method.
def function_Name puts "Sample Function Name" yield() puts "monkey" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end"...
[ "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167", "0.73626167"...
0.0
-1
code block paramets are enclosed between |parameter_name|
def code_block_parameter puts "random function name" yield 10, 20, 30 #yield (10,20,30) --> not working puts "after Yield, Yes () are optional" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def code\n str = Indentation.get\n str << \"var #{name} = function(#{@parameters.join(', ')}) {\\n\"\n Indentation.indent { str << \"#{block}\\n\" }\n str << \"#{Indentation.get}};\\n\"\n str\n end", "def yieldparam_tag(text); end", "def m12a(p1,p2,p3, &blk)\n\tyield(p1,p2) # два па...
[ "0.6844057", "0.6674636", "0.6464549", "0.6450759", "0.64361006", "0.64361006", "0.6356482", "0.63479406", "0.63126856", "0.62919724", "0.6279644", "0.62644047", "0.6240531", "0.6240011", "0.616068", "0.6160082", "0.6160082", "0.60925835", "0.60686475", "0.60672027", "0.60588...
0.63985
6
Returns all the plan in the system.
def all_plans file = File.read('./data/bundle.json') plan_hash = JSON.parse(file) plans = plan_hash['plans'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_plans\n if current_user.typeofuser == \"admin\" then\n @tenant = current_user.tenant\n @current_plan = @tenant.pricing_plan\n @selected_plan = PricingPlan.find(@tenant.selected_plan_id)\n @pricing_plans = PricingPlan.where(:plan_type => 'public')\n end\n end", "def plans\n ...
[ "0.7926094", "0.7530647", "0.7410767", "0.73074496", "0.7189474", "0.70819163", "0.6938462", "0.6937519", "0.6937519", "0.6922988", "0.6914073", "0.68426526", "0.68238723", "0.67964655", "0.67837745", "0.6783648", "0.6762163", "0.675067", "0.6743963", "0.6743817", "0.6728411"...
0.69127774
11
Prints the best plan for the selected features. Shows the total price of the plan selected.
def to_s if match? "Best Plan: " + @plans_name + "for $" + '%.2f' % [(@cost * 100).round / 100.0] else "No matching plan for your features" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optimal_plan=(plans)\n @plans = plans\n @cost = 0.00\n @plans_name = \"\"\n @features_count = 0\n @plans.each do |plan|\n @cost += plan['cost']\n @plans_name += plan['name'] + \" \"\n @features_count += plan['features'].size\n end\n end", "def do_filtered_plan_display\n ...
[ "0.62128544", "0.58965933", "0.57153493", "0.5684067", "0.5590316", "0.55577505", "0.5530362", "0.55002445", "0.54985905", "0.54802513", "0.5435955", "0.54123163", "0.53586847", "0.5356282", "0.5331135", "0.5311932", "0.5305011", "0.52871114", "0.52792466", "0.52788854", "0.5...
0.70799404
0
is there at least one matching plan(s) for requested features
def match? @plans and @plans.size > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_feature?(*feature_names, match: :all?)\n features = get_var!(\"features\", single_match: :force)\n feature_names.map(&:to_s).send(match) do |feature_name|\n features.include? feature_name\n end\n end", "def cheaper?(plan)\n cost = plan.inject(0) {|sum,plan| sum + plan['cost']}\n feat...
[ "0.6741976", "0.64889693", "0.64785147", "0.6353291", "0.6352293", "0.6303821", "0.6282219", "0.6277143", "0.62335676", "0.61741847", "0.61596876", "0.6124389", "0.6063933", "0.6063024", "0.60503775", "0.6031704", "0.6029332", "0.5998901", "0.5987527", "0.5957292", "0.5953631...
0.708158
0
returns an array of all combinations of plans where the selected feature exist Example F1 selected feature existing in following plans [[P1],[P1,P2]...]
def matching_combinations(plans, selected_features) a = {} # array of plan indexed by feature # Example F1 => [P1, P2], F2 => [P2, P3] ... plans.each do |plan| plan['features'].each do |f| a[f] ||= [] a[f] << plan end end # Returns an array of all combinations of elements from all arrays. # [P1,P2].product([P3,P4]) #=> [[P1,P3],[P1,P4],[P2,P3],[P2,P4]] # @ref http://ruby-doc.org/core-1.9.3/Array.html#method-i-product combinations = selected_features.drop(1).inject(a[selected_features[0]]) do |result, element| result.product(a[element] || []) end || [] # Get the unique plans as 2 different features can belong to same plan combinations.each do |plans| plans = [plans] if plans.is_a?(Hash) plans.flatten! plans.uniq! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def combinations\n self.locations.product(self.criterias)\n end", "def plans(within_product=nil)\n product_id = within_product ? within_product.enabled_products.map(&:id) + [within_product.id] : nil\n Plan.where(:id => plan_ids, :product_id => product_id).all\n end", "def opt_param...
[ "0.6114172", "0.6042254", "0.57879674", "0.5766543", "0.57328206", "0.56937814", "0.56345755", "0.56344414", "0.5536038", "0.5522393", "0.54283637", "0.5384993", "0.53054136", "0.52885693", "0.5281848", "0.52582914", "0.5251883", "0.5247608", "0.52353096", "0.5226844", "0.518...
0.77840865
0
set lowest plan and compute global name/feature_count/cost
def optimal_plan=(plans) @plans = plans @cost = 0.00 @plans_name = "" @features_count = 0 @plans.each do |plan| @cost += plan['cost'] @plans_name += plan['name'] + " " @features_count += plan['features'].size end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cheaper?(plan)\n cost = plan.inject(0) {|sum,plan| sum + plan['cost']}\n features_count = plan.inject(0) {|sum,plan| sum + plan['features'].size}\n @cost.nil? or cost < @cost or (cost == @cost && features_count > @features_count)\n end", "def plan\n 0\n end", "def plan; end", "def to_s\n ...
[ "0.65415066", "0.6359894", "0.60918415", "0.60409456", "0.59103656", "0.58384174", "0.5773555", "0.5761045", "0.57514215", "0.5713995", "0.5692845", "0.5675192", "0.56427705", "0.56001556", "0.558127", "0.55578923", "0.5552348", "0.55357087", "0.548267", "0.548267", "0.548014...
0.6954604
0
Is the matching plan cheaper? We make two assumptions here: 1. If cost are equal, return the plan with more features as cheaper plan 2. If cost are equal, feature count is same and feature belongs to both plan, the first plan retrieved is selected. This behavior can be easily changed. Based on business need both plan can be shown to user or A/B test can be performed on the plan
def cheaper?(plan) cost = plan.inject(0) {|sum,plan| sum + plan['cost']} features_count = plan.inject(0) {|sum,plan| sum + plan['features'].size} @cost.nil? or cost < @cost or (cost == @cost && features_count > @features_count) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n if match?\n \"Best Plan: \" + @plans_name + \"for $\" + '%.2f' % [(@cost * 100).round / 100.0]\n else\n \"No matching plan for your features\"\n end\n end", "def matching_combinations(plans, selected_features)\n a = {}\n \n # array of plan indexed by feature\n # Example...
[ "0.68194604", "0.6333256", "0.6147887", "0.60911", "0.59614336", "0.59326947", "0.58656025", "0.5775174", "0.5746929", "0.57186216", "0.57186216", "0.5688096", "0.568036", "0.5651539", "0.55394995", "0.54938084", "0.54895586", "0.547203", "0.5471945", "0.5430631", "0.5408961"...
0.8141394
0
Takes the User object and returns the months since last login.
def adjust_balances_if_monthchange(user) #Works out how many months have passed since last login. The formula ensures it works over new year. months_since_last_login = (DateTime.now.year*12+DateTime.now.month) - (user.last_login.year*12+user.last_login.month) logger.debug "\nUpdated current cadets areers by #{months_since_last_login} months." #If no months have passed, this is skipped, otherwise the cadet balences are incremented. #Note that cadets marked as discharged aren't updated. months_since_last_login.times { current_user.cadets.each { |c| #updates the cadet's balances. c.balance = c.balance - user.amount_per_month unless c.discharged?; c.save! } } return months_since_last_login end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def months\n\t\treturn self * 30.days\n\tend", "def months\n\t\treturn self * 30.days\n\tend", "def months ; self * 30.days ; end", "def months() 30 * days end", "def months\n @years * 12\n end", "def months_since(date)\n return (DateTime.now - date.to_datetime).to_i*(12/365.25)\n end", "de...
[ "0.652", "0.652", "0.64711374", "0.64426523", "0.63297087", "0.62746316", "0.61150825", "0.6061112", "0.60335386", "0.6023007", "0.59973747", "0.5994615", "0.5968101", "0.59560156", "0.59429145", "0.590177", "0.5901532", "0.5900217", "0.5882207", "0.5841226", "0.5822846", "...
0.5980503
12
to prevent undefined method when forms are involved
def protect_against_forgery? false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def form; end", "def forms; end", "def form_data?; end", "def injection_form\n # Nothing to do here\n end", "def form\n end", "def ing_form; end", "def spoofForm(val)\n @deltaflag = false\n @form = val\n end", "def form_view\n end", "def patient_forms\n # blank\n end", "def form_...
[ "0.7534891", "0.7295134", "0.7042261", "0.69481647", "0.6913049", "0.67655593", "0.663577", "0.6473257", "0.63841915", "0.6318648", "0.62957895", "0.6165333", "0.6165333", "0.6165333", "0.6165333", "0.6152266", "0.61469185", "0.61469185", "0.61275476", "0.60492545", "0.602257...
0.0
-1
adds the necessary javascript include tags, stylesheet tags, and load event with necessary javascript to activate wym editor(s)
def wym_editor_initialize(*dom_ids) editor_ids = (@wym_editor_ids || []) + wym_extract_dom_ids(*dom_ids) output = [] output << stylesheet_link_tag('/wymeditor/wymeditor/skins/default/screen') output << javascript_include_tag('/wymeditor/jquery/jquery') output << javascript_include_tag('/wymeditor/wymeditor/lang/en.js') output << javascript_include_tag('/wymeditor/wymeditor/jquery.wymeditor.js') output << javascript_include_tag('/wymeditor/wymeditor/jquery.wymeditor.explorer.js') output << javascript_include_tag('/wymeditor/wymeditor/jquery.wymeditor.mozilla.js') output << javascript_include_tag('/wymeditor/wymeditor/jquery.wymeditor.opera.js') output << javascript_include_tag('/wymeditor/wymeditor/jquery.wymeditor.safari.js') output << javascript_include_tag('/javascripts/boot_wym.js') output.join("\n") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_js\n AssetManager.include_contrib_library [:core_ui, :jquery_tab]\n AssetManager.include_local_library [ 'ckeditor/init']\n\n AssetManager.include_css [:blog_global]\n end", "def page_script(context={})\n \n [\"/htmleditor/js/jquery.wysiwyg.js\",\n \"/htmleditor/js/ysd.editor.js\...
[ "0.7019391", "0.6608026", "0.6321885", "0.6229285", "0.62082946", "0.61583054", "0.6098102", "0.6011592", "0.60063833", "0.5863114", "0.58468765", "0.5834803", "0.5834803", "0.5790196", "0.5755622", "0.5695198", "0.56814504", "0.5668234", "0.5648277", "0.5646434", "0.5643013"...
0.69603467
1
cheap way to get module_function s from everything
def gentest argv argv = argv.dup @both = false process_opts(argv) if /^-/ =~ argv.first @service_controller = deduce_services_controller @ui = Hipe::IndentingStream.new($stdout,'') file = argv.shift mod = deduce_module_from_file file mod.spec.invocation_name = File.basename(file) get_actuals mod, argv @ui.indent!.indent! go_app(mod, file) go_desc(mod, file) do go_exp go_act(mod, argv) end exit(0) # rake is annoying end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def module_function(sym, *rest) end", "def call\n moduleFunction\n end", "def register_module_function(object); end", "def modules_for_helpers(modules_or_helper_prefixes); end", "def modules_for_helpers(args); end", "def method_module\n home.method_module\n end", "def modules; end", "def modu...
[ "0.7539681", "0.66389096", "0.6538773", "0.6528515", "0.6448185", "0.63964003", "0.63705623", "0.63705623", "0.63705623", "0.6216277", "0.6207098", "0.61999846", "0.6125097", "0.61241394", "0.6110246", "0.6099739", "0.60307765", "0.60126466", "0.60106075", "0.6010462", "0.594...
0.0
-1
Sets the token value for the current session and returns it in a masked form that's safe to send to the client. See section 3.4 of "BREACH: Reviving the CRIME attack".
def masked_authenticity_token(session) one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN_LENGTH) encrypted_csrf_token = xor_byte_strings(one_time_pad, real_csrf_token(session)) masked_token = one_time_pad + encrypted_csrf_token Base64.strict_encode64(masked_token) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def masked_authenticity_token(session, form_options: T.unsafe(nil)); end", "def set_token\n self.token = SecureRandom.hex(16)\n end", "def set_token\n self.token = SecureRandom.hex(16)\n end", "def set_token\n self.token ||= SecureRandom.uuid.gsub(/\\-/, '').first(5).upcase\n end", "def set_tok...
[ "0.6830139", "0.65041685", "0.65041685", "0.64283067", "0.6327143", "0.6318878", "0.6278038", "0.6204214", "0.61473805", "0.6131066", "0.61267567", "0.6109995", "0.6098966", "0.60460377", "0.6044267", "0.60171235", "0.5985372", "0.59787583", "0.59399724", "0.5924458", "0.5910...
0.70682895
0
Checks the client's masked token to see if it matches the session token. Essentially the inverse of +masked_authenticity_token+.
def valid_authenticity_token?(session, encoded_masked_token) return false if encoded_masked_token.nil? || encoded_masked_token.empty? masked_token = Base64.strict_decode64(encoded_masked_token) return false if masked_token.length != AUTHENTICITY_TOKEN_LENGTH * 2 # Split the token into the one-time pad and the encrypted # value and decrypt it one_time_pad = masked_token[0...AUTHENTICITY_TOKEN_LENGTH] encrypted_csrf_token = masked_token[AUTHENTICITY_TOKEN_LENGTH..-1] csrf_token = xor_byte_strings(one_time_pad, encrypted_csrf_token) csrf_token == real_csrf_token(session) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_authenticity_token?(session, encoded_masked_token); end", "def masked_authenticity_token(session)\n one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN_LENGTH)\n encrypted_csrf_token = xor_byte_strings(one_time_pad, real_csrf_token(session))\n masked_token = one_time_pad + ...
[ "0.8165088", "0.6949309", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.6852407", "0.67660624", "0.67561024", "0.67561024", "0.67561024", "0.67531353", "0.67362356...
0.8027464
1
Destroy all records and stop Daemon script on logout
def destroy system "ruby streaming_script.rb stop" session[:username] = nil User.all.each do |user| user.destroy end User.reset_pk_sequence Tweet.all.each do |tweet| tweet.destroy end Tweet.reset_pk_sequence reset_session redirect_to root_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n log_out\n end", "def destroy\n kill\n reset\n end", "def daemon_clean_up\n TaskQueue.where(id: $daemon[:heartbeat_task_queue_id]).destroy_all\n File.delete($daemon[:pid_file])\nend", "def clean_sessions\n self.log_puts(\"Cleaning sessions on appserver.\") if @debug\n...
[ "0.66424865", "0.6568091", "0.65014905", "0.64252025", "0.6346752", "0.63371754", "0.63297087", "0.6321891", "0.6320664", "0.6310702", "0.6285546", "0.6282958", "0.6278167", "0.62675714", "0.62645936", "0.6254862", "0.6188635", "0.6183023", "0.61717826", "0.6139106", "0.61391...
0.66317403
1
def full_address address = [self.street_address, self.city] address.push(self.state) unless self.state.blank? address.push(self.postal_code) unless self.postal_code.blank? address.push(self.country) address.join(", ") end
def all_phones_vendor if self.phone.blank? && self.alt_phone.blank? return "Not shown" elsif self.alt_phone.blank? return self.phone elsif self.phone.blank? return self.alt_phone else return "#{self.phone} / #{self.alt_phone}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_address\n\t\t[\"#{self.street}\", self.city, self.country].compact.join(', ')\n\tend", "def full_address\n full_address = \"\"\n unless self.address.blank?\n full_address += self.address\n end\n unless self.city.blank?\n full_address += \", \" + self.city\n end\n unless self....
[ "0.92671585", "0.9200169", "0.9180925", "0.917997", "0.91260433", "0.90960443", "0.9096008", "0.9065554", "0.90654063", "0.8994806", "0.89553076", "0.890423", "0.8900255", "0.8865048", "0.88640606", "0.8838104", "0.88274795", "0.8826684", "0.8825708", "0.8808252", "0.87865716...
0.0
-1
def check_address? [street_address_changed?, city_changed?, state_changed?, postal_code_changed?, country_changed?].any? end
def inactive_date if inactive_changed? if inactive? self.inactive_from = Time.now else self.inactive_from = nil end end def new_ownership @user = User.find(self.created_by) Ownership.create(business_id: self.id, user_id: self.created_by, email_address: @user.email, created_by: self.created_by) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def address_changed?\n \tstreet_changed? || city_changed? || state_changed?\n end", "def full_hq_address_changed?\n hq_address_changed? || hq_zip_code_changed? || hq_city_changed? || hq_country_changed?\n end", "def should_geocode?\n address.present? && (address_changed? || !latitude || !longitude)\n ...
[ "0.88526523", "0.8323529", "0.7554205", "0.7497203", "0.74474555", "0.74288017", "0.7410452", "0.7330024", "0.7250618", "0.72253186", "0.70726055", "0.70486546", "0.7045269", "0.7023302", "0.6990546", "0.6892447", "0.6883941", "0.687011", "0.6840467", "0.6832624", "0.6819438"...
0.0
-1
GET /calendars/1 GET /calendars/1.xml
def show @calendar = Calendar.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @calendar } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calendars\n records 'calendar', '/calendars.xml', :method => :get\n end", "def calendar\n get '/gtfs/calendar'\n end", "def calendar_events(calendar_id)\n records \"/calendars/#{calendar_id}/calendar_events.xml\", :method => :get\n end", "def list_calendars\n unless @calendar...
[ "0.83324295", "0.7815758", "0.73857427", "0.73124325", "0.7286438", "0.7247076", "0.7195674", "0.71288174", "0.70427966", "0.7022576", "0.69627964", "0.695235", "0.69320506", "0.69304955", "0.69044256", "0.680493", "0.67488253", "0.6747682", "0.6746255", "0.67403746", "0.6724...
0.7297926
5
GET /calendars/new GET /calendars/new.xml
def new @calendar = Calendar.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @calendar } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @calendario = Calendario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @calendario }\n end\n end", "def new\n @calendar_event = CalendarEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { rend...
[ "0.75729984", "0.7558967", "0.7361929", "0.7361929", "0.73416984", "0.73271686", "0.7290582", "0.71744484", "0.71178424", "0.7048005", "0.7029269", "0.70134854", "0.69354343", "0.69273424", "0.6912992", "0.6858443", "0.68197453", "0.6809624", "0.67458385", "0.6713474", "0.671...
0.7901439
3
POST /calendars POST /calendars.xml
def create @calendar = Calendar.new(params[:calendar]) respond_to do |format| if @calendar.save flash[:notice] = 'Calendar was successfully created.' format.html { redirect_to(@calendar) } format.xml { render :xml => @calendar, :status => :created, :location => @calendar } else format.html { render :action => "new" } format.xml { render :xml => @calendar.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def schedule\n POST \"https://www.googleapis.com/calendar/v3/calendars/#{calendar_id}/events\"\n render \"schedule\"\n end", "def calendars\n records 'calendar', '/calendars.xml', :method => :get\n end", "def http_mk_calendar(request, _response)\n body = request.body_as_string\n pa...
[ "0.7142082", "0.71316516", "0.68008906", "0.6781165", "0.6524191", "0.6507283", "0.6478495", "0.64572924", "0.64560366", "0.64473957", "0.62847143", "0.6217834", "0.61973417", "0.61833847", "0.61407286", "0.6137919", "0.61292046", "0.612832", "0.6123774", "0.60921174", "0.605...
0.6699629
4
PUT /calendars/1 PUT /calendars/1.xml
def update @calendar = Calendar.find(params[:id]) respond_to do |format| if @calendar.update_attributes(params[:calendar]) flash[:notice] = 'Calendar was successfully updated.' format.html { redirect_to(@calendar) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @calendar.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @calendar = Calendar.find(params[:id])\n\n respond_to do |format|\n if @calendar.update_attributes(params[:calendar])\n format.html { redirect_to @calendar, :notice => 'Calendar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ...
[ "0.67149985", "0.6685749", "0.6567797", "0.6494846", "0.64824784", "0.64787394", "0.6461926", "0.6461926", "0.6413853", "0.6378897", "0.63606536", "0.6280817", "0.6242284", "0.6197591", "0.6190485", "0.6185639", "0.6165237", "0.6163055", "0.6144471", "0.6144471", "0.6144471",...
0.6937048
2
DELETE /calendars/1 DELETE /calendars/1.xml
def destroy @calendar = Calendar.find(params[:id]) @calendar.destroy respond_to do |format| format.html { redirect_to(calendars_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @calendar = Calendar.find(params[:id])\n @calendar.destroy\n\n respond_to do |format|\n format.html { redirect_to(bin_calendars_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @calendar = Calendar.find(params[:id])\n @calendar.destroy\n\n respond_to do...
[ "0.7565846", "0.75267005", "0.75267005", "0.75267005", "0.7416957", "0.7382632", "0.73236775", "0.71978337", "0.71686584", "0.71468234", "0.70761853", "0.7074887", "0.70444226", "0.69760174", "0.69760174", "0.69760174", "0.69476295", "0.6935693", "0.69210047", "0.67908245", "...
0.7489783
4
This algorythm is not ok, because it depends on the input. If I sort the nail sequence then the algorythm fails
def findFirstNail(plankBegin, plankEnd, nails) do_debug "b:#{plankBegin} e:#{plankEnd} nails:#{nails}" result = -1 # The index of nail in the original array resultPos = -1 # The index of nail in the sorted array nailLower = 0 nailUpper = nails.size - 1 nailMid = 0 while nailLower <= nailUpper do nailMid = (nailLower + nailUpper) / 2 nailPosMid = nails[nailMid][1] do_debug "l:#{nailLower} u:#{nailUpper} m:#{nailMid} npm:#{nailPosMid}" if nailPosMid < plankBegin nailLower = nailMid + 1 do_debug "rising lower bound nailLower:#{nailLower}" elsif nailPosMid > plankEnd nailUpper = nailMid - 1 do_debug "lowering upper bound nailUpper:#{nailUpper}" else nailUpper = nailMid - 1 result = nails[nailMid][0] resultPos = nailMid do_debug "adjusting: upper bound nailUpper:#{nailUpper}" do_debug "result: #{result}" do_debug "resultPos: #{resultPos}" end end [result, resultPos] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(n)\n siblings = n.to_s.chars.each_slice(1).to_a\n siblings.sort {|x,y| -(x <=> y)}.join.to_i\nend", "def sequence(hidden, open)\n weight = { 1 => \"A\", 2 => \"2\", 3 => \"3\", 4 => \"4\", 5 => \"5\", 6 => \"6\", 7 => \"7\", 8 => \"8\", 9 => \"9\", \n 10 => \"T\", 11 => \"J\", 12 => \"Q\",...
[ "0.6679203", "0.6467372", "0.6438212", "0.6434923", "0.6413566", "0.634645", "0.6256383", "0.6164571", "0.61275226", "0.6104325", "0.6102129", "0.6092222", "0.60886526", "0.6066543", "0.60653037", "0.6042917", "0.6025384", "0.60250777", "0.60055864", "0.59936637", "0.59666616...
0.0
-1
I could extract the return of this function into an object data_clump
def determine_damage if Random.rand(100) < critical_rate [fighter_attack * 2, FightEvent.attack_types['critical']] else [fighter_attack, FightEvent.attack_types['normal']] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def get_data()\t\n\tend", "def getc() end", "def getc() end", "def getc() end", ...
[ "0.61500263", "0.61500263", "0.61500263", "0.61500263", "0.61500263", "0.61500263", "0.61500263", "0.61500263", "0.61500263", "0.61500263", "0.61500263", "0.61500263", "0.61417675", "0.60870653", "0.60870653", "0.60870653", "0.59817535", "0.59810597", "0.59617096", "0.59605724"...
0.0
-1
GET /restaurants/1/tables GET /restaurants/1/tables.json
def index @tables = @restaurant.tables end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @restaurant_table = RestaurantTable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant_table }\n end\n end", "def list(table)\n self.get(\"/#{table}\")\n end", "def listRestaurants\n _restaurants = Restaurant...
[ "0.7248467", "0.6869382", "0.68106014", "0.6714031", "0.6665551", "0.66593635", "0.66562", "0.6310047", "0.6297372", "0.62689877", "0.6236629", "0.62266326", "0.62266326", "0.62266326", "0.6197502", "0.6129593", "0.61229014", "0.61080986", "0.60944676", "0.6091092", "0.608061...
0.7427656
0
GET /restaurants/1/tables/1 GET /restaurants/1/tables/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @restaurant_table = RestaurantTable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant_table }\n end\n end", "def index\n @tables = @restaurant.tables\n end", "def index \n restaurant = Restaurant.all\n ...
[ "0.7315217", "0.7297612", "0.6770574", "0.6756205", "0.67242134", "0.66625845", "0.6605243", "0.6538266", "0.6438962", "0.63313365", "0.63099295", "0.62681705", "0.62656367", "0.62656367", "0.62656367", "0.6200736", "0.61851645", "0.61309767", "0.6121084", "0.61134136", "0.61...
0.0
-1
POST /restaurants//tables POST /restaurants/1/tables.json
def create @table = @restaurant.tables.build(table_params) respond_to do |format| if @table.save format.html { redirect_to restaurant_tables_path(@restaurant), notice: 'Table was successfully created.' } format.json { render :show, status: :created, location: @table } else format.html { render :new } format.json { render json: @table.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n if current_user.restaurant_ids.include?(params[:restaurant_id].to_i)\n # find new table number\n table_index = 1\n tables = Table.where(restaurant_id: params[:restaurant_id])\n if !tables.nil? && tables.count > 0\n tables.each do |table|\n table_index = table.tab...
[ "0.72751194", "0.676111", "0.6393096", "0.6262105", "0.5993949", "0.58371073", "0.5829471", "0.5816438", "0.5790426", "0.5720594", "0.5675311", "0.56332034", "0.560765", "0.55981475", "0.5595866", "0.5579365", "0.5562936", "0.5526544", "0.5522176", "0.5507415", "0.5474045", ...
0.71772075
1
PATCH/PUT /restaurants/1/tables/1 PATCH/PUT /restaurants/1/tables/1.json
def update respond_to do |format| if @table.update(table_params) format.html { redirect_to restaurant_tables_path(@restaurant), notice: 'Table was successfully updated.' } format.json { render :show, status: :ok, location: @table } else format.html { render :edit } format.json { render json: @table.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @restaurant_table = RestaurantTable.find(params[:id])\n\n respond_to do |format|\n if @restaurant_table.update_attributes(params[:restaurant_table])\n format.html { redirect_to @restaurant_table, notice: 'Restaurant table was successfully updated.' }\n format.json { head :no_c...
[ "0.6857745", "0.6312511", "0.6252273", "0.6060474", "0.602739", "0.5971374", "0.5960167", "0.5894511", "0.58566034", "0.58282554", "0.5821747", "0.5800232", "0.57935786", "0.57913935", "0.57905793", "0.5781102", "0.57748574", "0.57748574", "0.57748574", "0.57748574", "0.57634...
0.6892507
0
DELETE /restaurants/1/tables/1 DELETE /restaurants/1/tables/1.json
def destroy @table.destroy respond_to do |format| format.html { redirect_to tables_url, notice: 'Table was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @restaurant_table = RestaurantTable.find(params[:id])\n @restaurant_table.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurant_tables_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # DELETE\n # TODO: removes a specific restaur...
[ "0.7486505", "0.7044491", "0.6873011", "0.67982674", "0.67982674", "0.67982674", "0.67982674", "0.67982674", "0.67982674", "0.67982674", "0.67982674", "0.6787941", "0.67438287", "0.67438287", "0.67438287", "0.67352796", "0.67216164", "0.66654927", "0.66171163", "0.6615374", "...
0.6285904
84
Use callbacks to share common setup or constraints between actions.
def set_restaurant @restaurant = Restaurant.find(params[:restaurant_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 table_params params.require(:table).permit(:restaurant_id, :number_table) 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
two arguments and returns the product of the two numbers.
def multiply(a,b) a * b end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def product(num1, num2)\n num1 * num2\nend", "def multiply_two_numbers( x, y )\n x * y\nend", "def prod(x,y)\n x*y\nend", "def multiply(first_number, second_number)\n return first_number * second_number\nend", "def multiply(first_number, second_number)\n return first_number * second_number\nend", "d...
[ "0.80911416", "0.8019841", "0.78480786", "0.78205353", "0.78205353", "0.7803001", "0.7801665", "0.77984434", "0.7797936", "0.7796563", "0.7793577", "0.7771764", "0.7767486", "0.7764761", "0.7746023", "0.77152795", "0.7681972", "0.7681675", "0.76719564", "0.7670739", "0.764938...
0.0
-1
read options from YAML config
def configure # config file default options configuration = { :options => { :verbose => false, :color => 'AUTO' } } # set default config if not given on command line config = @options[:config] unless config config = [ File.join(@working_dir, "oct.conf"), File.join(@working_dir, ".oct.conf"), File.join(@working_dir, "config", "oct.conf"), File.expand_path(File.join("~", ".oct.conf")) ].detect { |filename| File.exists?(filename) } end if config && File.exists?(config) # rewrite options full path for config for later use @options[:config] = config # load options from the config file, overwriting hard-coded defaults config_contents = YAML::load(File.open(config)) configuration.merge!(config_contents.symbolize_keys!) if config_contents && config_contents.is_a?(Hash) else # user specified a config file?, no error if user did not specify config file raise "config file not found" if @options[:config] end # the command line options override options read from the config file @options = configuration[:options].symbolize_keys!.merge!(@options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_config!\n return unless options.empty?\n\n data = ::YAML.load_file(File.open(\"#{directory.path}/supernova.yml\", \"r\"))\n load_paths.push(*data.fetch(\"load_paths\", []))\n\n load_paths.map! do |path|\n File.absolute_path(path, directory.path)\n end\n\n @options = da...
[ "0.70201164", "0.69457424", "0.6906089", "0.6888912", "0.6713834", "0.6694016", "0.6479926", "0.64688617", "0.64497", "0.6407037", "0.6399066", "0.6394115", "0.6391378", "0.63850623", "0.6383569", "0.6380703", "0.63534874", "0.63323563", "0.6317484", "0.6312028", "0.6283605",...
0.0
-1
use the sorted outputs for comparison
def insync?(is) if defined? @should and @should case self.should_to_s when "all" self.provider.all_privs_set? when self.is_to_s(is) true else false end else true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compare(x, y); end", "def bigSorting(unsorted)\n\nend", "def sorted_results\n results.sort\n end", "def sort_entries; end", "def e5115_sublinear_sort(values)\n end", "def comp(array1, array2)\n p array1\n p array2\n if array1.nil? || array2.nil?\n return false\n else\n array2 = arr...
[ "0.679415", "0.67423755", "0.66697353", "0.6431097", "0.6404233", "0.6330936", "0.62546384", "0.6240586", "0.621792", "0.6169064", "0.61684763", "0.6167926", "0.6160956", "0.6160407", "0.6155046", "0.61501056", "0.6135104", "0.6116335", "0.60716003", "0.6070032", "0.6058721",...
0.0
-1
Ask user for second integer
def get_integer puts "Type another integer." gets.chomp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def second_value\n print \"type in the second number: \"\n gets.chomp.to_f\n end", "def number_choice_one\n puts \"Now I need two numbers to use with that operator.\"\n puts \"Type your first number: \"\n gets.chomp.to_i\nend", "def ask_for_number\n gets.chomp.to_i\n end", "def fetch_numb...
[ "0.7979498", "0.712082", "0.702661", "0.68912244", "0.6888151", "0.68196124", "0.6731593", "0.6641218", "0.6618343", "0.65130925", "0.6512656", "0.6483483", "0.64365077", "0.6422527", "0.6417073", "0.6410352", "0.64049006", "0.6396377", "0.6394682", "0.6388099", "0.6385723", ...
0.6597788
9
returns :left or :right; if the edge that this path starts from is treated as the bottom, which way does the path curve?
def compute_direction(this_exit, other_exit, curvilinear_type) if curvilinear_type == STRAIGHT # no curve but we still need a direction, and we need to ensure both # "half paths" have different directions return this_exit < other_exit ? :left : :right end return :none if !other_exit || !this_exit if (this_exit + curvilinear_type) % 6 == other_exit :left elsif (other_exit + curvilinear_type) % 6 == this_exit :right end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bottomright; return self.right, self.bottom; end", "def bottomleft; return self[0], self.bottom; end", "def left_edge?\n x == 0\n end", "def test_top_edge_enumerated_left_to_right\n assert_equal [0, 1, 0, 1, 0], @p.edge(:top)\n end", "def find_bottom_path(cell)\n find_path(cell) { | cell...
[ "0.67251366", "0.6326786", "0.6302117", "0.6272363", "0.60861903", "0.6085516", "0.60582817", "0.6051316", "0.6044524", "0.59614885", "0.5930089", "0.590992", "0.59020245", "0.5897348", "0.5894792", "0.58718705", "0.586092", "0.58526284", "0.5834471", "0.5832742", "0.5831373"...
0.55353653
33
Stamps all files matching DIR_PATTERNS and the +includepaths+ option unless they have already been stamped
def run!(options={}) options[:exclude_paths] ||= [] options[:include_paths].each do |path| DIR_PATTERS << path end if options[:include_paths] DIR_PATTERS.each do |main_dir| Dir.glob(main_dir).each do |path| # skip to the next file if this file matches exclude_paths next if options[:exclude_paths].detect { |pattern| File.fnmatch(pattern, path) } StampFile.new(path, options).stamp! end end true # return true (success) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_exclusions(globs); end", "def enhance_file_list\n return unless @enhanced_mode\n @current_dir ||= Dir.pwd\n\n begin\n actr = @files.size\n\n # zshglob: M = MARK_DIRS with slash\n # zshglob: N = NULL_GLOB no error if no result, this is causing space to split\n # file sometimes for sing...
[ "0.5891279", "0.583747", "0.57488465", "0.56499076", "0.56059915", "0.5542858", "0.5538062", "0.5534155", "0.5521908", "0.5513069", "0.5460612", "0.54544026", "0.5437576", "0.543569", "0.54348433", "0.54218185", "0.5394347", "0.5375221", "0.5355468", "0.53522056", "0.5348523"...
0.7404886
0
Read a CSV string into an array of CSVEntries.
def read(string) lines = string.split("\n") header = lines[0] attributes = header.split(',').map! { |v| v.to_sym } # Struct.new('CSVEntry', *attributes) ret = [] lines.drop(1).each do |line| values = line.split(',') opts = {} values.each_with_index do |val, idx| opts[attributes[idx]] = val end ret << Struct::CSVEntry.new(opts) end ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csv_to_array(csv_name)\n\tCSV.read(csv_name)\nend", "def csv_to_array(csv); end", "def readCSV(filename)\n resultArray = Array.new\n\n # read csv file\n File.open(filename) { |file|\n while line = file.gets\n row = CSV.parse_line( Kconv::kconv(line, Kconv::UTF8, Kconv::SJIS) )\n resultArray...
[ "0.7203955", "0.69532484", "0.69352037", "0.6906603", "0.6906603", "0.6905589", "0.6748106", "0.66476566", "0.6629817", "0.64393413", "0.6424258", "0.641854", "0.6372537", "0.6286747", "0.6269038", "0.60965294", "0.6086337", "0.6079646", "0.6033713", "0.60110503", "0.6008343"...
0.7536426
0
Turns an array of CSVEntries (see read) into a String.
def write(objects = []) return '' if objects.empty? str = '' vars = objects[0].instance_variables.select! { |v| v != :@i_expect_that_nobody_will_use_this_name }.map { |v| v } str << vars.map { |i| i[1..-1] }.join(',') str << "\n" objects.each_with_index do |obj, obj_indx| vars.each_with_index do |var, var_indx| val = obj.instance_variable_get(var) str << val str << ',' if var_indx != vars.size - 1 end str << "\n" if obj_indx != objects.size - 1 end str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csv(array)\n nilfix = array.map { |s| blank(s) ? \"\" : s }\n quoted = nilfix.map { |s| '\"' + s.gsub('\"',\"'\") + '\"' }\n return quoted.join(',')\nend", "def array_to_string(arr)\n arr.map { |e| \"'#{sanitize(e)}'\" }.join(\",\")\n end", "def csv_to_s(rows, cols: nil)\n \"\".tap do\n ...
[ "0.65259695", "0.65242416", "0.63135713", "0.63063574", "0.63063574", "0.62707233", "0.61600703", "0.6146522", "0.613142", "0.5907627", "0.58337617", "0.57742923", "0.57685876", "0.571128", "0.5704074", "0.5700728", "0.56952745", "0.56589544", "0.5655195", "0.5655195", "0.563...
0.0
-1
Try ping three times. Return true if at least one time responds. def ping3
def update_ping result = false 3.times do command = "ping -c 1 -W #{PING_MIN_INTERVAL} #{@hostname} 2> /dev/null 1> /dev/null" if system(command) result = true break end end write_cache("ping", result) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ping target, attempts = 5\n try = 0\n while try < attempts\n result = exec(Beaker::Command.new(\"ping -c 1 #{target}\"), :accept_all_exit_codes => true)\n return true if result.exit_code == 0\n\n try += 1\n end\n result.exit_code == 0\n end", "def ping\n tries = 3\n begin\n ...
[ "0.6861726", "0.65738636", "0.65690535", "0.635896", "0.6145886", "0.6058369", "0.6047648", "0.60227", "0.6017396", "0.5995556", "0.59912825", "0.5983551", "0.5948659", "0.5899114", "0.58788985", "0.58781224", "0.5876417", "0.5875402", "0.58700114", "0.5869033", "0.5845669", ...
0.6751828
1
Return from cached ping data.
def fetch(name) load_cache(name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ping(data)\n end", "def status_from_cache ip\n clean_cache\n node['cloudflare']['threat_control']['status_cache'].fetch(ip)['status'].to_sym\nrescue KeyError\n # not found\n :none\nend", "def cache_online(mysql_conf:, ping_time:)\n query = <<~SQL\n SELECT hostname FROM lastping WHERE pin...
[ "0.6933489", "0.6347994", "0.634467", "0.619526", "0.60900897", "0.60096264", "0.5960896", "0.5909245", "0.58225656", "0.57883567", "0.57853013", "0.5766617", "0.57516116", "0.569318", "0.5675052", "0.5674137", "0.5662367", "0.56117666", "0.55946875", "0.5571985", "0.55473095...
0.51789427
88
GET /districts GET /districts.json
def index @districts = District.all.includes(:taluks) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_district_list ( year )\n get_api_resource \"#{@@api_base_url}districts/#{year}\"\n end", "def show\n @districtclass = Districtclass.find(params[:id])\n @districts = @districtclass.districts.all(:order => 'district_name')\n\n respond_to do |format|\n format.html # show.html.erb\n fo...
[ "0.7804373", "0.7537338", "0.71356726", "0.71229523", "0.711125", "0.71006674", "0.7097041", "0.700757", "0.6957552", "0.6886389", "0.6882672", "0.68217546", "0.66347384", "0.66016793", "0.6533538", "0.64426905", "0.6438084", "0.6401699", "0.63545704", "0.63545704", "0.632517...
0.6722273
12
GET /districts/1 GET /districts/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @districtclass = Districtclass.find(params[:id])\n @districts = @districtclass.districts.all(:order => 'district_name')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @districtclass }\n end\n end", "def show\n @clidistrict = Clidistrict....
[ "0.7618955", "0.7602007", "0.7562016", "0.75585264", "0.7389093", "0.73535764", "0.73185223", "0.7141811", "0.71397454", "0.71239215", "0.6902166", "0.68801874", "0.6741882", "0.6722628", "0.67122036", "0.67121875", "0.66947186", "0.66947186", "0.66947186", "0.66247153", "0.6...
0.0
-1
POST /districts POST /districts.json
def create @district = District.new(district_params) respond_to do |format| if @district.save format.html { redirect_to @district, notice: 'District was successfully created.' } format.json { render :show, status: :created, location: @district } else format.html { render :new } format.json { render json: @district.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @admins_district = Admins::District.new(admins_district_params)\n\n respond_to do |format|\n if @admins_district.save\n format.html { redirect_to @admins_district, notice: 'District was successfully created.' }\n format.json { render :show, status: :created, location: @admins_...
[ "0.73754716", "0.71334803", "0.7103008", "0.70803386", "0.70637786", "0.7062713", "0.7040849", "0.70311344", "0.70261407", "0.6893635", "0.6869062", "0.67810947", "0.6735712", "0.6735712", "0.66597795", "0.6647939", "0.6609418", "0.6574611", "0.65476805", "0.6431698", "0.6324...
0.76711434
1
PATCH/PUT /districts/1 PATCH/PUT /districts/1.json
def update respond_to do |format| if @district.update(district_params) format.html { redirect_to @district, notice: 'District was successfully updated.' } format.json { render :show, status: :ok, location: @district } else format.html { render :edit } format.json { render json: @district.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @district = District.find(params[:id])\n\n respond_to do |format|\n if @district.update_attributes(params[:district])\n flash[:success] = \"Район успешно отредактирован.\"\n format.html { redirect_to @district }\n format.json { head :no_content }\n else\n fl...
[ "0.7126122", "0.6996551", "0.69761693", "0.69454235", "0.69368136", "0.69137615", "0.6912139", "0.68911105", "0.6760865", "0.67091334", "0.66382796", "0.6565201", "0.65612084", "0.65612084", "0.6485658", "0.6357987", "0.62105393", "0.6091936", "0.60824805", "0.59730554", "0.5...
0.7215769
1
DELETE /districts/1 DELETE /districts/1.json
def destroy @district.destroy respond_to do |format| format.html { redirect_to districts_url, notice: 'District was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @district.destroy\n respond_to do |format|\n format.html { redirect_to admin_districts_url, notice: '删除成功!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @congressional_district = CongressionalDistrict.find(params[:id])\n @congressional_district.destroy...
[ "0.77810276", "0.77323526", "0.77285606", "0.772048", "0.77181786", "0.76601684", "0.76569086", "0.76493096", "0.7582375", "0.74829644", "0.72289246", "0.7227101", "0.72161055", "0.7208485", "0.715053", "0.715053", "0.70897263", "0.69843394", "0.6975609", "0.6886563", "0.6685...
0.77683413
2
Never trust parameters from the scary internet, only allow the white list through.
def district_params params.require(:district).permit(:name, :code, :regional_name_value, taluks_attributes: [:id, :_destroy, :name, :code, :regional_name_value, panchayats_attributes: [:id, :_destroy, :name, :code, :regional_name_value, places_attributes: [:id, :_destroy, :name, :code, :place_type, :regional_name_value] ] ]) 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
Use callbacks to share common setup or constraints between actions.
def get_entity(name) # These are the valid entities and their validators are defined if ["Taluk","Panchayat","Place"].include?(name) return name.constantize, name.downcase+"_params", name.downcase else return nil end 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
SESSION 1 PROMPT =begin Given a binary tree, flatten it to a linked list inplace. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ 5 \ 6 =end
def flatten_tree(root, prev = nil) return root if root.nil? flatten_tree(root.left) flatten_tree(root.right) tmp = root.right unless root.left.nil? root.right = root.left root.left = nil root = root.right until root.right.nil? root.right = tmp end root end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flatten(root)\n stack = [root]\n\n while stack.any?\n current_node = stack.pop\n\n if current_node.child\n stack << current_node.next if current_node.next\n\n current_node.next = current_node.child\n current_node.child.prev = current_node\n stack << current_node.child\n current...
[ "0.72990847", "0.7271779", "0.68742156", "0.67825526", "0.67161083", "0.66788054", "0.64865303", "0.6417936", "0.63861215", "0.61944836", "0.6142488", "0.60923606", "0.6083021", "0.60218424", "0.6000489", "0.5998313", "0.5996439", "0.59837335", "0.5980911", "0.5943467", "0.59...
0.6872538
3
fetches the product referenced by the id.
def fetch_product @product = Product.visible.find(params[:id]) if params[:id] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_by_id(id)\n get_product_by_id(id)\n end", "def get_product_by_id(product_id)\n return Product.find(product_id)\n end", "def getProduct(id)\n @products.find {|prod| prod.productId.to_i == id.to_i}\n end", "def getProduct( product_id)\n params = Hash.new\n params['product_id'...
[ "0.80749166", "0.7794719", "0.7640569", "0.7373178", "0.73709536", "0.73395765", "0.73023564", "0.7291947", "0.72218937", "0.7219605", "0.71767926", "0.7139996", "0.70568436", "0.70204425", "0.6978034", "0.6946414", "0.69326305", "0.6916953", "0.6833144", "0.676108", "0.67127...
0.78149086
1
creates a cookie that will store the products this user viewed.
def store_visited_product id = @product.id unless cookies[:user_visited_products] cookies[:user_visited_products] = id else cookies_array = cookies[:user_visited_products].to_s.split(',') if cookies_array.size < 20 cookies_array << id unless cookies_array.include?("#{id}") cookies[:user_visited_products] = cookies_array.join(",") end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_products_to_cookies\n if cookies[:product].blank?\n cookies[:product] = [params[:id]]\n else\n @recently = cookies[:product].split('&').last(8)\n unless @recently.include?(params[:id])\n cookies[:product] = [cookies[:product]] << params[:id]\n end\n end\n\n end", "def...
[ "0.7519355", "0.6408353", "0.63304436", "0.631407", "0.62956756", "0.6283701", "0.6258405", "0.6217388", "0.619936", "0.6197179", "0.6183296", "0.6136613", "0.6128804", "0.6124218", "0.6124218", "0.6124218", "0.6124218", "0.6124218", "0.6124218", "0.6124218", "0.61016715", ...
0.7477063
1
a = CartItem.new; a.test_model test method for activerecord def test_model return "It works" end
def empty_cart self.each do |item| item.cart_id = nil item.save! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_method\n return \"this is a test from the order model!\"\n end", "def test_model\n tacoma = Vehicle.new(color: \"Silver\", model_year: 2007, manufacturer: \"Toyota\", model: \"Tacoma\")\n actual = tacoma.model\n assert_equal('Tacoma', actual, \"'Tacoma' as a string should be returned\")\n\n...
[ "0.78336215", "0.6553211", "0.6224346", "0.61664706", "0.61626905", "0.61290526", "0.61266017", "0.61266017", "0.61266017", "0.61232984", "0.608635", "0.60043126", "0.60043126", "0.60043126", "0.60043126", "0.60043126", "0.60043126", "0.60043126", "0.60043126", "0.60043126", ...
0.0
-1
Add a node to the project graph.
def add_node(node) @nodes.add node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(node)\r\n @nodes << node\r\n end", "def add_node(node); end", "def add_node(name, node)\n language.nodes[name] = node if name\n node\n end", "def add_node(node)\n @nodes[node.id.to_i] = node\n node.db = self\n end", "def add_node(node)\n node...
[ "0.75790536", "0.7533743", "0.7449676", "0.7437881", "0.7423904", "0.7324917", "0.7315779", "0.7194684", "0.7064985", "0.7031119", "0.70273966", "0.7005919", "0.70036244", "0.6947567", "0.6860344", "0.68166935", "0.6773264", "0.6758635", "0.67541605", "0.67330635", "0.6679167...
0.8292682
0
Add multiple nodes at once.
def add_nodes(*nodes) @nodes.merge nodes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(*nodes)\n @nodes.push(*nodes)\n end", "def add_childs(*nodes)\n nodes.each do |node|\n self.addChild(node)\n end\n end", "def AddNodes(nodes)\n\tnodes.each do |n|\n\t\tn.id=@lastId\n\t\tDefineGroup(n)\n\t\t@lastId=@lastId+1\n\tend\n\treturn nodes\n end", "def add(node)\r\n @no...
[ "0.8452777", "0.73931134", "0.73497957", "0.72169966", "0.711111", "0.70864254", "0.7069811", "0.70236915", "0.67949355", "0.6767138", "0.6742206", "0.67292094", "0.6646378", "0.663818", "0.6628216", "0.6596066", "0.65833205", "0.64750105", "0.6293812", "0.6269824", "0.618248...
0.83360803
1
Add an edge to the project graph.
def add_edge(from, to, cost) @edges << Edge.new(from, to, cost) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_edge(edge)\n @edges.push(edge)\n end", "def add_edge(e)\n @edges[e.from] << e\n end", "def add_edge( edge )\n super( edge.source, edge.target, edge )\n __add_edge__( edge )\n end", "def add_edge(edge)\n edge.each { |node| add_vertex(node) }\n @structure[edge[0]] << ...
[ "0.79741365", "0.7947667", "0.75388736", "0.75327075", "0.7507143", "0.7441213", "0.73779684", "0.7363834", "0.7262812", "0.7224285", "0.71899885", "0.70623076", "0.7038201", "0.70257527", "0.6943856", "0.6922219", "0.68484205", "0.6831056", "0.6820543", "0.6763121", "0.67477...
0.6934615
15
Set maximum project duration by adding an edge with negative duration as weight.
def max_duration=(duration) nodes = @nodes.to_a add_edge(nodes.last, nodes.first, -duration) duration end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maximum_duration=(value)\n @maximum_duration = value\n end", "def set_duration\n if self.end_time\n # self.duration = (end_time - start_time).to_i\n self.duration = (end_time - start_time).to_i\n else\n self.duration = DEFAULT_DURATION\n self.end_time = sel...
[ "0.57675135", "0.5741691", "0.5448167", "0.5161886", "0.5148244", "0.51042074", "0.50982696", "0.50919807", "0.5077229", "0.5076094", "0.50020987", "0.50020987", "0.49458435", "0.4879381", "0.48665136", "0.4855394", "0.48398173", "0.48382357", "0.48365098", "0.48259312", "0.4...
0.77499884
0
Determine earliest and latest starting times by using the Tripe algorithm to find longest paths between all nodes.
def triple # Determine number of nodes. n = @nodes.size # Initialize distance matrix (n×n) with 0 in the diagonal and -∞ elsewhere. d = Array.new(n) { |i| Array.new(n) { |j| i == j ? 0 : -INFINITY } } # For all edges (i,j) ∈ E: set d[i,j] = σ(i,j) @edges.each { |e| d[e.from][e.to] = e.cost } # For all nodes v ∈ V: @nodes.each do |v| # For all pairs (i,j) with i,j ∈ V\{v} and d[i,v] > -∞: nodes_ij = @nodes - [v] nodes_ij.each do |i| next if d[i][v] == -INFINITY nodes_ij.each do |j| # If the path i->v->j is longer than i->j until now, set i->v->j as new distance between i and j. d[i][j] = [ d[i][j], d[i][v] + d[v][j] ].max end end end # Return earliest and lates starting times. result = {} @nodes.each { |i| result[i] = { es: d[0][i], ls: -d[i][0] } } result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortest_path(nodes, starting, ending)\n queue = [starting]\n previous = {}\n previous[starting] = nil\n while !queue.empty?\n p queue\n last_node = queue.pop\n if last_node == ending\n path = []\n while previous[last_node]\n path.unshift(last_node)\n last_node = previous[l...
[ "0.6018098", "0.5829604", "0.5681305", "0.56467295", "0.54656386", "0.5455208", "0.5406139", "0.5398582", "0.53266966", "0.53228617", "0.5316201", "0.52985454", "0.5273384", "0.5239892", "0.5237051", "0.52320856", "0.52318907", "0.5222776", "0.52156544", "0.5174332", "0.51662...
0.5384313
8
returns an Array of Arrays of Parts, Parts represent labels for self.ontology_class
def acts_of_synonymy_for_ref syn = self.proj.sensus.by_ontology_class(self.ontology_class_id).by_ref(self.ref_id).ordered_by_label.collect{|s| s.label}.uniq syns = [] syn.each_with_index do |s1,i| syn[(i+1)..(syn.size)].each do |s2| syns << [s1, s2] end end syns end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parts\n @parts\n end", "def parts(user_id = nil)\n part_elements = []\n if is_a_node?\n if user_id\n part_elements = Element.part_elements_for_element_id_by_user_id(self.id, user_id)\n else\n part_elements = Element.part_elements_for_element_id(self.id)\n end\n ...
[ "0.6326445", "0.62433267", "0.56026816", "0.56026816", "0.55608624", "0.5538963", "0.55355686", "0.55355686", "0.5475658", "0.54666924", "0.54503626", "0.542177", "0.5332671", "0.53080904", "0.53021836", "0.52837396", "0.52423835", "0.5206719", "0.52003604", "0.51916754", "0....
0.0
-1
returns an Array of Arrays of OntologyClasses
def acts_of_homonymy_for_ref syn = self.proj.sensus.by_label(self.label_id).by_ref(self.ref_id).ordered_by_label.collect{|s| s.ontology_class}.uniq syns = [] syn.each_with_index do |s1,i| syn[(i+1)..(syn.size)].each do |s2| syns << [s1, s2] end end syns end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def class_list\n array = []\n ObjectSpace.each_object(Class) {|m| array << m }\n array\n end", "def classes\n\t\tlist = []\n\t\teach_class { |class_constant|\n\t\t\tlist\t<< class_constant\n\t\t}\n\t\treturn list\n\tend", "def classes\n return [] unless classes = self[\"class\"]\n ...
[ "0.7007354", "0.6787406", "0.6668519", "0.6584261", "0.65691274", "0.65691274", "0.63448393", "0.6343149", "0.6319327", "0.63011175", "0.62924606", "0.6217814", "0.6139036", "0.6084551", "0.6067559", "0.6035598", "0.6016144", "0.60121894", "0.60020626", "0.59833604", "0.59822...
0.0
-1
Callback from the CLLocationManager
def locationManager manager, didUpdateToLocation: new, fromLocation: old coordinate = new.coordinate size = @webView.bounds.size params = { markers: 'color:blue|%s,%s' % [coordinate.latitude, coordinate.longitude], zoom: 14, size: '%dx%d' % [size.width, size.height], sensor: 'false' } url = "http://maps.googleapis.com/maps/api/staticmap?#{encodeParams params}" loadUrl url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def onLocationChanged(eventData)\n processLocation(eventData.location)\n end", "def geo_location_callback\n @@geo_callback_counter += 1\n if @params['accuracy'].to_i < @@geo_data_accuracy\n @@geo_data_accuracy = @params['accuracy'].to_i \n @@geo_latitude = @params['latitude'].to_f\n ...
[ "0.65029335", "0.6359073", "0.626782", "0.6178148", "0.6082558", "0.6057392", "0.6005049", "0.5952406", "0.5753182", "0.57295656", "0.5716179", "0.5647721", "0.5615434", "0.5610879", "0.5582051", "0.5553366", "0.55330884", "0.54896355", "0.5458575", "0.5435114", "0.5371824", ...
0.0
-1
inserting a new row into the database contact
def save if self.id self.update else sql = <<-SQL INSERT INTO contacts (name, phone_number, address, email) VALUES (?, ?, ?, ?) SQL DB[:conn].execute(sql, name, phone_number, address, email) @id = DB[:conn].execute("SELECT last_insert_rowid() FROM contacts")[0][0] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save\n if id\n Connection.conn.exec_params('UPDATE contacts SET name = $1, email = $2 WHERE id = $3::int;', [name,email,id])\n else\n pg_contact = Connection.conn.exec_params('INSERT INTO contacts (name,email) VALUES ($1, $2) RETURNING *;', [name,email])\n self.id = pg_contact[0][\"id\"]\n...
[ "0.6945833", "0.66643983", "0.66426486", "0.65783554", "0.65502375", "0.652647", "0.6502897", "0.6468677", "0.64677274", "0.64457864", "0.64041525", "0.6390677", "0.63866675", "0.6381132", "0.633995", "0.6336467", "0.63266736", "0.63254476", "0.63178056", "0.6316364", "0.6245...
0.69711155
0
updating the database row mapped to the Contact instance.
def update sql = "UPDATE contacts SET name = ?, phone_number = ?, address = ?, email = ? WHERE id = ?" DB[:conn].execute(sql, name, phone_number, address, email, id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @contact = current_user.contacts.find(params[:id])\n @contact.update_attributes(params[:contact])\n end", "def update fields\n self.contact = @nimble.put \"contact/#{self.id}\", { fields: fields }\n return nil unless self.contact\n self\n end", "def contact_update(handle, ...
[ "0.6964599", "0.68154514", "0.6657135", "0.6624171", "0.65670824", "0.6502961", "0.6457798", "0.6424585", "0.6363718", "0.6337078", "0.6334092", "0.63161355", "0.6309855", "0.62971133", "0.6266566", "0.6264457", "0.6253173", "0.62450945", "0.62222177", "0.6220779", "0.6201020...
0.70957
0