query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
DELETE /credit_point_packs/1 DELETE /credit_point_packs/1.json
def destroy @credit_point_pack.destroy respond_to do |format| format.html { redirect_to credit_point_packs_url } format.json { head :no_content } end end
[ "def deleteFlatpack( flatpack_id)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n return doCurl(\"delete\",\"/flatpack\",params)\n end", "def destroy\n @recycling_point.destroy\n render json: @recycling_point, status: :ok\n end", "def destroy\n @charge_point.destroy\n respond_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Express the result with one emoji.
def emoji if failure? FAILURE_EMOJI else ERROR_EMOJI end end
[ "def to_emoji\n case self\n when (200..299), 960, 961\n \"\\u{26A1}\" # thunderstorm\n when (300..399)\n \"\\u{1F326}\" # light rain (drizzle)\n when (500..599)\n \"\\u{2614}\" # rain\n when (600..699)\n when 800\n \"\\u{1F31E}\" # clear sky\n when 801\n \"\\u{26C5}\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Collect all distinct tire model / tire category combinations for this brand Tire models are allowed to appear under more than one category
def get_all_tire_categories cats = TireModelInfo.joins('INNER JOIN tire_models ON tire_models.tire_model_info_id = tire_model_infos.id', 'INNER JOIN tire_categories ON tire_models.tire_category_id = tire_categories.id') .where(tire_manufacturer_id: self.id) ...
[ "def get_all_tgp_tire_categories\n models = TireModelInfo.joins('INNER JOIN tire_models ON tire_models.tire_model_info_id = tire_model_infos.id')\n .where(tire_manufacturer_id: self.id).where('tgp_category_id IS NOT NULL')\n .select('DISTINCT tire_model_infos.id,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Collect all distinct tire model / TGP category combinations for this brand Tire models are allowed to appear under more than one category
def get_all_tgp_tire_categories models = TireModelInfo.joins('INNER JOIN tire_models ON tire_models.tire_model_info_id = tire_model_infos.id') .where(tire_manufacturer_id: self.id).where('tgp_category_id IS NOT NULL') .select('DISTINCT tire_model_infos.id, tire_mo...
[ "def get_all_tire_categories\n cats = TireModelInfo.joins('INNER JOIN tire_models ON tire_models.tire_model_info_id = tire_model_infos.id',\n 'INNER JOIN tire_categories ON tire_models.tire_category_id = tire_categories.id')\n .where(tire_manufacturer_id: self...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Collect all distinct tire model / car type combinations for this brand
def get_all_car_types models = TireModelInfo.joins('INNER JOIN tire_models ON tire_models.tire_model_info_id = tire_model_infos.id') .select('tire_model_infos.*, tire_models.tire_code AS "tire_code", MIN(tire_models.orig_cost) AS "starting_cost"') .where(tire_manufa...
[ "def unique_brands\n\t$data.map{|name| name[\"brand\"]}.uniq \nend", "def all_vehicle_types\n method = \"allVehicleTypes\"\n hash = post_request(method)\n\n # breaks down big hash of cars into hashes \n vehicles = hash[\"DBEntityVehicleType\"]\n vehicle_array = []\n\n if !hash[\"DBEntityVehicleT...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /cards/1 PUT /cards/1.xml
def update # @card = Card.find(params[:id]) respond_to do |format| if @card.update_attributes(params[:card]) flash[:notice] = 'Card was successfully updated.' format.html { redirect_to(@card) } format.xml { head :ok } else format.html { render :action => "edit" } ...
[ "def update\n \n @card = Card.find(params[:id])\n\n respond_to do |format|\n if @card.update_attributes(params[:card])\n flash[:notice] = 'Card was successfully updated.'\n format.html { redirect_to(@card) }\n format.xml { head :ok }\n else\n format.html { render :actio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /cards/1 DELETE /cards/1.xml
def destroy # @card = Card.find(params[:id]) @card.destroy respond_to do |format| format.html { redirect_to(:back) } format.xml { head :ok } end end
[ "def delete(name)\r\n id = name_to_id(name)\r\n self.class.delete(\"/cards/#{id}.xml\")\r\n end", "def delete(name)\n id = name_to_id(name)\n puts \"Deleting card with ID #{id}.\"\n self.class.delete(\"/cards/#{id}.xml\")\n end", "def destroy\n @card = Card.find(params[:id])\n @card.destr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Autotest will look for spec commands in the following locations, in this order: bin/spec default spec bin/loader installed in Rubygems
def spec_commands [ File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')), File.join(Config::CONFIG['bindir'], 'spec') ] end
[ "def spec_commands\n [File.join(Config::CONFIG['bindir'], 'spec'), 'spec']\n end", "def spec_cmd\n @spec_cmd ||= ( File.exist?('script/spec') ? 'script/spec' : find_spec_cmd )\n end", "def test\n Dir.chdir @gemspec.full_gem_path do\n if File.exist? 'Rakefile' then\n install_rake unless ra...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /Embeddable/open_responses/1 GET /Embeddable/open_responses/1.xml
def show @open_response = Embeddable::OpenResponse.find(params[:id]) if request.xhr? render :partial => 'show', :locals => { :open_response => @open_response } else respond_to do |format| format.html # show.html.haml format.jnlp { render :partial => 'shared/installer', :locals =>...
[ "def show\n @open_id = OpenId.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @open_id }\n end\n end", "def index\n @responses = Response.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /Embeddable/open_responses POST /Embeddable/open_responses.xml
def create @open_response = Embeddable::OpenResponse.new(params[:open_response]) cancel = params[:commit] == "Cancel" if request.xhr? if cancel redirect_to :index elsif @open_response.save render :partial => 'new', :locals => { :open_response => @open_response } else ...
[ "def ocsp_response\n @ocsp_response ||= if (ocsp_response = @node.at('ocspStapling/ocspResponse'))\n OCSPResponse.new(ocsp_response)\n end\n end", "def destroy\n @open_response = Embeddable::OpenResponse.find(params[:id])\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /Embeddable/open_responses/1 PUT /Embeddable/open_responses/1.xml
def update cancel = params[:commit] == "Cancel" @open_response = Embeddable::OpenResponse.find(params[:id]) if request.xhr? if cancel || @open_response.update_attributes(params[:embeddable_open_response]) render :partial => 'show', :locals => { :open_response => @open_response } else ...
[ "def update\n @open_id = OpenId.find(params[:id])\n\n respond_to do |format|\n if @open_id.update_attributes(params[:open_id])\n flash[:notice] = 'OpenId was successfully updated.'\n format.html { redirect_to(@open_id) }\n format.xml { head :ok }\n else\n format.html { r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /Embeddable/open_responses/1 DELETE /Embeddable/open_responses/1.xml
def destroy @open_response = Embeddable::OpenResponse.find(params[:id]) respond_to do |format| format.html { redirect_to(open_responses_url) } format.xml { head :ok } format.js end # TODO: We should move this logic into the model! @open_response.page_elements.each do |pe| p...
[ "def destroy\n @open_id = OpenId.find(params[:id])\n @open_id.destroy\n\n respond_to do |format|\n format.html { redirect_to(open_ids_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @scrap_xml = ScrapXml.find(params[:id])\n @scrap_xml.destroy\n\n respond_to do |forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return the number of matches in the file. Don't read the entire file into memory; read it only (num_lines_per_batch) lines at a time
def num_matches_in_file(fname, match_regexp) num_lines_per_batch = 5000 num_matched = 0 if File.exist? fname File.open(fname, "r") do |f| # use an enumerator to read just (num_lines_per_batch) lines at a time f.lazy.each_slice(num_lines_per_batch) do |lines| ...
[ "def count_lines identifier\n count = 0\n\n File.open(identifier.to_cache_path) do |file|\n # Process file block-by-block to keep memory usage low.\n while block = file.read(4096)\n count += block.count(\"\\n\")\n end\n end\n\n return count\nend", "def count_lines(all_lines_from_file)\n all_lin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates self.models and build a route for the model raise an error if the model is already known
def register_model(model) raise ArgumentError, "already know this model" if models.include?(model) models << model build_route_for_model(model) end
[ "def update\n self.model = find_model\n model.update_attributes(params[model_slug])\n respond_with_contextual model\n end", "def link(*models)\n binding.pry if models.select{ |model| model.nil? }.any?\n properties = (models.last.class == Hash ? models.pop : {})\n models = fill_mod...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads the file at path and turn it to a ruby object based on the file extension. If the file extension is not supported, will raise an error. uses JSON.parse(File.read(path)) and YAML.load_file(path) for '.json' and '.yaml' otherwise, will forward the handling such that '.foobaar' maps to :read_foobar(path)
def read_file(path) raise ArgumentError, "don't know extension #{ext}, use from [#{extensions.join(', ')}]" unless understands_ext?(path) ext = File.extname(path) case ext when '.json' JSON.parse(File.read(path)) when '.yaml' YAML.load_file(path) else self.sen...
[ "def parse_config_file config_path\n File.open(config_path, \"r\") do |file|\n case File.extname(file).delete(\".\")\n when \"json\" then JSON.parse(file.read)\n when \"yml\" then YAML.load_file(file)\n else\n file.close\n raise LoadError, \"Type of file is not sup...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Wether or not this DB understands the extension of the file at path.
def understands_ext?(path) extensions.find{|ext| ext == File.extname(path)} end
[ "def supported_file?(path)\n ext = File.extname(path)\n return true if ext.empty?\n ext =~ /\\.rbc\\Z/\n end", "def file_has_valid_extension?\n file_extension = File.extname(@filename)\n ACCEPTED_FILE_EXTENSIONS.include? file_extension\n end", "def extname? path\n (last_dot_idx = pat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the main name of a path, i.e., the basename without the extension main_name('/a/b/c/foo.bar') => 'foo'
def main_name(path) File.basename(path).sub(/\.[^\.]+$/,'') end
[ "def basename_no_ext path\n File.basename path, '.*'\n end", "def file_name_from_path(path)\n path.split(\"/\")[-1]\n end", "def get_name(path)\n return path[/^.*\\/(.+?)\\/?$/, 1]\n end", "def rootname filename\n if (last_dot_idx = filename.rindex '.')\n (filename.index '/', last_dot_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the perspective name and extension name (a 2 items array) for the given path. By default the blobs for resources content are stored in files named 'resource' with ext starting with a dot
def persp_and_ext_for_basename(path) [main_name(path).sub('resource-epo-',''), File.extname(path)] end
[ "def extname\n File.extname path\n end", "def file_name_from_path(path)\n path.split(\"/\")[-1]\n end", "def plugin_name(path)\r\n File.basename(path)\r\n end", "def extname\n @path.extname\n end", "def extensions\n path.basename.to_s.split(\".\").drop(1)\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the basename of a resource blob for a perspective named persp and in a format with extension ext (including the leading dot). see also persp_and_ext_for_basename
def basename_for_persp_and_ext(persp, ext) "resource-epo-#{persp}#{ext}" end
[ "def persp_and_ext_for_basename(path)\n [main_name(path).sub('resource-epo-',''), File.extname(path)]\n end", "def basename\n File.basename(source_path, File.extname(source_path))\n end", "def basename\n File.basename(filename)\n end", "def basename\n suffixed? ? name.sub(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Saves one or more resource at the filesystem path given at root This method is mainly an handy helper around batch_save, look at the source and at batch_save's doc
def save(root, resource, perspective=:default, exts=nil) exts ||= extensions batch_save(root, [resource].flatten, [perspective].flatten, [exts].flatten) end
[ "def batch_save(root, resources, persps, exts)\n batch_save_actions(root, resources, persps, exts) do |action|\n action.perform\n end\n end", "def batch_save_actions(root, resources, persps, exts)\n if block_given?\n resources.each do |resource|\n db_path = File.join(root,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Saves all the resources, under all the perspectives persps, and all format given by extensions exts at the filesystem path root. resources, perps, exts, must respond to :each, like for Enumerable
def batch_save(root, resources, persps, exts) batch_save_actions(root, resources, persps, exts) do |action| action.perform end end
[ "def batch_save_actions(root, resources, persps, exts)\n if block_given?\n resources.each do |resource|\n db_path = File.join(root, resource.path(identifying_sym))\n yield PrepareDirAction.new(db_path)\n exts.each do |ext|\n persps.each do |persp|\n bas...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Yields all the action needed to store all the resources at perspectives persps and with formats exts. All actions respond to :perform (it is when they're executed). If no block given, returns an Enumerator with these actions.
def batch_save_actions(root, resources, persps, exts) if block_given? resources.each do |resource| db_path = File.join(root, resource.path(identifying_sym)) yield PrepareDirAction.new(db_path) exts.each do |ext| persps.each do |persp| basename = base...
[ "def run_actions\n catch_exceptions do\n @success = if block_given?\n result = yield\n actions.each {|action| results[action] = result}\n !!result\n else\n actions.compact.each {|action| !skip_actions && results[action] = object.send(action)}\n results...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Return logical path with digest spliced in. "foo/bar37b51d194a7513e45b56f6524f2d51f2.js" Returns String.
def digest_path if DigestUtils.already_digested?(@name) logical_path else logical_path.sub(/\.(\w+)$/) { |ext| "-#{etag}#{ext}" } end end
[ "def digest_path\n logical_path.sub(/\\.(\\w+)$/) { |ext| \"-#{digest}#{ext}\" }\n end", "def get_path(sha1)\r\n sha1[0...2] + '/' + sha1[2..40]\r\n end", "def get_path(sha1)\n sha1[0...2] + '/' + sha1[2..40]\n end", "def path(logical_path, fingerprint = true, prefix = nil)\n if fingerpri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Return load path + logical path with digest spliced in. Returns String.
def full_digest_path File.join(@load_path, digest_path) end
[ "def digest_path\n logical_path.sub(/\\.(\\w+)$/) { |ext| \"-#{digest}#{ext}\" }\n end", "def digest_path\n if DigestUtils.already_digested?(@name)\n logical_path\n else\n logical_path.sub(/\\.(\\w+)$/) { |ext| \"-#{etag}#{ext}\" }\n end\n end", "def loaded_path; end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Get charset of source. Returns a String charset name or nil if binary.
def charset metadata[:charset] end
[ "def charset\n param_values(\"charset\").first\n end", "def charset\n return @args[:charset]\n end", "def content_type_charset\n\t\treturn nil unless self.content_type\n\t\tname = self.content_type[ CONTENT_TYPE_CHARSET_RE, :charset ] or return nil\n\n\t\tenc = Encoding.find( name )\n\t\tself.lo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: Return the version of the environment where the asset was generated.
def environment_version metadata[:environment_version] end
[ "def assets_version\n ENV[\"RAILS_ASSET_ID\"] || ''\n end", "def version_from_env\n ENV[env]\n end", "def get_application_version()\n return @variables['application']['version']\n end", "def current_version\n # Note that this logic does not work for products other than\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Returns String hexdigest of source.
def hexdigest DigestUtils.pack_hexdigest(digest) end
[ "def to_s\n hexdigest\n end", "def hexdigest\n generate_digest if @digest.nil?\n @digest.unpack('H*')[0]\n end", "def sha\n Digest::SHA2.new.update(source).to_s\n end", "def hexdigest(*) end", "def hexdigest\n @digest.unpack('H*'.freeze).first\n end", "def checksum\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Returns String base64 digest of source.
def base64digest DigestUtils.pack_base64digest(digest) end
[ "def asset_digest(source)\n return '' unless defined? settings\n return '' unless settings.respond_to?(:assets)\n return '' unless settings.assets.respond_to?(:[])\n settings.assets[source] && settings.assets[source].digest\n end", "def to_s\n @str ||= Base64.encode64(get_dig...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /administration/characters GET /administration/characters.xml
def index @characters = Character.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @characters } end end
[ "def index\n @characters = @user.characters.find :all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @characters }\n end\n end", "def show\n @game_characters = GameCharacters.find(params[:id])\n\n respond_to do |format|\n format.html # show....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /administration/characters/new GET /administration/characters/new.xml
def new @character = Character.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @character } end end
[ "def new\n @character = Character.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @character }\n end\n end", "def new\n @contacter = Contacter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /administration/characters POST /administration/characters.xml
def create @character = Character.new(params[:character]) respond_to do |format| if @character.save format.html { redirect_to([:administration, @character], :notice => 'Character was successfully created.') } format.xml { render :xml => @character, :status => :created, :location => @char...
[ "def add_characters( characters )\n @root << characters.to_xml\n end", "def http_post_character( req )\n # validates the name field has data.\n if req[:name].nil?\n return { :status => STATUS_ERROR, :error => \"Name required to create a character.\", :request => req }\n end\n\n # crea...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /administration/characters/1 PUT /administration/characters/1.xml
def update @character = Character.get(params[:id]) params[:character] = params[:character].map { |x,y| [x, y.empty? ? nil : y ] }.to_hash respond_to do |format| if @character.update(params[:character]) format.html { redirect_to([:administration, @character], :notice => 'Character was successf...
[ "def update\n respond_to do |format|\n if @character.update_attributes(params[:character])\n flash[:notice] = 'Character was successfully updated.'\n format.html { redirect_to(@character) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /administration/characters/1 DELETE /administration/characters/1.xml
def destroy @character = Character.get(params[:id]) @character.destroy respond_to do |format| format.html { redirect_to(administration_characters_url) } format.xml { head :ok } end end
[ "def destroy\n @contacter = Contacter.find(params[:id])\n @contacter.destroy\n\n respond_to do |format|\n format.html { redirect_to(bin_contacters_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @character.destroy\n\n respond_to do |format|\n format.html { redirect...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /formatings GET /formatings.json
def index @formatings = Formating.all end
[ "def formats\n []\n end", "def show\n @format_lookup = FormatLookup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @format_lookup }\n end\n end", "def formats; end", "def show\n @format = Format.find(params[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /formatings POST /formatings.json
def create @formating = Formating.new(formating_params) respond_to do |format| if @formating.save format.html { redirect_to @formating, notice: 'Formating was successfully created.' } format.json { render :show, status: :created, location: @formating } else format.html { ren...
[ "def create\n @format = Format.new(params[:format])\n\n respond_to do |format|\n if @format.save\n format.html { redirect_to @format, notice: 'Format was successfully created.' }\n format.json { render json: @format, status: :created, location: @format }\n else\n format.html { r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /formatings/1 PATCH/PUT /formatings/1.json
def update respond_to do |format| if @formating.update(formating_params) format.html { redirect_to @formating, notice: 'Formating was successfully updated.' } format.json { render :show, status: :ok, location: @formating } else format.html { render :edit } format.json { r...
[ "def update\n @format = Format.find(params[:id])\n\n respond_to do |format|\n if @format.update_attributes(params[:format])\n format.html { redirect_to @format, notice: 'Format was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /formatings/1 DELETE /formatings/1.json
def destroy @formating.destroy respond_to do |format| format.html { redirect_to formatings_url, notice: 'Formating was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @format = Format.find(params[:id])\n @format.destroy\n\n respond_to do |format|\n format.html { redirect_to formats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @format.destroy\n respond_to do |format|\n format.html { redirect_to formats_ur...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
helper method to fill the train full of passengers
def fill_train(train) 120.times { train.board(active_passenger, station) } end
[ "def initialize(station)\r\n @station = station\r\n @train = nil\r\n @passengers = Array.new\r\n end", "def apply_to(train)\n train.category = category\n train.signalling_headcode = signalling_headcode\n train.reservation_headcode = reservation_headcode\n trai...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /sms/1 DELETE /sms/1.json
def destroy @sm = Sm.find(params[:id]) @sm.destroy respond_to do |format| format.html { redirect_to sms_url } format.json { head :no_content } end end
[ "def destroy\n @sms = Sm.find(params[:id])\n @sms.destroy\n\n respond_to do |format|\n format.html { redirect_to sms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sms = Sms.find(params[:id])\n @sms.destroy\n\n respond_to do |format|\n format.html { red...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the worker method name, given the routing string.
def method_name(queue) queue.split("__").last end
[ "def method_name\n name_segments.last\n end", "def make_route_name( route )\n\t\taction_method = route[:action] or return '(Unknown)'\n\t\treturn action_method.name\n\tend", "def get_name\n @route_name\n end", "def route_name\n return \"#{self.name}\"\n end", "def retrieve_task_name(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /setup_images GET /setup_images.json
def index @setup_images = SetupImage.all end
[ "def get_images_data\t\t\t\t\t\t\n\t\t{ payload: { 'makes' => makes_dropdown, 'images' => images_array('none').compact}, success: true}\n\tend", "def images\n response = JSON.parse( self.class.get(\"#{BASE_URL}/contest/#{@api_key}/images\") )\n end", "def images\n\n hydra = Typhoeus::Hydra.new\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /setup_images POST /setup_images.json
def create @setup_image = SetupImage.new(setup_image_params) respond_to do |format| if @setup_image.save format.html { redirect_to setup_path(@setup_image.setup_id), notice: 'Setup was successfully updated.' } format.json { render :show, status: :created, location: @setup_image }...
[ "def image_create # rubocop:disable Metrics/AbcSize\n attrcheck = {\n 'REST end point' => @options[:rest_endpoint],\n 'Create JSON' => @options[:create_json]\n }\n @validate.attrvalidate(@options, attrcheck)\n file = File.read(@options[:create_json])\n create_data = JSON.parse(file)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /setup_images/1 PATCH/PUT /setup_images/1.json
def update respond_to do |format| if @setup_image.update(setup_image_params) format.html { redirect_to @setup_image.setup, notice: 'Setup image was successfully updated.' } format.json { render :show, status: :ok, location: @setup_image } else format.html { render :edit } ...
[ "def update\n @image = Image.find(params[:id])\n\n #we can allow updating an image name and description and unit, but not the image data. for that we need to create a new image\n update_params = image_params\n update_params.delete(\"image\")\n\n if @image.update(update_params)\n head :no_content...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /setup_images/1 DELETE /setup_images/1.json
def destroy @setup_image.destroy respond_to do |format| format.html { redirect_to :back } format.json { head :no_content } end end
[ "def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend", "def destroy\n @step_image.destroy\n respond_to do |format|\n format.html { redirect_to step_images_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @image = Image.find(params[:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find current link associate with the currently viewed page, then walk up the parents and show
def expand_to_current current_location = $window.location.path # `window.location.pathname` # walk down tree links = @sidenav.find("a") current_link = links.select do |l| l.attr("href") == current_location end.first return unless current_link current_link.add_class("current-page") ...
[ "def find_parents(this_page)\n trail = [this_page]\n if this_page.path.include?(\"/\")\n path = this_page.path\n while path.include?(\"/\")\n path, _, current = path.rpartition(\"/\")\n page_id = path\n page_id += \"/index\"\n trail << (find_resource(page_id) || path.rpa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Backup wallet to image file, it contain accounts image, assets image and keys image.
def backup_wallet client.make_request('/backup-wallet', 'post', params: {}) end
[ "def backup_image\n vm.backup(BACKUP_IMAGE_NAME)\n end", "def backup_image\n case provider\n when :libvirt\n system \"sudo virt-clone -o #{IMAGE_NAME} -n #{IMAGE_NAME}_sav --file /var/lib/libvirt/images/#{IMAGE_NAME}_sav.qcow2\"\n when :virtualbox\n # Shutdown the system\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Restore wallet by image file.
def restore_wallet(account_image: {}, asset_image: {}, key_images: {}) params = { account_image: account_image, asset_image: asset_image, key_images: key_images } client.make_request('/restore-wallet', 'post', params: params) end
[ "def restore\n path = PathHelper.path(fid)\n begin\n $mg.store_file(dkey, classname, path)\n rescue => e\n raise e if $debug\n end\n end", "def _restore # restore ?(label)\r\n pc = @pc\r\n\r\n $state.data = $gtk.deserialize_state 'app/save.txt'\r\n @pc = $state.data.pc\r\n\r\n d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Trigger to rescan block information into related wallet.
def rescan_wallet client.make_request('/rescan-wallet', 'post', params: {}) end
[ "def handle_rescan\n EM.defer { @node.store.rescan }\n {:state => \"Rescanning ...\"}\n end", "def rescan()\n @mutex.synchronize { @cv.signal() }\n end", "def after_redeem() end", "def hard_reset\n load.hard_reset unless !load\n self.update(coins: 0, load: nil, user: nil, state:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Recovery wallet and accounts from root XPubs. All accounts and balances of bip44 multiaccount hierarchy for deterministic wallets can be restored via root xpubs.
def recovery_wallet(xpubs: []) client.make_request('/recovery-wallet', 'post', params: {xpubs: xpubs}) end
[ "def recover_exchanges\n @exchanges.values.each do |x|\n begin\n x.recover_from_network_failure\n rescue Exception => e\n # TODO: logger\n $stderr.puts \"Caught exception when recovering exchange #{x.name}\"\n end\n end\n end", "def recover_exchanges\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the information of wallet.
def wallet_info client.make_request('/wallet-info', 'post', params: {}) end
[ "def getwalletinfo\n node.wallet ? node.wallet.to_h : {}\n end", "def getwalletinfo\n return {} unless node.wallet\n {wallet_id: node.wallet.wallet_id, version: node.wallet.version}\n end", "def wallet_summary\n get 'walletSummary'\n end", "def source_wallet\n wal...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a stored pdef
def definition(name) @pdef_registry[name.to_sym] end
[ "def get_definition\n\n end", "def definition\n if @data['definition']\n @data['definition']\n else\n @data['definition'] = field_fetch('D')\n end\n end", "def definition\n return @definition\n end", "def definition; parse_hitname; @definition; end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
just one banner for store
def one_banner if self.class_type == 'banner' && Multimedium.find_all_by_class_type('banner').count > 0 self.errors.add(:base, "This store already has one banner") false end end
[ "def banner\n self.class.banner\n end", "def banner\n self.class.instance_variable_get(:@__banner)\n end", "def banner\n JSON.pretty_generate({ 'banner' => output(varnishadm(\"banner\"))})\n end", "def banner(banner = nil)\n @banner = banner if banner\n @banner\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
set the style of the file accordingly to the class_type
def set_styles if self.class_type == 'variant' {:thumb => '300x300!'} elsif self.class_type == 'banner' {:banner => '800x100!'} elsif self.class_type == 'logo' {:logo => '400x60>'} end end
[ "def set_external_class_file_format(opts)\n opts = check_params(opts,[:class_names,:file_formats])\n super(opts)\n end", "def to_file style = default_style\n end", "def fetch_style_class\n\t\tstyles = Dir.entries(\"./styles\").select do |entry|\n\t\t File.extname(entry).eql? \".rb\"\n\t\ten...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
set the url where the files are going to be accessed based on the class_type
def set_url_base_on_parent! if self.class_type == 'variant' "/assets/upload/variants/:id/:style/:basename.:extension" elsif self.class_type == 'banner' "/assets/upload/banner/:style/:basename.:extension" elsif self.class_type == 'logo' "/assets/upload/logo/:style/:basename.:ext...
[ "def url_class=(klass)\n @_url_class = klass\n end", "def url_path_class=(klass)\n @_url_path_class = klass\n end", "def url_for_klass klass, options={}\r\n klass ||= 0\r\n if klass.is_a? Klass\r\n guid = klass.guid\r\n else\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /cc_statements/1 GET /cc_statements/1.xml
def show @cc_statement = CcStatement.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @cc_statement } end end
[ "def show\n @statement = Statement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @statement }\n end\n end", "def new\n @cc_statement = CcStatement.new\n @cc_statement.build_cc_all\n \n respond_to do |format|\n format....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /cc_statements/new GET /cc_statements/new.xml
def new @cc_statement = CcStatement.new @cc_statement.build_cc_all respond_to do |format| format.html # new.html.erb format.xml { render :xml => @cc_statement } end end
[ "def new\n @statement = Statement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @statement }\n end\n end", "def new\n @statement = Statement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /cc_statements POST /cc_statements.xml
def create #I need :parent_id set to 0 by default for itself and next_sib if params[:cc_statement][:cc_all_attributes][:parent_id] == "" params[:cc_statement][:cc_all_attributes][:parent_id] = "0" end #we need the parent id to set next_sib params[:cc_statement][:cc_all_attributes][:next_sib] +...
[ "def create\n @statement = Statement.new(params[:statement])\n\n respond_to do |format|\n if @statement.save\n format.html { redirect_to(statements_path, :notice => 'Statement was successfully created.') }\n format.xml { render :xml => @statement, :status => :created, :location => @stateme...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /cc_statements/1 PUT /cc_statements/1.xml
def update @cc_statement = CcStatement.find(params[:id]) #we need the parent id to set next_sib params[:cc_statement][:cc_all_attributes][:next_sib] += "_" params[:cc_statement][:cc_all_attributes][:next_sib] += params[:cc_statement][:cc_all_attributes][:parent_id] respond_to do |format| ...
[ "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end", "def update\n # TOD...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /cc_statements/1 DELETE /cc_statements/1.xml
def destroy @cc_statement = CcStatement.find(params[:id]) @cc_statement.destroy respond_to do |format| format.html { redirect_to(cc_statements_url) } format.xml { head :ok } end end
[ "def destroy\n @statement = Statement.find(params[:id])\n @statement.destroy\n\n respond_to do |format|\n format.html { redirect_to(statements_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @knowledge_statement = RiGse::KnowledgeStatement.find(params[:id])\n @knowledge...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return the name for DocumentFragment
def name '#document-fragment' end
[ "def nodeName\n \"#document-fragment\"\n end", "def fragment_name; end", "def name\n 'document'\n end", "def name\n \"document\"\n end", "def nodeName\n \"#document\"\n end", "def first_node_name\n first_child = @fragment.children.first\n (first_ch...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Only the owner of the venture is allowed to perform certain actions
def authenticate_venture_owner! render "errors/404" unless Venture.find(params[:venture_id]).user_id == current_user.id end
[ "def owner_su\n evento = Event.find_by_id(params[:id])\n unless evento.entry.agent == current_user || current_user.superuser==true\n user = current_user\n logger.error(\"ERROR: ATTEMPT TO EDIT AN EVENT THAT DOES NOT BELONG TO HIM\")\n logger.error(\"USER WAS: \" + user.login)\n flash[:not...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
==== Parameters env:: A hash of environment keys to be merged into the default list. opt:: A hash of options (see below). ==== Options (opt) :post_body:: The post body for the request. :req:: The request string. This will only be used if :post_body is left out. ==== Returns FakeRequest:: A Request object that is built ...
def fake_request(env = {}, opt = {}) if opt[:post_body] req = opt[:post_body] env[:content_type] ||= "application/x-www-form-urlencoded" else req = opt[:req] end FakeRequest.new(env, StringIO.new(req || '')) end
[ "def build_request(params = {}, env = {})\n params = Merb::Parse.params_to_query_string(params)\n\n query_string = env[:query_string] || env['QUERY_STRING']\n env[:query_string] = query_string ? \"#{query_string}&#{params}\" : params\n \n post_body = env[:post_body] ||...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Dispatches an action to the given class. This bypasses the router and is suitable for unit testing of controllers. ==== Parameters controller_klass:: The controller class object that the action should be dispatched to. action:: The action name, as a symbol. params:: An optional hash that will end up as params in the co...
def dispatch_to(controller_klass, action, params = {}, env = {}, &blk) params = merge_controller_and_action(controller_klass, action, params) dispatch_request(build_request(params, env), controller_klass, action.to_s, &blk) end
[ "def dispatch_action(klass, action, status=200)\n # build controller\n controller = klass.new(self, status)\n if Dispatcher.use_mutex\n @@mutex.synchronize { controller._dispatch(action) }\n else\n controller._dispatch(action)\n end\n controller\n end", "def dispatch...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Keep track of cookie values in CookieJar within the context of the block; you need to set this up for secific controllers. ==== Parameters controller_classes:: Controller classes to operate on in the context of the block. &blk:: The context to operate on; optionally accepts the cookie jar as an argument.
def with_cookies(*controller_classes, &blk) cookie_jar = CookieJar.new before_cb = lambda { |c| c.cookies.update(cookie_jar) } after_cb = lambda { |c| cookie_jar.update_from_request(c.request) } controller_classes.each do |klass| klass._before_dispatch_callbacks << before_cb ...
[ "def each(&block)\n @cookies.each(&block)\n end", "def cookies\n @controller.send(:cookies)\n end", "def cookies_required(options={}, &block)\n options[:controller]||=self.to_s.sub(/Controller$/, '').underscore\n options[:template]||=options[:controller] + '/cookies_required'\n self...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Dispatches an action to the given class and using HTTP Basic Authentication This bypasses the router and is suitable for unit testing of controllers. ==== Parameters controller_klass:: The controller class object that the action should be dispatched to. action:: The action name, as a symbol. username:: The username. pa...
def dispatch_with_basic_authentication_to(controller_klass, action, username, password, params = {}, env = {}, &blk) env["X_HTTP_AUTHORIZATION"] = "Basic #{Base64.encode64("#{username}:#{password}")}" params = merge_controller_and_action(controller_klass, action, params) dispatc...
[ "def dispatch_to(controller_klass, action, params = {}, env = {}, &blk)\n params = merge_controller_and_action(controller_klass, action, params)\n dispatch_request(build_request(params, env), controller_klass, action.to_s, &blk)\n end", "def dispatch_action(klass, action, status=200)\n # b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prepares and returns a request suitable for dispatching with dispatch_request. If you don't need to modify the request object before dispatching (e.g. to add cookies), you probably want to use dispatch_to instead. ==== Parameters params:: An optional hash that will end up as params in the controller instance. env:: An ...
def build_request(params = {}, env = {}) params = Merb::Parse.params_to_query_string(params) query_string = env[:query_string] || env['QUERY_STRING'] env[:query_string] = query_string ? "#{query_string}&#{params}" : params post_body = env[:post_body] || env['POST_BO...
[ "def create_request(env)\n request = env.to_hash.slice(:method, :url, :request_headers)\n request[:request_headers] = request[:request_headers].dup\n request\n end", "def create_request(env)\n Request.new(env)\n end", "def doorkeeper_request=(env)\n @_doorkeeper_request = ActionDi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
An HTTP GET request that operates through the router. ==== Parameters path:: The path that should go to the router as the request uri. params:: An optional hash that will end up as params in the controller instance. env:: An optional hash that is passed to the fake request. Any request options should go here (see +fake...
def get(path, params = {}, env = {}, &block) env[:request_method] = "GET" mock_request(path, params, env, &block) end
[ "def get(path, params = {}, env = {})\n request(path, env.merge(method: Rack::GET, params: params))\n end", "def get(path, params={}, &block)\n\t\t\tapi_request(Net::HTTP::Get, build_uri(path, params), &block)\n\t\tend", "def get(path, params={}); make_request(:get, host, port, path, params); end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
An HTTP POST request that operates through the router. ==== Parameters path:: The path that should go to the router as the request uri. params:: An optional hash that will end up as params in the controller instance. env:: An optional hash that is passed to the fake request. Any request options should go here (see fake...
def post(path, params = {}, env = {}, &block) env[:request_method] = "POST" mock_request(path, params, env, &block) end
[ "def post(path, params = {}, env = {})\n request(path, env.merge(method: \"POST\".freeze, params: params))\n end", "def post(path, params={}); make_request(:post, host, port, path, params); end", "def post(path, &block)\n route 'POST', path, &block\n end", "def api_gateway_post(pat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
An HTTP PUT request that operates through the router. ==== Parameters path:: The path that should go to the router as the request uri. params:: An optional hash that will end up as params in the controller instance. env:: An optional hash that is passed to the fake request. Any request options should go here (see fake_...
def put(path, params = {}, env = {}, &block) env[:request_method] = "PUT" mock_request(path, params, env, &block) end
[ "def put(path, params = {}, env = {})\n request(path, env.merge(method: \"PUT\".freeze, params: params))\n end", "def put(path, params={}); make_request(:put, host, port, path, params); end", "def put(path, &block)\n route 'PUT', path, &block\n end", "def multipart_put(path, params...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
An HTTP DELETE request that operates through the router ==== Parameters path:: The path that should go to the router as the request uri. params:: An optional hash that will end up as params in the controller instance. env:: An optional hash that is passed to the fake request. Any request options should go here (see fak...
def delete(path, params = {}, env = {}, &block) env[:request_method] = "DELETE" mock_request(path, params, env, &block) end
[ "def delete(path, params = {}, env = {})\n request(path, env.merge(method: \"DELETE\".freeze, params: params))\n end", "def delete(path, params={}); make_request(:delete, host, port, path, params); end", "def delete(uri, params = {})\n send_request(uri, :delete, params)\n end", "def de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The workhorse for the dispatchto helpers. ==== Parameters request:: A request object that has been setup for testing. controller_klass:: The class object off the controller to dispatch the action to. action:: The action to dispatch the request to. &blk:: The controller is yielded to the block provided for actions prior...
def dispatch_request(request, controller_klass, action, &blk) controller = controller_klass.new(request) yield controller if block_given? controller._dispatch(action) Merb.logger.info controller._benchmarks.inspect Merb.logger.flush controller end
[ "def dispatch_to(controller_klass, action, params = {}, env = {}, &blk)\n params = merge_controller_and_action(controller_klass, action, params)\n dispatch_request(build_request(params, env), controller_klass, action.to_s, &blk)\n end", "def dispatch_action(klass, action, request, response, sta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks to see that a request is routable. ==== Parameters request:: The request object to inspect. ==== Raises Merb::ControllerExceptions::BadRequest:: No matching route was found. ==== Returns Hash:: The parameters built based on the matching route.
def check_request_for_route(request) match = ::Merb::Router.match(request) if match[0].nil? && match[1].empty? raise ::Merb::ControllerExceptions::BadRequest, "No routes match the request. Request uri: #{request.uri}" else match[1] end end
[ "def validate(request)\n return unless @scope.should_validate?(request.params)\n\n validate!(request.params)\n end", "def validate_request(request)\n request_content = Hashie::Mash.new(request)\n begin\n valid_deployment_profile?(request_content.profile_id)\n valid_repos?(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Registers the metrics to be collected
def register_metrics! return if @registered @registered = true with_instance do |t| # Worker related t.add_gauge :dynflow_active_workers, 'The number of currently busy workers', [:queue, :world] t.add_counter :dynflow_worker_events, 'The nu...
[ "def collect(metrics = {})\n metrics\n end", "def initialize(...)\n @metrics = {}\n register(...)\n end", "def collect(metrics)\n metrics\n end", "def metrics\n @metrics ||= collect_metrics\n end", "def collect_metrics(*)\n raise NotImplementedError, '...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
calculate contribution of each feature (f) for each class (k)
def calc_contribution(f) each_class do |k| a, b, c, d = get_A(f, k), get_B(f, k), get_C(f, k), get_D(f, k) s = 0.0 x, y = b+d, a+c s = (d/x)**(@k) - (c/y)**(@k) if not x.zero? and not y.zero? set_feature_score(f, k, s) end end
[ "def calc_contribution(f)\n each_class do |k|\n a, b = get_A(f, k), get_B(f, k)\n \n s = a + b\n \n set_feature_score(f, k, s)\n end\n end", "def calc_contribution(f)\n each_class do |k|\n a, c = get_A(f, k), get_C(f, k)\n \n s =0.0\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Call the method given on the array of associated objects if the method is an array method, otherwise call the method on the association's dataset.
def method_missing(meth, *args, &block) (ARRAY.respond_to?(meth) ? @instance.send(:load_associated_objects, @reflection, @reload) : @instance.send(@reflection.dataset_method)). send(meth, *args, &block) end
[ "def wrap_array_method(method_name)\n self.class.send(:define_method, method_name) do |*args, &block|\n array = records.elements\n count_before = array.count\n response = array.send(method_name, *args, &block)\n # update the association if the array has changed\n association_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /fractions POST /fractions.json
def create @fraction = Fraction.new(fraction_params) respond_to do |format| if @fraction.save format.html { redirect_to @fraction, notice: 'Fraction was successfully created.' } format.json { render :show, status: :created, location: @fraction } else format.html { render :ne...
[ "def create\n @member_fraction = MemberFraction.new(member_fraction_params)\n\n respond_to do |format|\n if @member_fraction.save\n format.html { redirect_to member_fractions_path, notice: 'Member fraction was successfully created.' }\n format.json { render :show, status: :created, location...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /fractions/1 PATCH/PUT /fractions/1.json
def update respond_to do |format| if @fraction.update(fraction_params) format.html { redirect_to @fraction, notice: 'Fraction was successfully updated.' } format.json { render :show, status: :ok, location: @fraction } else format.html { render :edit } format.json { render...
[ "def update\n respond_to do |format|\n if @member_fraction.update(member_fraction_params)\n format.html { redirect_to member_fractions_path, notice: 'Member fraction was successfully updated.' }\n format.json { render :show, status: :ok, location: @member_fraction }\n else\n format...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /fractions/1 DELETE /fractions/1.json
def destroy @fraction.destroy respond_to do |format| format.html { redirect_to fractions_url, notice: 'Fraction was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @member_fraction.destroy\n respond_to do |format|\n format.html { redirect_to member_fractions_url, notice: 'Member fraction was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @subcellular_fraction = SubcellularFraction.find(params[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /framedp_summaries/1 GET /framedp_summaries/1.json
def show @framedp_summary = FramedpSummary.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @framedp_summary } end end
[ "def new\n @framedp_summary = FramedpSummary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @framedp_summary }\n end\n end", "def index\n @summaries = Summary.all\n render json: @summaries\n end", "def index\n @patient_summaries = PatientSu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /framedp_summaries/new GET /framedp_summaries/new.json
def new @framedp_summary = FramedpSummary.new respond_to do |format| format.html # new.html.erb format.json { render json: @framedp_summary } end end
[ "def create\n @framedp_summary = FramedpSummary.new(params[:framedp_summary])\n\n respond_to do |format|\n if @framedp_summary.save\n format.html { redirect_to @framedp_summary, notice: 'Framedp summary was successfully created.' }\n format.json { render json: @framedp_summary, status: :cre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /framedp_summaries POST /framedp_summaries.json
def create @framedp_summary = FramedpSummary.new(params[:framedp_summary]) respond_to do |format| if @framedp_summary.save format.html { redirect_to @framedp_summary, notice: 'Framedp summary was successfully created.' } format.json { render json: @framedp_summary, status: :created, locat...
[ "def new\n @framedp_summary = FramedpSummary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @framedp_summary }\n end\n end", "def create\n @summary = Summary.new(summary_params)\n\n if @summary.save\n render json: @summary, status: :create...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /framedp_summaries/1 PUT /framedp_summaries/1.json
def update @framedp_summary = FramedpSummary.find(params[:id]) respond_to do |format| if @framedp_summary.update_attributes(params[:framedp_summary]) format.html { redirect_to @framedp_summary, notice: 'Framedp summary was successfully updated.' } format.json { head :no_content } el...
[ "def create\n @framedp_summary = FramedpSummary.new(params[:framedp_summary])\n\n respond_to do |format|\n if @framedp_summary.save\n format.html { redirect_to @framedp_summary, notice: 'Framedp summary was successfully created.' }\n format.json { render json: @framedp_summary, status: :cre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /framedp_summaries/1 DELETE /framedp_summaries/1.json
def destroy @framedp_summary = FramedpSummary.find(params[:id]) @framedp_summary.destroy respond_to do |format| format.html { redirect_to framedp_summaries_url } format.json { head :no_content } end end
[ "def destroy\n @summary.destroy\n respond_to do |format|\n format.html { redirect_to summaries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gstr1_summary = Gstr1Summary.find(params[:id])\n @gstr1_summary.destroy\n\n respond_to do |format|\n format.html {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Use this boolean method to determine whether this customer_file can be used to collect a payment. Checks all of the following: The "authorized" flag is true. There is a minimum authorized amount. Customer and user records are attached, i.e., neither has been deleted.
def customer_has_authorized_payment? authorized and authorized_amount.try(:>, 0) and has_customer_account? end
[ "def charge_is_allowed?\n\t\tif not customer_has_authorized_payment?\n\t\t\terrors.add :base, I18n.t('views.customer_file.new_charge.you_are_not_authorized')\n\t\t\tfalse\n\t\telsif valid? and charge_amount.present? and authorized_amount and charge_amount.to_i <= authorized_amount\n\t\t\ttrue\n\t\telse\n\t\t\terror...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Use this boolean method to determine whether the charge_amount can be collected. Also ensures that the customer still exists and has authorized payment to this provider.
def charge_is_allowed? if not customer_has_authorized_payment? errors.add :base, I18n.t('views.customer_file.new_charge.you_are_not_authorized') false elsif valid? and charge_amount.present? and authorized_amount and charge_amount.to_i <= authorized_amount true else errors.add :charge_amount, I18n.t('...
[ "def charge?\n false\n end", "def needs_handling_charge?\n true\n end", "def charged?\n stripe_charge_id.present?\n end", "def chargeable?() \n verbose = false\n\n return false if complete\n\n return false if order.nil?\n\n days = (Date.today - Date.parse(created_at.strftime(\"%Y-%...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /term_counts/1 GET /term_counts/1.xml
def show @term_count = TermCount.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @term_count } end end
[ "def show\n @term_count = TermCount.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @term_count }\n end\n end", "def term_count(term)\n term_counts[term].to_i # need #to_i if unmarshalled\n end", "def new\n @term_count = Term...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /term_counts/new GET /term_counts/new.xml
def new @term_count = TermCount.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @term_count } end end
[ "def new\n @term_count = TermCount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @term_count }\n end\n end", "def create\n @term_count = TermCount.new(params[:term_count])\n\n respond_to do |format|\n if @term_count.save\n flash[:not...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /term_counts POST /term_counts.xml
def create @term_count = TermCount.new(params[:term_count]) respond_to do |format| if @term_count.save flash[:notice] = 'TermCount was successfully created.' format.html { redirect_to(@term_count) } format.xml { render :xml => @term_count, :status => :created, :location => @term_...
[ "def term_count(term)\n term_counts[term].to_i # need #to_i if unmarshalled\n end", "def create\n @term_count = TermCount.new(params[:term_count])\n\n respond_to do |format|\n if @term_count.save\n format.html { redirect_to @term_count, notice: 'Term count was successfully created.' }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /term_counts/1 PUT /term_counts/1.xml
def update @term_count = TermCount.find(params[:id]) respond_to do |format| if @term_count.update_attributes(params[:term_count]) flash[:notice] = 'TermCount was successfully updated.' format.html { redirect_to(@term_count) } format.xml { head :ok } else format.html...
[ "def update\n @term_count = TermCount.find(params[:id])\n\n respond_to do |format|\n if @term_count.update_attributes(params[:term_count])\n format.html { redirect_to @term_count, notice: 'Term count was successfully updated.' }\n format.json { head :no_content }\n else\n format...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /term_counts/1 DELETE /term_counts/1.xml
def destroy @term_count = TermCount.find(params[:id]) @term_count.destroy respond_to do |format| format.html { redirect_to(term_counts_url) } format.xml { head :ok } end end
[ "def destroy\n @term_count = TermCount.find(params[:id])\n @term_count.destroy\n\n respond_to do |format|\n format.html { redirect_to term_counts_url }\n format.json { head :no_content }\n end\n end", "def delete_term(t_id)\n\n request = API_URL + \"terms/#{t_id}\"\n @response = RestClien...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
HELPER METHODS =========================================== The two drivers have slightly different ways of yielding hashes of results, so this method must be implemented to provide a uniform interface.
def each_hash(result) # :nodoc: raise NotImplementedError end
[ "def each_result\n results.each { |res| yield(res.key, res) }\n end", "def hash_comparison(source, result)\n source.each do |key, value|\n # puts \"#{key}: #{value} <==> #{result[key]}\"\n deep_comparison(value, result[key], key)\n end\n end", "def get_hash_results(input, dbs)\n search...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a new MySQL database with optional :charset and :collation. Charset defaults to utf8mb4. Example: create_database 'charset_test', charset: 'latin1', collation: 'latin1_bin' create_database 'matt_development' create_database 'matt_development', charset: :big5
def create_database(name, options = {}) if options[:collation] execute "CREATE DATABASE #{quote_table_name(name)} DEFAULT COLLATE #{quote_table_name(options[:collation])}" elsif options[:charset] execute "CREATE DATABASE #{quote_table_name(name)} DEFAULT CHARACTER SET #{quote_table_n...
[ "def create_database(name, options = {})\n if options[:collation]\n execute \"CREATE DATABASE \\\"#{name}\\\" DEFAULT CHARACTER SET \\\"#{options[:charset] || 'utf8'}\\\" COLLATE \\\"#{options[:collation]}\\\"\"\n else\n execute \"CREATE DATABASE \\\"#{name}\\\" DEFAULT CHARACTER SET...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the database character set.
def charset show_variable "character_set_database" end
[ "def charset\n show_variable 'character_set_database'\n end", "def default_character_set\n data.default_character_set\n end", "def default_character_set\n data[:default_character_set]\n end", "def character_set_name\n @charset.name\n end", "def current_charset\n codeset\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Drops a table from the database. [:force] Set to +:cascade+ to drop dependent objects as well. Defaults to false. [:if_exists] Set to +true+ to only drop the table if it exists. Defaults to false. [:temporary] Set to +true+ to drop temporary table. Defaults to false. Although this command ignores most +options+ and the...
def drop_table(table_name, **options) schema_cache.clear_data_source_cache!(table_name.to_s) execute "DROP#{' TEMPORARY' if options[:temporary]} TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}" end
[ "def drop_table(table_name, options = {})\n execute \"DROP#{' TEMPORARY' if options[:temporary]} TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}\"\n end", "def drop_table(*args)\n options = args.extract_options!\n ar...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Builds a ChangeColumnDefinition object. This definition object contains information about the column change that would occur if the same arguments were passed to change_column. See change_column for information about passing a +table_name+, +column_name+, +type+ and other options that can be passed.
def build_change_column_definition(table_name, column_name, type, **options) # :nodoc: column = column_for(table_name, column_name) type ||= column.sql_type unless options.key?(:default) options[:default] = column.default end unless options.key?(:null) optio...
[ "def build_change_column_definition(table_name, column_name, type, **options) # :nodoc:\n td = create_table_definition(table_name)\n cd = td.new_column_definition(column_name, type, **options)\n ChangeColumnDefinition.new(cd, column_name)\n end", "def new_column_definition(base, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
SHOW VARIABLES LIKE 'name'
def show_variable(name) query_value("SELECT @@#{name}", "SCHEMA") rescue ActiveRecord::StatementInvalid nil end
[ "def show_variable(name)\n variables = select_all(\"SHOW VARIABLES LIKE '#{name}'\")\n variables.first['Value'] unless variables.empty?\n end", "def descriptor\n ConfigvarsRails.variable_descriptor name\n end", "def get_php_connect_info\n return \"$#{@var_name} = mysql_connect(\\\"#{@h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Make sure we carry over any changes to ActiveRecord.default_timezone that have been made since we established the connection
def sync_timezone_changes(raw_connection) end
[ "def ensure_utc_timestamps\n #ActiveRecord::Base.connection.execute(\"SET TIME_ZONE = '+00:00'\")\n end", "def populate_timezones\n if new_record?\n self.created_at_timezone ||= Time.zone.name\n else\n if self.deleted?\n self.deleted_at_timezone ||= Time.zone.name\n end\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Produces a planet from Stargate.
def planet fetch('stargate.planets') end
[ "def planet\n fetch('dune.planets')\n end", "def planet; end", "def planet\n fetch('dragon_ball.planets')\n end", "def instantiate_sun_and_planets\n sun = SolarSystem.new(\"Sun\")\n \n mars = Planet.new(\"Mars\", \"red\", 6.4171e23, 230000000, \"Mars has 2 moons: Phobos and ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Produces a quote from Stargate.
def quote fetch('stargate.quotes') end
[ "def quote\n fetch('seinfeld.quote')\n end", "def quote\n quote_of_the_day[0...second_to_last_index(quote_of_the_day, \"~\")].gsub(/(\\A[^a-zA-z0-9\"']*|\\s*\\z)/, \"\")\n end", "def quote\n fetch('final_space.quotes')\n end", "def quote\n fetch('simpsons.quo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Index of provided node in children list
def index_of(child) children.index(child) end
[ "def node_child_index(parent, child); node_children(parent).index(child); end", "def get_child_index\n return 0\n end", "def index( child )\n count = -1\n @children.find { |i| count += 1 ; i.hash == child.hash }\n count\n end", "def each_child_index\n end", "def index_in_parent\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }