query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Sets the gracePeriodInMinutes property value. The number of minutes to wait before restarting the device after an app installation.
def grace_period_in_minutes=(value) @grace_period_in_minutes = value end
[ "def grace_period_in_minutes\n return @grace_period_in_minutes\n end", "def grace_period\n @grace_period\n end", "def grace_period_hours=(value)\n @grace_period_hours = value\n end", "def settings_sleep_timeout_in_minutes=(value)\n @se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the restartNotificationSnoozeDurationInMinutes property value. The number of minutes to snooze the restart notification dialog when the snooze button is selected.
def restart_notification_snooze_duration_in_minutes return @restart_notification_snooze_duration_in_minutes end
[ "def restart_notification_snooze_duration_in_minutes=(value)\n @restart_notification_snooze_duration_in_minutes = value\n end", "def schedule_imminent_restart_warning_in_minutes\n return @schedule_imminent_restart_warning_in_minutes\n end", "def snooze_duratio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the restartNotificationSnoozeDurationInMinutes property value. The number of minutes to snooze the restart notification dialog when the snooze button is selected.
def restart_notification_snooze_duration_in_minutes=(value) @restart_notification_snooze_duration_in_minutes = value end
[ "def restart_notification_snooze_duration_in_minutes\n return @restart_notification_snooze_duration_in_minutes\n end", "def schedule_imminent_restart_warning_in_minutes=(value)\n @schedule_imminent_restart_warning_in_minutes = value\n end", "def restart_settin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Optionally produces a unique key to ensure uniqueness of this job. See the Generators module methods for example job_id generators you can use.
def create_job_id application_job_overrides_method!(__method__) # default implementation for framework jobs Generators.generate_uuid(self) end
[ "def unique_key\n @unique_key ||= section.identifier\n end", "def job_key(job)\n raise NotImplementedError.new(\"neither Collector.job_key() nor Job.key() are implemented\") unless job.respond_to?(:key)\n job.key()\n end", "def job_key\n Digest::MD5.hexdigest(path)\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new GetDecksResponse
def initialize(response) handle_errors(response) JSON.parse(response.body).each do |key, value| if key == 'decks' # Keep the API response count, it will differ when invalid decks are stripped @decks_count = value.size instance_variable_set( ...
[ "def decks(**args)\n decks_request(**args).decks\n end", "def get_new_deck\n HTTParty.get(\"https://deckofcardsapi.com/api/deck/#{@@deck_id}/shuffle/\")\n response = HTTParty.get(\"https://deckofcardsapi.com/api/deck/#{@@deck_id}/draw/?count=52\") # returns a hash of data\n cards = response[\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Validator for decks in decks
def decks_contains_valid_decks @decks.each do |deck| next if deck.is_a?(ZombieBattleground::Api::Models::Deck) && deck.valid? && deck.errors.size.zero? errors.add(:decks, 'decks must be an array of Deck') end end
[ "def remove_invalid_decks\n @decks.select! do |deck|\n deck.is_a?(ZombieBattleground::Api::Models::Deck) &&\n deck.valid? &&\n deck.errors.size.zero?\n end\n end", "def validate\n # valid if list of headers identical to list of drills and data items...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes invalid vards from deck
def remove_invalid_decks @decks.select! do |deck| deck.is_a?(ZombieBattleground::Api::Models::Deck) && deck.valid? && deck.errors.size.zero? end end
[ "def chosen_set_validity!(playing_cards)\n @set_found = is_a_set? @chosen_cards\n @chosen_cards.each {|card| playing_cards.delete card} if @set_found\n clean_slate # Clears player picks\n end", "def remove_invalid_cards\n @cards.select! do |card|\n card.is_a?(ZombieBattleground::Api:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Mock a crappy remote API call that could toss an exception on some upstream error. It also mocks a return value of ':pending' when it's not complete and returns ':happy' when it's complete.
def crappy_api_call $count += 1 # First two calls fail raise "OH SNAP" if $count < 3 # Next few calls say pending return :pending if $count < 5 # Then finally done return :happy end
[ "def crappy_api_call\n $count += 1\n\n # First two calls fail\n raise \"OH SNAP\" if $count < 3\n\n # Next few calls say pending\n return :pending if $count < 5\n\n # Then finally done\n return :happy if $count > 5\nend", "def test_api_bad_request\n mock_clients bad_req_code, bad_req_code\n\n assert_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Open the bookmarks and return an REXML::Document. If the cache option is provided, the document is loaded from the localpath specified.
def open require 'rexml/document' xml = if cache && File.exist?(cache) File.read(cache) else request :all end File.open(cache, 'wb') { |io| io.write(xml) } if cache REXML::Document.new(xml) end
[ "def open_with_cache(path)\n if @cache[path]\n if @verbose\n puts \"Opening cached contents of http://pollex.org.nz#{path} ...\"\n end\n @cache[path]\n else\n if @verbose\n puts \"Connecting to http://pollex.org.nz#{path} ...\"\n end\n page = Nok...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determine if any bookmarks have been updated since the time specified.
def updated_since?(time) time < last_updated_at end
[ "def fresh_at?(time)\n time >= updated_at\n end", "def content_changed_since?(last_updated)\n stale?(:last_modified => last_updated)\n end", "def updated_since?(timestamp)\n self.updated_at > timestamp\n end", "def up_to_date?\n updated_at > ( Time.now - outdated_after )\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Yield each bookmark to the block that requires synchronization. The :since option may be specified to indicate the time of the most recently updated bookmark. Only bookmarks whose time is more recent than the time specified are yielded.
def synchronize(options={}) if since = options[:since] since.utc return false unless updated_since?(since) else since = Time.at(0) since.utc end open.elements.each('posts/post') do |el| attributes = el.attributes time = Time.iso8601(attributes['tim...
[ "def each\n bookmark = @first\n while bookmark\n yield bookmark\n bookmark = bookmark.next_sibling\n end\n end", "def each_transaction_since(block)\n\t\t\tunless block.is_a?(Block)\n\t\t\t\tblock = get_block(block)\n\t\t\tend\n\n\t\t\tinfo = @j...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initializes all keys to `UNSET_VALUE`
def initialize super keys.each do |key| set(key, self.class::UNSET_VALUE) end end
[ "def unsets\n self[\"$unset\"] ||= {}\n end", "def reset_initial_values\n @initial_values.clear if @initial_values\n @missing_initial_values.clear if @missing_initial_values\n end", "def reset_values\n @field_names.each { |key|\n @fields[key].value = nil\n }\n end", "def r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a configuration line/stanza for the specified key and value. The returned line should include linefeed `\\n` if not empty. The default implementations returns "=\\n".
def config_for(key, value) "#{key}=#{value && value}\n" end
[ "def line_contents\n if value.kind_of?(Array)\n value.map { |v, i| \"#{key}#{@option_sep}#{v}\" }\n else\n \"#{key}#{@option_sep}#{value}\"\n end\n end", "def to_cookiestxt_line(linefeed = \"\\n\")\n [\n @domain,\n @for_domain ? True : False,\n @path,\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This gets a game cliche from a list of cliches in a text file
def get_game_cliche #initialize variable chosen_line = nil #Get the cliche File.foreach("game_cliches.txt").each_with_index do |line, number| chosen_line = line if rand < 1.0/(number+1) end return chosen_line.chomp end
[ "def readfile(filename, elf_attack = 3)\n max_x, max_y = readfile_coords(filename)\n grid = Array.new(max_x + 1) { Array.new(max_y + 1) }\n units = []\n unit_id = 0\n y = 0\n #File.readlines(filename).each do |line|\n lines.each do |line|\n x = 0\n line.chars.each do |c|\n if c == '#'\n gri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This gets a business model from a list in a text file
def get_business_model #initialize variable chosen_line = nil #Get the cliche File.foreach("business_models.txt").each_with_index do |line, number| chosen_line = line if rand < 1.0/(number+1) end return chosen_line.chomp end
[ "def load_file(f)\n all_orgs = []\n f.lines do |line|\n next unless f.lineno > 3\n org = Organism.new\n fields = line.split(\"\\s\")\n org.taxid = fields[0]\n org.lineage = fields[1]\n org.name = fields[2].gsub(/\"/,\"\")\n org.rank = fields[3]\n org.number = fields[4]\n all_orgs.push(o...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This gets a game genre from a list in a text file
def get_game_genre #initialize variable chosen_line = nil #Get the cliche File.foreach("game_genres.txt").each_with_index do |line, number| chosen_line = line if rand < 1.0/(number+1) end return chosen_line.chomp end
[ "def genres\n @genres ||= File.readlines(txt('genres')).map(&:strip)\nend", "def load_genre(file_name)\n\t\tindata = []\n\t\tCSV.foreach(\"#{file_name}\", col_sep: \"|\") do |row|\n\t\t\tgenre_for_movie = [row[5].to_i,row[6].to_i,row[7].to_i,row[8].to_i,row[9].to_i,row[10].to_i,row[11].to_i,row[12].to_i,row[13]....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The top left of checkerboard should always be filled with [r] You should assume the size input is always an integer You should not assume the size input is always positive number Input size of <= 0 will return an empty string
def checkerboard(size) for i in 1..size do i % 2 == 0 ? checker=0 : checker=1 for j in 1..size do if checker == 1 print "[r]" checker = 0 else print "[b]" checker = 1 end end puts "\n" end end
[ "def checkerboard(size)\n return \"\" if size <= 0\n completed_board = \"\"\n\n first_line = size.times do |n|\n if n.odd?\n completed_board << \"[r]\"\n else\n completed_board << \"[b]\"\n end\n end\n\n # binding.pry\nend", "def checker_board(size)\n\n size.times do |i|\n puts \"X \" *...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The number of alarms. Returns an Integer.
def count @alarms.objects.find { |o| o.name == "count" }.val end
[ "def alarms\n data[:alarms]\n end", "def count\n @monkeys.count\n end", "def alarms\n data.alarms\n end", "def aps_notification_count_for_application(application_name)\n redis.llen(aps_application_queue_key(application_name)).to_i\n end", "def amountOfNotifications\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Query alarms. options A Hash of options: :start A DateTime instance describing the earliest time to query history for. :end A DateTime instance describing the latest time to query history for.
def query options from = options.fetch :start to = options.fetch :end query = @alarms.objects.find { |o| o.name == "query" } filter = OBIX::Builder.new do obj do abstime name: "start", val: from.iso8601 abstime name: "end", val: to.iso8601 end end.ob...
[ "def query options\n from = options.fetch :start\n to = options.fetch :end\n\n query = @history.objects.find { |o| o.name == \"query\" }\n\n filter = OBIX::Builder.new do\n obj do\n abstime name: \"start\", val: from.iso8601\n abstime name: \"end\", val: to.iso8601\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the measure record associated with the device
def measure_for_device(device_id, measure_id) device = Device.where(:name => device_id) # use first on device to get record from association, then # use first again on measures to get measure record device.first.measures.where(:name => measure_id).first if device.any? end
[ "def definition\n if @sub_id\n QME::QualityMeasure.query_measures({'id' => @measure_id, 'sub_id' => @sub_id}, @bundle_id).first()\n else\n QME::QualityMeasure.query_measures({'id' => @measure_id}, @bundle_id).first()\n end\n end", "def measures\n instance.measures.values\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
write a function to search target in nums. If target exists, then return its index, otherwise return 1. Template 1 is the most basic and elementary form of Binary Search. It is the standard Binary Search Template that most high schools or universities use when they first teach students computer science. Template 1 is u...
def search(nums, target) left = 0 right = nums.length - 1 while left <= right pivot = left + (right - left) / 2 return pivot if nums[pivot] == target if target < nums[pivot] right = pivot - 1 else left = pivot + 1 end end -1 end
[ "def binary_search(arr, target, min_idx, max_idx)\n # Ensure valid arguments\n raise ArgumentError, \"The first argument must be an array.\" unless arr.is_a?(Array)\n raise ArgumentError, \"The array provided must contain all integer values.\" unless arr.all? {|el| el.is_a?(Integer)}\n raise ArgumentError, \"Th...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a handler to the reactor. A handler is a callable taking a single argument, the message.
def add_handler(handler) @handlers << handler end
[ "def add_message_handler(&block)\n @message_handlers << block\n end", "def on_message &handler\n\t\t@message_handlers << handler\n\tend", "def register_handler(handler)\n @handler = handler\n self\n end", "def register_handler(new_handler)\n @@handlers << new_handler\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /recovery_passwords GET /recovery_passwords.json
def index @recovery_passwords = RecoveryPassword.all end
[ "def index\n @passwords = application.passwords.all\n end", "def index\n @passwords = current_user.passwords\n end", "def password\n respond_to do |format|\n format.html\n format.json { render json: { :password => get_password } }\n end\n end", "def forgot_password\n user = validat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /recovery_passwords POST /recovery_passwords.json
def create @recovery_password = RecoveryPassword.new(recovery_password_params) respond_to do |format| if @recovery_password.save format.html { redirect_to @recovery_password, notice: 'Recovery password ha sido creado.' } format.json { render :show, status: :created, location: @recovery_pa...
[ "def generate_new_password_for_guest(args = {}) \n post(\"/guestaccess.json/#{args[:guestId]}/newpassword\", args)\nend", "def create\n @password = application.passwords.new(password_params)\n\n respond_to do |format|\n if @password.save\n format.html { redirect_to [application, @password], noti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /recovery_passwords/1 DELETE /recovery_passwords/1.json
def destroy @recovery_password.destroy respond_to do |format| format.html { redirect_to recovery_passwords_url, notice: 'Recovery password ha sido eliminado.' } format.json { head :no_content } end end
[ "def destroy\n @password.destroy\n respond_to do |format|\n format.html { redirect_to passwords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @password = password.find(params[:id])\n \n @password.destroy\n\n respond_to do |format|\n format.html { redire...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
== Constraints Chef libraries are evaluated before the recipe that places the chef_gem that it needs is put into place. This places two constraints on this library: 1) A 'require' must be done in a method 2) This class cannot use 'Subclass < Superclass' As Net::LDAP is a class it cannot be included as a module
def initialize require 'rubygems' require 'net-ldap' require 'cicphash' end
[ "def load_needed_dependencies!\n super\n if File.exist?(policyfile)\n debug(\"Policyfile found at #{policyfile}, using Policyfile to resolve dependencies\")\n Chef::Policyfile.load!(logger: logger)\n elsif File.exist?(berksfile)\n debug(\"Berksfile found at #{berksfil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
== Bind This method should not be used directly. It is used to bind to the directory server. The databag_name is the name of the databag that is used for looking up connection credentials. It returns a connected ruby Net::LDAP object
def bind( host, port, credentials, databag_name, use_tls ) # :yields: host, port, credentials, databag_name, use_tls credentials = credentials.kind_of?(Hash) ? credentials.to_hash : credentials.to_s unless databag_name.kind_of?(String) or databag_name.kind_of?(Symbol) raise "Invalid databag_name: ...
[ "def bind\n conn = Net::LDAP.new :host => @config[:server],\n :port => @config[:port],\n :base => @config[:base]\n if @config[:encryption]\n conn.encryption @config[:encryption]\n end\n \n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
== Search This method is used to search the directory server. It accepts the connection resource object described above along with the basedn to be searched. Optionally it also accepts an LDAP filter and scope. The default filter is objectClass= and the default scope is 'base' It returns a list of entries.
def search( c, basedn, *constraints ) # :yields: connection_info, basedn, filter, scope self.bind( c.host, c.port, c.credentials, c.databag_name, c.use_tls ) unless @ldap raise "Must specify base dn for search" unless basedn ( filter, scope, attributes ) = constraints filter = filter.nil? ? N...
[ "def query_ldap(session_handle, base, scope, filter, fields)\n vprint_status(\"Searching LDAP directory\")\n search = wldap32.ldap_search_sA(session_handle, base, scope, filter, nil, 0, 4)\n vprint_status(\"search: #{search}\")\n\n if search['return'] == LDAP_SIZELIMIT_EXCEEDED\n print_error(\"LDAP...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
== Get Entry This method accepts a connection resource object. It is intended to be used with Chef::Resource::LdapEntry objects that will also have a .dn method indicating Distinguished Name to be retrieved. It returns a single entry.
def get_entry( c, dn ) # :yields: connection_info, distinguished_name self.bind( c.host, c.port, c.credentials, c.databag_name, c.use_tls ) unless @ldap entry = @ldap.search( base: dn, filter: Net::LDAP::Filter.eq( 'objectClass', '*' ), scope: Net::L...
[ "def retrieve_entry(dn)\n entries = @ldap.search(base: dn, scope: Net::LDAP::SearchScope_BaseObject, return_result: true)\n if entries\n entries.first\n end\n end", "def entry(dn = @base)\n entry = @ldap.search(\n base: dn,\n filter: Net::LDAP::Filter.eq('objectClass', '*'),\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
== Add Entry This method accepts a connection resource object, a distinguished name, and the attributes for the entry to be added.
def add_entry( c, dn, attrs ) # :yields: connection_info, distinguished_name, attributes self.bind( c.host, c.port, c.credentials, c.databag_name, c.use_tls ) unless @ldap # Ensure no duplicates by casting as a case insensitive, case preserving hash attrs = CICPHash.new.merge(attrs) # Ensu...
[ "def add_subscription_entry(name, entry)\n\t\tend", "def add(entry)\n @entries[entry.tag] = entry\n end", "def add(dn, attributes)\n attributes = normalize_attributes(attributes)\n log_dispatch(:add, dn, attributes)\n adapter.add(dn, attributes)\n end", "def add_entry\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
== Modify Entry Accepts a connection resource object as the first argument, followed by an Array of ldap operations. It is intended to be used with Chef::Resource::LdapEntry objects that will also have a .dn method that returns the DN of the entry to be modified. Each ldap operation in the ldap operations list is an Ar...
def modify_entry( c, dn, ops ) # :yields: connection_info, distinguished_name, operations entry = self.get_entry( c, dn ) @ldap.modify dn: dn, operations: ops raise "Unable to modify record: #{@ldap.get_operation_result.message}" unless @ldap.get_operation_result.message =~ /(Success|Attribute or ...
[ "def update_entry(entry, ldap_attrs, user_attrs, ldap_key, user_key)\n if user_attrs.has_key?(user_key)\n if ldap_attrs.has_key?(ldap_key)\n if user_attrs[user_key] != ldap_attrs[ldap_key].first\n entry << LDAP.mod(LDAP::LDAP_MOD_REPLACE, ldap_key, user_attrs[user_key].is_a?(String) ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
== Delete Entry Expects a connection resource object, along with a .dn method that returns the Distinguished Name of the entry to be deleted.
def delete_entry( c, dn ) # :yields: connection_info, distinguished_name self.bind( c.host, c.port, c.credentials, c.databag_name, c.use_tls ) unless @ldap @ldap.delete dn: dn raise "Unable to remove record: #{@ldap.get_operation_result.message}" unless @ldap.get_operation_result.message =~ /(Succe...
[ "def delete(dn)\n @conn.delete :dn => dn\n end", "def delete_entry(entry)\n fetcher.delete_acl_entry(entry)\n end", "def delete_entry(entry)\n @address_book.entries.delete(entry)\n puts \"#{entry.name} has been deleted\"\n end", "def delete_entry(entry)\n address_book.entries.dele...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Just an idea, instead of localeStorage, saving the current project in Redis in a hash. Not implemented.
def cache(user) "#{user.id}_project" end
[ "def cache_key\n super + I18n.locale.to_s\n end", "def cache_key_for(path, options)\n \"#{path}:#{I18n.locale}:#{options[:bundle] ? '1' : '0'}\"\n end", "def current_locale\n Thread.current[:\"localite:locale\"] || base\n end", "def translations_hash; end", "def project_key; frozen_v...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
turn a href into an absolute path
def make_path(base, href) return href if href[0] == '/' base + href end
[ "def to_absolute( root, link )\n\n parsed = URI.parse( link )\n if parsed.scheme == 'file'\n parsed.scheme = nil\n return parsed.to_s\n end\n\n return link if URI.parse( link ).host\n\n begin\n # remove anchor\n link = URI.encode( link.to...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
reduce any '../', './', and '//' in a path or uri
def reduce_path(path) if path =~ /^(https?:\/\/.+)(\/.*)/ prefix = $1 path = $2 relative = false else prefix = nil relative = path[0] != '/' end while path.sub!(/\/*[^\/]+\/+\.\./, ''); end while path.sub!(/\/+\.\/+/, '/'); end path = path[2.....
[ "def normalize_uri(*strs)\n new_str = strs * \"/\"\n\n new_str = new_str.gsub!(\"//\", \"/\") while new_str.index(\"//\")\n\n # Makes sure there's a starting slash\n unless new_str[0,1] == '/'\n new_str = '/' + new_str\n end\n\n new_str\n end", "def normalize_uri(*strs)\n new_str = st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create an empty page with necessary assets for project +p+
def create_empty_page(p) cli.say 'Creating project page' FileUtils.mkdir_p(browse_file(p, '.')) %w[favicon-32.png style.css].each do |i| FileUtils.cp(template_file(i), browse_file(p, i)) end write_file(p, 'about.html') do build_from_template('about.html', citation: MiGA::MiGA.CITATION) ...
[ "def generate_project_page(p)\n # Redirect page\n write_file(p, '../index.html') { build_from_template('redirect.html') }\n\n # Summaries\n summaries = Dir[\"#{p.path}/*.tsv\"].map do |i|\n b = File.basename(i, '.tsv')\n generate_summary_page(i, p)\n \"<li><a href='s-#{b}.html'>#{format_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create landing page for project +p+
def generate_project_page(p) # Redirect page write_file(p, '../index.html') { build_from_template('redirect.html') } # Summaries summaries = Dir["#{p.path}/*.tsv"].map do |i| b = File.basename(i, '.tsv') generate_summary_page(i, p) "<li><a href='s-#{b}.html'>#{format_name(b)}</a></li>...
[ "def create_empty_page(p)\n cli.say 'Creating project page'\n FileUtils.mkdir_p(browse_file(p, '.'))\n %w[favicon-32.png style.css].each do |i|\n FileUtils.cp(template_file(i), browse_file(p, i))\n end\n write_file(p, 'about.html') do\n build_from_template('about.html', citation: MiGA::MiGA...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create page for the summary +path+ in project +p+
def generate_summary_page(path, p) b = File.basename(path, '.tsv') table = '<table class="table table-hover table-responsive">' File.open(path, 'r') do |fh| fh.each do |ln| r = ln.chomp.split("\t") if $. == 1 table += '<thead><tr>' + r.map { |i| "<th scope=col>#{f...
[ "def generate_project_page(p)\n # Redirect page\n write_file(p, '../index.html') { build_from_template('redirect.html') }\n\n # Summaries\n summaries = Dir[\"#{p.path}/*.tsv\"].map do |i|\n b = File.basename(i, '.tsv')\n generate_summary_page(i, p)\n \"<li><a href='s-#{b}.html'>#{format_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create page for dataset +d+ within project +p+
def generate_dataset_page(p, d) data = { unmiga_name: d.name.unmiga_name, information: format_metadata(d), results: format_results(d) } write_file(p, "d_#{d.name}.html") do build_from_template('dataset.html', data) end end
[ "def generate_datasets_index(p)\n cli.say 'Creating index pages'\n data = format_dataset_index(p)\n data.each do |k, v|\n write_file(p, \"#{k}_datasets.html\") do\n v[:list] = 'None' if v[:list] == ''\n build_from_template(\n 'datasets.html',\n v.merge(:\"#{k}_datasets_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create pages for reference and query dataset indexes
def generate_datasets_index(p) cli.say 'Creating index pages' data = format_dataset_index(p) data.each do |k, v| write_file(p, "#{k}_datasets.html") do v[:list] = 'None' if v[:list] == '' build_from_template( 'datasets.html', v.merge(:"#{k}_datasets_active" => 'acti...
[ "def index_pages\n debug_msg \" generating pages search index\"\n\n pages = @files.select do |file|\n file.text?\n end\n\n pages.each do |page|\n debug_msg \" #{page.page_name}\"\n record = page.search_record\n @index[:searchIndex] << search_string(record.shift)\n @index...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Format +obj+ metadata as a table
def format_metadata(obj) '<table class="table table-sm table-responsive">' + obj.metadata.data.map do |k, v| case k when /^run_/, :plugins, :user next when :web_assembly_gz v = "<a href='#{v}'>#{v[0..50]}...</a>" when :datasets v = v.size e...
[ "def info_table(record = @record)\n model = record.class\n\n data = model.exposable_attributes(:pdf, human: true).map do |attr, method|\n [model.human_attribute_name(attr), record.send(method).to_s]\n end\n\n table data\n gap\n end", "def metadata_table metric\n\t\tt = metric.map{|k,v| [k,v]}...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Format +obj+ results as cards
def format_results(obj) o = '' obj.each_result do |key, res| links = format_result_links(res) stats = format_result_stats(res) next unless links || stats name = format_name(key) url_doc = 'http://manual.microbial-genomes.org/part5/workflow#' + key.to_s.tr('_', '-') ...
[ "def render(obj)\n # We can't use a case statement here becuase \"when Hash\" doesn't work for\n # ActiveSupport::OrderedHash - respond_to?(:values) is a more reliable\n # indicator of hash-like behavior.\n if NilClass === obj\n print(\"null\")\n \n elsif TrueClass === obj\n print(\"tr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Write +file+ within the browse folder of project +p+ using the passed block output as content
def write_file(p, file) File.open(browse_file(p, file), 'w') { |fh| fh.print yield } end
[ "def write(block)\n @filemgr.write(block, @contents)\n end", "def set_write_file(&block)\n @write_proc = block\n end", "def write_content\n File.open(absolute_path,'w') do |file|\n file << content if content\n end\n # TODO git functionality\n end", "def to_pwdump_file(path, &b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Use a +template+ file to generate content with a hash of +data+ over the layout page if +layout+ is true
def build_from_template(template, data = {}, layout = true) cont = File.read(template_file(template)).miga_variables(data) return cont unless layout build_from_template( 'layout.html', data.merge(content: cont, project_name: cli.load_project.name), false ) end
[ "def mustache(template, args={}, layout=true)\n args = args.update(:site => site, :site_tags => tags, :current_user => current_user)\n layout_class = UserApp::Views::Layout\n layout_class.template = design.layout\n view_class = UserApp::Views.const_get(template.to_s.classify)\n vi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Path to the template browse file
def template_file(file) File.join( MiGA::MiGA.root_path, 'lib', 'miga', 'cli', 'action', 'browse', file ) end
[ "def template_path\n File.expand_path('../templates', __FILE__)\n end", "def template_path\n File.join(File.dirname(__FILE__), \"templates\", \"Cloudfile.erb\")\n end", "def template_path(path)\n File.join(@site.source.to_s, TEMPLATE_DIR, path.to_s)\n end", "def rtfile_temp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Path to the browse file in the project
def browse_file(p, file) File.join(p.path, 'browse', file) end
[ "def path_to_current_file\n @path\n end", "def path\n project.path\n end", "def path\n @file.path\n end", "def control_file\n File.join(AimsProject::CONTROL_DIR, self.control)\n end", "def template_file(file)\n File.join(\n MiGA::MiGA.root_path,\n 'lib', 'miga', 'cli...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
determine the future value of an investment of present_value with given interest rate over time periods number of periods (years) that the interest is cumulated rate the annual rate of return present_value the value at the start of the period compound_frequency number of compounds / period(year)
def future_value(rate,periods,present_value,compound_frequency = 1) compound_frequency = resolve_compound_frequency!(compound_frequency) if compound_frequency == :continuous return continuous_compound_fv(rate,periods,present_value) end future_value = present_value * (1+rate/compound_freq...
[ "def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end", "def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n end", "def future...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
determine the present value required to acheive a future value with given interest rate over time periods number of periods (years) that the interest is cumulated rate the annual rate of return future_value the value at the end of the period
def present_value(rate,periods,future_value) present_value = future_value / (1+rate)**periods end
[ "def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n end", "def future_value(rate,periods,present_value,compound_frequency = 1)\n compound_frequency = resolve_compound_frequency!(c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
determine the rate of return over a period periods number of periods (years) that the interest is cumulated present_value the value at the start of the period future_value the value at the end of the period
def compound_return(periods,present_value,future_value) pv = present_value.to_d fv = future_value.to_d n = periods.to_d rate = ((fv / pv)**(1/n))-1 end
[ "def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end", "def future_value(rate,periods,present_value,compound_frequency = 1)\n compound_frequency = resolve_compound_frequency!(compound_frequency)\n if compound_frequency == :continuous\n ret...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
determine the investment horizon (length of time) required to create a future value given a present value and interest rate present_value the value at the start of the period future_value the value at the end of the period rate the annual rate of return
def investment_horizon(rate,present_value,future_value) pv = present_value.to_d fv = future_value.to_d periods = Math.log(fv/pv) / Math.log(1+rate) end
[ "def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end", "def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n end", "def future...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
determine the effective annual rate for a given simple interest rate compounded over a given number of periods rate simple annual rate compound_per_period compound / period
def effective_annual_rate(rate,compound_frequency) compound_frequency = resolve_compound_frequency!(compound_frequency) if compound_frequency == :continuous return continuous_effective_annual_rate(rate) end m= compound_frequency e_rate = (1 + rate/m)**m -1 end
[ "def current_compound_interest_rate() 4.3 end", "def nominal_anticipated_given_efective(effective_rate, periods)\n nominalRate = (1+(effective_rate.to_f/100))**(1/periods.to_f)-1\n toAnticipated = nominalRate / (1+nominalRate)\n (toAnticipated * periods.to_f * 100).round(4)\n end", "def intere...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Migrating this to `authorizerhomerooms`
def authorized_homerooms if EnvironmentVariable.is_true('ENABLE_HOMEROOM_AUTHORIZATION_V2') authorizer.homerooms else authorizer.allowed_homerooms_DEPRECATED(acknowledge_deprecation: true) end end
[ "def authorizes\n @authorizes.constantize\n end", "def authorize\n end", "def valid_author_headers\n {\n \"Authorization\" => author_token_generator(author.id)\n }\n end", "def documentation_authorizer\n @documentation_authorizer ||= Documentation.config.authorizer.new(controller)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Query for students through homeroom, but scoped within studentlevel authorization check. This is essentially doublewrapping the authorizaiton checks; the homeroom authorization check should separately only allow access when the educator can access all students in the homeroom.
def authorized_students(homeroom) authorized do homeroom.students .active .includes(:event_notes, :interventions, :homeroom) .to_a end end
[ "def homerooms(options = {})\n # Query for all students up front, then pass through authorizer.\n unsafe_all_students = Student.active.includes(:homeroom).to_a\n students = authorized { unsafe_all_students }\n\n # In memory, group each list by homeroom.\n unsafe_students_by_homeroom = unsafe_all_stud...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Serializes a Student into a hash with other fields joined in (that are used to perform filtering and slicing in the UI). This may be slow if you're doing it for many students without eager includes.
def fat_student_hash(student) HashWithIndifferentAccess.new(student.as_json({ except: [ :primary_phone, :primary_email, :student_address ] }).merge({ has_photo: student.has_photo, discipline_incidents_count: student.most_recent_school_year_discipline_incidents_cou...
[ "def flat_row_hash(student)\n # Remove some fields by default, these are likely to be misleading.\n # Allow callers to remove other fields (eg, address) for other uses,\n # to safelist with `only` instead.\n as_json_options = @options.fetch(:as_json, {\n except: [:created_at, :updated_at]\n })\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
SpEd Data as defined by Somerville Schools
def sped_data(student) { sped_level: sped_level(student), sped_tooltip_message: sped_tooltip_message(student), sped_bubble_class: sped_bubble_class(student) } end
[ "def sped_data\n {\n sped_level: sped_level,\n sped_tooltip_message: sped_tooltip_message,\n sped_bubble_class: sped_bubble_class\n }\n end", "def parse_schools_data(schools)\n parsed_schools = schools\n return parsed_schools\n end", "def summer_olympics_sport; end", "def summe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /featured_clients GET /featured_clients.json
def index @featured_clients = FeaturedClient.all end
[ "def index\n @clients = current_user.clients\n render json: @clients\n end", "def get_featured\n render json: Event.where(is_featured: true), status: :ok\n end", "def create\n @featured_client = FeaturedClient.new(featured_client_params)\n\n respond_to do |format|\n if @featured_client.sav...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /featured_clients POST /featured_clients.json
def create @featured_client = FeaturedClient.new(featured_client_params) respond_to do |format| if @featured_client.save format.html { redirect_to @featured_client, notice: 'Featured client was successfully created.' } format.json { render :show, status: :created, location: @featured_clie...
[ "def update_features(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/features\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n features:[{\"name\":\"public_dashboards\",\"enabled\":true},\n {\"name\":\"publishe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /featured_clients/1 PATCH/PUT /featured_clients/1.json
def update respond_to do |format| if @featured_client.update(featured_client_params) format.html { redirect_to @featured_client, notice: 'Featured client was successfully updated.' } format.json { render :show, status: :ok, location: @featured_client } else format.html { render :...
[ "def update_features(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/features\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n features:[{\"name\":\"public_dashboards\",\"enabled\":true},\n {\"name\":\"publishe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /featured_clients/1 DELETE /featured_clients/1.json
def destroy @featured_client.destroy respond_to do |format| format.html { redirect_to featured_clients_url, notice: 'Featured client was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n http_api.delete(\"clients/#{@name}\")\n end", "def destroy\n render json: @api_v1_client if @api_v1_client.destroy\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Convert value to bit array to_multi_bit( '0b101010', 6 ) => [1,0,1,0,1,0] to_multi_bit( '0b101010', 10 ) => [1,0,1,0,1,0,0,0,0,0] to_multi_bit( '0b101010', 3 ) => [1,0,1] to_multi_bit( '0b01010' ) => [1,0,1,0] minimum array size for val to_multi_bit( '' ) => [0] null string is equivalent to 0
def to_multi_bit( val, array_size=-1 ) array_size = Integer(array_size) unless array_size.kind_of?(Integer) if val == '' then val = '0' end begin val = Integer(val).to_s(2) rescue => e raise ParameterError, "#{__method__} contains invalid string for number" end arr = val....
[ "def to_bit(**options) = convert_to('bit', **options)", "def input_to_bitstring( value )\r\n value\r\n end", "def number_to_bit_array(number, minimum_binary_places = 0)\n assert_non_negative(number)\n array = []\n while number > 0\n array << (number & 1)\n number >...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
class_exsits?("String") => ture class_exists?("djfakf20dak") => false
def class_exists?(classname) str = classname.to_s eval("defined?(#{str}) && #{str}.is_a?(Class)") == true end
[ "def class_exists? string\n\tc = Object.const_get string\n\treturn c.is_a? Class\nrescue NameError\n\treturn false\nend", "def class_exists?(class_name_str)\r\n begin\r\n true if class_name_str.constantize\r\n rescue NameError\r\n false\r\n end\r\n end", "def class_exists?(name)\n get_cla...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns info for the specified venue.
def venue(id) options = { :venue_id => id } get('/venue_info', options) end
[ "def venue_info(venue_id)\n venue = self.class.foursquare.venue(venue_id)\n info = {}\n info[:category_id] = venue.categories.first.id\n info[:category_name] = venue.categories.first.name\n info[:total_checkins] = venue.stats.checkinsCount\n info\n end", "def venue(id_or_slug, opts={})\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /communities/new GET /communities/new.json
def new @community = Community.new respond_to do |format| format.html # new.html.erb format.json { render json: @community } end end
[ "def new\n @community = @district.communities.new\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end", "def create\n @community = current_user.communities.new(community_params)\n\n respond_to do |format|\n if @community.save\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /communities/1 PUT /communities/1.json
def update @community = Community.find(params[:id]) respond_to do |format| if @community.update_attributes(params[:community]) format.html { redirect_to @community, notice: 'Community was successfully updated.' } format.json { head :no_content } else format.html { render act...
[ "def update\n @community = Community.find(params[:id])\n\n if @community.update(community_params(params[:community]))\n head :no_content\n else\n render json: @community.errors, status: :unprocessable_entity\n end\n end", "def update\n @community = current_user.own_communities.find(param...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /communities/1 DELETE /communities/1.json
def destroy @community = Community.find(params[:id]) @community.destroy respond_to do |format| format.html { redirect_to communities_url } format.json { head :no_content } end end
[ "def destroy\n @community = Community.find(params[:id])\n @community.destroy\n\n respond_to do |format|\n format.html { redirect_to communities_url }\n format.json { head :ok }\n end\n end", "def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to co...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Load appium.txt (toml format) into system ENV the basedir of this file + appium.txt is what's used
def load_appium_txt opts raise 'opts must be a hash' unless opts.kind_of? Hash opts.each_pair { |k,v| opts[k.to_s.downcase.strip.intern] = v } opts = {} if opts.nil? file = opts.fetch :file, nil raise 'Must pass file' unless file verbose = opts.fetch :verbose, false # Check for env vars in .txt parent_d...
[ "def load_appium_txt opts\n raise 'opts must be a hash' unless opts.kind_of? Hash\n opts.each_pair { |k,v| opts[k.to_s.downcase.strip.intern] = v }\n opts = {} if opts.nil?\n file = opts.fetch :file, nil\n raise 'Must pass file' unless file\n verbose = opts.fetch :verbose, false\n # Check for env vars in .tx...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the server url for sauce or local based on env vars.
def server_url return @custom_url if @custom_url if !@sauce_username.nil? && !@sauce_access_key.nil? "http://#{@sauce_username}:#{@sauce_access_key}@ondemand.saucelabs.com:80/wd/hub" else "http://127.0.0.1:#{@port}/wd/hub" end end
[ "def server_url\n port = config[:ports].sample\n \"#{config[:hostname]}:#{port}#{config[:pathname]}\"\n end", "def env_url\n ENV['SWAN_URL']\n end", "def env_url\n ENV['CHRONOS_URL']\n end", "def get_base_uri(server = Server::DEFAULT)\r\n ENVIRONMENTS[environment][server].clone\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a png screenshot and saves to the target path. Example: screenshot '/tmp/hi.png'
def screenshot png_save_path @driver.save_screenshot png_save_path nil end
[ "def screenshot png_save_path\n @driver.save_screenshot png_save_path\n end", "def screenshot(png_save_path)\n @driver.save_screenshot png_save_path\n end", "def screenshot!\n page.save_screenshot(Rails.root.join('tmp/rspec_screens/screenshot.png'))\n end", "def make_screenshot_here\n d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set implicit wait and default_wait to zero.
def no_wait @last_waits = [@default_wait, 0] @default_wait = 0 @driver.manage.timeouts.implicit_wait = 0 end
[ "def no_wait\n @last_waits = [@default_wait, 0]\n @default_wait = 0\n @driver.manage.timeouts.implicit_wait = 0\n end", "def default_wait\n @default_wait\n end", "def set_wait timeout=@default_wait\n @driver.manage.timeouts.implici...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set implicit wait and default_wait to timeout, defaults to 30. if set_wait is called without a param then the second to last wait will be used. ```ruby` set_wait 2 set_wait 3 set_wait 2 ````
def set_wait timeout=nil if timeout.nil? # puts "timeout = @default_wait = @last_wait" # puts "timeout = @default_wait = #{@last_waits}" timeout = @default_wait = @last_waits.first else @default_wait = timeout # puts "last waits before: #{@last_waits}" @last_w...
[ "def set_wait timeout=@default_wait\n @driver.manage.timeouts.implicit_wait = timeout\n end", "def set_wait(timeout = nil)\n if timeout.nil?\n # Appium::Logger.info \"timeout = @default_wait = @last_wait\"\n # Appium::Logger.info \"timeout = @default_wait = #{@last_waits}\"\n tim...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the default client side wait. This value is independent of what the server is using
def default_wait @default_wait end
[ "def wait_timeout\n @wait_timeout ||= options[:wait_timeout] || DEFAULT_WAIT_TIMEOUT\n end", "def default_wait_for_time\n 5\n end", "def wait_time\n @wait_time ||= (ENV[\"QC_LISTEN_TIME\"] || 5).to_i\n end", "def waiter_options\n @waiter_options || {}\n end", "def wai...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Quit the driver and Pry. quit and exit are reserved by Pry.
def x driver_quit exit # exit pry end
[ "def quit\n exit(1)\n end", "def command_quit\n\t exit(0) \n end", "def quit; @quit = 1 end", "def exit_program\n exit\n end", "def terminate\n @driver.quit\n end", "def quit\r\n Log.info(\"Closing browser..\")\r\n @driver.quit\r\n end", "def quit\r\n raise Shells::...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds and returns the 1st node whose value is 'value'
def find(value) self.each {|node| return node if node.value == value} end
[ "def node_with_value(value)\n current_node = @head\n while current_node.value\n return current_node if current_node.value == value\n current_node = current_node.next_node\n end\n end", "def get(value)\n @children.each { |child| return child if child.value == value }\n return nil\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
find_all(value) finds and return (in an array) all the nodes whose value is 'value'
def find_all(value) nodes = [] self.each {|node| nodes << node if node.value == value} nodes end
[ "def elements_by_xpath(value)\n find_by_xpath(value)\n end", "def find_all_nodes(xpath, select_result_value=false)\n if self.feed_data_type != :xml\n raise \"The feed data type is not xml.\"\n end\n return FeedTools::XmlHelper.try_xpaths_all(self.root_node, [xpath],\n :sel...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
push(value) adds a value 'value' to the end of the linked list
def push(value) last.next_node = Node.new(value, nil) end
[ "def push(data_value)\r\n @head_value = LinkedListNode.new(data_value, @head_value)\r\n end", "def push(value)\n insert(value)\n self\n end", "def append(value)\n node = Node.new\n node.value = value\n if head.nil?\n @head = node\n else\n curr = head\n curr = cu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The "type" of dependencies this manager manages. This can be the language, tool, etc.
def type raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#type` method") end
[ "def dependency_type_name\n @values.fetch('dependencyTypeName') { \n @values['dependencyTypeName'] = nil\n }\n end", "def type\n @klass.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Class) ? \"class\" : \"module\"\n end", "def dependency_kind\n @values['depend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Implementation's of this method in subclasses are the methods that are responsible for all the heavylifting when it comes to determining the dependencies (and their licenses). They should return an array of `LicenseScout::Dependency`.
def dependencies [] end
[ "def licenses\n licenses = []\n uris = metadata[dataset_uri][dct.license.to_s]\n if uris.nil?\n []\n else\n uris.each do |uri|\n l = metadata[uri]\n licenses << License.new(:uri => uri, :name => l[dct.title.to_s])\n end\n return l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A helper that allows you to quickly create a new Dependency (with the type)
def new_dependency(name, version, path) LicenseScout::Log.debug("[#{type}] Found #{name} #{version}#{" #{path}" unless path.nil?}") Dependency.new(name, version, path, type) end
[ "def d(*args)\n Dependency.new(*args)\n end", "def create_dependency_type(kind, category, dependency_type = nil)\n # support wildcard case for all dependency types in a category.\n kind = kind.to_sym\n category = category.to_sym\n if WILDCARD == dependency_type\n types = self.se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates and returns a new RecBack MazeHelper object. Many options are supported: [:width] The number of columns in the maze. [:height] The number of rows in the maze. [:seed] The maze algorithm to use. This should be a class,
def initialize(options = {}) @width = (options[:width] || 10).to_i @height = (options[:height] || @width).to_i @seed = (options[:seed] || rand(0xFFFF_FFFF)).to_i @grid = Array.new(height) {Array.new(width, 0)} srand(@seed) # start carving the maze passage from the upper-left corner ...
[ "def create_maze\n\t\tgrid = initialize_empty_maze\n\t\treturn grid\n\tend", "def generate_maze\r\n puts \"Great! Let's get this started up...\"\r\n print \"How many rows should this maze have? \"\r\n x_coord = @helper.get_valid_numbers_only($stdin.gets.chomp, 2000) #To test, put in 5\r\n print \"How ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns original window if defined, current window if not See Windowuse
def original_window @original_window ||= window end
[ "def get_window\n manager.is_reparenting?() ? frame_window : window\n end", "def get_window; @window; end", "def window\r\n return $window\r\n end", "def local_window; end", "def get_active_window\n xdotool(\"getactivewindow\").chomp\n end", "def window\n nil\n end", "def usa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns estimated effort for a ProjectPhase by calculating the sum of the estimated effort for each StockDeliverableType and CustomDeliverableType
def estimated_effort total_estimated_effort = 0 self.project_phase_deliverables.each do |deliverable| total_estimated_effort += deliverable.estimated_effort.to_f unless deliverable.nil? end return total_estimated_effort end
[ "def total_estimated_effort\n sum = 0.0\n self.project_phase_deliverables.each do |deliverable|\n if deliverable.total_effort.nil?\n next\n end\n sum += deliverable.total_effort\n end\n return sum\n end", "def total_estimated_effort\n sum = 0.0;\n self.project_phase_delive...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
function to get the total logged effort for this deliverable
def logged_effort total_logged_effort = 0 self.project_phase_deliverables.each do |deliverable| total_logged_effort += deliverable.logged_effort.to_f unless deliverable.nil? end return total_logged_effort end
[ "def total_actual_effort\n sum = 0.0\n self.project_phase_deliverables.each do |deliverable|\n sum += deliverable.total_logged_effort\n end\n return sum\n end", "def total_logged_effort\n self.effort_logs.inject (0){|sum, ef| sum + ef.effort}\n end", "def estimated_effort\n total_estima...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
function to return the aggregated project phase deliverables with both stock and custom
def project_phase_deliverables project_phase_deliverables = [] stock_deliverable_types.each do |stock| stock.deliverables.each do |d| project_phase_deliverables << d end end custom_deliverable_types.each do |custom| custom.deliverables.each do |d| project_phase_deliver...
[ "def gather_collections\n project_phase = ProjectPhase.find(@project_phase_id)\n\n # TODO: Add the custom deliverables into this list\n\n # Encode the id as stock_<id>\n sdt = project_phase.stock_deliverable_types unless project_phase.nil?\n @stock_deliverable_types = sdt.map {|s| [s.deliverable_type...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
gets the current theme or returns default if it comes back blank
def get_theme use_theme = Preference.get_setting('CURRENT_THEME') (use_theme == '' ? 'default' : use_theme).downcase end
[ "def current_theme \n if @current_theme.nil? \n @current_theme = get_default_theme \n end \n @current_theme \n end", "def current_theme\n @_current_theme ||= current_site.get_theme.decorate\n end", "def current_theme\n @theme\n end", "def get_defa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The value which is used for sorting. Used on the preset scenario list
def sorting_value respond_to?(:ordering) ? ordering : 0 end
[ "def value\n requested_sort[:key]\n end", "def default_sort_value\n default_sort.fetch(:value, nil)\n end", "def selected_sort_value\n sort_param.present? ? sort_param : default_sort_value\n end", "def default_sort_attribute\n ::Mincer.config.sorting.sort_attribute\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates the four required columns that constitutes a single cascading namespace settings attribute. This helper is only appropriate if the setting is not already present as a noncascading attribute. Creates the `setting_name` column along with the `lock_setting_name` column in both `namespace_settings` and `application...
def add_cascading_namespace_setting(setting_name, type, **options) lock_column_name = "lock_#{setting_name}".to_sym check_cascading_namespace_setting_consistency(setting_name, lock_column_name) namespace_options = options.merge(null: true, default: nil) add_column(:namespace_s...
[ "def setting(name)\n settings.find_by(name: name) || begin\n t = setting_templates.find_by!(setting_name: name)\n\n setting_args = {\n name: t.setting_name,\n type: t.setting_klass,\n setting_template: t,\n value_type: t.value_type,\n owner: self\n }\n\n set...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Because pagy gem method pagy_next_url return url base on request url, but sometime we want specify base url. So this is what this method doing.
def next_url_for_path(path, pagy) return unless pagy.next url = URI.parse(path); url_query = Rack::Utils.parse_query url.query url.query = Rack::Utils.build_query url_query.merge(pagy.vars[:page_param].to_s => pagy.next) url.to_s end
[ "def next_url\n next_page ? url(next_page) : nil\n end", "def next_page_url\n \"#{request.path}?page=#{@page + 1}\"\n end", "def next_page_path; end", "def link_next_page; target_uri(next_page); end", "def paginable_base_url(page = 1)\n return url_for(@paginable_path_params.merge({ cont...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /magic_item_names GET /magic_item_names.json
def index @magic_item_names = MagicItemName.all end
[ "def get_item_names\n items = []\n Static.get_item_list.values.each do |f|\n items << f[\"name\"]\n end\n items\n end", "def name_list\n begin\n @products = Product.pluck(:name)\n render json: { names: @products }, status: 200\n rescue => exception\n render json: {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /magic_item_names POST /magic_item_names.json
def create @magic_item_name = MagicItemName.new(magic_item_name_params) respond_to do |format| if @magic_item_name.save format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully created.' } format.json { render :show, status: :created, location: @magic_item_nam...
[ "def index\n @magic_item_names = MagicItemName.all\n end", "def do_name( items )\n @callback[ OK, items ]\n end", "def item_name\n name\n end", "def update_item_names\n #puts \"Display number of #{self.name} changed. Updating names of '#{items.count}' Items....\"\n items.each { | i | i.p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /magic_item_names/1 PATCH/PUT /magic_item_names/1.json
def update respond_to do |format| if @magic_item_name.update(magic_item_name_params) format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully updated.' } format.json { render :show, status: :ok, location: @magic_item_name } else format.html { render :...
[ "def _update_item(http, headers, path, body, name)\n resp = retry_request(http, \"PATCH\", path, body, headers)\n if resp.is_a?(Net::HTTPOK)\n Chef::Log.info(\"Updated keystone item '#{name}'\")\n else\n _raise_error(resp, \"Unable to update item '#{name}'\", \"_update_item\")\n end\nend", "def update_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /magic_item_names/1 DELETE /magic_item_names/1.json
def destroy @magic_item_name.destroy respond_to do |format| format.html { redirect_to magic_item_names_url, notice: 'Magic item name was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @itemname = Itemname.find(params[:id])\n @itemname.destroy\n\n respond_to do |format|\n format.html { redirect_to itemnames_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # :id here represents the name so we don't have to change the routes\n @item...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
3 ways to register filter 1. builtin filter filter.add_filter(:mtime, :passed, 30, :days) 2. custom filter filter.add_filter(my_filter) (my_filter must implements match?(path) method) 3. block filter filter.add_filter do |path| filter operations end
def add_filter(*args, &block) # 3. block filter if block_given? filter = File::Visitor::Filter::Proc.new(block) @filters.push(filter) return true end # 2. custom filter if (1 == args.size) custom_filter = args.shift unless (custom_filter.respond_to?...
[ "def register_filter(mod); end", "def addFilter( &block )\n\t\t@filters << block\n\tend", "def add_filter(name, &block)\n raise ArgumentError, \"Expected block to be given\" if block.nil?\n\n @filters[name] = block\n end", "def define_filter(name, &block)\n filters[name.to_sym] = block\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
dir: target directory mode: file visit all files dir visit directory only handler: proc to call
def visit_with_mode(dir, mode, &handler) assert_directory(dir) entries = Dir.entries(dir) .sort_by { |filename| filename } if @direction == :desc entries.reverse! end entries.each do |entry| next if (dot_dir?(entry) && !@visit_dot_dir) abs_path = File.jo...
[ "def process_directory(dir, files, rec)\n dir.children(true).each do |f|\n # ignore sub-directories\n if f.directory?\n if rec == false\n next\n else\n process_directory(f.expand_path, files, rec)\n end\n end\n pro...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns only the children with +results+
def children_with_results children.select(&:any_results_including_children?) end
[ "def children_with_results(reload = false)\n children(reload).select(&:has_results_including_children?)\n end", "def children_and_child_competitions_with_results(reload = false)\n children_and_child_competitions(reload).select(&:has_results_including_children?)\n end", "def children\n if !@children\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns only the Races with +results+
def races_with_results races.select(&:any_results?) end
[ "def races_with_results\n races_copy = races.select {|race|\n !race.results.empty?\n }\n #races_copy.sort! alphere this causes races on the public results page to sort in an unexpected order.\n races_copy\n end", "def races_with_results\n races.select { |race| !race.results.empty? }.sort\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an array with the relative path of the selected songs (Overrides def on MusicBaseController)
def get_selected_paths return get_songs_column( :path ) end
[ "def get_selected_paths\n return get_songs_relation.pluck( :path )\n end", "def get_selected_paths\n return get_songs_search_from_params.songs_found.map { |s| s[SongsSearch::IDX_SONG_PATH] }\n end", "def path\n File.expand_path File.join(songs.first.path, '..').gsub(' ','\\ ')\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
NOTE do not pattern your production application after this (refer to test_should_create_customer_profile_transaction_auth_only_and_then_prior_auth_capture_requests instead as the correct way to do an auth then capture). capture_only "is used to complete a previously authorized transaction that was not originally submit...
def test_should_create_customer_profile_transaction_auth_only_and_then_capture_only_requests @gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:auth_only)) assert response = @gateway.create_customer_profile_transaction( transaction: { customer_profile_id:...
[ "def capture(options)\n hash = { transaction: { type: :prior_auth_capture,\n amount: options.fetch(:amount),\n customer_profile_id: options.fetch(:customer_profile_id),\n customer_payment_profile_id: options.fetc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get an strategy by its id
def get(id) self.class.strategies.select { |strategy| strategy.id == strategy.id } end
[ "def find(id)\n id_to_adapter[id]\n end", "def strategy\n @strategy\n end", "def provider_by_id(id)\n providers.select { |provider| provider.id == id }.first\n end", "def find_by_id(id)\n service_registry[id]\n end", "def find(name)\n @strategies[name] || @alia...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /connectors POST /connectors.json
def create @connector = Connector.new(connector_params) respond_to do |format| if @connector.save format.html { redirect_to @connector, notice: 'Connector was successfully created.' } format.json { render :show, status: :created, location: @connector } else format.html { ren...
[ "def create_connector(connector_id, request)\n start.uri('/api/connector')\n .url_segment(connector_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end", "def create\n @url_connector = UrlConnector.new(params[:url_connector])\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /connectors/1 PATCH/PUT /connectors/1.json
def update respond_to do |format| if @connector.update(connector_params) format.html { redirect_to @connector, notice: 'Connector was successfully updated.' } format.json { render :show, status: :ok, location: @connector } else format.html { render :edit } format.json { r...
[ "def patch_connector(connector_id, request)\n start.uri('/api/connector')\n .url_segment(connector_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .patch()\n .go()\n end", "def update_connector(connector_id, request)\n start.uri('/api/connector')\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }