query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Use callbacks to share common setup or constraints between actions.
def set_sub_gtp @sub_gtp = SubGtp.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 sub_gtp_params params.require(:sub_gtp).permit(:name, :start_date, :end_date, :gtp_planner_id, :description) 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.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.629...
0.0
-1
Initializes an instance of the priv command interaction.
def initialize(shell) super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_priv()\n\t\toriginal = console.disable_output\n\n\t\tconsole.disable_output = true\n\t\tconsole.run_single('use priv')\n\t\tconsole.disable_output = original\n\tend", "def initialize(*args)\n super\n\n @config = @bot.config\n @db = @config.db\n @keywords = eval(\"/#{@config.keywords.join(\"|...
[ "0.6404711", "0.63963985", "0.6237617", "0.6109133", "0.6064643", "0.5985336", "0.58945507", "0.5883316", "0.5873429", "0.5857034", "0.58471245", "0.5841618", "0.5810321", "0.57791656", "0.57741445", "0.57717276", "0.5763433", "0.5738241", "0.5713353", "0.5701586", "0.5696665...
0.0
-1
List of supported commands.
def commands { "add_user" => "Attempt to add a user with all tokens", "add_localgroup_user" => "Attempt to add a user to a local group with all tokens", "add_group_user" => "Attempt to add a user to a global group with all tokens", "list_tokens" => "List tokens available under current user context", "impersonate_token" => "Impersonate specified token", "snarf_hashes" => "Snarf challenge/response hashes for every token" } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def supported_commands\n commands.keys\n end", "def command_list\n options[:commands] || SimpleFormWysihtml::WysihtmlInput.configuration.commands\n end", "def commands\n @commands ||= []\n end", "def command_list\n options[:commands] || SimpleFormEpicEditor::EpicEdito...
[ "0.8938241", "0.7830504", "0.7820144", "0.77746046", "0.7711566", "0.76977605", "0.76638305", "0.7633258", "0.7607837", "0.7577421", "0.75107753", "0.74979514", "0.7493746", "0.7444907", "0.7428958", "0.73487663", "0.73222965", "0.7318901", "0.73056424", "0.7290221", "0.72376...
0.69792855
37
Name for this dispatcher
def name "Incognito" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __name__\n ɴ = self.class.__instances__[ self ]\n namespace.name_get_hook.( ɴ ) if ɴ\n end", "def name\n raise \"No name defined for #{self.class}\"\n end", "def name\n @_name\n end", "def __name\n @name\n end", "def name\n @name ||= [action, resource...
[ "0.6927767", "0.6926757", "0.69123614", "0.6853134", "0.67808104", "0.67779154", "0.67463726", "0.6713713", "0.6700321", "0.6696751", "0.66803014", "0.6661351", "0.66343075", "0.65620005", "0.6530012", "0.6526361", "0.65254605", "0.65023094", "0.64946187", "0.64905834", "0.64...
0.0
-1
=============================================================================== Functions =============================================================================== Convert virtual server status to string (p. 255 in API docs)
def vserver_status_to_string(code) case code when 0 then :DISABLED when 1 then :ALL_UP when 2 then :PARTIAL_UP when 3 then :FUNC_UP when 4 then :DOWN else :UNKNOWN end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status_to_s\n \tSTATUSES[self.status].humanize\n end", "def stringify_status(status_code)\n case status_code\n when 0\n 'paused'\n when 1\n 'not_checked_yet'\n when 2\n 'up'\n when 8\n 'seems_down'\n when 9\n 'down'\n else\n 'unknown'\n end\nend", "def status(vid)\n per...
[ "0.70782053", "0.7019346", "0.6945704", "0.6886483", "0.68228686", "0.68157065", "0.68157065", "0.6795706", "0.673512", "0.671233", "0.670309", "0.65599823", "0.65163267", "0.64362645", "0.64112794", "0.6388191", "0.6378549", "0.6377949", "0.63372177", "0.63257974", "0.630402...
0.80030495
0
Method to add an item to a list input: list, item name, and optional quantity steps: take user iput for adding to the list then store the new item in the list with type and quanity if entered, otherwise default to 1 output: updated list with new items
def add_item(item,quantity,first_list) if quantity == "" quantity = 1 else quantity end first_list[item] = quantity end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_item(list, item, quantity = 1)\r\n# input: list, item name, and optional quantity\r\n# steps: \r\n # check for optional quantity. if not present, set to default (1)\r\n list[item] = quantity\r\n # update list with input\r\n puts \"#{item.upcase} has been added to your grocery list!\"\r\n p list\r\n# o...
[ "0.81843245", "0.8103236", "0.80465186", "0.80463594", "0.80463594", "0.79781854", "0.79781854", "0.7874995", "0.78575486", "0.78433603", "0.77653503", "0.77598256", "0.77196974", "0.76999605", "0.76596737", "0.7656036", "0.7645109", "0.76142395", "0.7612911", "0.76082677", "...
0.7332146
65
p first_list Method to remove an item from the list input: user input steps: take user input and remove called item entirely from the list output: updated list without item
def remove_item(item,first_list) first_list.delete(item) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove(list, item)\r\n# input: ask what item user wants to remove\r\nif list.include?(item)\r\n\tlist.delete(item)\r\nend \r\np list\r\nend", "def remove(input_list, item)\n input_list.delete(item)\nend", "def list_remover(list_input_remover, item_name_remove)\n list_input_remover.delete(item_name_remove...
[ "0.74010694", "0.7381669", "0.7318991", "0.73156357", "0.72247696", "0.7193633", "0.70881015", "0.6998555", "0.6877324", "0.6845984", "0.68455565", "0.6826958", "0.6824693", "0.68237793", "0.6813861", "0.6810997", "0.67982495", "0.6796393", "0.6796393", "0.6796393", "0.679639...
0.7671949
0
p first_list Method to update the quantity of an item input: item on the list already steps: loop through the hash to find the item(identify the key) and update the quantity of the item output: updated list with new quantity
def update_item(item,quantity_changed,first_list) first_list[item] = quantity_changed end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_quantity(list_name, item, value)\r\n# input: list, item name, new quantity\r\n# steps: find item in the hash and change quantity to new quantity\r\n list_name[item] = value\r\n# output: updated hash with new value for item key\r\n p list_name\r\nend", "def list_update(hash_items, item_name, quantity...
[ "0.76015717", "0.7443031", "0.74327445", "0.7423861", "0.7423239", "0.7382262", "0.73714656", "0.73225826", "0.73129976", "0.7312429", "0.7267582", "0.7209003", "0.72015697", "0.72005033", "0.7183269", "0.7176014", "0.7174689", "0.71694314", "0.7156517", "0.71562064", "0.7153...
0.7454552
1
p first_list Method to print a list and make it look pretty input: hash with most updated list values steps: puts the items of the list out, edit the UI to make it look nice output: call at the end of driver code to show everything together
def print_list(first_list) puts "Here is your final list:" first_list.each {|item, quantity| puts "* #{item} : #{quantity}"} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print\n placeholder = @head\n list = \"\"\n while placeholder.next\n list += placeholder.data + \"\\n\"\n placeholder = placeholder.next\n end\n list += placeholder.data + \"\\n\" # the plus \"\\n\" added because of the way the spec is written.\n printf list\n end", "def print_li...
[ "0.66020685", "0.65871316", "0.6563155", "0.6535062", "0.6506489", "0.649958", "0.64872074", "0.6417781", "0.6372414", "0.6363784", "0.6331164", "0.6321144", "0.6319266", "0.63136995", "0.63110405", "0.6305797", "0.6299238", "0.6297623", "0.627453", "0.6265868", "0.62590134",...
0.6821637
0
Guess a letter in the word. Should return a boolean. true if the letter is in the word, false if not.
def guess!(letter) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_a_letter?(guess)\n return true if @word.include?(guess)\n return false\n end", "def guess? (letter)\n \t\tif word.include?(letter)==true\n \t\tvalid_guess(letter)\n \telse\n \t\tinvalid_guess(letter)\n \tend\n end", "def guess(letter)\n is_letter = /^[a-zA-Z]$...
[ "0.8994069", "0.87517023", "0.86169404", "0.8269511", "0.8221202", "0.81884867", "0.8154289", "0.8148583", "0.8101668", "0.8087106", "0.80786675", "0.80406666", "0.7989068", "0.7977379", "0.7970985", "0.79282546", "0.7907872", "0.7904457", "0.78869206", "0.7875014", "0.785293...
0.7275001
63
Whether all letters in the word have been guessed correctly.
def guessed_all_correct? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_letters_guessed?\n @word_to_guess.each do |letter_in_word_to_guess|\n if !has_been_guessed_correctly?(letter_in_word_to_guess)\n return false\n end\n end\n return true\n end", "def guessed?\n \t(word.split('') - selected_letters).empty?\n\tend", "def guessed_all_correc...
[ "0.8753852", "0.82281834", "0.8184084", "0.812885", "0.78522384", "0.78156537", "0.7806234", "0.76857656", "0.76422155", "0.7641001", "0.75981367", "0.7556777", "0.7556777", "0.75401086", "0.74589837", "0.7452604", "0.745196", "0.7396778", "0.7377083", "0.734662", "0.7336425"...
0.7449121
17
Display the current state of the guessed word for the player.
def output_word end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_current_status\n print_guess_word_status = \"\"\n @guess_word_status.each do |letter|\n print_guess_word_status += \"#{letter} \"\n end\n puts \"\\nYou guessed #{@failed_attempts} times wrong so far. Remember, when reaching 10 you lose!\"\n puts \"Guess word status = #{print_guess_wor...
[ "0.7531623", "0.7346968", "0.7246588", "0.72383136", "0.7211357", "0.7192306", "0.7129289", "0.7115634", "0.70630425", "0.70554155", "0.70217097", "0.70103836", "0.698339", "0.69407344", "0.68970245", "0.68349004", "0.6811168", "0.6798287", "0.6793523", "0.676205", "0.676161"...
0.0
-1
Run the game loop, which continues until the player wins or loses.
def game_loop end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game_loop\n\t\tuntil @board.check_for_winner || @board.no_more_moves\n\t\t\tputs \"Player #{@next_player.token}, it's your turn.\"\n\t\t\tputs @board\n\t\t\tplay_legal_location\n\t\t\tswitch_player\n\t\tend\n\t\tputs @board\n\t\tputs \"Game over!\"\n\t\tif @board.check_for_winner\n\t\t\tputs \"#{@board.check_f...
[ "0.82155037", "0.8211584", "0.8136985", "0.8025803", "0.7980007", "0.7964301", "0.7878089", "0.78751934", "0.77606887", "0.77413857", "0.7640193", "0.76123106", "0.7594395", "0.7549432", "0.75268656", "0.7499377", "0.7467143", "0.7462011", "0.7456943", "0.7442739", "0.744155"...
0.7336497
29
sh_string("git config branch.`git branch | grep '^\' | sed e 's/\ //'`.remote", "origin")
def sh_string(cmd, default) val = sh(cmd).strip rescue nil (val.nil? || val.empty?) ? default : val end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def branch_remote_name(branch_name)\n `git config branch.#{branch_name}.remote`.strip\n end", "def gitpath\n %x{git config --get remote.origin.url | sed \"s;^.*root/;;\" | sed \"s;\\.git$;;\"}.squish\n end", "def getMainGitRemote\n remotes = sh(\"git remote\", log: false).split\n if remot...
[ "0.73339945", "0.72094995", "0.71889347", "0.71766585", "0.7020216", "0.69666195", "0.69666195", "0.69666195", "0.69666195", "0.69666195", "0.69666195", "0.6921087", "0.68715703", "0.68693244", "0.67894375", "0.67876154", "0.6762442", "0.67475134", "0.67475134", "0.67417336", ...
0.0
-1
Run in shell, return both status and output
def sh_with_code(cmd) cmd << " 2>&1" outbuf = '' outbuf = `cd "#{@root}" && #{cmd}` [outbuf, $?] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_with_status(*args)\n _print_command(*args)\n args.last.delete :errexit if args.last.is_a? Hash\n args.last.delete :xtrace if args.last.is_a? Hash\n pid = Process.spawn(*args)\n return Process.wait2(pid).last\nend", "def execute\n { 'output' => `#{@cmd}`, 'process_status' => $? }\n ...
[ "0.7322158", "0.71865475", "0.71731544", "0.71719855", "0.71719855", "0.70740944", "0.70121205", "0.69848377", "0.6982044", "0.69333357", "0.69099736", "0.6891982", "0.68855286", "0.6879806", "0.68705595", "0.6859825", "0.6846686", "0.6823922", "0.68231094", "0.6801541", "0.6...
0.63299406
59
constructor, loads credentials and endpoint
def initialize(host, id = nil) @hypervisor = 'opennebula' @host = host @xmlhost = host_info(host, id) @public_cloud_conf = {} # create or open cache db @db = InstanceCache.new(File.join(VAR_LOCATION, 'remotes', 'im', 'one.d', 'one-cache.db')) region = {} %w[user password endpoint capacity].each do |key| if key == 'capacity' region[key] = {} %w[cpu memory].each do |key_c| xpath = "/HOST/TEMPLATE/ONE_#{key.upcase}/#{key_c.upcase}" value = @xmlhost.retrieve_elements(xpath)[0] if @xmlhost.retrieve_elements(xpath)[0].nil? || value == '' raise "Region for host #{@xmlhost} does not have "\ "'#{key_c.upcase}' defined in host template" end region[key][key_c] = value.to_i end else xpath = "/HOST/TEMPLATE/ONE_#{key.upcase}" value = @xmlhost.retrieve_elements(xpath)[0] if @xmlhost.retrieve_elements(xpath)[0].nil? || value == '' raise "Region for host #{@xmlhost} does not have "\ "'#{key.upcase}' defined in host template" end region[key] = value end end secret = "#{region['user']}:#{region['password']}" @client = OpenNebula::Client.new(secret, region['endpoint'], :sync => true) @cpu = region['capacity']['cpu'] @memory = region['capacity']['memory'] @cpu = 0 if @cpu.nil? @memory = 0 if @memory.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n load_site\n load_creds\n end", "def initialize(credentials)\n @credentials = credentials\n end", "def initialize(endpoint, username, password, options = nil)\n @endpoint = URI.parse(endpoint)\n @username = username\n @password = password\n @options = options || {...
[ "0.78442943", "0.77534676", "0.75714636", "0.75683576", "0.7498439", "0.7281481", "0.7258951", "0.7255047", "0.72207344", "0.71776646", "0.71758187", "0.7152563", "0.7135422", "0.713", "0.71232337", "0.71229017", "0.7119845", "0.7119845", "0.7084338", "0.70505", "0.7024142", ...
0.0
-1
DEPLOY action, also sets ports and ip if needed
def deploy(id, host, xml_text, lcm_state, deploy_id) if %w[BOOT BOOT_FAILURE].include? lcm_state one_info = get_deployment_info(host, xml_text) # load_default_template_values tid = one_value(one_info, 'TEMPLATE_ID') if tid.nil? || tid == '' STDERR.puts('Cannot find TEMPLATE_ID in deployment file') exit(-1) end extra_template = "REMOTE_OPENNEBULA = YES\n"\ "REMOTE_OPENNEBULA_VM_ID = #{id}\n" # The OpenNebula context will be included xml = OpenNebula::XMLElement.new xml.initialize_xml(xml_text, 'VM') if xml.has_elements?('TEMPLATE/CONTEXT') # Since there is only 1 level ',' will not be added context_str = xml.template_like_str('TEMPLATE/CONTEXT') if xml['TEMPLATE/CONTEXT/TOKEN'] == 'YES' # TODO: use OneGate library. See ec2_driver.rb token_str = generate_onegate_token(xml) if token_str context_str << "\nONEGATE_TOKEN=\"#{token_str}\"" end end extra_template << context_str end t = OpenNebula::Template.new_with_id(tid, @client) rc = t.instantiate(REMOTE_NAME_PREFIX+id, true, extra_template, false) if OpenNebula.is_error?(rc) STDERR.puts(rc.to_str) exit(-1) end deploy_id = "#{DEPLOY_ID_PREFIX}#{rc}" vm = get_remote_vm(deploy_id) if !context_str.nil? new_context_update = 'CONTEXT = [' << context_str << ']' new_context_update = new_context_update.gsub("\n", ",\n") rc = vm.updateconf(new_context_update) end if OpenNebula.is_error?(rc) STDERR.puts(rc.to_str) exit(-1) end vm.release rc = vm.update("REMOTE_OPENNEBULA_DEPLOY_ID = \"#{deploy_id}\"", true) if OpenNebula.is_error?(rc) STDERR.puts('Error adding REMOTE_OPENNEBULA_DEPLOY_ID ' \ "attribute to VM #{rc}: #{rc.to_str}") end puts(deploy_id) else restore(deploy_id) deploy_id end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deploy\n params = {\n :migrate => migrate,\n :ref => ref,\n }\n params[:serverside_version] = serverside_version if serverside_version\n params[:migrate_command] = migrate_command if migrate\n update_with_response api.post(collection_uri + \"/deploy\", 'depl...
[ "0.68398833", "0.6826289", "0.6611397", "0.6609333", "0.66085535", "0.6572724", "0.6548016", "0.6534807", "0.6504093", "0.6474948", "0.64487976", "0.63587165", "0.6276242", "0.6201769", "0.6196431", "0.61891896", "0.6117333", "0.60950327", "0.60571", "0.602292", "0.602292", ...
0.5443327
58
Reboot (hard) an instance
def reset(deploy_id) vm = get_remote_vm(deploy_id) rc = vm.reboot(true) return unless OpenNebula.is_error?(rc) STDERR.puts(rc.to_str) exit(-1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reboot\n node.update!(alive: false)\n run(\"reboot\")\n end", "def reboot\n # There is no trackable status change for the instance being\n # rebooted, so it's up to CPI client to keep track of agent\n # being ready after reboot.\n # Due to this, we can't deregister the instance fro...
[ "0.7963722", "0.7787953", "0.7775481", "0.77715755", "0.7758933", "0.76177174", "0.7581427", "0.7581395", "0.7457657", "0.738019", "0.7314796", "0.72893363", "0.72108734", "0.72108734", "0.7172692", "0.71468717", "0.71048707", "0.70973504", "0.7057923", "0.70512784", "0.70368...
0.0
-1
Get the OpenNebula hybrid section of the template. With more than one section the HOST element is used and matched with the host
def get_deployment_info(host, xml_text) xml = REXML::Document.new xml_text one = nil all_one_elements = xml.root.get_elements('//USER_TEMPLATE/PUBLIC_CLOUD') # First, let's see if we have an one site that matches # our desired host name all_one_elements.each do |element| cloud = element.elements['HOST'] if cloud && cloud.text.upcase == host.upcase one = element end end if !one # If we don't find the one site, and ONE just # knows about one one site, let's use that if all_one_elements.size == 1 one = all_one_elements[0] else STDERR.puts('Cannot find PUBLIC_CLOUD element in deployment '\ ' file or no HOST site matching the requested in the '\ 'template.') exit(-1) end end one end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def section\n @section ||= @hash[@default]\n end", "def get_host_template_conn(host)\n conn = {}\n\n # TODO: some nice / generic way (even for configuration?)\n tmpl = host.to_hash['HOST']['TEMPLATE']['PROVISION_CONNECTION']\n tmpl ||= {}\n ...
[ "0.53782815", "0.52656364", "0.52656364", "0.5265362", "0.5068938", "0.50150055", "0.49190456", "0.48939323", "0.48847666", "0.48420006", "0.48284036", "0.48140392", "0.48010707", "0.47980922", "0.4774903", "0.47318086", "0.47318086", "0.47318086", "0.47277927", "0.47245786", ...
0.46502087
28
Returns the value of the xml specified by the name or the default one if it does not exist +xml+: REXML Document, containing one hybrid information +name+: String, xpath expression to retrieve the value +block+: Block, block to be applied to the value before returning it
def one_value(xml, name, &block) value = value_from_xml(xml, name) || @defaults[name] if block_given? && value block.call(value) else value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ec2_value(xml, name, &block)\n value = value_from_xml(xml, name) || @defaults[name]\n if block_given? && value\n block.call(value)\n else\n value\n end\n end", "def get_attribute_or_element_value(xml, attr, default = nil, &f)\n val = default\n begin\...
[ "0.6841215", "0.61217886", "0.5885647", "0.5653056", "0.564701", "0.564701", "0.564701", "0.564701", "0.564701", "0.564701", "0.564701", "0.564701", "0.564701", "0.56464404", "0.56325257", "0.56325257", "0.56325257", "0.56152755", "0.555675", "0.54732054", "0.5438118", "0.5...
0.7426028
0
Load the default values that will be used to create a new instance, if not provided in the template. These values are defined in the ONE_DRIVER_DEFAULT file
def load_default_template_values @defaults = {} return unless File.exist?(ONE_DRIVER_DEFAULT) fd = File.new(ONE_DRIVER_DEFAULT) xml = REXML::Document.new fd fd.close return if !xml || !xml.root xml.elements.each('/TEMPLATE/PUBLIC_CLOUD/*') do |e| @defaults[e.name] = e.text end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_default_template_values\n @defaults = Hash.new\n\n if File.exist?(EC2_DRIVER_DEFAULT)\n fd = File.new(EC2_DRIVER_DEFAULT)\n xml = REXML::Document.new fd\n fd.close()\n\n return if !xml || !xml.root\n\n ec2 = xml.root.elements[\"PUBLIC_C...
[ "0.7454183", "0.6610017", "0.6609968", "0.6599633", "0.6599633", "0.64986616", "0.6492828", "0.64809185", "0.647805", "0.64520675", "0.63493824", "0.62878126", "0.6282636", "0.6198357", "0.6195092", "0.61897826", "0.6169279", "0.61603004", "0.61580384", "0.6155451", "0.615264...
0.767942
0
Retrive the vm object for the remote opennebula
def get_remote_vm(deploy_id) begin match = deploy_id.match(/#{DEPLOY_ID_PREFIX}(.*)/) if match.nil? raise "Deploy ID #{deploy_id} was not created with this driver" end id = match[1] OpenNebula::VirtualMachine.new_with_id(id, @client) rescue StandardError => e STDERR.puts e.message exit(-1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vm(name)\n @conn.vms.get(name)\n end", "def get_vm_info()\n promise = @compute_client.virtual_machines.get(@rg_name, @instance_name)\n result = promise.value!\n OOLog.info(\"vm info :\"+result.body.inspect)\n return result.body\n end", "def get_vm(_pool_name, _vm_name)\n ...
[ "0.7054613", "0.67966455", "0.67595893", "0.6741441", "0.66779935", "0.66211396", "0.6577788", "0.65726554", "0.65482205", "0.64775383", "0.63733447", "0.6348524", "0.62529844", "0.6243596", "0.62423825", "0.62390083", "0.6195624", "0.61728704", "0.61533356", "0.6131661", "0....
0.6333244
12
TODO: move this method to a OneGate library. See ec2_driver.rb
def generate_onegate_token(xml) # Create the OneGate token string vmid_str = xml['ID'] stime_str = xml['STIME'] str_to_encrypt = "#{vmid_str}:#{stime_str}" user_id = xml['TEMPLATE/CREATED_BY'] if user_id.nil? STDERR.puts do "VMID:#{vmid} CREATED_BY not present" \ ' in the VM TEMPLATE' end return end user = OpenNebula::User.new_with_id(user_id, OpenNebula::Client.new) rc = user.info if OpenNebula.is_error?(rc) STDERR.puts do "VMID:#{vmid} user.info" \ " error: #{rc.message}" end return end token_password = user['TEMPLATE/TOKEN_PASSWORD'] if token_password.nil? STDERR.puts do "VMID:#{vmid} TOKEN_PASSWORD not present"\ " in the USER:#{user_id} TEMPLATE" end return end cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc') cipher.encrypt cipher.key = token_password onegate_token = cipher.update(str_to_encrypt) onegate_token << cipher.final Base64.encode64(onegate_token).chop end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ec2\n Fog::Compute::AWS.new(aws_access_key_id: @aws_access_key_id, aws_secret_access_key: @aws_secret_access_key)\n end", "def ec2\n @ec2 ||= aws_init { AWS::EC2.new }\n end", "def createEC2Client(region,credentials)\n begin\n return Aws::EC2::Client.new(region: region,credentials: credentials)...
[ "0.6412104", "0.6067864", "0.6048499", "0.6016768", "0.5970166", "0.5931317", "0.59228504", "0.5902403", "0.5886226", "0.5874563", "0.58397824", "0.580537", "0.5792478", "0.576913", "0.5735006", "0.57140404", "0.5651638", "0.5639803", "0.56096244", "0.5562703", "0.5559436", ...
0.0
-1
if any of the metadata string methods are called then we return what the value is
def method_missing(method_name) if METADATA.include? method_name.to_s content_of(method_name.to_s) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_string(attr); end", "def method_missing(method_name)\n if method_name.to_s =~ /^meta_(.*)/\n key = $1\n\n\t#special treatment for opengraph (og:) and twitter card (twitter:) tags\n\tkey.gsub!(\"_\",\":\") if key =~ /^og_(.*)/ || key =~ /^twitter_(.*)/\n\n scrape_meta_data\n\n @d...
[ "0.62241805", "0.61679083", "0.6076499", "0.60424095", "0.59391284", "0.5869902", "0.5843046", "0.58261406", "0.5762472", "0.57332927", "0.5730696", "0.5723737", "0.5723737", "0.5723737", "0.5723737", "0.5723737", "0.5723737", "0.5723737", "0.5723737", "0.5723737", "0.5653332...
0.6109207
2
protected: other instances of same class can call, but nothing else can call
def total_subsalary total_subsalary = 0 self.employees.each do |employee| if employee.is_a?(Manager) total_subsalary += employee.salary + employee.total_subsalary else total_subsalary += employee.salary end end total_subsalary end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invoke\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n raise 'must be implemented in subclasses'\r\n end", "def private; end", "def call\n # implement in subclasses\n end", "def internal; end", "def called_from; end", "def called_from; end", "def protec...
[ "0.6801277", "0.6744745", "0.6737658", "0.6650992", "0.64579695", "0.64579695", "0.64363766", "0.64227176", "0.63850516", "0.6383231", "0.6383231", "0.6383231", "0.6383231", "0.6383231", "0.6383231", "0.6383231", "0.6383231", "0.63484734", "0.63484734", "0.63484734", "0.62821...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @requested_user = User.find(params[:user_id].to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def post_params params.permit(:body, :is_public) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
move to the same folder with the same path every time
def move_files_to_daily(from_folder) to_folder = from_folder + DAILY_FOLDER create_folder_if_needed(to_folder) Dir.glob("#{from_folder}/*") do |filename| to_path = "/#{to_folder}/#{File.basename(filename)}" delete_file_if_there(to_path) move_file(filename, to_path) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_dirs\n \n end", "def move\n display_change\n File.move(@real_path, new_path, false)\n end", "def move_to(new_path)\n self.path = new_path\n self.save\n end", "def move_to!(dest)\n Pow(dest).parent.create_directory\n move_to(dest)\n end", "def ...
[ "0.721656", "0.7172951", "0.69556314", "0.6949734", "0.6877508", "0.67675513", "0.6759571", "0.66765743", "0.6649242", "0.66202784", "0.6567973", "0.64962316", "0.6438254", "0.6437632", "0.6421178", "0.6421079", "0.6419021", "0.64129007", "0.6397149", "0.6346507", "0.625306",...
0.5673649
97
move to a timestamped file with the same path
def move_files_to(from_folder) Dir.glob("#{from_folder}/*") do |filename| to_path = "#{timestamped(filename)}" delete_file_if_there(to_path) move_file(filename, to_path) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backup_existing_file(file_path)\n FileUtils.move(file_path, \"#{file_path}-#{Time.now.to_i.to_s}\")\n end", "def timestomp(original, doplegangar)\n#\tcommandz(\"touch -r #{original} #{doplegangar}\") # one liner with touch command :p\n\n\t#Pure Ruby way :)\n\tfoo = File.stat(original) #Stat original ...
[ "0.6791986", "0.63771737", "0.6258981", "0.6252241", "0.6242135", "0.61669236", "0.6163575", "0.6114384", "0.6102261", "0.60144985", "0.6014297", "0.60137403", "0.60015804", "0.5995325", "0.59951484", "0.5990877", "0.59835166", "0.59828174", "0.59747064", "0.5940765", "0.5892...
0.0
-1
test 3749 merchant authorizate to do echeck using 087901 with same username IMPTEST, password cert3d6Z test 3740 echeckVerification
def test_37 customer_hash = { 'orderId' => '37', 'amount' => '3001', 'orderSource'=>'telephone', 'billToAddress'=>{ 'firstName' => 'Tom', 'lastName' => 'Black'}, 'echeck'=>{ 'accNum' =>'10@BC99999', 'accType' => 'Checking', 'routingNum' => '053100300'} } hash = customer_hash.merge(@@merchant_hash) echeck_response = CnpOnlineRequest.new.echeck_verification(hash) assert_equal('301', echeck_response.echeckVerificationResponse.response) assert_equal('Invalid Account Number', echeck_response.echeckVerificationResponse.message) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_26\n customer_hash = {\n 'orderId' => '26',\n 'amount' => '18698',\n 'orderSource'=>'ecommerce',\n 'card'=>{\n 'number' =>'5194560012341234',\n 'expDate' => '1212',\n 'type' => 'MC'},\n 'allowPartialAuth' => 'true',\n 'healthcareIIAS' => ...
[ "0.59909636", "0.5965581", "0.59653383", "0.5870781", "0.58284515", "0.58219314", "0.58152115", "0.58121777", "0.5789508", "0.57786137", "0.57625026", "0.575325", "0.5741692", "0.5725838", "0.567994", "0.56701636", "0.5661113", "0.5645067", "0.56449646", "0.56141424", "0.5608...
0.71268046
0
Helpers TODO Ideally, this would also map what most people think is the title of a book to the actual title of the book, or the hashing could fall back to a search of the YAML file for the coresponding ID for the closest match. An example: Gullivers Travel > Gulliver's Travels into Several Remote Nations of the World
def flatten_title(title) return title.strip.downcase end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def book_mapping(book)\n title = book.title.downcase.gsub(/\\s+/, '')\n CONFIG[:sources][translation][:mappings][title] || title\n end", "def titleIdentifier\n titleIdentifier = title + ' / ' + author\n titleIdentifier\n end", "def hash\n title.hash\n end", "def book_b...
[ "0.6147915", "0.60868615", "0.605608", "0.59406054", "0.5769675", "0.5730543", "0.5589632", "0.5589632", "0.55805904", "0.55702066", "0.5562028", "0.5558919", "0.55406183", "0.55127525", "0.55072075", "0.5500081", "0.54988813", "0.54567856", "0.54521316", "0.544666", "0.54407...
0.0
-1
Environment setup if the catalog is missing.
def setup_env() puts puts 'Setting up your environment. This should only take a minute.' puts # This uri is the one for robots to grab the catalog, if you want to download it yourself it is # https://www.gutenberg.org/cache/epub/feeds/rdf-files.tar.zip catalog_uri = 'http://gutenberg.pglaf.org/cache/generated/feeds/rdf-files.tar.zip' start = Time.now system("wget -w 2 -m -H #{catalog_uri} -nH -nd") system("gunzip < rdf-files.tar.zip | tar xf -") Dir.chdir(@base_dir) do # The files need some cleanup to work properly with the rdf gem. If they don't have a title, they won't parse and the script will choke. Run this from base_dir if you aren't using automated setup: # grep -rLZ ":title" . | while IFS= read -rd '' x; do rm -f "$x"; done # Then run this to make sure it comes back clean: # grep -rLZ ":title" . | while IFS= read -rd '' x; do echo "$x"; done # The problem is caused by books that were removed. They give a 404 error if you try to find them manually, but are still listed in the catalog since the catalog is auto-generated by crawling their own site. # Ruby defaults to using /bin/sh but I specifically want to run this in the bash shell so that read has the -d option system("bash", "-c", "grep -rLZ \":title\" . | while IFS= read -rd \'\' x; do rm -f \"$x\"; done") end end_time = Time.now ttr = end_time-start print 'Time to set up catalog: ' if @verbose puts ttr if @verbose end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_environment; end", "def check_and_set_environment\n check_env\n set_env\n end", "def ensure_has_environment_files()\n\n end", "def prepare_environment(env)\n load_environment_properties(env)\n raise 'environment problem:environment not found' if @env_config.nil?\n creat...
[ "0.689019", "0.67580867", "0.668639", "0.6643552", "0.624322", "0.624322", "0.6202857", "0.61749125", "0.615598", "0.606985", "0.6063047", "0.6046122", "0.60258025", "0.6015414", "0.5943558", "0.59229326", "0.5918527", "0.5902307", "0.5895565", "0.5861902", "0.58570623", "0...
0.58295536
21
This helper method gets the correct path to a book stored on the gutenberg.pglaf.org mirror
def get_mirror_uri(id, type) # The path changes between what's in the catalog RDF and the mirror structure so it needs patching. # Note that mobi format is the same as kindle (their naming convention changed on miror) base = 'gutenberg.pglaf.org/cache/epub/' uri = base + id.to_s + '/' case type when /kindle.images/ uri += "pg#{id}-images.mobi" when /kindle.noimages/ uri += "pg#{id}.mobi" when /.txt/ uri += "pg#{id}.txt.utf8" when /epub.images/ uri += "pg#{id}-images.epub" when /epub.noimages/ uri += "pg#{id}.epub" end # A return is unneeded since it is implied, but let's be explicit return uri end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def directory(autor_params = self.book_data.autor)\n File.join(CONFIG[Rails.env.to_sym][\"books_path\"],directory_name(autor_params))\n end", "def dir_of(book_id)\n File.expand_path(LibraryLocator.identity(book_id).relpath, root)\n end", "def book\n fetch('harry_potter.books')\n ...
[ "0.6479694", "0.6448653", "0.6438103", "0.6352078", "0.6269229", "0.61514497", "0.6104147", "0.60723037", "0.59943914", "0.58572865", "0.58514", "0.5809931", "0.57838356", "0.5749693", "0.5749693", "0.5725362", "0.57081616", "0.5669899", "0.5642357", "0.5619922", "0.561726", ...
0.54259855
32
For some reason, I was not able to get the :current_or_upcoming_reservation method to be serialized by a custom serializer class.
def current_or_upcoming_reservation reservation = object.current_or_upcoming_reservation if reservation == nil return nil end { 'id' => reservation.id, 'check_in_date' => reservation.check_in_date, 'check_out_date' => reservation.check_out_date, 'first_name' => reservation.first_name, 'last_name' => reservation.last_name, 'room_number' => reservation.room_number, 'confirmation_code' => reservation.confirmation_code } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_field_deserializers()\n return super.merge({\n \"draftShift\" => lambda {|n| @draft_shift = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ShiftItem.create_from_discriminator_value(pn) }) },\n \"schedulingGroupId\" => lambda {|n| @scheduling_gro...
[ "0.6547051", "0.6206245", "0.6168467", "0.6127846", "0.61185247", "0.61022234", "0.595067", "0.5940366", "0.5933894", "0.58579814", "0.58578205", "0.5854347", "0.58541065", "0.5845949", "0.584399", "0.58257174", "0.58117604", "0.58077604", "0.57926893", "0.5785984", "0.577898...
0.6721979
0
add_mesh is called during Geometry collection
def add_mesh(name) #if name == nil #if @is_microsoft # name = "mesh" + @id_gen.get_next_id() #end #end mesh = { "primitives" => [ ] } if name != nil mesh["name"] = name end index = @meshes.length @meshes.push(mesh) return index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_mesh\r\n Console.log( 'BezierSurface.update_mesh' )\r\n d = TT::Instance.definition( @instance )\r\n transformation = d.model.edit_transform\r\n subdivisions = final_subdivs()\r\n # Init a PolygonMesh with an rough geometry estimate for best performance.\r\n points = count_...
[ "0.7003588", "0.6995983", "0.6641158", "0.598482", "0.5901851", "0.5872582", "0.551987", "0.551987", "0.54976064", "0.5468016", "0.5371149", "0.5303461", "0.52560204", "0.52478385", "0.5216313", "0.5109604", "0.50888455", "0.5077411", "0.50669396", "0.5054967", "0.5039898", ...
0.72589076
0
add_mesh_primitive is called during final buffer consolidation
def add_mesh_primitive(mesh_id, position_accessor_id, normal_accessor_id, uvs_accessor_id, indices_accessor_id, material_id) primitive = { "attributes" => { "POSITION" => position_accessor_id, "NORMAL" => normal_accessor_id }, "indices" => indices_accessor_id, "mode" => 4, "material" => material_id } if uvs_accessor_id != nil primitive["attributes"]["TEXCOORD_0"] = uvs_accessor_id end @meshes[mesh_id]["primitives"].push(primitive) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_mesh\r\n Console.log( 'BezierSurface.update_mesh' )\r\n d = TT::Instance.definition( @instance )\r\n transformation = d.model.edit_transform\r\n subdivisions = final_subdivs()\r\n # Init a PolygonMesh with an rough geometry estimate for best performance.\r\n points = count_...
[ "0.6562644", "0.6421875", "0.6325042", "0.59788555", "0.5714663", "0.53168637", "0.5305046", "0.5305046", "0.52976924", "0.52869415", "0.5200192", "0.51351917", "0.50989056", "0.5082726", "0.50825495", "0.49850786", "0.49816787", "0.49400678", "0.49329263", "0.49317974", "0.4...
0.7388039
0
This method used to display sort link for header of list Parameters: text : link text param: name of column on which sorting should be done
def sort_link_helper(text, param) params.delete(:action) key = param key += "_reverse" if params[:sort] == param options = { :url => {:action => 'list', :params => params.merge({:id=> current_user.id,:sort => key, :page => nil, :folder_name => @folder_name})}, :update => 'pms_tabs_contents', } html_options = { :title => "Sort by this field", } link_to_remote(text, options, html_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def link_sort_header(column_translation_code )\n #title ||= column.titleize\n if column_translation_code.index('.') then\n column=column_translation_code.split.last\n else\n column=column_translation_code\n end\n css_class = (column == sort_column) ? \"current #{sort_direction}\" : nil\n ...
[ "0.77658826", "0.7579513", "0.74985504", "0.74578404", "0.7432296", "0.74304366", "0.7376361", "0.72810596", "0.723407", "0.7206561", "0.7197254", "0.7191653", "0.7165385", "0.7080495", "0.70654285", "0.7039729", "0.7001755", "0.69662344", "0.6948589", "0.69352305", "0.693513...
0.72851753
7
This method used to display user name as link in messages list Parameters: id : user id rec_id: conversation id action: action name for link(edit/show)
def name_link_helper(id, rec_id, action) if action == 'show' action = user_message_path(current_user.id, rec_id) else action = edit_user_message_path(current_user.id, rec_id) end text = get_name(id) name = (text.blank?)? '............' : text new_name = truncate(name, :length => 20) html_options = { :title => name, } link_to(new_name, action, html_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subject_link_helper(text, rec_id, action)\n if action == 'show'\n action = user_message_path(current_user.id, rec_id)\n else\n action = edit_user_message_path(current_user.id, rec_id)\n end\n subject = (text.nil? || '' == text) ? '.............' : text\n new_subject = subject.length >...
[ "0.6631824", "0.6555984", "0.6448964", "0.63873124", "0.6316551", "0.6300465", "0.60281837", "0.60034746", "0.59882194", "0.5957367", "0.5951042", "0.58970535", "0.5889511", "0.58836675", "0.58025455", "0.5801291", "0.5801291", "0.5801291", "0.57682014", "0.5756551", "0.57196...
0.7930646
0
This method used to display subject as link in messages list Parameters: text : subject text of message rec_id: conversation id action: action name for link(edit/show)
def subject_link_helper(text, rec_id, action) if action == 'show' action = user_message_path(current_user.id, rec_id) else action = edit_user_message_path(current_user.id, rec_id) end subject = (text.nil? || '' == text) ? '.............' : text new_subject = subject.length > 30 ? subject.slice(0..29) + '...' : subject html_options = { :title => subject, } link_to(new_subject, action, html_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def link\n subject_link\nend", "def name_link_helper(id, rec_id, action)\n if action == 'show'\n action = user_message_path(current_user.id, rec_id)\n else\n action = edit_user_message_path(current_user.id, rec_id)\n end\n text = get_name(id)\n name = (text.blank?)? '............' : tex...
[ "0.6491241", "0.6388563", "0.63586974", "0.60998327", "0.6028217", "0.6022844", "0.5996237", "0.5971504", "0.58853", "0.58826417", "0.5834865", "0.5826878", "0.5777235", "0.5752227", "0.57422346", "0.5732825", "0.57313484", "0.570917", "0.56848985", "0.5648686", "0.56341857",...
0.83534336
0
This method returns name of user in format of 'first_name last_name' Parameters: id : user id
def get_name(id) return "" if !id user = User.find(id) user.first_name + ' ' + user.last_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_full_name(user_id)\n if user_id\n u = User.find(user_id)\n return u.firstname + \" \" + u.lastname\n else\n return \"Unknown\"\n end\n end", "def full_name_with_id\n id.to_s + \": \" + user.first_name + \" \" + user.last_name\n end", "def get_user_name_by_id(user_id)\n ...
[ "0.8549786", "0.82834005", "0.81430554", "0.81192607", "0.80804044", "0.8026223", "0.78860986", "0.78860986", "0.78333163", "0.77680427", "0.7759774", "0.77241427", "0.770962", "0.76613", "0.7628523", "0.76216364", "0.7613054", "0.75067586", "0.74964863", "0.74630886", "0.739...
0.90832955
0
This method displays error messages for forms. Parameters: message : object of messgae with all values and errors hash
def error_messages_for_message(message) if message and !message.errors.empty? str = '<div style="margin:5px;color:red;border:1px solid red;">' message.errors.each do |key, val| str += '<b> * '+ key.to_s.capitalize + '</b>: '+ val +' <br/>' end str += '</div>' end str.html_safe unless str.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def form_errors(model_obj)\n render partial: 'layouts/form_messages', locals: {model: model_obj}\n end", "def form_error(name, message)\n if respond_to?(:flash)\n old = flash[:form_errors] || {}\n flash[:form_errors] = old.merge(name.to_s => message.to_s)\n else\n ...
[ "0.69694585", "0.66553986", "0.6609491", "0.6537955", "0.6536435", "0.6515304", "0.6510481", "0.64702874", "0.6417486", "0.6406421", "0.640497", "0.6368419", "0.63573456", "0.6339816", "0.63206047", "0.6316702", "0.62993443", "0.6284606", "0.6280073", "0.62784356", "0.6276436...
0.74772733
0
GET /qualifications GET /qualifications.json
def index @qualifications ||= Qualification.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_qualifications\n @qualifications = Qualification.all\n end", "def index\n @qualifications = Qualification.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qualifications }\n end\n end", "def index\n @qualifications = Qualificati...
[ "0.79484135", "0.72101796", "0.70642364", "0.6659305", "0.6433964", "0.63248324", "0.62969923", "0.62828857", "0.6262868", "0.6137683", "0.6073714", "0.6037152", "0.60060096", "0.5964753", "0.5913543", "0.58828735", "0.58518803", "0.58518803", "0.58518803", "0.5843335", "0.57...
0.70305896
3
GET /qualifications/1 GET /qualifications/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_qualifications\n @qualifications = Qualification.all\n end", "def index\n @qualifications = Qualification.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qualifications }\n end\n end", "def show\n @qualification = Qualification...
[ "0.75008506", "0.7344306", "0.7340522", "0.7124533", "0.6987734", "0.67092556", "0.6481473", "0.6481434", "0.6481434", "0.6481434", "0.645547", "0.6420157", "0.6362899", "0.63040966", "0.62292975", "0.6093061", "0.6090488", "0.6044341", "0.60396093", "0.6031635", "0.60279626"...
0.0
-1
POST /qualifications POST /qualifications.json
def create @profile ||= Profile.find(params[:profile_id]) @qualification = @profile.qualifications.new(qualification_params) @qualification.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def qualification_params\n params.require(:qualification).permit(:name, :experience, :project_id, :user_id)\n end", "def qualification_params\n params.require(:qualification).permit(:name, :q_type)\n end", "def create\n @qualification = Qualification.new(params[:qualification])\n\n respon...
[ "0.7061001", "0.6925278", "0.687265", "0.67445683", "0.6710166", "0.66898906", "0.66554725", "0.6480371", "0.6296001", "0.6269745", "0.62607026", "0.62558275", "0.6149648", "0.61309236", "0.6119616", "0.60779285", "0.59752166", "0.59752166", "0.59752166", "0.59537214", "0.590...
0.6930414
1
PATCH/PUT /qualifications/1 PATCH/PUT /qualifications/1.json
def update @profile ||= Profile.find(params[:profile_id]) @qualification.update(qualification_params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @qualification = Qualification.find(params[:id])\n\n respond_to do |format|\n if @qualification.update_attributes(params[:qualification])\n format.html { redirect_to @qualification, notice: 'Qualification was successfully updated.' }\n format.json { head :no_content }\n e...
[ "0.7227292", "0.7083315", "0.68756163", "0.68668646", "0.6523286", "0.64510584", "0.63474584", "0.62829214", "0.6280645", "0.615767", "0.6144918", "0.61046183", "0.6074729", "0.6048282", "0.60362583", "0.6025107", "0.6004947", "0.5985721", "0.59792566", "0.59792566", "0.59792...
0.64759904
5
DELETE /qualifications/1 DELETE /qualifications/1.json
def destroy @profile ||= @qualification.profile @qualification.destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @qualification = Qualification.find(params[:id])\n @qualification.destroy\n\n respond_to do |format|\n format.html { redirect_to qualifications_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qualification = Qualification.find(params[:id])\n @qual...
[ "0.77073973", "0.7530752", "0.73803735", "0.7237642", "0.69190496", "0.68361026", "0.66907", "0.66552854", "0.6653643", "0.66169995", "0.6581652", "0.6528976", "0.6520366", "0.6494792", "0.6452186", "0.639028", "0.6389181", "0.638515", "0.63824064", "0.6366674", "0.63665354",...
0.6606298
10
Use callbacks to share common setup or constraints between actions.
def set_qualification @qualification ||= Qualification.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 qualification_params params.require(:qualification).permit(:qualification, :college_name, :university, :year, :profile_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
3. Multiply By Five
def multiply_by_five(n) n * 5 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiply_by_five(n)\r\n n * 5\r\n end", "def Multiply(x)\n (x * 3)\nend", "def multiplicationby3(a)\n return a*3\nend", "def multiply_sum_by_3rd_argument\n\n end", "def multiply(number)\n\tputs number * 3\nend", "def multiply(nums)\r\n nums.reduce(:*)\r\nend", "def multiply_fifteen nu...
[ "0.78892946", "0.7724849", "0.759177", "0.7554317", "0.7479272", "0.7458124", "0.74298394", "0.7420319", "0.7420142", "0.73170686", "0.7309743", "0.72947305", "0.7271382", "0.7260455", "0.72331065", "0.7221784", "0.72183704", "0.72183704", "0.721594", "0.7201889", "0.71979344...
0.78205824
7
Test tautology of an expression
def test_tautology tt = Tautology.new("a") assert_equal(false, tt.check_tautology) tt = Tautology.new("a & b") assert_equal(false, tt.check_tautology) tt = Tautology.new("(!a | (a & a))") assert_equal(true, tt.check_tautology) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_for_tautology\n counter = 0\n random_decision = Decider.new(@propositional_statement, @random_truth_values).evaluate_expression\n if random_decision == false\n what_simulator_tells = \"False\"\n elsif random_decision == true\n @possible_truth_tables.each do |possible_truth_table|\n ...
[ "0.676147", "0.64015967", "0.59568995", "0.588531", "0.5818323", "0.58148134", "0.58019", "0.58004785", "0.565553", "0.5574708", "0.5462632", "0.54240817", "0.5389987", "0.5383143", "0.53430384", "0.532312", "0.5299833", "0.5289597", "0.5277144", "0.5269386", "0.5235485", "...
0.6986104
0
For a Palindromic string, the right side from the center, has the same length as left, if the left side of the palindromic string is within the boundary of current center Palidromic String else it be Right Most Index of current Palidromic substring Index of current item Given a string of abababa b a(5) a(mirror = 5) b(3) b(mirror = 3) a(1) a(mirror = 1)
def manacher_algorithm(s) manacher_string = ['$','#'] s.chars.each do |char| manacher_string.push(char,'#') end manacher_string.push '@' computed_count = [0]*manacher_string.length right = center = 0 (1...manacher_string.size).each do |index| mirror = center * 2 - index if index < right computed_count[index] = [right - index, computed_count[mirror]].min end while(manacher_string[index + (1 + computed_count[index])] == manacher_string[index - (1 + computed_count[index])]) computed_count[index] += 1 end if index + computed_count[index] > right center = index right = index + computed_count[index] end end computed_count.reduce(0) {|s,count| s+=((count+1)/2)} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def palindrome_index(str) \n left_init = 0\n right_init = str.size - 1\n is_pal = true\n while (left_init <= right_init) do\n is_pal = false if str[left_init] != str[right_init]\n left_init += 1\n right_init -= 1\n end\n return -1 if is_pal\n (0..str.size-1).each do |i|\n ...
[ "0.7418359", "0.72962797", "0.7244798", "0.72322047", "0.72287357", "0.71623033", "0.70915365", "0.708148", "0.6981145", "0.6980351", "0.69399804", "0.6938485", "0.6875693", "0.6860314", "0.6806877", "0.6794051", "0.67908895", "0.67834944", "0.67672116", "0.6765206", "0.67404...
0.0
-1
want to repeat this a number of times
def confirm_js_operation assert Capybara.current_driver, :selenium # default javascript driver visit root_path alert = page.driver.browser.switch_to.alert assert alert.text, 'welcome#index' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeater(repeats=1, &proc)\n repeats.times {proc.call}\nend", "def repeater(count=1)\n count.times {|ii| yield }\nend", "def repeater( num=1, &block )\n\n\n\tnum.times do\n\n\t yield if block_given?\n\n\tend\n\n\n\nend", "def repeater(n = 1)\n\tn.times { yield }\nend", "def repeater(n = 1)\n\tn.time...
[ "0.73638666", "0.723887", "0.7227117", "0.7216147", "0.71578795", "0.71451896", "0.7143573", "0.7032851", "0.70115465", "0.6982386", "0.69817024", "0.69619954", "0.6960826", "0.6949273", "0.6874711", "0.6830678", "0.6821878", "0.68178326", "0.6804449", "0.678072", "0.67800176...
0.0
-1
this function is redirect /login/logout
def destroy redirect_to "/login/logout" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logout\r\n clear_login_data\r\n redirect_to params[:return_to] || '/'\r\nend", "def logout\r\n clear_login_data\r\n redirect_to(params[:return_to] || '/', allow_other_host: true)\r\nend", "def logout\n \tlog_out\n \tredirect_to login_path\n end", "def logout \n sign_out\n# render :text =>...
[ "0.7865592", "0.7824726", "0.7754176", "0.7745508", "0.7681317", "0.76204324", "0.760792", "0.7601914", "0.7590449", "0.75299716", "0.7506431", "0.74893963", "0.7482827", "0.7477048", "0.7477048", "0.74573445", "0.7438584", "0.74104786", "0.74104786", "0.7403672", "0.7389772"...
0.71542716
62
Parser Methods expression = term ('OR' term)
def parse_expression parse_term while(@cur_token.kind == :OR) accept_it parse_term end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def or_clause\n a = and_clause\n\n space\n if accept(/or +/i)\n b = or_clause\n AST.new(:or, [a, b])\n else\n a\n end\n end", "def OrExpr(path, parsed); end", "def or( *args ); { $or => args } end", "def rewrite_or(expression)\n first ...
[ "0.7381775", "0.728678", "0.7150653", "0.71388596", "0.7050791", "0.6973161", "0.68950766", "0.684701", "0.6831282", "0.67956984", "0.6673699", "0.6673533", "0.66711736", "0.6652873", "0.6637553", "0.6603554", "0.6595684", "0.6530274", "0.652857", "0.65026313", "0.6501933", ...
0.83450395
0
term = factor ('AND'(empty|'NOT') factor)
def parse_term parse_factor while(@cur_token.kind == :AND) accept_it if(@cur_token.kind == :NOT) accept_it end parse_factor end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_AND(clause)\n \"#{clause.gsub!(' AND ', ' ').strip!}\"\n clause.gsub!('( ', '(')\n clause.gsub!(' )', ')')\n clause\n end", "def scan_for_and(token); end", "def and_clause\n a = factor_list\n\n space\n if accept(/and +/i)\n b = and_clause\n AST.new...
[ "0.6620559", "0.63525295", "0.62548083", "0.622246", "0.62117773", "0.62040025", "0.61858", "0.61645633", "0.6138735", "0.6138735", "0.60349005", "0.59873426", "0.5966954", "0.58799154", "0.5871639", "0.5869593", "0.58208853", "0.5719315", "0.5650426", "0.5631356", "0.5616078...
0.7871556
0
factor = searchstring | '('expression')'
def parse_factor case @cur_token.kind when :SEARCHSTRING accept_it when :LPAREN accept_it parse_expression accept(:RPAREN) else error("") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_exp(input, variable, expression); end", "def factor\n if @look == '(' \n match '('\n expression\n match ')'\n elsif is_alpha?@look\n ident\n else\n emit_ln \"MOVE ##{get_num},D0\"\n end\nend", "def factor\n case\n when scan(/\\(/) then expr.tap { scan(/\\)/) }\n else number...
[ "0.6965674", "0.6706789", "0.6624132", "0.61631984", "0.6028285", "0.6028285", "0.59997463", "0.58881855", "0.58365786", "0.5825421", "0.5810217", "0.5804402", "0.57774013", "0.5760756", "0.57347924", "0.57245725", "0.57223153", "0.57095456", "0.56832516", "0.56817627", "0.56...
0.70662594
0
def teardown end def setup end
def prepare [ "alpha", "bravo", "charly" ].each do |name| @engine.register_participant(name) do |workitem| workitem.attributes[name] = true workitem.attributes["key"] = name end end #@engine.register_participant("display_workitem") do |workitem| # puts # puts #end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recycle; teardown; setup; end", "def teardown; end", "def teardown; end", "def teardown\r\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n...
[ "0.9024827", "0.90016574", "0.90016574", "0.8866362", "0.8846447", "0.8846447", "0.8846447", "0.8846447", "0.8846447", "0.8846447", "0.8846447", "0.8846447", "0.8760204", "0.8760204", "0.8760204", "0.8760204", "0.8760204", "0.8760204", "0.8760204", "0.8760204", "0.8760204", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_transaction_log @transaction_log = TransactionLog.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 transaction_log_params params.require(:transaction_log).permit(:transaction_loggable_id, :transaction_loggable_type, :gateway_request_object, :gateway_response_object, :transaction_type, :gateway_transaction_id, :other_detail, :gateway_type, :gateway_name, :status) 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.6980244", "0.6782812", "0.6745103", "0.6741142", "0.6733961", "0.65925", "0.6503602", "0.64967257", "0.64822173", "0.64796996", "0.6456357", "0.6439594", "0.63803256", "0.6376499", "0.63644457", "0.6319286", "0.6299465", "0.6298051", "0.62935406", "0.62923044", "0.6291212"...
0.0
-1
switches turn to white team
def white_turn @teams[:white].current_team = true @teams[:black].current_team = false @current_team = @teams[:white] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def black_turn\n @teams[:white].current_team = false\n @teams[:black].current_team = true\n @current_team = @teams[:black]\n end", "def white_turn?\n true if @current_team == @teams[:white]\n end", "def change_turn\n if @player_to_move == \"w\"\n @player_to_move = \"b\"\n ...
[ "0.8225626", "0.7685818", "0.69824743", "0.6978284", "0.69694096", "0.6900057", "0.687356", "0.6868478", "0.6827523", "0.6760238", "0.666436", "0.6568076", "0.6558211", "0.65234214", "0.65088296", "0.64865106", "0.64493424", "0.6419812", "0.641345", "0.6397102", "0.63856125",...
0.8727116
0
switches turn to black team
def black_turn @teams[:white].current_team = false @teams[:black].current_team = true @current_team = @teams[:black] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def white_turn\n @teams[:white].current_team = true\n @teams[:black].current_team = false\n @current_team = @teams[:white]\n end", "def black_turn?\n true if @current_team == @teams[:black]\n end", "def white_turn?\n true if @current_team == @teams[:white]\n end", "def winning_team\n blu...
[ "0.8386182", "0.7626453", "0.7298047", "0.71636593", "0.7086499", "0.6859112", "0.68466544", "0.6816143", "0.67380804", "0.6710139", "0.67076135", "0.67008674", "0.66853523", "0.6663039", "0.665792", "0.66404635", "0.662968", "0.66266966", "0.6580532", "0.65176105", "0.650775...
0.88123256
0
checks if current team is the white team
def white_turn? true if @current_team == @teams[:white] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def black_turn?\n true if @current_team == @teams[:black]\n end", "def white_turn\n @teams[:white].current_team = true\n @teams[:black].current_team = false\n @current_team = @teams[:white]\n end", "def on_a_team?\n !team.nil?\n end", "def winning_team\n blue_team.winner? ? blue_team : r...
[ "0.7679898", "0.7458442", "0.7320971", "0.7111919", "0.6947026", "0.6898112", "0.653822", "0.64668375", "0.64398754", "0.64319265", "0.6399491", "0.6345147", "0.6339268", "0.6298339", "0.6244094", "0.62206703", "0.6218677", "0.6209473", "0.61906946", "0.6176197", "0.61636287"...
0.8517023
0
checks if current team is the black team
def black_turn? true if @current_team == @teams[:black] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def white_turn?\n true if @current_team == @teams[:white]\n end", "def black_turn\n @teams[:white].current_team = false\n @teams[:black].current_team = true\n @current_team = @teams[:black]\n end", "def winning_team\n blue_team.winner? ? blue_team : red_team\n end", "def white_turn\n @te...
[ "0.823477", "0.7691264", "0.7406411", "0.720812", "0.71724385", "0.67807555", "0.6616099", "0.6440831", "0.6403774", "0.6387835", "0.6379802", "0.63382465", "0.6326346", "0.62829787", "0.6236307", "0.62297404", "0.6190614", "0.61768985", "0.61674434", "0.61659515", "0.6154591...
0.86234045
0
prints the whole title card
def print_title type("ZJCRUMPTON PRESENTS:".green.to_s, 'mid') print " #{"______ _ _ ______ __ _ | | | \\ | | | | | | | \\ \\ \\ | | | |__| | | | | | | |--| < \\_\\_| | |_| \\_\\ \\_|__|_| |_|__|_/ ____|_|".red} #{"______ _ _ ______ ______ ______ | | | | | | | | / | / | | | | |--| | | |---- '------. '------. |_|____ |_| |_| |_|____ ____|_/ ____|_/".blue} \n\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output_header\n puts\n puts '-' * @title.length\n puts @title\n puts '-' * @title.length\n end", "def header(title)\n \n clear = %x[clear]\n puts clear\n \n puts \" +++++++++++ +++++++++ ++++ \" \n puts \" +++++++++++++ +++++++++ +++ \" ...
[ "0.75152266", "0.7431166", "0.7299669", "0.72499454", "0.71702313", "0.7147426", "0.69500446", "0.6947994", "0.69450665", "0.69450665", "0.69419897", "0.6927492", "0.6898638", "0.68889666", "0.6852403", "0.68488425", "0.6846808", "0.68450254", "0.6816344", "0.68133485", "0.68...
0.7405994
2
prints out options for the selected menu menu is based on passed argument
def print_options(type) case type when 'start_menu' type("Enter 1 to start a new game.\n".green) type("Enter 2 to load your saved game.\n\n\n".green) entry_prompt when 'player_prompt' puts "Enter coordinates (IE: a2) to select a piece.".green puts "Enter 1 to save you game.".green entry_prompt when 'move' puts "Enter coordinates (IE: a4) to select a location.".green puts "Enter 1 to choose a different piece.".green entry_prompt end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_menu_options\n\t\tputs \"----------------------------------------------\"\n\t\tputs \"1) Rename List | 2) Add task \"\n\t\tputs \"3) Complete task | 4) Uncomplete task\"\n\t\tputs \"5) Prioritize task | 6) Normalize task \"\n \t\tputs \"7) Add due date | 8) Remove du...
[ "0.8086756", "0.7571654", "0.7537273", "0.75360084", "0.74403065", "0.74229956", "0.7395799", "0.73605067", "0.73448855", "0.731715", "0.72387993", "0.72275", "0.71899825", "0.71456546", "0.7144825", "0.7079102", "0.7078504", "0.70533216", "0.7033972", "0.70147014", "0.700728...
0.6628538
69
takes user on the correct path from the start menu, either creating a new game or loading the save
def start_choice(choice) case choice when 1 type("You chose: NEW GAME\n\n".green) new_game when 2 type("You chose: LOAD GAME\n\n".green) load_game else invalid_input('input') entry_prompt start_choice(ask_for_number) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_game\n puts \"What would you like to do?\"\n puts \"1. Load Saved Game\"\n puts \"2. Start New Game\"\n choice = gets.chomp\n if choice == \"1\"\n find_save_file\n elsif choice == \"2\"\n initialize\n end\n end", "def start_game\n puts \"What would you like to do?\"\n...
[ "0.7561683", "0.7561683", "0.7259585", "0.71107835", "0.6923952", "0.6922696", "0.6840612", "0.6759774", "0.67512", "0.67370814", "0.67172956", "0.6676852", "0.6671335", "0.6617036", "0.6562885", "0.65599334", "0.65365535", "0.6497006", "0.64828974", "0.6427041", "0.6387832",...
0.56858957
77
asks player to provide a name for the white team's player
def name_white_player type("#{'Player for:'.green} #{'white team'.white} #{'- enter your name: '.yellow}") @teams[:white].name = gets.chomp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_player_name(name)\n return prompt(\"Player Name? [Player #{name}]\",\"Player #{name}\")\n end", "def name_black_player\n type(\"#{'Player for:'.green} #{'black team'.white} #{'- enter your name: '.yellow}\")\n @teams[:black].name = gets.chomp\n end", "def get_player_name\n if players[1].n...
[ "0.7841373", "0.7685846", "0.75718534", "0.74505967", "0.73689705", "0.733976", "0.72677356", "0.7258602", "0.7251143", "0.7227337", "0.72045404", "0.7184797", "0.714564", "0.7140495", "0.7118671", "0.7095617", "0.7085659", "0.7066632", "0.706005", "0.7058461", "0.70332205", ...
0.81149286
0
asks player to provide a name for the black team's player
def name_black_player type("#{'Player for:'.green} #{'black team'.white} #{'- enter your name: '.yellow}") @teams[:black].name = gets.chomp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name_white_player\n type(\"#{'Player for:'.green} #{'white team'.white} #{'- enter your name: '.yellow}\")\n @teams[:white].name = gets.chomp\n end", "def get_player_name(name)\n return prompt(\"Player Name? [Player #{name}]\",\"Player #{name}\")\n end", "def get_player_name\n if players[1].n...
[ "0.7976827", "0.77216154", "0.7685963", "0.7478291", "0.72917277", "0.71783555", "0.7170644", "0.70881927", "0.7078855", "0.70709294", "0.7064926", "0.70583886", "0.7058246", "0.7038369", "0.7034805", "0.70071954", "0.699217", "0.69879866", "0.69713825", "0.6967278", "0.69668...
0.8150292
0
prompts user for input then converts it to a number
def ask_for_number gets.chomp.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_number(prompt)\n\tprint prompt\n\tgets.to_f #allow decimal input\nend", "def input_to_num\n @input = @input.to_i\n end", "def do_input\n prompted, item = input_prompt\n print '? ' unless prompted\n val = $stdin.gets.chomp\n\n # All digits (and decimal point)\n val = (val.include?('...
[ "0.79354733", "0.7447985", "0.74178916", "0.7247312", "0.72462624", "0.723891", "0.7220596", "0.71920496", "0.71566695", "0.71538204", "0.711922", "0.7072901", "0.7053107", "0.70156616", "0.7009074", "0.6980639", "0.6974647", "0.6909604", "0.69037", "0.68984914", "0.6867887",...
0.76948416
1
prints crowns for a loading animation
def loading_animation type("#{@teams[:white].symbols[:King]}\n#{@teams[:black].symbols[:King]}\n#{@teams[:white].symbols[:King]}\n#{@teams[:black].symbols[:King]}\n\n") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loading_bar\n loading_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n 1.upto(loading_array.length.to_i) do |i|\n printf(\"\\rCycles Complete: %d\", i)\n sleep(0.1)\n end\n end", "def loading (program = \"Name encoder\", i = 0)\n puts \"#{program} initialized\"\n sleep(0.25)\n ...
[ "0.7034363", "0.6489571", "0.6380736", "0.6248727", "0.6233712", "0.61804855", "0.61020976", "0.6099028", "0.60933155", "0.6039089", "0.59984004", "0.57841974", "0.574408", "0.57373136", "0.57229024", "0.57016784", "0.56791013", "0.5661128", "0.5657017", "0.5616773", "0.55946...
0.7288459
0
tells the user who's turn it is
def your_turn type("#{"It's".green} #{@current_team.name.white}#{'\'s turn:'.green}\n\n\n") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def turn\n puts \"Turn #{@board.count_turn + 1}, player #{get_current_player.name} choose:\"\n @board.play_turn\n end", "def determine_turn\n @player = if @player1_turn\n puts \"It is #{@player1}'s turn\"\n \"X\"\n\n else\n puts \"It is #{@playe...
[ "0.7293138", "0.7069228", "0.69367814", "0.6893225", "0.6786929", "0.6741196", "0.6717709", "0.67038614", "0.6686439", "0.6682928", "0.66309863", "0.6618814", "0.6612355", "0.65727437", "0.6546621", "0.65449727", "0.6539463", "0.6527754", "0.65038425", "0.6489009", "0.6467209...
0.70177025
2
standard prompt displayed before user is allowed to interact with the program
def entry_prompt type('Type your choice here, then press enter: '.yellow) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prompt; end", "def prompt; end", "def prompt; end", "def prompt; end", "def prompt\n print \">> \"\nend", "def prompt\n print '> '\n $stdout.flush\nend", "def prompt\n\tputs \"Any Key to continue\"\n\tgets\nend", "def prompt\n unless interactive?\n raise Inspec::UserInteractionRequi...
[ "0.7931703", "0.7931703", "0.7931703", "0.7931703", "0.74359477", "0.7339464", "0.7337837", "0.732908", "0.72860837", "0.7279361", "0.7258893", "0.7256837", "0.7230861", "0.7230861", "0.7230861", "0.7206102", "0.71710736", "0.7152717", "0.71520615", "0.71324414", "0.7127651",...
0.0
-1
send out email once user fills out form def deliver_email(entry) redirect_to entries_path end
def load_entry @entry = Entry.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_new_entry(entry, current_user)\n @greeting = \"Hi\"\n #@current_user = current_user.entries\n @entry = entry\n\n mail to: 'adam.overstreet@gmail.com',\n \t\tfrom: current_user.email,\n \t\tsubject: 'Door-to-Door Donations Confirmation'\n end", "def emailform\n end", "def emailform\...
[ "0.7018109", "0.6862234", "0.6862234", "0.6681052", "0.6518459", "0.6515272", "0.644318", "0.6377006", "0.6328698", "0.62924546", "0.6255402", "0.62415856", "0.62410694", "0.622213", "0.62168264", "0.6213351", "0.61861646", "0.6169801", "0.61522526", "0.6140186", "0.6109013",...
0.0
-1
require that they have an entry and get these attributes
def entry_params params.require('entry').permit(:name_item, :description_item, :category, :pickup_date, :pickup_time, :street1, :street2, :city, :state, :zipcode, :phone ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entries_attributes\n entries.map(&:attributes)\n end", "def attributes\n data.require(:attributes)\n end", "def __read_info_entry(entries)\n info_entry = entries.detect do |entry|\n entry[:chunks] == ['info']\n end\n info_entry ||= {}\n # if there is an info entry, remove...
[ "0.6898217", "0.66999704", "0.64629275", "0.62694097", "0.61796945", "0.6117739", "0.610731", "0.60681206", "0.6053503", "0.604108", "0.6039463", "0.6023326", "0.60130346", "0.59392095", "0.59392095", "0.59392095", "0.59392095", "0.59392095", "0.59392095", "0.59392095", "0.59...
0.0
-1
Called on export start
def start_export( img_width, img_height) @width ||= img_width # If they be nil @height ||= img_height x_factor, y_factor = (@width / img_width.to_f), (@height / img_height.to_f) @stash = @exporter @exporter = Tracksperanto::Tool::Scaler.new(@exporter, :x_factor => x_factor, :y_factor => y_factor) super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_export\n end", "def before_export2engine\n \n end", "def export\n\n end", "def export\n\n end", "def set_export_status\n update_status(:export)\n end", "def post_import\n end", "def run_export\n fail \"No conference found!\" if @conference.nil?\n\n @asset_paths = []\...
[ "0.7913466", "0.74271977", "0.7082675", "0.70427144", "0.70306766", "0.6830993", "0.6402314", "0.63280755", "0.63095737", "0.63095737", "0.62900174", "0.62900174", "0.62624353", "0.613888", "0.6082638", "0.605597", "0.5904745", "0.58607775", "0.58607775", "0.58607775", "0.586...
0.5729845
30
Never trust parameters from the scary internet, only allow the white list through.
def subscriber_params params.require(:subscriber).permit(:firstname, :email) 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
This is only a basic validation of a BIC
def valid?(bic) return false unless bic.size == 8 || bic.size == 11 # length 8 or 11 return false unless (bic[0..3] =~ /[^A-Z]/).nil? # first 4 must be letters only COUNTRY_CODES.include?(bic[4..5]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_acc(acc, bik)\n # Для проверки контрольной суммы перед расчётным счётом\n # добавляются три последние цифры БИКа банка.\n acc = bik[-3..-1] + acc\n\n # Вычисляется контрольная сумма со следующими весовыми\n # коэффициентами: (7,1,3,7,1,3,7,1,3,7,1,3,7,1,3,7,1,3,7,1,3...
[ "0.6070559", "0.59488624", "0.5935295", "0.5749316", "0.5743318", "0.5737688", "0.5688212", "0.5688212", "0.5688212", "0.5688212", "0.5688212", "0.56878626", "0.56273943", "0.56056", "0.56056", "0.55973166", "0.55647933", "0.55496603", "0.55394304", "0.5527554", "0.54917777",...
0.57709324
3
If title changes tell friendly_id to regenerate slug when saving record
def should_generate_new_friendly_id? changes.keys.include?("title") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_save\n if !new? && (title = fields[title_field_name])\n set_slug_from_title(title)\n end\n fix_generated_slug_conflicts if changed_columns.include?(:slug)\n super\n end", "def should_generate_new_friendly_id?\n title_changed?\n end", "def should_generate_new_friendl...
[ "0.8270145", "0.78085434", "0.78085434", "0.78085434", "0.78085434", "0.7742754", "0.76930267", "0.7683458", "0.7629472", "0.7613564", "0.7602356", "0.75667655", "0.7566078", "0.7513961", "0.7496648", "0.74631554", "0.74624467", "0.7449101", "0.7424003", "0.7373639", "0.73035...
0.7050214
32
If title changes tell friendly_id to regenerate slug when saving record
def should_generate_new_friendly_id? title_changed? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_save\n if !new? && (title = fields[title_field_name])\n set_slug_from_title(title)\n end\n fix_generated_slug_conflicts if changed_columns.include?(:slug)\n super\n end", "def should_generate_new_friendly_id?\n title_changed?\n end", "def should_generate_new_friendl...
[ "0.8270574", "0.78080547", "0.78080547", "0.78080547", "0.78080547", "0.77433854", "0.7692604", "0.76843226", "0.763033", "0.7613728", "0.76019615", "0.75665337", "0.7566487", "0.7513577", "0.7497538", "0.7463252", "0.7450088", "0.7424881", "0.7374714", "0.7303831", "0.730383...
0.74628216
16
Helps to resolve the situation where you have a path and an id and if the path is unfriendly then a different finder method is required than find_by_path.
def find_by_path_or_id(path, id) Categories::Finder.by_path_or_id(path, id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_by_path_or_id(path, id)\n Pages::Finder.by_path_or_id(path, id)\n end", "def find_by_path_or_id!(path, id)\n page = find_by_path_or_id(path, id)\n\n raise ::ActiveRecord::RecordNotFound unless page\n\n page\n end", "def get(path_or_id, *args)\n if path_or_i...
[ "0.7010804", "0.67969805", "0.6516029", "0.6424654", "0.6077647", "0.6077647", "0.5883441", "0.58255064", "0.5807146", "0.5801758", "0.5780469", "0.5729827", "0.5691598", "0.56877965", "0.5673709", "0.56637156", "0.56542814", "0.5649295", "0.563974", "0.55861425", "0.5569104"...
0.66693527
2
Helps to resolve the situation where you have a path and an id and if the path is unfriendly then a different finder method is required than find_by_path. raise ActiveRecord::RecordNotFound if not found.
def find_by_path_or_id!(path, id) category = find_by_path_or_id(path, id) raise ActiveRecord::RecordNotFound unless category category end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_by_path_or_id!(path, id)\n page = find_by_path_or_id(path, id)\n\n raise ::ActiveRecord::RecordNotFound unless page\n\n page\n end", "def find_by_path_or_id(path, id)\n Pages::Finder.by_path_or_id(path, id)\n end", "def find_by_path_or_id(path, id)\n Cate...
[ "0.7402342", "0.7030801", "0.65411705", "0.6437763", "0.6415991", "0.6326213", "0.6297448", "0.6234611", "0.6229724", "0.61817074", "0.6139166", "0.5914113", "0.58958876", "0.58629984", "0.58199626", "0.57827884", "0.5774697", "0.57661474", "0.5757639", "0.57403", "0.57242286...
0.6504644
4
Finds pages by their title. This method is necessary because pages are translated which means the title attribute does not exist on the pages table thus requiring us to find the attribute on the translations table and then join to the pages table again to return the associated record.
def by_title(title) Categories::Finder.by_title(title) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def by_title(title)\n Pages::Finder.by_title(title)\n end", "def find_by_title(*opts)\n find_by_titles(opts).pages.first\n end", "def find_page(title, options = {})\n @page_found_with_redirect = false\n title = start_page if title.blank?\n title = Wiki.titleize(title)\n page = pages...
[ "0.74127746", "0.72449136", "0.6858551", "0.6841288", "0.62851214", "0.61950666", "0.60407317", "0.60100716", "0.5981598", "0.5890943", "0.5885435", "0.5831959", "0.5794474", "0.57694584", "0.5764155", "0.5748347", "0.57030624", "0.56478727", "0.5643043", "0.559194", "0.55891...
0.56567144
17
Finds pages by their slug. This method is necessary because pages are translated which means the slug attribute does not exist on the pages table thus requiring us to find the attribute on the translations table and then join to the pages table again to return the associated record.
def by_slug(slug, conditions = {}) Categories::Finder.by_slug(slug, conditions) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def by_slug(slug, conditions = {})\n Pages::Finder.by_slug(slug, conditions)\n end", "def page(slug_id)\n\t\treturn self.pages.where(:slug => slug_id).first\n\tend", "def get_by_slug(slug)\n record = @dao.search({ 'slug' => slug }, { limit: 1 })\n translate(record)\n end", "def set_p...
[ "0.72655594", "0.6728623", "0.6090306", "0.57884264", "0.5647794", "0.55431396", "0.5487454", "0.5477305", "0.54729474", "0.54266894", "0.5300549", "0.5154568", "0.51424354", "0.51394117", "0.5135318", "0.51204145", "0.5111836", "0.5111836", "0.5101385", "0.50882727", "0.5078...
0.55978817
5
Wrap up the logic of finding the pages based on the translations table.
def with_globalize(conditions = {}) Categories::Finder.with_globalize(conditions) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index_page_languages\n ids = connection.select_values %{select distinct language_id from contents where related_object_id = #{id} AND related_object_type = '#{toplevel_class.name}' AND data is not null AND data != '' AND ((type = 'Page' AND page_name = 'index') OR type = 'Abstract')}\n Language.find(ids)...
[ "0.6509702", "0.6387379", "0.611204", "0.6003661", "0.5945044", "0.5891134", "0.5833077", "0.57863873", "0.57089865", "0.5664054", "0.5643008", "0.5639391", "0.5639275", "0.5637722", "0.5631671", "0.5627686", "0.5591971", "0.5586563", "0.55804193", "0.55615973", "0.5557613", ...
0.0
-1
Returns the string version of nested_url, i.e., the path that should be generated by the router
def nested_path ['', nested_url].join('/') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nested_path\n ['', nested_url].join('/')\n end", "def to_s\n if nesting\n to_relative_path\n elsif local\n to_local_path\n else\n to_absolute_path\n end\n end", "def url\n URI.parse(endpoint).join(path.to_s).to_s\n end", "def to_s\n @pa...
[ "0.8501492", "0.6797978", "0.67935026", "0.676538", "0.6731034", "0.67275995", "0.67275995", "0.6725167", "0.67167974", "0.6693856", "0.6592472", "0.6573296", "0.6471564", "0.6427111", "0.6423839", "0.6401004", "0.63846934", "0.6367828", "0.63487196", "0.63461053", "0.6296845...
0.85820824
1
4 tipos: globales, locales, instancia, clase LOCALES: una variable definida dentro de un metodo no puede ser accedida fuera del metodo. a las reglas desde donde puede ser accedida una variable se le denomina ALCANCE.
def aprobado?(nota1, nota2) promedio = (nota1 + nota2)/2 promedio >= 5? true : false #IF ternario end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_variables\n @countries = Country.sorted\n @time_periods = TimePeriod.sorted\n\n @locales = []\n I18n.available_locales.sort.each do |locale|\n @locales << [I18n.t(\"shared.locale.long.#{locale}\"), locale]\n end\n end", "def locale=(_arg0); end", "def frecuencia_pago_...
[ "0.6444349", "0.59278935", "0.5847936", "0.56842685", "0.56842685", "0.56842685", "0.56842685", "0.56842685", "0.56842685", "0.56842685", "0.55617034", "0.5546351", "0.5520011", "0.5493388", "0.5479532", "0.54776317", "0.5467338", "0.5414287", "0.53982353", "0.53940725", "0.5...
0.0
-1
creates a notification + comment_statuses
def perform return unless users_to_notify.present? CommentStatus.transaction do users_to_notify.each do |u| CommentStatus.create!(comment_id: @comment.id, user_id: u.id) end Notification.create!(comment_id: @comment.id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_notification\n Notification.create(\n notifiable_id: self.post.id, notifiable_type: 'Post', \n notification_type: 'Comment', source_user_id: self.user_id, target_user_hash: {},\n target_user_ids: [self.owner.id] , seen: false, custom_text: self.con...
[ "0.68467206", "0.6207711", "0.61797094", "0.61797094", "0.61674386", "0.60964376", "0.6063063", "0.600798", "0.5902683", "0.5902683", "0.58674616", "0.5849185", "0.58415586", "0.5831072", "0.579814", "0.5797185", "0.5778326", "0.5735482", "0.57185215", "0.5699202", "0.5697608...
0.64507896
1
This is turned off until/unless we decide to offer advanced search to the public (unlikely).
def advanced_search raise ActionController::RoutingError.new('Not Found') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def include_global_search\n true\n end", "def search; end", "def show_super_search_links_on_index\n false \n end", "def search_time_limit\n super\n end", "def has_simple_search?\n self.search_type.to_s == \"simple\" && !self.is_static?\n end", "def override_search?(searc...
[ "0.7372237", "0.67446774", "0.66027445", "0.6446811", "0.64158607", "0.6337546", "0.6337546", "0.63221264", "0.62880236", "0.6275247", "0.62426794", "0.62422043", "0.6216111", "0.6206002", "0.61991364", "0.6181739", "0.61645275", "0.61512995", "0.61479735", "0.61443883", "0.6...
0.5883572
48
This functionality is disabled: config.autocomplete_enabled above is set to false, and in addition, SOLR's suggester response is turned off anyway. ( See blacklight/app/models/concerns/blacklight/suggest/response.rb ) Let's explicitly turn off this method: that way, if you request /catalog/suggest.json?q=SOME_SEACH_STRING you'll get a 404 instead of bogus empty results.
def suggest raise ActionController::RoutingError.new('Not Found') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suggestions\n response.try(:[], \"suggest\").try(:[], @suggest_key).try(:[], request_params[:q]).try(:[], \"suggestions\") || []\n end", "def suggest\n @suggestions = suggestions_service.suggestions\n render 'suggest', layout: false\n end", "def autocomplete_suggesters!(config)\n co...
[ "0.6990364", "0.68997014", "0.6787475", "0.6687125", "0.6641864", "0.6639829", "0.65595233", "0.6551084", "0.6527991", "0.6514366", "0.65140486", "0.6460107", "0.63800925", "0.6294778", "0.6224753", "0.6203179", "0.6192876", "0.61767226", "0.61521167", "0.60931534", "0.604018...
0.5904526
25
Tell Blacklight to include things in context, that will become available to our custom SearchBuilder extensions
def search_service_context { current_user: current_user } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_context\n builder = Builder.new(view_context)\n\n builder.with_snippet(@snippet) if @snippet.present?\n @snippets.each(&builder.method(:with_snippet)) if @snippets.present?\n builder.with_project(@project) if @project.present? && @project.persisted?\n builder.with_grou...
[ "0.741506", "0.6702789", "0.6702789", "0.6702789", "0.6455106", "0.6304227", "0.61342394", "0.60851127", "0.6073062", "0.60352755", "0.60352755", "0.60352755", "0.60352755", "0.60352755", "0.60352755", "0.60352755", "0.60352755", "0.60352755", "0.60352755", "0.60352755", "0.6...
0.6353833
5
What ViewComponent class to use for a given search result on the results screen, for Work or Collection. Called by _document_list.
def view_component_class_for(model) if model.kind_of?(Work) SearchResult::WorkComponent elsif model.kind_of?(Collection) SearchResult::CollectionComponent else raise ArgumentError.new("Don't know proper search results ViewModel class for #{model}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_results_collection_tools(wrapping_class: \"search-widgets\", component: Blacklight::Document::ActionsComponent)\n actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, {}).map { |_k, v| v }\n\n render(component.new(actions: actions, classes: wrap...
[ "0.6049012", "0.6028257", "0.5949914", "0.59476817", "0.5845456", "0.58427614", "0.5821559", "0.57216334", "0.5706465", "0.5693133", "0.5617881", "0.5602988", "0.55851245", "0.5581241", "0.55793196", "0.55719703", "0.5528082", "0.54995227", "0.54995227", "0.547866", "0.547206...
0.80385005
0
Some bad actors sometimes send query params that Blacklight doesn't expect and can't handle. They look like they are scanning for vulnerabilities which don't apply to us and it's fine that they get an error, but let's avoid them resulting in uncaught exceptions reported in our error tracker, while giving a nice error response. We use `respond_to?(:to_hash)` to try to allow either Hash or ActionController::Params, since it seems like in specs it can be straight Hash and this is a weird implementation detail. A render in a before_action will halt further processing, as intended.
def catch_bad_blacklight_params # Lazily doing errmsg formatting as an inline proc, to avoid having to make another method. # We want to try to output useful error message, but sometimes that raises too. param_display = lambda do |param_hash| begin "Invalid URL query parameter f=#{param_hash.to_unsafe_h.to_param}" rescue StandardError "Invalid URL query parameter f=#{param_hash.to_s}" end end # someone trying to do an injection attack in the `page` param somehow # triggered a Solr 400, let's nip it in the bud. if params[:page].present? && params[:page] !~ /\A\d+\Z/ render(plain: "illegal page query parameter", status: 400) && return end # Correct range facets look like: # params[:range] == {"year_facet_isim"=>{"begin"=>"1900", "end"=>"1950"}} # &range%5Byear_facet_isim%5D%5Bbegin%5D=1900&range%5Byear_facet_isim%5D%5Bend%5D=1950 # # Can also be empty string values in there. # # Make sure it has that shape, or just abort, becuase it is likely to make blacklight_range_limit # choke and uncaught exception 500. # # Additionally, newlines and other things that aren't just integers can cause an error too, # just insist on \d+ or empty string only. # # We do allow one exception through: the URL `blacklight_range_limit` uses # to display a link to a search for records with no dates. if params[:range].present? unless params[:range].respond_to?(:to_hash) render(plain: "Invalid URL query parameter range=#{param_display.call(params[:range])}", status: 400) && return end params[:range].each_pair do |_facet_key, range_limits| # Workaround for issue https://github.com/sciencehistory/scihist_digicoll/issues/2231 # # `blacklight_range_limit` can show a "date missing" search link, # which adds an extra pair of range parameters: # range[-year_facet_isim][]=[* TO *] # This would normally trigger our "Invalid URL query parameter" error below, # but we choose to let it through in this one particular case. next if _facet_key == "-year_facet_isim" && range_limits == ["[* TO *]"] unless range_limits.respond_to?(:to_hash) && range_limits[:begin].is_a?(String) && range_limits[:end].is_a?(String) && range_limits[:begin] =~ /\A\d*\z/ && range_limits[:end] =~ /\A\d*\z/ render(plain: "Invalid URL query parameter range=#{param_display.call(params[:range])}", status: 400) && return end end end # facet param :f is a hash of keys and values, where each key is a facet name, and # each value is an *array* of strings. Anything else, we should reject it as no good, # because Blacklight is likely to raise an uncaught exception over it. # # eg &f=expect%3A%2F%2Fdir if params[:f].present? if !params[:f].respond_to?(:to_hash) render(plain: "Invalid URL query parameter f=#{param_display.call(params[:f])}", status: 400) && return end params[:f].each do |facet, value| unless facet.is_a?(String) render(plain: "Invalid URL query parameter f=#{param_display.call(params[:f])}", status: 400) && return end unless value.is_a?(Array) && value.all? {|v| v.is_a?(String)} render(plain: "Invalid URL query parameter f=#{param_display.call(params[:f])}", status: 400) && return end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GET\r\n@env[\"action_dispatch.request.query_parameters\"] ||= (normalize_encode_params(super) || {})\r\nrescue TypeError => e\r\nraise ActionController::BadRequest.new(:query, e)\r\nend", "def handle_query_param\n if params[:query].is_a? ActionController::Parameters \n params[:query].permit!\n p...
[ "0.68545526", "0.6830921", "0.6184292", "0.6106494", "0.60724795", "0.59913003", "0.59117275", "0.5890649", "0.58670557", "0.58604336", "0.58538365", "0.5811976", "0.5784461", "0.5782825", "0.5782825", "0.5780162", "0.5773766", "0.5772345", "0.5772345", "0.5772345", "0.577234...
0.65410197
2
Out of the box, Blacklight allows for search results to be requested as (and served as) JSON. That feature is not working, and we have no plans to fix it, but as a courtesy (and to avoid noisy 500 errors) we're providing an actual 406 error message, consistent with the behavior on other controllers on our app that don't handle JSON requests. See discussion at:
def catch_bad_request_headers if request.headers["accept"] == "application/json" render plain: "Invalid request header: we do not provide a JSON version of our search results.", status: 406 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def catch_bad_format_param\n if ['json', 'rss'].include? params[:format]\n render plain: \"Invalid parameter: we do not provide search results in #{params[:format]} format.\", status: 406\n end\n end", "def show406\n render '406', status: :not_acceptable\n end", "def not_found\n re...
[ "0.6316472", "0.6307616", "0.62752247", "0.614949", "0.61204207", "0.61014736", "0.6080683", "0.6070007", "0.60551864", "0.60207903", "0.6013586", "0.60132843", "0.6004552", "0.6001601", "0.60007846", "0.59693563", "0.5924968", "0.592445", "0.5920825", "0.59111255", "0.589400...
0.7277446
0
Trigger this by requesting e.g. /catalog.rss /focus/alchemy.json See
def catch_bad_format_param if ['json', 'rss'].include? params[:format] render plain: "Invalid parameter: we do not provide search results in #{params[:format]} format.", status: 406 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feed\n end", "def feed\n\n end", "def index\n #body, ok = SuperfeedrEngine::Engine.retrieve(Feed.first) \n @entries = Entry.all\n end", "def on_request_uri(cli, request)\r\n print_status(\"Request: #{request.uri}\")\r\n if request.uri =~ /#{Regexp.escape(get_resource)}/\r\n print_stat...
[ "0.61097914", "0.6086256", "0.5738352", "0.55961275", "0.5526059", "0.55047005", "0.54613465", "0.54613465", "0.54613465", "0.54613465", "0.54613465", "0.54613465", "0.54613465", "0.54613465", "0.54613465", "0.54613465", "0.54613465", "0.54577065", "0.5400775", "0.53921944", ...
0.0
-1
When posting on facebook, it modifies our facet params from eg `?f[facet_name][]=value` to `?f[facet_name][0]=value`. This breaks blacklight. We fix and REDIRECT to fixed URL, to maintain having one canonical URL. Future versions of Blacklight may accomodate these malformed URLs through an alternate strategy and not need this redirect:
def redirect_hash_facet_params if params[:f].respond_to?(:transform_values) && params[:f].values.any? { |x| x.is_a?(Hash) } original_f_params = params[:f].to_unsafe_h corrected_params = {} corrected_params[:f] = original_f_params.transform_values do |value| value.is_a?(Hash) ? value.values : value end redirect_to helpers.safe_params_merge_url(corrected_params), :status => :moved_permanently end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_facet_params_and_redirect(field, value)\n new_params = add_facet_params(field, value)\n\n # Delete page, if needed. \n new_params.delete(:page)\n\n # Delete any request params from facet-specific action, needed\n # to redir to index action properly. \n Blacklight::Solr::FacetPaginator.req...
[ "0.6597839", "0.61600626", "0.5983686", "0.59667385", "0.5894803", "0.5764789", "0.56793076", "0.5593688", "0.5541853", "0.55159456", "0.5482273", "0.5435406", "0.5435406", "0.5420292", "0.5414121", "0.53986186", "0.53986186", "0.53986186", "0.5362653", "0.5322507", "0.531094...
0.6758074
0
Things that used to be facets or similar, but no longer are. Bit of a mess to change the Rails params safely.
def redirect_legacy_filter_params if params[:filter_public_domain].present? && params[:filter_public_domain] != "0" new_params = params.to_unsafe_h.deep_dup new_params.delete(:filter_public_domain) new_params[:f] ||= {} new_params[:f][:rights_facet] ||= {} new_params[:f][:rights_facet] = ["http://creativecommons.org/publicdomain/mark/1.0/"] # for safety, run through url_for with only_path redirect_to url_for(new_params.merge(only_path: true)), :status => :moved_permanently elsif params[:filter_copyright_free].present? && params[:filter_copyright_free] != "0" new_params = params.to_unsafe_h.deep_dup new_params.delete(:filter_copyright_free) new_params[:f] ||= {} new_params[:f][:rights_facet] ||= {} new_params[:f][:rights_facet] = ["Copyright Free"] # for safety, run through url_for with only_path redirect_to url_for(new_params.merge(only_path: true)), :status => :moved_permanently end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unsolved_params\n \n end", "def remove_facet_params(field, value, source_params=params)\n p = source_params.dup.symbolize_keys!\n # need to dup the facet values too,\n # if the values aren't dup'd, then the values\n # from the session will get remove in the show view...\n p[:f] = p[:f]....
[ "0.6880927", "0.67956334", "0.6627959", "0.6559112", "0.6556066", "0.654813", "0.6525622", "0.6519538", "0.6478871", "0.6462421", "0.6386253", "0.6357795", "0.63335943", "0.6327476", "0.6319711", "0.63118684", "0.63026017", "0.6286804", "0.6279038", "0.6271891", "0.62667096",...
0.0
-1
If the user enters an impossible date range with begin after end, swap the dates by actually mutating `params` (ugly but it works), instead of letting blacklight_range_limit raise.
def swap_range_limit_params_if_needed return if params.empty? start_date = params.dig(:range, :year_facet_isim, :begin) end_date = params.dig(:range, :year_facet_isim, :end) return unless start_date.present? && end_date.present? return unless start_date.to_i > end_date.to_i params['range']['year_facet_isim']['begin'] = end_date params['range']['year_facet_isim']['end'] = start_date end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_ranges(params)\n @min = params.fetch(:min, 0).to_f\n @max = params.fetch(:max, 100).to_f\n end", "def url_params_for_date_range\n begin\n start_date = Date.parse(params[:start])\n end_date = Date.parse(params[:end])\n rescue ArgumentError\n halt 'Invalid date format'\n end\n\n...
[ "0.65653455", "0.65304583", "0.61185145", "0.6037472", "0.60222995", "0.60102487", "0.6000647", "0.59880525", "0.5901823", "0.58325684", "0.580983", "0.58074373", "0.575697", "0.5754871", "0.5749039", "0.5734671", "0.57266456", "0.57126504", "0.56980675", "0.56929153", "0.569...
0.81763536
0
When a user (in practice, a bot) makes a call directly to /catalog/range_limit rather than the usual /catalog?q=&range, this bypasses the preprocessing normally performed by the `before_action` methods for index, which supplies a range_start and range_end parameter and ensures they are in the correct order, then makes a second request to range_limit .
def screen_params_for_range_limit if (params['range_end'].nil?) || (params['range_start'].nil?) || (params['range_start'].to_i > params['range_end'].to_i) render plain: "Calls to range_limit should have a range_start " + "and a range_end parameter, and range_start " + "should be before range_end.", status: 406 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_range_limit_params(*args)\n super unless on_home_page?\n end", "def range_limit\n solr_field = params[:range_field] # what field to fetch for\n start = params[:range_start].to_i\n finish = params[:range_end].to_i\n \n solr_params = solr_search_params(params)\n \n # Remo...
[ "0.73316634", "0.717059", "0.6529967", "0.6487878", "0.62634", "0.6206942", "0.6187005", "0.6055564", "0.59447753", "0.59033775", "0.5870128", "0.58237725", "0.5768", "0.5762289", "0.57615197", "0.57615197", "0.57358295", "0.57005745", "0.56975573", "0.569432", "0.568755", ...
0.73529536
0
View a player's stats for a specific game.
def person_game_stats(person_id, **options) game = options.delete(:gamePk) || 'current' get("/people/#{person_id}/stats/game/#{game}", **options)['stats'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_stats_for_player(name, game)\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats] if player_hash[:player_name] == name\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats] if player_hash[:player_name] == name\n end\nend", "def show\n ...
[ "0.7151988", "0.71411294", "0.7071055", "0.69824773", "0.68097615", "0.67996347", "0.6783116", "0.6769052", "0.6734739", "0.67270786", "0.6707726", "0.6619218", "0.6614694", "0.66026956", "0.6597569", "0.6593359", "0.6577404", "0.6533824", "0.6533824", "0.6520714", "0.6513867...
0.7219573
0