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
lengths(words) => [5, 4, 2, 2, 4] def lengths(word) output = word.split('') .length puts output end def lengths(words) empty_array = [] words.each do |word| word_length = word.length empty_array.push(word_length) end return empty_array end puts lengths(words) Round 2 Write a Ruby function called transmogrifier This function should accept three arguments, which you can assume will be numbers. Your function should return the "transmogrified" result The transmogrified result of three numbers is the product (numbers multiplied together) of the first two numbers, raised to the power (exponentially) of the third number. For example, the transmogrified result of 5, 3, and 2 is (5 times 3) to the power of 2 is 225. Use your function to find the following answers. transmogrifier(5, 4, 3) transmogrifier(13, 12, 5) transmogrifier(42, 13, 7)
def transmogrifier(num1, num2, num3) transmogrified = ((num1*num2) * num3) return transmogrified end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lengths(words)\n words.map do |word|\n word.length\n end\nend", "def word_sizes(string)\n string.split.map do |word|\n word.size\n end.tally\n \nend", "def word_lengths(words)\n words.split.map { |word| \"#{word} #{word.size}\" }\nend", "def word_lengths(words)\n words.split(' ').map { |word...
[ "0.69299996", "0.68836695", "0.68257153", "0.6823472", "0.67481667", "0.6738128", "0.6714115", "0.67007834", "0.66619575", "0.66493887", "0.66137016", "0.65939283", "0.65709996", "0.65697974", "0.65692747", "0.6562452", "0.6520141", "0.65001065", "0.6490536", "0.64900935", "0...
0.0
-1
Round 3 Write a function called toonify that takes two parameters, accent and sentence. If accent is the string "daffy", return a modified version of sentence with all "s" replaced with "th". If the accent is "elmer", replace all "r" with "w". Feel free to add your own accents as well! If the accent is not recognized, just return the sentence asis. toonify("daffy", "so you smell like sausage") => "tho you thmell like thauthage"
def toonify(accent, sentence) if accent == 'daffy' return sentence.gsub('s', 'th') elsif accent == 'elmer' return sentence.gsub('r', 'w') else return sentence end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toonify (accent, sentence)\n if accent == 'daffy'\n return sentence.gsub('s','th')\n elsif accent =='elmer'\n return sentence.gsub('r','w')\n else\n return sentence\n end\n end", "def toonify(accent, sentence)\n\tif accent == \"daffy\"\n\t\tre = /s/\n\t\tsentence = sentence.replac...
[ "0.90410376", "0.8999232", "0.89314", "0.89139175", "0.88607925", "0.88350093", "0.88226575", "0.8660102", "0.86111856", "0.85057545", "0.8347041", "0.8024091", "0.79702425", "0.65046346", "0.6374063", "0.63612473", "0.61297655", "0.6120786", "0.6080848", "0.60139555", "0.600...
0.90243095
1
Round 4 Write a function word_reverse that accepts a single argument, a string. The method should return a string with the order of the words reversed. Don't worry about punctuation. word_reverse("Now I know what a TV dinner feels like") => "like feels dinner TV a what know I Now"
def word_reverse(string) reversed_word = string.split(' ').reverse().join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_reverse(string)\n reversed_word = string.split(' ').reverse().join(' ').reverse()\nend", "def word_reverse(str)\n p str.split(' ').reverse.join(' ')\nend", "def word_reverse (str)\n str.split(' ').reverse.join(' ')\nend", "def reverse_words(word)\n p word.reverse.split.reverse.join(' ')\nend...
[ "0.8573091", "0.8570861", "0.8439694", "0.843195", "0.8421283", "0.8407072", "0.8381471", "0.83662903", "0.83473426", "0.8332238", "0.8328316", "0.82603925", "0.82494426", "0.8199482", "0.8199482", "0.8171515", "0.81603736", "0.8131489", "0.8131069", "0.8125518", "0.81094265"...
0.84777814
2
Round 5 Write a function letter_reverse that accepts a single argument, a string. The function should maintain the order of words in the string but reverse the letters in each word. Don't worry about punctuation. This will be very similar to round 4 except you won't need to split them with a space.
def word_reverse(string) reversed_word = string.split(' ').reverse().join(' ').reverse() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def letter_reverse (str)\n str.split(' ').map { |each| each.reverse }.join(' ')\nend", "def letter_reverse(str)\n p str.reverse.split(' ').reverse.join(' ')\nend", "def letterReverse(aString)\n return aString.reverse!.split.reverse.join(\" \")\nend", "def letterReverse (str)\n str.split('').reverse.j...
[ "0.78569853", "0.7827703", "0.78112555", "0.7803691", "0.7762825", "0.7722032", "0.75566876", "0.7532119", "0.7530557", "0.7317376", "0.7186251", "0.7169247", "0.7150262", "0.7149876", "0.71458846", "0.7090349", "0.7067958", "0.7051906", "0.702455", "0.7023777", "0.6987322", ...
0.68269825
61
puts reversed_word('whats up there buddy') Round 6 Write a function longest that accepts a single argument, an array of strings. The method should return the longest word in the array. In case of a tie, the method should return either. longest(["oh", "good", "grief"]) => "grief" longest(["Nothing" , "takes", "the", "taste", "out", "of", "peanut", "butter", "quite", "like", "unrequited", "love"]) => "unrequited"
def longest(array) return array.max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_word_in_array(array)\n array.sort_by(&:length).reverse[0]\nend", "def longest(words=[])\r\n result = ''\r\n words.inject do |memo, word|\r\n result = memo.length > word.length ? memo : word\r\n end\r\n result # don't use puts here, just return a value\r\nend", "def longest_word_in_array(arr...
[ "0.7788333", "0.775992", "0.7641569", "0.7609698", "0.7585937", "0.7585478", "0.756581", "0.755528", "0.7551067", "0.7540802", "0.75364083", "0.7530776", "0.75067186", "0.750571", "0.75023323", "0.7499738", "0.7499064", "0.7491996", "0.7487524", "0.7468841", "0.7441914", "0...
0.70784223
82
Find container that was added with given key
def find(key) raise UnknownEntity unless key?(key) collection[ukey(key)] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_by_key(key)\n find_by_id(key) # backlog method looks exactly the same except for the parameter type\n end", "def find_by_key(key)\n by_key[key]\n end", "def find_by_key(key)\n by_key[key]\n end", "def find_by_key(key)\n find_by('key', key)\n end", "d...
[ "0.6667924", "0.64860517", "0.64860517", "0.64410836", "0.63841796", "0.6318494", "0.62892115", "0.62892115", "0.62892115", "0.62892115", "0.62892115", "0.6277866", "0.6277866", "0.6260197", "0.61761004", "0.61044544", "0.6065051", "0.60620284", "0.6025401", "0.59484065", "0....
0.60549146
18
Iterate throw all registered containers
def each_container(&block) collection.each_value(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block)\n config.resolver.each(_container, &block)\n end", "def each(&block)\n @_componentable_container.each(&block)\n end", "def each(&block)\n @services.each { |c|\n yield c\n }\n end", "def each\n _registry.each do |name, s...
[ "0.6700357", "0.65271366", "0.61161953", "0.6114471", "0.6024874", "0.5981238", "0.5825936", "0.5818672", "0.58153105", "0.5809472", "0.5786065", "0.57444715", "0.56771535", "0.56591135", "0.5642689", "0.5632302", "0.5631373", "0.557811", "0.5561838", "0.5558931", "0.55567896...
0.6379058
2
does the store carry at least one type of apparel?
def must_carry_mens_or_womens_apparel errors.add(:mens_apparel, 'or womens apparel must be provided') unless mens_apparel || womens_apparel end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_appstore?\n !appstore_url.blank?\n end", "def valid_ape_type?(type)\n ITEM_TYPES.include?(type)\n end", "def requires_master?\n return app_type unless item_class.respond_to?(:no_master_association)\n\n app_type && !item_class.no_master_association\n end", "def transfer_applicant?...
[ "0.66719437", "0.6437701", "0.643133", "0.6360413", "0.63330936", "0.625309", "0.62432534", "0.62058216", "0.6195411", "0.6190126", "0.6094071", "0.6071654", "0.6049728", "0.60464597", "0.6042863", "0.6022997", "0.59546185", "0.59434205", "0.5864521", "0.5863726", "0.5836035"...
0.0
-1
=begin def translate(word) vowels = %w[a e i o u] if vowels.include?(word[0]) word + 'ay' elsif vowels.include?(word[2]) word[2..1] + word[0..1] + 'ay' else word[1..1] + word[0] + 'ay' end end =end
def translate(word) split_words = word.split(' ') words = [] vowels = %w[a e i o u] split_words.each do |word| word = qu_in_word(word) if vowels.include?(word[0]) words.push(word + 'ay') else count = 0 word.length.times do |number| vowels.include?(word[number]) ? break : count += 1 end words.push(word[count..-1] + word[0..(count - 1)] + 'ay') end end words.join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate word\n alpha = ('a'..'z').to_a\n vowels = %w[a e i o u]\n consonants = alpha - vowels\n\n if vowels.include?(word[0])\n word + 'ay'\n elsif consonants.include?(word[0]) && consonants.include?(word[1])\n word[2..-1] + word[0..1] + 'ay'\n elsif consonants.include?(word[0])\n word[1..-1] ...
[ "0.90905386", "0.9008723", "0.8832819", "0.87669843", "0.87153536", "0.8612807", "0.85827637", "0.8523076", "0.8521589", "0.84026164", "0.8398594", "0.8244818", "0.82202613", "0.8201613", "0.8185553", "0.811662", "0.8115236", "0.81128913", "0.80840904", "0.8062673", "0.800803...
0.89228815
2
GET /generic_monographs GET /generic_monographs.json
def index # @cd = DisGenericMonograph.all c = DisGenericMonograph.paginate(:page => params[:page], :per_page => 10) e = c.count c = c.as_json d = [{"Count" => e}] m = {"a" => c ,"b" => d} # n = c.to_a << @m respond_with m end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @dis_generic_monographs = DisGenericMonograph.all\n end", "def set_generic_monograph\n @generic_monograph = DisGenericMonograph.find(params[:id])\n end", "def index\n @carbon_monoxides = CarbonMonoxide.all\n render json: @carbon_monoxides\n end", "def index\n @mugshots = Mug...
[ "0.72994554", "0.6578816", "0.61421484", "0.60313845", "0.59895104", "0.59883827", "0.5962852", "0.5911853", "0.5881038", "0.5856985", "0.5837744", "0.58331686", "0.5830423", "0.5815923", "0.5801677", "0.5768015", "0.57534057", "0.5738991", "0.5713735", "0.57081336", "0.57050...
0.54754114
52
GET /generic_monographs/1 GET /generic_monographs/1.json
def show respond_with DisGenericMonograph.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @dis_generic_monographs = DisGenericMonograph.all\n end", "def set_generic_monograph\n @generic_monograph = DisGenericMonograph.find(params[:id])\n end", "def set_dis_generic_monograph\n @dis_generic_monograph = DisGenericMonograph.find(params[:id])\n end", "def show\n @mon...
[ "0.7117769", "0.68601", "0.6176479", "0.6096295", "0.60313207", "0.5977206", "0.59743595", "0.59550494", "0.58728987", "0.5868262", "0.57663786", "0.5741195", "0.5739581", "0.572653", "0.56960005", "0.56865853", "0.5683712", "0.567336", "0.56633085", "0.56395644", "0.56324846...
0.60208786
5
POST /generic_monographs POST /generic_monographs.json
def create @generic_monograph = DisGenericMonograph.new(generic_monograph_params) if @generic_monograph.save flash[:notice] = "Task was successfully created." respond_with(@generic_monograph) else flash[:notice] = "Task was not created." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @dis_generic_monograph = DisGenericMonograph.new(dis_generic_monograph_params)\n\n respond_to do |format|\n if @dis_generic_monograph.save\n format.html { redirect_to @dis_generic_monograph, notice: 'Dis generic monograph was successfully created.' }\n format.json { render :sh...
[ "0.725019", "0.6527183", "0.62853223", "0.6051462", "0.5998686", "0.5963242", "0.5876825", "0.5857509", "0.5605803", "0.55473804", "0.55417436", "0.55203605", "0.55190766", "0.5468318", "0.5466052", "0.5458591", "0.54275644", "0.54235107", "0.54086214", "0.5407188", "0.539408...
0.6588582
1
PATCH/PUT /generic_monographs/1 PATCH/PUT /generic_monographs/1.json
def update respond_to do |format| if @generic_monograph.update(generic_monograph_params) format.html { redirect_to @generic_monograph, notice: 'Combination dose was successfully updated.' } format.json { render :show, status: :ok, location: @generic_monograph } else format.html { render :edit } format.json { render json: @generic_monograph.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @dis_generic_monograph.update(dis_generic_monograph_params)\n format.html { redirect_to @dis_generic_monograph, notice: 'Dis generic monograph was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_generic_monograph }\n ...
[ "0.6950538", "0.6186512", "0.5912196", "0.5759126", "0.57323134", "0.56698924", "0.5642399", "0.5625147", "0.5555262", "0.5549455", "0.5546836", "0.55107045", "0.5506319", "0.54964685", "0.54658", "0.5457902", "0.54573303", "0.5448029", "0.54310054", "0.5422654", "0.54156387"...
0.68079054
1
DELETE /generic_monographs/1 DELETE /generic_monographs/1.json
def destroy @generic_monograph.destroy respond_to do |format| format.html { redirect_to generic_monographs_url, notice: 'Combination dose was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @dis_generic_monograph.destroy\n respond_to do |format|\n format.html { redirect_to dis_generic_monographs_url, notice: 'Dis generic monograph was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mystic.destroy\n respond_to do |fo...
[ "0.7748482", "0.6723113", "0.6656479", "0.66391724", "0.6604661", "0.6599597", "0.65903807", "0.65793365", "0.6562374", "0.65418124", "0.65210265", "0.64999", "0.6478176", "0.646106", "0.6444571", "0.64402825", "0.64353585", "0.64325583", "0.64264965", "0.6423313", "0.6421916...
0.7340774
1
Use callbacks to share common setup or constraints between actions.
def set_generic_monograph @generic_monograph = DisGenericMonograph.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 generic_monograph_params params.require(:generic_monograph).permit(:generic_id, :dose, :contraindication, :precaution, :adverse_effect, :storage, :datasource_id, :status_id) 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
Searches through the instance variables of the class and creates a class method on the MetricFu module to read the value of the instance variable from the Configuration class.
def add_class_methods_to_metric_fu instance_variables.each do |name| method_name = name[1..-1].to_sym method = <<-EOF def self.#{method_name} configuration.send(:#{method_name}) end EOF MetricFu.module_eval(method) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def class_variables() end", "def method_missing(name, *args, &block)\n if !method_name_info(name).special?\n instance_variable_name = :\"@#{name}\"\n instance_variable_value = config[name]\n instance_variable_set instance_variable_name, instance_variable_value\n \n ...
[ "0.6010917", "0.5988616", "0.588814", "0.55677986", "0.55481255", "0.5540865", "0.5516397", "0.5500667", "0.53810984", "0.53671795", "0.5331947", "0.5318712", "0.530026", "0.52369976", "0.5236403", "0.5220656", "0.52202934", "0.5204634", "0.51872814", "0.51872814", "0.5153804...
0.6367096
0
Searches through the instance variables of the class and creates an attribute accessor on this instance of the Configuration class for each instance variable.
def add_attr_accessors_to_self instance_variables.each do |name| method_name = name[1..-1].to_sym MetricFu::Configuration.send(:attr_accessor, method_name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n config_hash = Huey::Request.get('config')\n Huey::Bridge::ATTRIBUTES.each do |attribute|\n instance_variable_set(\"@#{attribute}\", config_hash[attribute.to_s])\n end\n end", "def create_attr_hash\n data = {}\n self.instance_variables.each do |attr|\n value = ...
[ "0.6576774", "0.6414039", "0.6355501", "0.63488764", "0.62890494", "0.6238604", "0.6233555", "0.6225353", "0.622486", "0.61891216", "0.6187179", "0.6180488", "0.6176758", "0.6106808", "0.61013865", "0.6083923", "0.6072704", "0.60709083", "0.6061361", "0.6050953", "0.6044307",...
0.71927756
0
This does the real work of the Configuration class, by setting up a bunch of instance variables to represent the configuration of the MetricFu app.
def reset @base_directory = ENV['CC_BUILD_ARTIFACTS'] || 'tmp/metric_fu' @scratch_directory = File.join(@base_directory, 'scratch') @output_directory = File.join(@base_directory, 'output') @data_directory = File.join('tmp/metric_fu', '_data') @metric_fu_root_directory = File.join(File.dirname(__FILE__), '..', '..') @template_directory = File.join(@metric_fu_root_directory, 'lib', 'templates') @template_class = AwesomeTemplate set_metrics set_graphs set_code_dirs @flay = { :dirs_to_flay => @code_dirs, :minimum_score => 100, :filetypes => ['rb'] } @flog = { :dirs_to_flog => @code_dirs } @reek = { :dirs_to_reek => @code_dirs, :config_file_pattern => nil} @roodi = { :dirs_to_roodi => @code_dirs, :roodi_config => nil} @saikuro = { :output_directory => @scratch_directory + '/saikuro', :input_directory => @code_dirs, :cyclo => "", :filter_cyclo => "0", :warn_cyclo => "5", :error_cyclo => "7", :formater => "text"} @churn = {} @stats = {} @rcov = { :environment => 'test', :test_files => ['test/**/*_test.rb', 'spec/**/*_spec.rb'], :rcov_opts => ["--sort coverage", "--no-html", "--text-coverage", "--no-color", "--profile", "--rails", "--exclude /gems/,/Library/,/usr/,spec"], :external => nil } @rails_best_practices = {} @hotspots = {} @file_globs_to_ignore = [] @graph_engine = :bluff # can be :bluff or :gchart end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configuration; end", "def configuration; end", "def configuration; end", "def configuration; end", "def configuration; end", "def configurations; end", "def configuration\n @config ||= setup\n end", "def configure(config)\n @index = config[\"index\"].to_i\n setup_logging...
[ "0.6814277", "0.6814277", "0.6814277", "0.6814277", "0.6814277", "0.6810317", "0.67820996", "0.66698545", "0.66591436", "0.66561973", "0.6641759", "0.66300243", "0.6613372", "0.6610705", "0.658921", "0.65475", "0.6511322", "0.6498015", "0.64404005", "0.64319396", "0.642149", ...
0.0
-1
Perform a simple check to try and guess if we're running against a rails app.
def rails? @rails = File.exist?("config/environment.rb") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_rails!\n unless rails?\n abort unless agree \"`#{dest}' does not appear to be a rails app; continue? \"\n end\n end", "def rails_app?\n File.exist?(\"bin/rails\")\n end", "def rails?\n defined?(::Rails) && ::Rails.application.present? # &.initialized?\n end", ...
[ "0.79072785", "0.77253366", "0.7336583", "0.72391236", "0.71667975", "0.7110516", "0.6984167", "0.6897968", "0.68844837", "0.6883021", "0.68053484", "0.67850703", "0.6667793", "0.65767765", "0.6556767", "0.64240474", "0.6391418", "0.6374815", "0.6346428", "0.6331658", "0.6295...
0.6929708
7
Add the :stats task to the AVAILABLE_METRICS constant if we're running within rails.
def set_metrics if rails? @metrics = MetricFu::AVAILABLE_METRICS + [:stats, :rails_best_practices] else @metrics = MetricFu::AVAILABLE_METRICS end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metrics\n with_stats_lock do\n @stats_hash.keys.map { |spec| spec.to_s }\n end\n end", "def register_metrics!\n return if @registered\n @registered = true\n with_instance do |t|\n # Worker related\n t.add_gauge :dynflow_active_worke...
[ "0.61399865", "0.61227494", "0.60120887", "0.6007641", "0.6007641", "0.6007641", "0.59117913", "0.5882685", "0.58672464", "0.58121765", "0.5812006", "0.5781224", "0.5742837", "0.5701485", "0.5663753", "0.5661679", "0.5651341", "0.5615447", "0.56116164", "0.55966264", "0.55572...
0.6685454
0
Add the 'app' directory if we're running within rails.
def set_code_dirs if rails? @code_dirs = ['app', 'lib'] else @code_dirs = ['lib'] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_app\n unless File.exists?(app_dir)\n original_dir = FileUtils.pwd\n Dir.mkdir(root_dir) unless (!root_dir or File.exists?(root_dir))\n FileUtils.cd(root_dir) if root_dir\n `#{rails_str}`\n FileUtils.cd(original_dir)\n true\n end\n end", "def add_app_folder\n di...
[ "0.75601536", "0.7452783", "0.7274925", "0.7171399", "0.6955285", "0.6955285", "0.6902182", "0.6698023", "0.6697075", "0.66869164", "0.66184527", "0.6546597", "0.6530001", "0.64931935", "0.6473574", "0.6407198", "0.6395104", "0.6386372", "0.6290653", "0.6280043", "0.6266718",...
0.59165794
40
to be series sortable, append zero to 19
def add_zero_to_1_to_9(str) str.sub(/(?<=\D)\d\D?$/, '0\0' ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append_non_zero_number\n append table.pick_non_zero\n end", "def numtostring arr\n arr.each_with_index{|val, idx| arr[idx] = 'dojo' if val < 0}\n p arr\nend", "def sort_display_data\n if @total_data.has_key?(\"\") or @total_data.has_key?(nil) and @total_data.length > 1\n @total_da...
[ "0.5722433", "0.5479659", "0.54662114", "0.5384579", "0.53442067", "0.5329219", "0.53205633", "0.5305466", "0.52559304", "0.5220807", "0.51525974", "0.51238096", "0.5122514", "0.50719166", "0.5063247", "0.4994637", "0.4991463", "0.4990687", "0.4970495", "0.49636683", "0.49581...
0.0
-1
Unify the fields into a string
def to_s res = "\nname: " + name.to_s + "\nid: " + id.to_s + "\nservice: " + service.to_s + "\ntitle: " + title.to_s + "\nthumbnail: " + thumbnail.to_s + "\nhref: " + href.to_s res end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_str\n fields.collect do |field, body|\n send(field) if body.type == Object\n end.compact.sort.join(' ')\n end", "def format_fields(fields)\n if fields.instance_of?(Array)\n return fields.join(\",\")\n elsif fields.instance_of?(String)\n return fields\n ...
[ "0.7301817", "0.674092", "0.67388856", "0.66999316", "0.6568083", "0.6438982", "0.6345852", "0.63051367", "0.6304707", "0.62862426", "0.61989295", "0.61224663", "0.60774136", "0.6071137", "0.6021013", "0.60160464", "0.60008615", "0.5983785", "0.59837794", "0.5983541", "0.5969...
0.0
-1
Unify the fields into a hash
def to_hash res = { "name" => name, "id" => id, "service" => service, "title" => title, "thumbnail" => thumbnail, "href" => href } res end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fields_to_hash(these_fields)\n combined_fields = combine_multivalued_fields(these_fields)\n combined_pairs = combined_fields.map do |field|\n\n # does the normalize_ case ever happen?\n key = api_field_name_for(field.header) || normalize_header(field.header)\n [ key, encode_value...
[ "0.76092094", "0.73421687", "0.7162108", "0.7026138", "0.6974151", "0.69049734", "0.6844028", "0.68024844", "0.66448134", "0.6591479", "0.656911", "0.6546546", "0.65445405", "0.6533192", "0.6525319", "0.6479781", "0.6479664", "0.6452661", "0.6451121", "0.6401796", "0.63960207...
0.0
-1
for each SSM Key retrieve it's value and return an array of hashes
def reference_data @reference_data ||= KeyValues.new(@from_profile, @source).format_data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gets(aName,aKeyArray)\n j = 1\n cont = 0\n result = []\n while j < aKeyArray.length do\n i = searchKey(aName,aKeyArray[j])\n if i != '' then\n updateLastGet(i)\n subResult = serv_data[i].values[0]\n result[cont] = \"VALUE #{subResult.values[0...
[ "0.6092329", "0.601753", "0.5759598", "0.5717999", "0.57031745", "0.57018906", "0.5629861", "0.55918646", "0.557987", "0.557987", "0.5524857", "0.55208737", "0.5508724", "0.54679173", "0.546249", "0.543514", "0.5419979", "0.5419979", "0.5411093", "0.54002506", "0.53869236", ...
0.0
-1
this method will return only trip instances that it has had. should return all linsting instances == self. worked first try
def trips Trip.all.select do |trip| trip.listing == self end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trips\n Trip.all.select do |trip|\n trip.listing == self\n end\n\n end", "def trips\n Trip.all.select {|trip| trip.listing == self}\n end", "def trips\n Trip.all.select {|t| t.listing == self}\n end", "def trips\n Trip.all.select { |trip| trip.listing==self}\n end", ...
[ "0.77800363", "0.7767566", "0.77190864", "0.7707546", "0.76970965", "0.7687565", "0.7683228", "0.76801527", "0.7658864", "0.7658491", "0.7606506", "0.75469756", "0.7540549", "0.7522888", "0.74685377", "0.7465086", "0.72374", "0.7004925", "0.6954315", "0.68982697", "0.6859021"...
0.75797886
11
this method will count all of the a specific trip instance has had. I'm guessing I can use a previous method written. Trips method? will give me an integer back.
def trip_count trips.count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trip_count\n trips.count\n end", "def trip_count\n trips.length\n end", "def trip_count\n trips.length\n end", "def trip_count\n trips.length\n end", "def trip_count\n trips.length\n end", "def trip_count\n trips.length\n end", "def trip_count\n self.trips.c...
[ "0.87917596", "0.8513187", "0.85097307", "0.8508809", "0.8508809", "0.8508809", "0.8505742", "0.83736634", "0.8358884", "0.8353926", "0.8282063", "0.8274554", "0.8274554", "0.8222465", "0.72403204", "0.70993584", "0.68197274", "0.6807867", "0.67699116", "0.67570895", "0.67570...
0.8787178
1
Specifies the location to send answers to designated by the given labels. These labels must match the labels given to Machinelabel. Factory.setup do workstation :w do machine :m do ... send group1: "w:m1" send group2: "w:m2" end end end Use this method inside a machine block.
def send (hash) @routes.merge! hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def for_labels(*the_labels)\n raise OpenForLabelStatement unless working_labels.empty?\n self.working_labels += the_labels\n self\n end", "def set_labels(hash, labels)\n labels = [labels] unless labels.is_a? Array\n @server.call('d.set_custom1', hash, labels.join(', '))\n ...
[ "0.53286314", "0.52346635", "0.49682522", "0.4943947", "0.48821852", "0.483078", "0.48232606", "0.48162913", "0.47273862", "0.46414503", "0.46132672", "0.46070933", "0.46007177", "0.45828426", "0.45732787", "0.45669907", "0.45579606", "0.45431572", "0.45392242", "0.4518311", ...
0.0
-1
Specifies the answers to be referred to by the given labels. These labels must match the labels given to Machinesend. def process_answers ary1 = [] ary2 = [] answers.each do |a| ... end label group1: ary1 label group2: ary2 end Use this method inside a process block or inside a Machineprocess_answers method definition.
def label (hash) @labeled_answers.merge! hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_labeling\n process_adding_labels\n process_removing_labels\n end", "def parse_labels\n @labels.split.each do |lbl|\n vals = lbl.split(':')\n v = vals.first\n case v\n when \"form\"\n handle_form_label vals\n when \"instrument\"\n handle_instrument_labe...
[ "0.57750314", "0.56825393", "0.5591151", "0.5340398", "0.5337138", "0.53257984", "0.52031136", "0.51922965", "0.51735103", "0.5139653", "0.51356506", "0.5129648", "0.5112378", "0.51086885", "0.51034516", "0.5101648", "0.5101648", "0.5092396", "0.49782306", "0.4971085", "0.496...
0.6176948
0
Returns an array of the answers currently at this machine. By default,
def answers @answers ||= Factory.load_answers_at_machine(@location, @load_scores) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def answers\n []\n end", "def answers\n return @answers\n end", "def answers\n @answers ||= generate_answers\n end", "def answers\n [answer_1, answer_2]\n end", "def answers\n @answers ||= {}\n end", "def answers\n request('answers')\n ...
[ "0.7963172", "0.7488308", "0.73175883", "0.7266646", "0.7166783", "0.6777885", "0.665121", "0.664607", "0.664607", "0.6529227", "0.6522831", "0.65183765", "0.6349958", "0.6303838", "0.62968224", "0.62643814", "0.6184018", "0.615003", "0.6149309", "0.60974735", "0.60942036", ...
0.6915636
5
Returns a hash of the answers currently at this machine, keyed by language
def answers_keyed_by_language hash = Hash.new {|h,k| h[k] = [] } answers.each {|answer| hash[answer.language] << answer } hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def answers\n @answers ||= {}\n end", "def keyword_hash(lang=@lang)\n LANGUAGES[lang]\n end", "def user_languages_hash\n result = Hash.new\n\n I18n.available_locales.each do |locale|\n result[t(\"languages.#{locale.to_s}\")] = locale.to_s\n end\n \n return result\n ...
[ "0.6481944", "0.62176263", "0.5996037", "0.5932177", "0.5854237", "0.5819696", "0.5778338", "0.57440966", "0.5615111", "0.5573738", "0.54959536", "0.54569966", "0.54465926", "0.54162484", "0.5410884", "0.5382513", "0.53544545", "0.5345392", "0.5334789", "0.52785355", "0.52781...
0.7686113
0
Returns a new answer with the given blueprint and parents. def process_answers answers.each do |a| ary1 << make_answer(a.blueprint, a) ary2 << make_answer(a.blueprint.reverse, a) end label group1: ary1 label group2: ary2 end Use this method inside a process block or inside a Machineprocess_answers method definition.
def make_answer (blueprint, *parents) parent_ids = parents.collect {|answer| answer.id } Answer.new(nil, blueprint, @location, @location, parent_ids, Factory.cycle, nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_question_answer_tree\n before :each do\n @reply = 1\n @type_vendor = make_forms_for_app_type \"vendor\"\n @type_donor = make_forms_for_app_type \"donor\"\n \n @q1 = Questionnaire.create(:question => \"hello world\")\n @q2 = Questionnaire.create(:question => \"how are you?\...
[ "0.59596515", "0.55361146", "0.5426413", "0.54173076", "0.5416092", "0.53365755", "0.53365755", "0.5334735", "0.5283233", "0.5237453", "0.5222678", "0.51908827", "0.51536494", "0.50896204", "0.5064321", "0.5054957", "0.5046981", "0.5016765", "0.50117314", "0.4989565", "0.4980...
0.69876224
0
Returns the number of answers currently at this machine without forcing the answers to load. def process_answers if answer_count > 500 ... end label group1: ary1 end Use this method inside a process block or inside a Machineprocess_answers method definition.
def answer_count return @answers.length if @answers Factory.count_answers_at_machine(@location) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bad_results\n answer_choice_count = {}\n answer_choices = self.answer_choices\n answer_choices.each do |answer_choice|\n answer_choice_count[answer_choice.answer_choice_body] = answer_choice.responses.length\n end\n\n answer_choice_count\n end", "def n_results\n output = {}\n answe...
[ "0.62781805", "0.62276155", "0.6201172", "0.61235964", "0.60876024", "0.60167545", "0.6007431", "0.6007431", "0.5966726", "0.5965637", "0.59611744", "0.5868931", "0.5714675", "0.5684064", "0.56705743", "0.566917", "0.5668605", "0.56296676", "0.5516189", "0.5510711", "0.548838...
0.6999388
0
Internal use only. Defined by Machine subclasses.
def process_answers raise NoMethodError, "define process for machine #{@location} before running factory" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def machine; end", "def machine; end", "def machine; end", "def machine; end", "def machine; end", "def machine; end", "def machine; end", "def machine; end", "def private; end", "def machine=(_arg0); end", "def initialize(*)\n super\n machine\n end", "def machine=(new_machine); end", ...
[ "0.72880554", "0.72880554", "0.72880554", "0.72880554", "0.72880554", "0.72880554", "0.72880554", "0.72880554", "0.68016917", "0.6758225", "0.6701629", "0.65903014", "0.6295201", "0.6158165", "0.6158165", "0.6158165", "0.6158165", "0.6158165", "0.6158165", "0.6158165", "0.615...
0.0
-1
Filter view network items and activity based on entity type, action is deprecated will be removed
def my_network case params[:type] when 'trusted' @items = @person.trusted_friends_items(params[:filter_type]).sort_by{|i| i.item_type.downcase} @events = current_user.trusted_network_activity.page(params[:page]).per_page(25) else @items = @person.personal_network_items(params[:filter_type]).sort_by{|i| i.item_type.downcase} @events = current_user.network_activity.page(params[:page]).per_page(25) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def activities_for(filter: nil, type: _feed_type)\n Feed::ActivityList.new(self).filter(filter).with_type(type)\n end", "def extra_search_actions(items, extra_filters = [], kind = nil)\n (extra_filters || []).each do |filter|\n case filter\n when 'my_country'\n case kind || params[:ty...
[ "0.652229", "0.6421259", "0.6107175", "0.60653734", "0.59281796", "0.5832485", "0.5773322", "0.5760219", "0.57422835", "0.5681725", "0.56059235", "0.5572643", "0.5545241", "0.54194653", "0.5412291", "0.54117495", "0.54105407", "0.54024184", "0.53944016", "0.5384814", "0.53795...
0.6324346
2
has_many :posts has_many :users
def posts self.object.posts.sort_by{|post| post.id}.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_posts\n Post.joins(:user).where(users: {id: self.id})\n end", "def my_posts\n Post.where(user_id: self.id)\n end", "def index\n posted_user_ids = User.has_posted.pluck(:id)\n @posts = Post.includes(:book, :user).where(user_id: posted_user_ids)\n end", "def user_posts\n posts = ...
[ "0.7623238", "0.6807512", "0.66903895", "0.6488015", "0.6373045", "0.6347549", "0.62779236", "0.6240288", "0.62153375", "0.6203202", "0.6157127", "0.6121711", "0.6105165", "0.60576326", "0.60449153", "0.6011584", "0.60004306", "0.5993527", "0.5988148", "0.59294903", "0.591632...
0.5497055
71
TODO: solve static pages ids
def equal_to_params(controller, action) controller == params[:controller] && action.include?(params[:action]) if controller && action end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pages; end", "def pages\n end", "def site_pages \n Rails.application.reload_routes!\n page_routes = Rails.application.routes.routes.select do |route|\n route.verb == \"GET\" && !route.name.blank? && !route.name.match(/^edit/) && !route.name.match(\"translat\") && !route.name.match(\"external...
[ "0.7298104", "0.71460736", "0.67690337", "0.67471206", "0.660766", "0.660766", "0.660766", "0.660766", "0.660766", "0.660766", "0.660766", "0.660766", "0.660766", "0.660766", "0.660766", "0.660766", "0.65711683", "0.649829", "0.6430819", "0.63828135", "0.63820493", "0.63558...
0.0
-1
Only need this helper once, it will provide an interface to convert a block into a partial. 1. Capture is a Rails helper which will 'capture' the output of a block into a variable 2. Merge the 'body' variable into our options hash 3. Render the partial with the given options hash. Just like calling the partial directly.
def block_to_partial(partial_name, options = {}, &block) #puts "PARTIAL_NAME=#{partial_name},OPTIONS=#{options},BLOCK=#{block}" options.merge!(:body => capture(&block)) concat(render(:partial => partial_name, :locals => options)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block_to_partial(partial_name, options = {}, &block)\n options.merge!(:body => capture(&block))\n @options = options\n concat(render(:partial => partial_name), block.binding)\n end", "def block_to_partial(partial_name, options = {}, &block)\n options.merge!(:body => capture(&block))\n concat(...
[ "0.77908033", "0.7781661", "0.7781661", "0.7771526", "0.7771526", "0.7771526", "0.74103457", "0.7321377", "0.7313855", "0.7278552", "0.7225996", "0.6842992", "0.68315643", "0.6785507", "0.6662835", "0.66410714", "0.6602847", "0.6572013", "0.6539879", "0.65341526", "0.65145487...
0.76805353
6
GET /pricetypes GET /pricetypes.json
def index ensure_an_admin_role @pricetypes = Pricetype.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @ptypes = Ptype.find(params[:id])\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def index\n @ptypes = Ptype.all\n end", "def index\n @ptypes = Ptype.all\n end", "def types()\n\t\t@pokemon_types = []\n\t\t@pokemon_api[\"types\"].each do...
[ "0.7098777", "0.7082889", "0.70656204", "0.70656204", "0.70499074", "0.67209023", "0.67128813", "0.6612824", "0.6565768", "0.6556747", "0.65171546", "0.6475926", "0.64640087", "0.64589775", "0.64427745", "0.6416247", "0.6416214", "0.64113575", "0.64056", "0.64014184", "0.6398...
0.61185735
60
GET /pricetypes/1 GET /pricetypes/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @ptypes = Ptype.find(params[:id])\n end", "def index\n @ptypes = Ptype.all\n end", "def index\n @ptypes = Ptype.all\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def index\n @pre_print_types = PrePrintType.all\n\n respond_to do |...
[ "0.720306", "0.69025195", "0.69025195", "0.6631093", "0.6580078", "0.65065694", "0.6449087", "0.644413", "0.64064336", "0.6377752", "0.6373143", "0.63402414", "0.63326675", "0.6327099", "0.6314866", "0.63142866", "0.6311793", "0.63029534", "0.6299322", "0.6296339", "0.6294535...
0.0
-1
POST /pricetypes POST /pricetypes.json
def create @pricetype = Pricetype.new(pricetype_params) respond_to do |format| if @pricetype.save format.html { redirect_to @pricetype, notice: 'Pricetype was successfully created.' } format.json { render :show, status: :created, location: @pricetype } else format.html { render :new } format.json { render json: @pricetype.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type_params\n params.from_jsonapi.require(:type).permit(:name)\n end", "def create\n @type = Type.new(type_params)\n\n unless @type.save\n render json: @type.errors, status: :unprocessable_entity\n end\n \n end", "def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = re...
[ "0.6667789", "0.6441899", "0.63712263", "0.6289321", "0.6289321", "0.6245715", "0.6245715", "0.6212805", "0.6212805", "0.62044173", "0.60714066", "0.6068572", "0.6062268", "0.6045921", "0.6008005", "0.60065", "0.5970621", "0.59502786", "0.5945157", "0.5927338", "0.5910287", ...
0.60730547
10
PATCH/PUT /pricetypes/1 PATCH/PUT /pricetypes/1.json
def update respond_to do |format| if @pricetype.update(pricetype_params) format.html { redirect_to @pricetype, notice: 'Pricetype was successfully updated.' } format.json { render :show, status: :ok, location: @pricetype } else format.html { render :edit } format.json { render json: @pricetype.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @type.update(type_params)\n end", "def update\n respond_to do |format|\n if @spec_type.update(spec_type_params)\n format.html { redirect_to @spec_type, notice: 'Spec type was successfully updated.' }\n format.json { render :show, status: :ok, location: @spec_type }\n e...
[ "0.6347546", "0.6296984", "0.6278799", "0.6275465", "0.6262482", "0.62403977", "0.62403977", "0.62166166", "0.61902964", "0.6180412", "0.6174437", "0.61717933", "0.61661386", "0.61605716", "0.6146162", "0.614573", "0.614209", "0.61316186", "0.6125931", "0.6121973", "0.6104092...
0.6562807
0
DELETE /pricetypes/1 DELETE /pricetypes/1.json
def destroy @pricetype.destroy respond_to do |format| format.html { redirect_to pricetypes_url, notice: 'Pricetype was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n ...
[ "0.73798156", "0.7343801", "0.721607", "0.70976806", "0.7091887", "0.70742613", "0.70742613", "0.70737946", "0.7067571", "0.70593506", "0.70551926", "0.7036629", "0.700738", "0.69975984", "0.6975472", "0.6974206", "0.69698375", "0.6962976", "0.69595975", "0.6955237", "0.69521...
0.7376548
1
Use callbacks to share common setup or constraints between actions.
def set_pricetype @pricetype = Pricetype.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.61637366", "0.60446453", "0.59452957", "0.591511", "0.58885515", "0.5834122", "0.57761765", "0.5702554", "0.5702554", "0.5652102", "0.5619581", "0.5423898", "0.5409782", "0.5409782", "0.5409782", "0.5394745", "0.53780794", "0.5356209", "0.5338898", "0.53381324", "0.5328622...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def pricetype_params params.require(:pricetype).permit(:name) 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
Wraps the deep_cloneable gem deep_clone method to allow using the predefined associations and options from our Cloneable.acts_as_cloneable macro.
def deep_clone!(options = {}) processed_options = Para::Cloneable::IncludeTreeBuilder.new(self, cloneable_options).build options = options.reverse_merge(processed_options) callback = build_clone_callback(options.delete(:prepare)) deep_clone(options) do |original, clone| Para::Cloneable::AttachmentsCloner.new(original, clone).clone! callback&.call(original, clone) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deep_clone; end", "def deep_clone\n return @deep_cloning_obj if @deep_cloning\n @deep_cloning_obj = clone\n @deep_cloning_obj.instance_variables.each do |var|\n val = @deep_cloning_obj.instance_variable_get(var)\n begin\n @deep_cloning = true\n val = val.deep_clone\n res...
[ "0.79374623", "0.74966246", "0.7482058", "0.7159899", "0.71067685", "0.7042009", "0.7020679", "0.68281054", "0.68103254", "0.6760494", "0.6750986", "0.67439926", "0.6689758", "0.6678776", "0.66758543", "0.65711266", "0.65700716", "0.6535038", "0.6527982", "0.65121573", "0.643...
0.76570904
1
We ensure that the passed callback is actually callable on the object we're cloning. This is needed for associations because deep_cloneable calls the callback for every associated object.
def build_clone_callback(callback) case callback when Proc callback when Symbol ->(original, clone) { original.send(callback, clone) if original.respond_to?(callback, true) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clone_pre_copy_hook(clone_source_object, _opts = {})\n clone_source_object\n end", "def clone_temp\n clone.tap do |c|\n def c.save(*a)\n true\n end\n end\n end", "def initialize_copy(orig) \n super\n @delegated_to_object = @delegated_to_object.clone\n ...
[ "0.5658105", "0.50213337", "0.49550936", "0.49513608", "0.4924511", "0.49192488", "0.49093536", "0.48721215", "0.48316348", "0.48180613", "0.48180613", "0.48167148", "0.48160154", "0.47474736", "0.47469723", "0.47295466", "0.47180298", "0.47179538", "0.47179538", "0.47154334", ...
0.75211847
0
Returns webdriver capabilities for chrome browser
def chrome_capabilities Selenium::WebDriver::Remote::Capabilities.chrome( logging_prefs: {browser: 'ALL'}, 'chromeOptions' => { 'args' => %w[--ignore-certificate-errors], 'w3c' => false }, 'acceptSslCerts' => true, 'acceptInsecureCerts' => true ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_capabilities\n {\n :browserName => \"Chrome\",\n :version => nil,\n :platform => \"Linux\"\n }\n end", "def browser_caps(browser,browser_options)\n target = (browser.to_sym if ENV['BROWSER'].nil? or ENV['browser'].empty?) || (ENV['BROWSER'].to_sym)\n ...
[ "0.7280506", "0.70243466", "0.6899227", "0.680194", "0.6686297", "0.66435844", "0.65800536", "0.6466498", "0.6454511", "0.6454511", "0.64074486", "0.63275", "0.6298335", "0.6298335", "0.6298335", "0.6250818", "0.624858", "0.62260336", "0.61855286", "0.6182668", "0.6165267", ...
0.81232023
0
Registers :chrome webdriver options in Capybara framework
def register_chrome_driver Capybara.register_driver :chrome do |app| if ENV['SELENIUM_GRID'] == 'false' Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: chrome_capabilities) else Capybara::Selenium::Driver.new(app, browser: :remote, url: hub_url, desired_capabilities: chrome_capabilities) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scrapping_options\n opts = {\n headless: true\n }\n\n if Rails.env.production?\n if (chrome_bin = ENV.fetch('GOOGLE_CHROME_SHIM', nil))\n opts[:options] = { binary: chrome_bin }\n end\n else\n chrome_bin = '/usr/bin/google-chrome'\n opts[:options] = { binary: chrome_bin }\n end\n opts...
[ "0.7220167", "0.70062333", "0.6906341", "0.6695963", "0.65873945", "0.65040004", "0.64951307", "0.64898086", "0.64546084", "0.64195466", "0.6409399", "0.6401847", "0.6361569", "0.6305533", "0.6273613", "0.6190459", "0.61745954", "0.61311656", "0.6123459", "0.6032418", "0.6020...
0.73800695
0
Returns webdriver capabilities for firefox browser
def firefox_capabilities Selenium::WebDriver::Remote::Capabilities.firefox( logging_prefs: {browser: 'ALL'}, 'acceptSslCerts' => true, 'acceptInsecureCerts' => true, 'native_events' => true ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def firefox\n options = Selenium::WebDriver::Firefox::Options.new(profile: firefox_profile)\n options.headless! if config.headless\n\n options\n end", "def firefox\r\n @web_browser.firefox\r\n end", "def firefox\n @web_browser.firefox\n end", "def default_capabilities\n ...
[ "0.7060469", "0.70300734", "0.7022445", "0.69639164", "0.6904549", "0.66492707", "0.65623003", "0.6546828", "0.65064734", "0.64981073", "0.63461965", "0.63461965", "0.63127154", "0.63042223", "0.6295552", "0.6295552", "0.6295552", "0.62866884", "0.61872965", "0.6133089", "0.6...
0.865628
0
Registers :firefox webdriver options in Capybara framework
def register_firefox_driver Capybara.register_driver :firefox do |app| if ENV['SELENIUM_GRID'] == 'false' options = Selenium::WebDriver::Firefox::Options.new Capybara::Selenium::Driver.new(app, browser: :firefox, options: options, desired_capabilities: firefox_capabilities) else Capybara::Selenium::Driver.new(app, browser: :remote, url: hub_url, desired_capabilities: firefox_capabilities) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def firefox_options\n options = Selenium::WebDriver::Firefox::Options.new\n options.add_preference('intl.accept_languages', locale)\n options.add_argument('--headless') if headless\n options\n end", "def firefox\n options = Selenium::WebDriver::Firefox::Options.new(profile: firefox_profile)\n ...
[ "0.7815109", "0.7530077", "0.7256108", "0.7079577", "0.68835956", "0.6814004", "0.6480904", "0.6363908", "0.6362734", "0.6348524", "0.63122797", "0.62159866", "0.6215542", "0.6209992", "0.6164417", "0.6022008", "0.59987974", "0.59982044", "0.5986009", "0.5982393", "0.5978406"...
0.786688
0
Return absolute uri for path
def absolute_uri_path(path) "#{root_uri}#{path}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uri(path)\n s = File::expand_path(path).gsub(DIR, \"\").gsub(File::SEPARATOR, '/')\n return s == '' ? '/' : s\n end", "def uri(path)\n return File.join(@base_url, path)\n end", "def absolute_url\n domain + path\n end", "def path\n @path ||= filters.uri_escape(absolute_url) i...
[ "0.7787539", "0.7586607", "0.758113", "0.7573215", "0.7573215", "0.7544063", "0.747992", "0.736957", "0.73562634", "0.7326265", "0.7321616", "0.73165345", "0.72991306", "0.7286656", "0.7269893", "0.7259619", "0.7200553", "0.71972775", "0.7184429", "0.71646506", "0.7156175", ...
0.85709447
0
Return host with optional port Only returns port if protocols default port diffes from actual port.
def host_with_port uhost, uport = self.host, self.port if port != protocol.default_port "#{uhost}:#{uport}" else uhost end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def host_with_port\n [config.host, optional_port].compact.join(\":\")\n end", "def port_string\n (protocol == 'http://' && port == 80) || (protocol == 'https://' && port == 443) ? '' : \":#{port}\"\n end", "def optional_port; end", "def port(port, host = T.unsafe(nil)); end", "def port_default?...
[ "0.7663858", "0.73588896", "0.7333526", "0.71444106", "0.70652854", "0.7048128", "0.7034594", "0.70061225", "0.6895596", "0.6804654", "0.67131305", "0.66542584", "0.6651736", "0.6595916", "0.65558726", "0.65549535", "0.65393084", "0.64886016", "0.6436052", "0.6415306", "0.640...
0.7835748
0
GET /trucks GET /trucks.json
def index @trucks = Truck.all # @locations = Location.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @trucks = Truck.all\n\n render json: @trucks\n end", "def index\n @trucks = Truck.all\n end", "def show\n render json: @truck\n end", "def index\n @trucks = Truck.all\n\n if params[:name]\n @trucks = @trucks.where(name: params[:name])\n end\n\n if params[:category]...
[ "0.80307823", "0.731416", "0.7164783", "0.7121897", "0.69296175", "0.67625904", "0.6720958", "0.6694923", "0.6692682", "0.6692682", "0.66825765", "0.6666734", "0.6609426", "0.6608989", "0.6602574", "0.6591275", "0.6587129", "0.6566902", "0.64538693", "0.6440638", "0.64291596"...
0.6952556
4
GET /trucks/1 GET /trucks/1.json
def show @truck_owner = @truck.truck_owner end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @trucks = Truck.all\n\n render json: @trucks\n end", "def show\n render json: @truck\n end", "def show\n @trucking = Trucking.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trucking }\n end\n end", "def index\n...
[ "0.7787936", "0.7317396", "0.73098767", "0.7035118", "0.67179126", "0.6693695", "0.658614", "0.65643275", "0.65643275", "0.6545474", "0.6543067", "0.65225375", "0.65039456", "0.64927155", "0.64757264", "0.64757264", "0.64602107", "0.6422839", "0.6420908", "0.64172846", "0.640...
0.0
-1
POST /trucks POST /trucks.json
def create #truck_params.merge!("truck_owner_id" => current_user.id) --- see below #binding.pry @truck = current_user.trucks.new(truck_params) @file = params[:truck][:picture] extension = file_extension @file.original_filename filename = @truck.name.downcase.gsub(' ', '-') + "-" + current_user.id.to_s + "-" + Time.now.to_s.downcase.gsub(' ', '-').slice(0..-7) + extension @truck.image_url = "https://s3.amazonaws.com/food-trucks/#{filename}" #binding.pry #binding.pry s3 = Aws::S3::Resource.new(region:'us-east-1') obj = s3.bucket('food-trucks').object(filename) obj.upload_file(@file.tempfile) respond_to do |format| if @truck.save format.html { redirect_to @truck, notice: 'Truck was successfully created.' } format.json { render :show, status: :created, location: @truck } else format.html { render :new } format.json { render json: @truck.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @truck = Truck.new(truck_params)\n\n respond_to do |format|\n if @truck.save\n format.html { redirect_to @truck, notice: 'Truck was successfully created.' }\n format.json { render :show, status: :created, location: @truck }\n else\n format.html { render :new }\n ...
[ "0.7036486", "0.68568367", "0.67592937", "0.6654779", "0.6436277", "0.6388216", "0.6157088", "0.6076288", "0.6062036", "0.60233504", "0.60189545", "0.5997903", "0.5906992", "0.5889992", "0.58591104", "0.58503336", "0.5846625", "0.58242595", "0.5821811", "0.5820983", "0.581623...
0.0
-1
PATCH/PUT /trucks/1 PATCH/PUT /trucks/1.json
def update respond_to do |format| if @truck.update(truck_params) format.html { redirect_to @truck, notice: 'Truck was successfully updated.' } format.json { render :show, status: :ok, location: @truck } else format.html { render :edit } format.json { render json: @truck.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @trucking = Trucking.find(params[:id])\n\n respond_to do |format|\n if @trucking.update_attributes(params[:trucking])\n format.html { redirect_to @trucking, notice: 'Trucking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren...
[ "0.6541489", "0.6390542", "0.63833356", "0.6328744", "0.6302916", "0.63014597", "0.62604016", "0.6154636", "0.6149486", "0.61005473", "0.6087122", "0.6086946", "0.6086946", "0.608527", "0.6058995", "0.6042928", "0.60423833", "0.60241044", "0.6021453", "0.6021453", "0.6003288"...
0.6897278
4
DELETE /trucks/1 DELETE /trucks/1.json
def destroy @truck.destroy respond_to do |format| format.html { redirect_to truck_owner_path(current_user), notice: 'Truck was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @truck.destroy\n respond_to do |format|\n format.html { redirect_to trucks_url, notice: 'Truck was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @truck.destroy\n respond_to do |format|\n format.html { redirect_to trucks_url...
[ "0.7231065", "0.7231065", "0.7231065", "0.7231065", "0.7207699", "0.7199295", "0.7119235", "0.7105892", "0.70669246", "0.6993704", "0.6879151", "0.6875254", "0.68581015", "0.6847973", "0.6830082", "0.6830082", "0.6830082", "0.6824729", "0.68203306", "0.68203306", "0.68203306"...
0.69962114
9
Use callbacks to share common setup or constraints between actions.
def set_truck @truck = Truck.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 truck_params params.require(:truck).permit(:name, :web_url, :phone_number) 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.69780594", "0.678054", "0.6742781", "0.67387927", "0.67346025", "0.6590683", "0.6501642", "0.6495788", "0.6479752", "0.64763314", "0.645457", "0.6437739", "0.6377168", "0.6372484", "0.6363871", "0.63179374", "0.62981373", "0.6297456", "0.62916917", "0.6290227", "0.628954",...
0.0
-1
Validates request and raise error unless its valid.
def validate! raise BadRequestError.new(self.errors.full_messages.uniq.join(', ')) unless valid? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate\n unless (e = errors).empty?\n raise InvalidRequestError, e.first\n end\n end", "def validate_request(call)\n call.validate_request\n end", "def validate_request\n binding.pry if $debug\n rejected_error = validate_method || validate_arguments\n ...
[ "0.7961239", "0.7584518", "0.7424807", "0.72757614", "0.7253976", "0.6906612", "0.68173945", "0.67862344", "0.67519903", "0.6673786", "0.6640575", "0.6630986", "0.6554652", "0.65489763", "0.64986223", "0.6460378", "0.645132", "0.6426893", "0.6426893", "0.6426893", "0.64222836...
0.7263668
5
Creates dynamic method for validation like "use_attribute?" If the method exists at the instance, the method will be called. If the method does not exists at the instance, the rule will be applied. Ex.: use_age?, user_price?
def method_missing(m, *args, &block) mtd = m.to_s return send("#{mtd.to_sym}") if respond_to? mtd if mtd.starts_with? 'use_' and mtd.ends_with? '?' attr = mtd.gsub(/use_/,'').gsub('?','') val = send("#{attr.to_sym}") return (not val.empty?) if val.kind_of?(Array) return (not val.blank?) else raise NoMethodError.new("Undefined method '#{m}'!") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validates_with_method(*attribute_names)\n options = Macros.extract_options(attribute_names)\n validation_rules.add(Rule::Method, attribute_names, options)\n end", "def validation_rule(method_name, &block)\n method = MethodValidation.new(method_name)\n block_given? and method.block &blo...
[ "0.70928687", "0.68974805", "0.683181", "0.64547783", "0.6231495", "0.61799836", "0.6179913", "0.60706633", "0.60041404", "0.59929585", "0.5979444", "0.59377193", "0.59368175", "0.58783525", "0.586986", "0.5863075", "0.58529496", "0.5851797", "0.5838575", "0.5834401", "0.5834...
0.0
-1
GET /buses or /buses.json
def index @buses = Bus.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buses\n @buses = Bus.search(params[:source_search], params[:destination_search])\n end", "def index\n @buses = Bus.where(id: params[:id], event_id: params[:event_id])\n end", "def index\n @buses = Bus.order('leaving_from_id')\n\n respond_to do |format|\n format.html # index.html.erb\n ...
[ "0.64945203", "0.6422935", "0.62806463", "0.6220149", "0.6091267", "0.5867946", "0.5773491", "0.5770237", "0.5687361", "0.5583973", "0.5580797", "0.5574216", "0.55622816", "0.55621624", "0.5552885", "0.55494064", "0.55458933", "0.5544315", "0.5515147", "0.5507138", "0.5497016...
0.64182436
3
GET /buses/1 or /buses/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @buses = Bus.where(id: params[:id], event_id: params[:event_id])\n end", "def index\n @buses = Bus.all\n end", "def index\n @buses = Bus.all\n end", "def index\n @buses = Bus.order('leaving_from_id')\n\n respond_to do |format|\n format.html # index.html.erb\n format.js...
[ "0.6344552", "0.6305437", "0.6305437", "0.62324065", "0.60892606", "0.60346925", "0.6028397", "0.6009085", "0.58693695", "0.57752204", "0.5749657", "0.57324326", "0.5695317", "0.56766564", "0.56667954", "0.5665311", "0.565203", "0.5627598", "0.56126827", "0.5610154", "0.55217...
0.0
-1
methode qui lance un tour
def go @i += 1 puts "====================" puts "Tour n°#{@i}" puts "====================" #creation d'une boucle pour alterner les joueurs loop do @i < 9 if @i.odd? turn(@joueur1) else @i.even? turn(@joueur2) end break if @i == 9 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tour (starting, following)\n action(action_choice(starting.name), starting)\n if is_over? != true\n action(action_choice(following.name), following)\n end\nend", "def tourSuivant( vue )\n\t\t@nbTour += 1\n\t\tlistePNJ = Array.new\n\t\tvue.each do |y|\n\t\t\ty.each do |x|\n\t\t\t\tif x.pnj\n\t\t...
[ "0.6908922", "0.65438104", "0.6446926", "0.6350569", "0.61956143", "0.6148892", "0.598538", "0.5891644", "0.5798751", "0.5777618", "0.5777073", "0.57439715", "0.57439715", "0.57439715", "0.57439715", "0.57439715", "0.57439715", "0.57439715", "0.57439715", "0.57439715", "0.574...
0.573875
25
methode qui lance les actions
def turn(player) puts " C'est le tour de #{player.nom}" #affichage du plateau @plateau.visuel #demande au joueur ce qu'il joue puts "Ou veux tu placer ton pion?" puts "Info : Tapes de 1 à 9" @choix = gets.chomp.to_i puts "Tu as choisi la case #{@choix}" #appel de la methode de modification de la valeur de la case @plateau.play(@choix, player, player.token) #affichage du tableau avec les modifications @plateau.visuel #verification de la victoire ou non @plateau.victory(player.win, player.token) puts player.win if player.win == false go elsif puts "Le jeu est fini ! #{player.nom} à gagner" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def actions; end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def run_actions; end", "def action\n end", "def action_run\n end", "def add_actions; end", "def act\n end", "def action\n end", "def action_hook; end", "d...
[ "0.8501771", "0.79257023", "0.79257023", "0.79257023", "0.79257023", "0.79257023", "0.78135073", "0.7649977", "0.7649962", "0.76465166", "0.76082754", "0.74465936", "0.7428575", "0.73799425", "0.7111861", "0.71108115", "0.69776875", "0.69589907", "0.6862069", "0.6856793", "0....
0.0
-1
helper method for delete:
def maximum(tree_node = @root) return tree_node if tree_node.right == nil maximum(tree_node.right) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n \n end", "def delete\n \n end", "def delete\n end", "def delete\n\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n\n\tend", "def delete\n ...
[ "0.8373501", "0.80260485", "0.8013269", "0.80042505", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.79107374", "0.7799738", "0.77781236", "0.7493549", "0.7422571", "0.74152577", "0.7396308", "0.73679674", "0.7326224", "0.7326224...
0.0
-1
Checks if an extension is known. Returns the associated format.
def known_extension?(f) f = ".#{f}" unless f[0,1] == '.' EXTENSION_TO_FORMAT[f] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uses_extension?\n @format =~ /\\.[^\\.]+$/\n end", "def format_extension\n extensions.reverse.detect { |ext|\n @environment.mime_types(ext) && !@environment.engines(ext)\n }\n end", "def available_extension?(extension)\n %w[png svg json jpg jpeg].include?(extension)\n end", ...
[ "0.7693235", "0.7670485", "0.69244754", "0.692352", "0.68594396", "0.67498106", "0.67130375", "0.67095864", "0.6668468", "0.66631484", "0.66131467", "0.65970534", "0.6594477", "0.65283316", "0.6524604", "0.6442593", "0.63958675", "0.6387726", "0.63615906", "0.6322402", "0.629...
0.7583987
2
Checks if a format is known. Returns the associated content type.
def known_format?(f) FORMAT_TO_CONTENT_TYPE[f] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def content_type\n if format == :auto\n MIME_TYPES.values.join(',')\n elsif MIME_TYPES.has_key? format\n MIME_TYPES[format]\n else\n raise ArgumentError, \"Unknown format '#{format}'\"\n end\n end", "def content_type\n if format == :auto\n ...
[ "0.747522", "0.747522", "0.74192584", "0.73139757", "0.7129845", "0.675387", "0.6727898", "0.66968566", "0.66531587", "0.6634469", "0.662036", "0.66054255", "0.656686", "0.65333974", "0.65037787", "0.6493091", "0.6489986", "0.647038", "0.6470336", "0.64406425", "0.64369", "...
0.82989985
0
Encode the string the given encoding
def encode(*args) self.class.new super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode(encoding)\n to_s.encode(encoding)\n end", "def encode(string); end", "def _encode_string(string)\n return string unless string.kind_of? String\n string.encode(\"UTF-8\", :undef => :replace, :invalid => :replace, :replace => \"?\")\n end", "def encode_string; end", "def enc...
[ "0.8474704", "0.81294596", "0.7757417", "0.77471954", "0.7503032", "0.7446872", "0.74240047", "0.736579", "0.736579", "0.730174", "0.72981435", "0.72763926", "0.7240497", "0.7195593", "0.71294093", "0.7125705", "0.7109486", "0.7054325", "0.7054325", "0.7052739", "0.7052053", ...
0.0
-1
Encode the given string into UTF8
def encode(input) return '' if input.nil? input.to_s.encode(Encoding::UTF_8) rescue Encoding::UndefinedConversionError input.dup.force_encoding(Encoding::UTF_8) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _encode_string(string)\n return string unless string.kind_of? String\n string.encode(\"UTF-8\", :undef => :replace, :invalid => :replace, :replace => \"?\")\n end", "def encode_utf8 string\n (string.respond_to?(:force_encoding) and string.respond_to?(:encoding)) ?\n string.force_encoding(Encod...
[ "0.867825", "0.86472607", "0.86472607", "0.823213", "0.8231667", "0.8125949", "0.80617046", "0.79565674", "0.781854", "0.77978075", "0.7784431", "0.77720326", "0.77171564", "0.76481396", "0.7646895", "0.76012784", "0.7581979", "0.75240725", "0.75166196", "0.7409157", "0.73798...
0.7235486
26
Encode the given UTF8 char.
def encode_char(char, safe_chars = {}) return char if safe_chars[char] code = char.ord hex = hex_for_non_alphanumeric_code(code) return char if hex.nil? hex = REPLACEMENT_HEX if NON_PRINTABLE_CHARS[code] if entity = HTML_ENTITIES[code] # rubocop:disable Lint/AssignmentInCondition "&#{entity};" else "&#x#{hex};" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_character(char)\n if @@has_ord ||= char.respond_to?(:ord)\n char.ord.to_s\n else\n char[0]\n end\n end", "def encode_char(immune, input)\n input\n end", "def utf8_character\n character.chr(Encoding::UTF_8)\n end", ...
[ "0.73036027", "0.69831973", "0.6925678", "0.6855185", "0.6855185", "0.6852243", "0.67387664", "0.661399", "0.6506056", "0.64923525", "0.6491837", "0.6447", "0.6442906", "0.63871187", "0.6318492", "0.6316012", "0.6300744", "0.62980205", "0.62935346", "0.6260566", "0.6250121", ...
0.6868852
3
Transforms the given char code
def hex_for_non_alphanumeric_code(input) if input < LOW_HEX_CODE_LIMIT HEX_CODES[input] else input.to_s(HEX_BASE) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def code_letter(name)\nname = name.downcase.tr(\"aeiou\", \"eioua\")\nname = name.downcase.tr(\"bcdfghjklmnpqrstvwxyz\", \"cdfghjklmnpqrstvwxyzb\")\nend", "def translate_codepoints(str)\n str.gsub(/#x\\h+/) {|c| c[2..-1].scanf(\"%x\").first.chr(Encoding::UTF_8)}\n end", "def decode_char(input)\n ...
[ "0.6850775", "0.6640804", "0.6547248", "0.65272546", "0.64983827", "0.64878976", "0.6372711", "0.63654643", "0.6349889", "0.6309973", "0.6267418", "0.6265755", "0.6230195", "0.61615217", "0.6102517", "0.60725844", "0.6054343", "0.6030891", "0.60298675", "0.5980496", "0.597802...
0.0
-1
Relatorio de listagem de todas as vendas
def allSalesReport # Save and open pdf #filename = File.join(Rails.root, "app/report", "SalesList.pdf") #pdf.render_file filename #send_file filename, :filename => "SalesList.pdf", :type => "application/pdf" # Open pdf send_data allSales_pdf.render, :filename => "SalesList.pdf", :type => "application/pdf" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @tipo_vendas = TipoVenda.all\n end", "def index\n @relatorio_plano_de_voos = RelatorioPlanoDeVoo.all\n end", "def relatorios\n end", "def index\n @vendas = Venda.eager_load(:comprador, :fornecedor, :produto).where(upload: params[:upload_id])\n end", "def index\n @item_vendas = I...
[ "0.6463977", "0.6408912", "0.6303204", "0.627538", "0.62547946", "0.61949223", "0.6140914", "0.613876", "0.61299676", "0.61118156", "0.6094996", "0.6093364", "0.608062", "0.60568976", "0.6056127", "0.6009088", "0.59838706", "0.59838706", "0.5978663", "0.5964523", "0.59431475"...
0.0
-1
Relatorio de listagem de venda para o fornecedor
def suplierSaleReport # Save and open pdf #filename = File.join(Rails.root, "app/report", "SalesList.pdf") #pdf.render_file filename #send_file filename, :filename => "SalesList.pdf", :type => "application/pdf" @sale = Sale.find(params[:id]) # Open pdf send_data suplierSale_pdf.render, :filename => "SuplierSale.pdf", :type => "application/pdf" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n #@vendas = Venda.all\n #@vendas = Venda.venda_diaria\t\n @vendas = Venda.includes(:cliente).where('DATE(created_at) = ?',Date.today)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @vendas }\n end\n end", "def index\n @tipo_vendas ...
[ "0.636157", "0.6350951", "0.6314228", "0.6247593", "0.6098972", "0.60638416", "0.59621185", "0.5933849", "0.5917265", "0.5912989", "0.5902474", "0.5895605", "0.5893873", "0.58839035", "0.5882533", "0.5875103", "0.587032", "0.5864712", "0.5850845", "0.58267564", "0.5825596", ...
0.0
-1
GET /reservations/1 GET /reservations/1.json
def show @reservation = Reservation.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @reservation } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n render json: reservations\n end", "def index\n @reservations = Reservation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reservations }\n end\n end", "def index\n @reservations = Reservation.all\n\n respond_to do |format|\n...
[ "0.7758369", "0.7455437", "0.7455437", "0.7453271", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7407612", "0.7224339", "0.717547", "0...
0.7434351
7
GET /reservations/new GET /reservations/new.json
def new @reservation = Reservation.new respond_to do |format| format.html # new.html.erb format.json { render json: @reservation } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @reservation = Reservation.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reservation }\n end\n end", "def new\n\t\t@reservation = Reservation.new\n\tend", "def new\n @reserf = Reserve.new\n\n respond_to do |format|\n format.html...
[ "0.7976941", "0.752405", "0.74309754", "0.74203265", "0.7392128", "0.73398656", "0.7239581", "0.7238058", "0.7161617", "0.71141356", "0.7062703", "0.7062703", "0.7060762", "0.69739974", "0.69480234", "0.694256", "0.694256", "0.6937633", "0.6850717", "0.6814992", "0.6797522", ...
0.7990907
1
POST /reservations POST /reservations.json
def create @reservation = Reservation.new(reservation_params) respond_to do |format| if @reservation.save format.html { redirect_to @reservation, notice: 'Reservation was successfully created.' } format.json { render json: @reservation, status: :created, location: @reservation } else format.html { render action: "new" } format.json { render json: @reservation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @reservation = Reservation.new(reservation_params)\n\n if @reservation.save\n render :show, status: :created, location: @reservation\n else\n render json: @reservation.errors, status: :unprocessable_entity\n end\n end", "def create_reservations\n Time.use_zone(@timezone) do...
[ "0.719537", "0.71615386", "0.71431714", "0.71431714", "0.7130943", "0.7123144", "0.7020095", "0.6983413", "0.69494253", "0.6922912", "0.6906279", "0.6906279", "0.68949294", "0.68930775", "0.68813384", "0.68267894", "0.680376", "0.6786492", "0.6770697", "0.6745307", "0.6724186...
0.7095066
6
PUT /reservations/1 PUT /reservations/1.json
def update @reservation = Reservation.find(params[:id]) respond_to do |format| if @reservation.update_attributes(reservation_params) format.html { redirect_to reservations_path, notice: 'Reservation was successfully updated.' } format.json { head :no_content } format.js else format.html { render action: "edit" } format.json { render json: @reservation.errors, status: :unprocessable_entity } format.js end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @reservation.update(reservation_params)\n render json: @reservation\n else\n render json: @reservation.errors, status: :unprocessable_entity\n end\n end", "def set_reservations\n @reservation = Reservation.find(params[:id])\n end", "def set_reservations\n @reser...
[ "0.70311517", "0.701632", "0.701632", "0.6893391", "0.66863275", "0.6680652", "0.667247", "0.6656188", "0.66545707", "0.6612647", "0.6612647", "0.6612647", "0.6612647", "0.6612647", "0.6612647", "0.6612647", "0.6612647", "0.6612647", "0.6612647", "0.6552662", "0.6552662", "...
0.0
-1
DELETE /reservations/1 DELETE /reservations/1.json
def destroy @reservation = Reservation.find(params[:id]) @reservation.destroy respond_to do |format| format.html { redirect_to reservations_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n reservation = Reservation.find(params[:id])\n if reservation\n reservation.destroy\n render json: reservation\n else \n render json: [\"Reservation doesnt exist\"], status: 404 \n end \n end", "def destroy\n @reservation.destroy\n\n respond_to do |format|\n fo...
[ "0.7746542", "0.7565957", "0.7543936", "0.7543936", "0.7543936", "0.7490353", "0.74337363", "0.7390154", "0.73016495", "0.73016495", "0.73016495", "0.73016495", "0.73016495", "0.73016495", "0.73016495", "0.73016495", "0.73016495", "0.73016495", "0.73016495", "0.73016495", "0....
0.76063955
3
overriden in order to render serialized user
def create build_resource(sign_up_params) resource.save yield resource if block_given? if resource.persisted? if resource.active_for_authentication? set_flash_message! :notice, :signed_up sign_up(resource_name, resource) user_details = Api::V1::UserSerializer.new(resource) articles = ActiveModel::Serializer::CollectionSerializer.new(Article.all.to_a, serializer: Api::V1::ArticleSerializer) render json: { user: user_details, articles: articles }, status: :created else set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}" expire_data_after_sign_in! respond_with resource, location: after_inactive_sign_up_path_for(resource) end else clean_up_passwords resource set_minimum_password_length respond_with resource end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_hack\n user.as_json\n end", "def user\n render @user\n end", "def user_serializer\n {\n username: username,\n email: email,\n id: id\n }\n end", "def render_user(user)\n if user\n h(user.login)\n else\n '(unknown)'.html_safe\n end\n end", "def _ren...
[ "0.6784882", "0.67600346", "0.6655761", "0.65378004", "0.6431656", "0.64227754", "0.6375891", "0.63585466", "0.62935513", "0.62002164", "0.6170713", "0.61660403", "0.61626756", "0.6153429", "0.61511576", "0.613903", "0.61280984", "0.6115786", "0.6110044", "0.61032265", "0.609...
0.0
-1
overriden because resource_name = :api_v1_user due to namespaces in routes.rb
def resource_name :user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_name\n\t\t:user\n\tend", "def resource_name\n \t\t:user\n \tend", "def resource_name\n :user\n end", "def resource_name\n :user\n end", "def resource_name\n :user\n end", "def resource_name\n :user\n end", "def resource_name\n :user\n end", "def resource_name\n :u...
[ "0.6849324", "0.6823672", "0.6803113", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.680025", "0.68...
0.6810987
2
Override for editing custom user fields (full_name, amka)
def sign_up_params params.require(:user).permit(:email, :password, :password_confirmation, :full_name, :amka, :father_amka, :mother_amka, :gender) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_user_name_field(user_name)\n end", "def proper_name # method to get the full name of user\n first_name + \" \" + last_name\n end", "def extend_fields\n if username.blank?\n # Synthesize a unique username from the email address or fullname\n n = 0\n startname = handle if (startnam...
[ "0.72102237", "0.68413293", "0.6795665", "0.67379457", "0.67061824", "0.6611072", "0.64455163", "0.6405744", "0.6403422", "0.6350648", "0.63425857", "0.62734544", "0.62683934", "0.6250859", "0.6250859", "0.6250859", "0.62015545", "0.61862046", "0.61842996", "0.61842996", "0.6...
0.0
-1
very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer N. Write a method that takes the array as an argument and returns this "outlier" N. Examples [2, 4, 0, 100, 4, 11, 2602, 36] Should return: 11 (the only odd number) [160, 3, 1719, 19, 11, 13, 21] Should return: 160 (the only even number)
def find_outlier(array) odd_array=[] even_array=[] array.each do |i| odd_array << i if i % 2 == 0 even_array << i if i % 2 != 0 end odd_array.size > even_array.size ? even_array[0] : odd_array[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_outlier(integers)\n answer = Array.new\n answer << integers[0] if integers[0].even?\n answer << integers[1] if integers[1].even?\n answer << integers[2] if integers[2].even?\n answer.length < 2 ? integers.select { |num| num.even? }.first : integers.select { |num| num.odd? }.first\nend", "def find_o...
[ "0.81638974", "0.80912226", "0.79702824", "0.79320204", "0.79155713", "0.7895303", "0.7888832", "0.78201056", "0.7746092", "0.7737106", "0.7725151", "0.76431423", "0.7635388", "0.76237893", "0.758933", "0.7525271", "0.7452129", "0.7020654", "0.6992041", "0.6951101", "0.694842...
0.8325568
0
Public: Returns the value at the head of the LinkedList. Examples
def head @head.next end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_first\r\n # if the list is empty, head is nil\r\n if @head.nil?\r\n return nil\r\n else \r\n value = @head.data\r\n return value\r\n end\r\n end", "def first\n # return value if head node is set\n if !@head.nil?\n @head.value\n else\n # otherwise raise an ex...
[ "0.80239606", "0.7980533", "0.7874925", "0.74381244", "0.7334042", "0.73070985", "0.729816", "0.7232249", "0.7230996", "0.71316797", "0.7114695", "0.7098524", "0.70861775", "0.7078569", "0.70720565", "0.70720565", "0.706974", "0.7052223", "0.7035776", "0.7032007", "0.7025263"...
0.67591715
45
Public: Checks to see if the LinkedList is empty. Examples
def empty? @head.next == nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty?\n !node_next(@head, 0)\n end", "def empty?\n node_next(@head, 0) == @tail\n end", "def is_list_empty?\n @head.nil?\n end", "def empty?\n \n @head == nil\n end", "def list_empty?\n return (@first_node == nil) ? true : false\n end", "def empty()\...
[ "0.808619", "0.79841375", "0.79121846", "0.79017", "0.7849999", "0.78498334", "0.7828492", "0.7773693", "0.77234215", "0.770682", "0.7684284", "0.7666984", "0.76391226", "0.7625747", "0.76221085", "0.7590762", "0.75690895", "0.7551998", "0.7542543", "0.7536963", "0.74892604",...
0.8029039
1
Public: Add a value to the beginning of the LinkedList value Ruby object to be inserted into the LinkedList Examples
def prepend(value) element = RubyStructures::Node.new(self, value) element.next = @head.next @head.next = element end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepend(value)\n #Instantiate the object to be the new head\n new_node = Node.new value\n #Set its next value to the current head\n new_node.next = @head\n @head.before = new_node\n #Set the new one as the new head by repointing SinglyLinkedList head to it\n @head = new_node\n end", "de...
[ "0.7599822", "0.7479863", "0.74746156", "0.74496645", "0.74496645", "0.7329911", "0.7305295", "0.7302448", "0.7296376", "0.72862536", "0.7269015", "0.7239412", "0.72342163", "0.7224887", "0.72221226", "0.71887165", "0.71550447", "0.7142723", "0.71423256", "0.7138623", "0.7129...
0.72739685
10
Public: Add a value to the end of the LinkedList value Ruby object to be inserted into the LinkedList Examples
def append(value) if self.empty? self.prepend(value) return end element = self.head # loop through each element in the LinkedList, until element.next # equals @head, signifying we have reached the end of the list. while(element != self.head) element = element.next end new_element = RubyStructures::Node.new(self, value) # insert the new element at the end of the LinkedList. new_element.next = element.next element.next = new_element end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append(value)\n new_node = ListNode.new(value)\n if self.head.nil?\n self.head = self.tail = new_node\n self.size = 1\n else\n set_next_and_prev(self.tail, new_node)\n self.tail = new_node\n self.size += 1\n end\n self.as_string\n end", "def append( value )\n last....
[ "0.77213836", "0.76858944", "0.7525128", "0.7506624", "0.74586207", "0.7456541", "0.74455255", "0.7423068", "0.7411595", "0.74040896", "0.7402254", "0.73595196", "0.7344331", "0.7333337", "0.73228025", "0.7320691", "0.72836983", "0.72681487", "0.7225237", "0.72145563", "0.720...
0.74416864
7
Public: Find an element by its value and return it. value Ruby object to be inserted into the LinkedList Examples
def search(value) return nil if self.empty? element = self.head while element.value != value if element.next.nil? return nil else element = element.next end end element end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(value)\n node = @head\n while node\n if node.value == value\n return node\n end\n node = node.next\n end\n\n return nil\n end", "def find(value)\n end", "def find(value)\n return nil if @head.nil?\n found = nil\n index = 0\n current_node = @head\n w...
[ "0.76592875", "0.7566252", "0.74363905", "0.7427008", "0.73797315", "0.7361095", "0.73133385", "0.72652996", "0.7193135", "0.714534", "0.71392184", "0.7052441", "0.70175", "0.70175", "0.6925433", "0.6877331", "0.6828829", "0.68132126", "0.6773499", "0.6702194", "0.6679808", ...
0.71639276
9
Public: Gets the Node at the head of the LinkedList. Examples
def item_at_head @head.next end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def head\n \t\tbegin\n \t\t raise \"Empty LinkedList\" if @size <= 0\n \t\t return @head.data\n\t\t rescue \n\t\t puts \"Empty\"\n\t\t end\n \tend", "def node_first\n @head\n end", "def get_head\n return nil if @head.nil?\nnode = @head\nnode.data\nend", "def first\n # return value if h...
[ "0.7804496", "0.77142227", "0.7325299", "0.72290486", "0.71786255", "0.71525043", "0.71004355", "0.69947225", "0.6964497", "0.69456005", "0.6926135", "0.6905195", "0.68381524", "0.6833448", "0.6823938", "0.68092877", "0.6804971", "0.6803443", "0.679368", "0.6783359", "0.67735...
0.6273393
81
Public: Returns the Node at the desired :index. index the Integer index value of Node to return. Examples
def item_at(index) element = self.head count = 0 while count < index return nil if element.nil? element = element.next count += 1 end element end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def node_at(index)\n if index >= self.size\n puts \"index out of range.\"\n else\n each_with_index do |node, i|\n return node if index == i \n end\n end\n end", "def at(index)\n self.traverse_list_with_count do |node, count|\n if count == index\n return node\n ...
[ "0.80650747", "0.8027868", "0.79429704", "0.79272574", "0.7888532", "0.7851094", "0.77796024", "0.77686954", "0.76669985", "0.7653813", "0.76342356", "0.76338434", "0.76329756", "0.7612621", "0.76124626", "0.756199", "0.75602156", "0.751233", "0.74686396", "0.7449787", "0.741...
0.0
-1
Public: Finds and removes the first occurrence of a Node with the desired value. value the Ruby object value to find and remove from the LinkedList Examples
def remove(value) element = self.head previous_element = @head while element.value != value if element.next.nil? return nil else previous_element = element element = element.next end end previous_element.next = element.next element end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_value value\r\n #find the pointer to the wanted node using LIST-SEARCH(value)\r\n #then delete that node with LIST-DELETE-BY-NODE(node)\r\n delete_node(self.search(value))\r\n end", "def remove(value)\n if head.value == value\n @head = head.next\n else\n current_node = head.n...
[ "0.8160187", "0.7892186", "0.7808302", "0.7783561", "0.7775286", "0.77493376", "0.7657638", "0.7645884", "0.75886655", "0.75370705", "0.7420589", "0.7416904", "0.73902255", "0.7367681", "0.73483914", "0.73420864", "0.724532", "0.7206845", "0.71579784", "0.71557736", "0.710428...
0.796211
1
Public: Removes the Node at the head of the LinkedList. Examples
def remove_at_head return nil if self.empty? element = self.head @head.next = nil || element.next element end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_head\r\n delete_node @head\r\n end", "def remove\n node = @head\n\n if node\n @head = node.next_node\n @tail = nil unless @head\n\n node.data\n end\n end", "def delete_head\n # If the SLL is empty, there's nothing there other than an empty head; return it\n if empt...
[ "0.8256307", "0.8019957", "0.798529", "0.781873", "0.7787474", "0.77815324", "0.7759401", "0.7680507", "0.7545846", "0.7539735", "0.74164957", "0.7415057", "0.7314388", "0.7291987", "0.7284368", "0.72573286", "0.72345537", "0.7224814", "0.7220998", "0.7212417", "0.7196266", ...
0.7766206
6
Public: Removes the Node at the tail of the LinkedList. Examples
def remove_at_tail return nil if self.empty? element = self.head previous_element = @head until element.next.nil? previous_element = element element = element.next end previous_element.next = nil element end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_tail\n remove_node(@tail)\n end", "def delete_tail\r\n delete_node @tail\r\n end", "def delete_tail\n # Create a var to hold the current_node; init with head\n current_node = @head\n\n # If the SLL is empty, there's nothing there other than an empty head; return it\n if empty?\n ...
[ "0.8417041", "0.8306721", "0.81403226", "0.79717743", "0.79101247", "0.79088134", "0.7886956", "0.78828025", "0.7868505", "0.777203", "0.7731927", "0.771812", "0.7708301", "0.7692971", "0.767367", "0.76596665", "0.76547086", "0.765237", "0.76325876", "0.7617206", "0.7588905",...
0.7739828
10
The main create method
def create(state) save_and_validate_parameters connect # Using the clone class, create a machine for TK # Find the identifier for the targethost to pass to rbvmomi config[:targethost] = get_host(config[:targethost]) # Use the root resource pool of a specified cluster, if any # @todo This does not allow to specify cluster AND pool yet unless config[:cluster].nil? cluster = get_cluster(config[:cluster]) # @todo Check for active hosts, to avoid "A specified parameter was not correct: spec.pool" config[:resource_pool] = cluster.resource_pool else # Find the first resource pool on any cluster config[:resource_pool] = get_resource_pool(config[:resource_pool]) end # Check that the datacenter exists datacenter_exists?(config[:datacenter]) # Check if network exists, if to be changed network_exists?(config[:network_name]) unless config[:network_name].nil? # Same thing needs to happen with the folder name if it has been set unless config[:folder].nil? config[:folder] = { name: config[:folder], id: get_folder(config[:folder]), } end # Allow different clone types config[:clone_type] = :linked if config[:clone_type] == "linked" config[:clone_type] = :instant if config[:clone_type] == "instant" # Create a hash of options that the clone requires options = { name: config[:vm_name], targethost: config[:targethost], poweron: config[:poweron], template: config[:template], datacenter: config[:datacenter], folder: config[:folder], resource_pool: config[:resource_pool], clone_type: config[:clone_type], network_name: config[:network_name], } # Create an object from which the clone operation can be called clone_obj = Support::CloneVm.new(connection_options, options) state[:hostname] = clone_obj.clone state[:vm_name] = config[:vm_name] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n \n end", "def create\n \t\n end", "def create\n \n end", "def create; end", "def create; end", "def create; end", "def create; end", "def create!\n end", "def create\r\n\r\n\r\n end", "def create\n end", "def create\r\n end", "def create\n end", ...
[ "0.8586292", "0.83243155", "0.83032656", "0.82115936", "0.82115936", "0.82115936", "0.82115936", "0.8153215", "0.8136422", "0.8133471", "0.8095186", "0.8002246", "0.79238683", "0.79238683", "0.79238683", "0.77623445", "0.7740055", "0.7699208", "0.76926553", "0.7628574", "0.76...
0.0
-1
The main destroy method
def destroy(state) return if state[:vm_name].nil? save_and_validate_parameters connect vm = get_vm(state[:vm_name]) vm_obj = Com::Vmware::Vcenter::VM.new(vapi_config) # shut the machine down if it is running if vm.power_state.value == "POWERED_ON" power = Com::Vmware::Vcenter::Vm::Power.new(vapi_config) power.stop(vm.vm) end # delete the vm vm_obj.delete(vm.vm) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy!; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n\t\...
[ "0.8235823", "0.81599665", "0.81599665", "0.81599665", "0.81599665", "0.81599665", "0.81599665", "0.81599665", "0.81599665", "0.81599665", "0.81599665", "0.8077508", "0.8077508", "0.79740614", "0.782718", "0.77600205", "0.77600205", "0.7726063", "0.7673139", "0.76314557", "0....
0.0
-1
Helper method for storing and validating configuration parameters
def save_and_validate_parameters # Configure the hash for use when connecting for cloning a machine @connection_options = { user: config[:vcenter_username], password: config[:vcenter_password], insecure: config[:vcenter_disable_ssl_verify] ? true : false, host: config[:vcenter_host], rev: config[:clone_type] == "instant" ? "6.7" : nil, } # If the vm_name has not been set then set it now based on the suite, platform and a random number if config[:vm_name].nil? config[:vm_name] = format("%s-%s-%s", instance.suite.name, instance.platform.name, SecureRandom.hex(4)) end raise format("Cannot specify both cluster and resource_pool") if !config[:cluster].nil? && !config[:resource_pool].nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_config(config)\r\n raise TransactionSupportError, \"Parameter 'key1' is required\" if config.key1.blank?\r\n raise TransactionSupportError, \"Parameter 'key2' is required\" if config.key2.blank?\r\n raise TransactionSupportError, \"Parameter 'pos_id' is required\" if config.pos_id...
[ "0.6727885", "0.65217656", "0.64720184", "0.6421335", "0.64016455", "0.6400702", "0.63585347", "0.63338643", "0.6331395", "0.63058406", "0.6288445", "0.62852025", "0.6265824", "0.6232755", "0.62223506", "0.61870515", "0.61805886", "0.6154504", "0.61076", "0.61076", "0.6104867...
0.6365
6
A helper method to validate the state
def validate_state(state = {}); end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_state\n errors.add(:state, \"must be yes, no or don't care\") unless state_changed? and %w(yes no dont_care).include? changes['state'][1]\n end", "def invalid?\n !@state\n end", "def verify(state) ; end", "def is_valid; end", "def valid; end", "def is_valid_state(state)\n temp...
[ "0.7685361", "0.7204157", "0.71687615", "0.70502776", "0.69686997", "0.69333065", "0.6869811", "0.68592036", "0.68433756", "0.68433756", "0.6837611", "0.6837611", "0.6837611", "0.6837611", "0.6837611", "0.6824323", "0.6823994", "0.682069", "0.6801818", "0.6801818", "0.6798891...
0.8486307
1
Sees in the datacenter exists or not
def datacenter_exists?(name) filter = Com::Vmware::Vcenter::Datacenter::FilterSpec.new(names: Set.new([name])) dc_obj = Com::Vmware::Vcenter::Datacenter.new(vapi_config) dc = dc_obj.list(filter) raise format("Unable to find data center: %s", name) if dc.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def datacenter_exists?(folder, name)\n dc_api = VSphereAutomation::VCenter::DatacenterApi.new(api_client)\n raise_if_unauthenticated dc_api, \"checking for datacenter `#{name}`\"\n\n opts = { filter_names: name }\n opts[:filter_folders] = get_folder(folder, \"DATACENTER\") if folder\n ...
[ "0.7077185", "0.70334375", "0.70077485", "0.6645091", "0.66017485", "0.6539742", "0.6495642", "0.6452316", "0.64396536", "0.640671", "0.64036036", "0.6403373", "0.6331183", "0.6272513", "0.62603533", "0.624374", "0.62267417", "0.6212251", "0.62039655", "0.61849576", "0.617891...
0.7810365
0