query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Delete a 'Copy Pods Resources' script phase if present
def remove_copy_resources_script_phase_from_target(native_target) build_phase = native_target.shell_script_build_phases.find { |bp| bp.name && bp.name.end_with?(COPY_PODS_RESOURCES_PHASE_NAME) } return unless build_phase.present? native_target.build_phases.delete(build_phase) ...
[ "def add_copy_resources_script_phase\n phase_name = \"Copy Pods Resources\"\n native_targets.each do |native_target|\n phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first ||\n native_target.new_shell_script_build_phase(phase_nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates or update a shell script build phase for the given target.
def create_or_update_shell_script_build_phase(native_target, script_phase_name, show_env_vars_in_log = '0') build_phases = native_target.build_phases.grep(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) build_phases.find { |phase| phase.name && phase.name.end_with?(script_phase_name) }.tap...
[ "def create_or_update_copy_xcframeworks_script_phase_to_target(native_target, script_path, input_paths_by_config = {}, output_paths_by_config = {})\n phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + COPY_XCFRAMEWORKS_PHASE_NAME)\n phase.she...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the resource output paths for all given input paths.
def resource_output_paths(resource_input_paths) resource_input_paths.map do |resource_input_path| base_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}' extname = File.extname(resource_input_path) basename = extname == '.xcassets' ? 'Assets' : File.b...
[ "def filepaths\n list = []\n list << \"Scenario.pione\"\n list += inputs\n list += outputs\n return list\n end", "def output_files\n input_files\n end", "def paths\n map{ |dir| Pathname.new(dir) }\n end", "def absolute_output_directories\n settings[:o...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the framework input paths for the given framework paths
def embed_frameworks_input_paths(framework_paths, xcframeworks) input_paths = framework_paths.map(&:source_path) # Only include dynamic xcframeworks as the input since we will not be copying static xcframework slices xcframeworks.select { |xcf| xcf.build_type.dynamic_framework? }.eac...
[ "def embed_frameworks_output_paths(framework_paths, xcframeworks)\n paths = framework_paths.map do |framework_path|\n \"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}\"\n end.uniq\n # Static xcframeworks are not copied to the ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the framework output paths for the given framework paths
def embed_frameworks_output_paths(framework_paths, xcframeworks) paths = framework_paths.map do |framework_path| "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/#{File.basename(framework_path.source_path)}" end.uniq # Static xcframeworks are not copied to the build dir ...
[ "def embed_frameworks_input_paths(framework_paths, xcframeworks)\n input_paths = framework_paths.map(&:source_path)\n # Only include dynamic xcframeworks as the input since we will not be copying static xcframework slices\n xcframeworks.select { |xcf| xcf.build_type.dynamic_framewor...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates a projects native targets to include on demand resources specified by the supplied parameters. Note that currently, only app level targets are allowed to include on demand resources.
def update_on_demand_resources(sandbox, project, native_targets, file_accessors, parent_odr_group, target_odr_group_name) category_to_tags = {} file_accessors = Array(file_accessors) native_targets = Array(native_targets) # Target...
[ "def add_resource_file_to_target(file, targetName, project)\n project.native_targets.each do |target|\n if target.name == targetName\n target.add_resources([file])\n end\n end\nend", "def add_resources_to_project(test_targets=false)\n return unless has_resources?\n add_files_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find or create a 'Copy Pods Resources' build phase
def add_copy_resources_script_phase unless target.includes_resources? native_targets.each do |native_target| TargetIntegrator.remove_copy_resources_script_phase_from_target(native_target) end return end script_path = target.copy_resources_...
[ "def add_copy_resources_script_phase\n phase_name = \"Copy Pods Resources\"\n native_targets.each do |native_target|\n phase = native_target.shell_script_build_phases.select { |bp| bp.name == phase_name }.first ||\n native_target.new_shell_script_build_phase(phase_nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes the embed frameworks build phase from embedded targets
def remove_embed_frameworks_script_phase_from_embedded_targets return unless target.requires_host_target? native_targets.each do |native_target| if AggregateTarget::EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES.include? native_target.symbol_type TargetIntegrator.remove_embed_framew...
[ "def remove_embed_frameworks_script_phase_from_target(native_target)\n remove_script_phase_from_target(native_target, EMBED_FRAMEWORK_PHASE_NAME)\n end", "def create_embed_frameworks_phase(project, t)\n \n t.build_phases.delete_if { |phase| \n phase.to_s == 'Embed Frameworks'\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates all target script phases for the current target, including creating or updating, deleting and reordering.
def add_user_script_phases native_targets.each do |native_target| TargetIntegrator.create_or_update_user_script_phases(target.target_definition.script_phases, native_target) end end
[ "def script_phase(options)\n raise Informative, 'Script phases can only be added within target definitions.' if current_target_definition.root?\n raise Informative, 'Script phases cannot be added to abstract targets.' if current_target_definition.abstract?\n current_target_definition.store_scri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a shell script build phase responsible for checking if the Pods locked in the Pods/Manifest.lock file are in sync with the Pods defined in the Podfile.lock.
def add_check_manifest_lock_script_phase phase_name = CHECK_MANIFEST_PHASE_NAME native_targets.each do |native_target| phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + phase_name) native_target.build_phases.unshift(phase)....
[ "def add_check_manifest_lock_script_phase\n phase_name = 'Check Pods Manifest.lock'\n native_targets.each do |native_target|\n next if native_target.shell_script_build_phases.any? { |phase| phase.name == phase_name }\n phase = native_target.project.new(Xcodeproj::Project::Obj...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Elevator, Sorts elevators based on the number of stops they have
def elevator elevators.sort_by { |e| e.stop_count }.first end
[ "def compute_list\n if elevator_direction == 'UP'\n floor_list.sort\n elsif elevator_direction == 'DOWN'\n floor_list.sort\n floor_list.reverse\n end\n floor_list\n end", "def elevator\n\t\t@elevators.each do |e|\n\t\t\t@people.each do |person|\n\t\t\t\tif ((e.current == @floor_num) &&...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method to run the whois program with the domain and parse the output into a hash
def parse_query(domain=nil) domain_file = "tmp/#{domain}_whois" #puts("DEBUG >>> whois/parse_query called on domain #{domain}. Cache file will be stored in #{domain_file}") begin domain = self.fqdn if domain == nil rescue NoMethodError raise ArgumentError, "wrong number of arguments (0 for 1...
[ "def whois(domain)\n raise InvalidDomainError unless domain.to_s =~ /\\.nz\\z/i\n\n fetch_content domain\n self\n end", "def whois_output\n return @whois_output if !@whois_output.blank?\n @whois_output = has_domain_and_server? ? server.raw_response!(domain) : ''\n end", "def whois...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
For each root ul/ol we are going to process all children, and then replace the root ul/ol.
def process_lists @doc.css('ul', 'ol').each do |list| # If we get a list (ol/ul) which is not a root, we stop processing. if list.ancestors('ul').count > 0 || list.ancestors('ol').count > 0 return end textile_list = [] list.css('li').each do |li| proc...
[ "def reprocess_items!\n @path_array = nil\n self.direct_items.each { |item| item.reprocess_child_items! }\n self.children.each { |category| category.reprocess_items! }\n end", "def collection_edit_tree_recurse(node)\n node['children'].each_with_index do |child, i|\n item = @model.fin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This should be in another class, we are not transforming to Textile, we are just removing the title tag.
def remove_title_if_present @doc.css('title').each { |node| node.remove } end
[ "def test_remove_title_tag\n assert_textile '', '<title>this is the title</title>'\n end", "def strip_title\n unless self.title.blank?\n self.title = self.title.gsub(/^\\s*/, '')\n end\n end", "def titleless_content\n parse if fresh?\n @content.sub(/h\\d\\..+/, '')\n end", "def remove_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Queue a verify API call in the Hydra.
def valid? @hydra.queue(request('verify')) end
[ "def verify_callback(*) end", "def verify!\n do_verification(:abort_process)\n end", "def add_verify(&block)\n @verify_function = block\n end", "def verify\n @bathroom.verify\n end", "def mock_verify\n @mock.mock_verify\n end", "def verify_call(*args)\n validate_eligible\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates automatically the total amount. There is a gotcha: If not all the payments are from the same money, this method won't calculate the total amount because this gem doesn't force the user to use a exchange service.
def total_amount common_currency = calculate_common_currency if common_currency.nil? self[:total_amount] else self[:total_amount] ||= PaymentAmount[calculate_total, common_currency] end end
[ "def total_payment\r\n checks.inject(0.00){|sum, check| sum += check.check_amount.to_f}\r\n end", "def update_total_amount\n sum = 0\n @items.each do |item|\n sum += item.get_price\n end\n @total_amount = sum\n @net_payable = @total_amount\n end", "def total_amount\n t ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
mount_command :: string > string
def mount_command(path) "udisksctl mount --block-device #{path}" end
[ "def guest_mount(guest_device)\n\t\tssh('mount', guest_device, VMMountPoint)\n\tend", "def mount! volume\n return :mounted if successful_remote_command?(\"mount #{volume.device} #{volume.mount_point}\")\n end", "def pipe_to(command1, command2) \n command1 + ' | ' + command2 \n end", "def mount(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
unmount_command :: string > string
def unmount_command(path) "udisksctl unmount --block-device #{path}" end
[ "def unmount! volume\n return :unmounted if successful_remote_command?(\"umount #{volume.device}\")\n end", "def unmount(mount_name, params)\n local = Pathname.new(params[:local]).expand_path\n info = active_mounts[local]\n raise \"No active mount-point found for #{local}\" if info.nil?\n STDE...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /testers GET /testers.json
def index @testers = Tester.all respond_to do |format| format.html # index.html.erb format.json { render json: @testers } end end
[ "def index\n @testers = Tester.all\n end", "def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end", "def list\n http.get(\"/takers\") do |response|\n respond_with_collectio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /testers/new GET /testers/new.json
def new @tester = Tester.new respond_to do |format| format.html # new.html.erb format.json { render json: @tester } end end
[ "def new\n @newtest = Newtest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @newtest }\n end\n end", "def new\n @testbed = Testbed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @testbed }\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /testers/1 PUT /testers/1.json
def update @tester = Tester.find(params[:id]) respond_to do |format| if @tester.update_attributes(params[:tester]) format.html { redirect_to @tester, notice: 'Tester was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } ...
[ "def update\n respond_to do |format|\n if @test_taker.update(test_taker_params)\n format.html { redirect_to @test_taker, notice: 'Test taker was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_taker }\n else\n format.html { render :edit }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /testers/1 DELETE /testers/1.json
def destroy @tester = Tester.find(params[:id]) @tester.destroy respond_to do |format| format.html { redirect_to testers_url } format.json { head :no_content } end end
[ "def destroy\n @one_test = OneTest.find(params[:id])\n @one_test.destroy\n\n respond_to do |format|\n format.html { redirect_to one_tests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Called by Mongrel2::Handler when it starts accepting requests. Overridden to start up the heartbeat thread.
def start_accepting_requests self.start_heartbeat super end
[ "def start_heartbeat\n @hb_received_at = Time.now\n send_heartbeat\n @heartbeat_timer = @reactor.periodical_timer(@heartbeat_interval) { send_heartbeat }\n end", "def heartbeat_start\n @heart = Thread.new do\n Logging.ndc.clear\n Logging.ndc.push('heartbeat-thread')\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Called by Mongrel2::Handler when the server is restarted. Overridden to restart the heartbeat thread.
def restart self.stop_heartbeat super self.start_heartbeat end
[ "def on_restart(&block); end", "def restart!\n CouchRest.post \"#{@uri}/_restart\"\n rescue RestClient::ServerBrokeConnection\n # Shouldn't really happen, but does in CouchDB 1.0.0\n end", "def restart_server\n stop_server\n sleep 1\n start_server\n end", "def restart_soon\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Called by Mongrel2::Handler when the server is shut down. Overridden to stop the heartbeat thread.
def shutdown self.stop_heartbeat super end
[ "def stop_heartbeat\n\t\t@heartbeat[ :shutdown ] = true\n\t\t@heartbeat.run.join if @heartbeat.alive?\n\tend", "def heartbeat_stop\n @heart.kill\n end", "def shut_down\n trigger(:shut_down_started)\n @server.stop(true) if @server\n @server_thread.join if @server_thread\n adapter.shut...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Disconnect any sockets that haven't sent any frames for at least SOCKET_IDLE_TIMEOUT seconds.
def cull_idle_sockets self.log.debug "Culling idle sockets." earliest = Time.now - self.class.idle_timeout self.connection_times.each do |sender_id, times| times.each do |conn_id, lastframe| next unless earliest > lastframe self.log.warn "Timing out connection %s:%d: last seen %0.3fs ago." % [ ...
[ "def cull_idle_sockets\n\t\tself.log.debug \"Culling idle sockets.\"\n\n\t\tearliest = Time.now - SOCKET_IDLE_TIMEOUT\n\n\t\tself.connections.each do |(sender_id, conn_id), lastframe|\n\t\t\tnext unless earliest > lastframe\n\n\t\t\t# Make a CLOSE frame\n\t\t\tframe = Mongrel2::WebSocket::Frame.close\n\t\t\tframe.s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Send a PING frame to all connected sockets.
def ping_all_sockets return if self.connections.empty? self.log.debug "Pinging %d connected sockets." % [ self.connections.length ] self.connections.each do |sender_id, conn_ids| frame = Mongrel2::WebSocket::Frame.new( sender_id, conn_id, '', {}, 'heartbeat' ) frame.opcode = :ping frame.fin = true s...
[ "def ping_all_sockets\n\t\tself.log.debug \"Pinging all connected sockets.\"\n\n\t\tself.connections.each do |(sender_id, conn_id), hash|\n\t\t\tframe = Mongrel2::WebSocket::Frame.new( sender_id, conn_id, '', {}, 'heartbeat' )\n\t\t\tframe.opcode = :ping\n\t\t\tframe.fin = true\n\n\t\t\tself.log.debug \" %s/%d: PI...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Validates different types based on regexp and such
def validate(type,input) if input.nil? then return false end if !(input.is_a? String) then return false end case type when 'Integer' return !(input.match(INTEGER_FORMAT).nil?) when 'String' return (input.length <= 1024) when 'Mail' return !(input.match(MAIL_FORMAT).nil?) end end
[ "def validate_pattern_type(v); end", "def is_string_or_regexp!(obj, obj_name)\n allow!(obj, [String, Regexp], \"#{obj_name} should be a String or Regexp\")\n end", "def validate_type(type, context:); end", "def valid_input?(owner, value)\n if value.nil?\n raise StandardError.new(\"Cann...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Validate payment_nonce_uuid if present Author: Aman Date: 30/05/2019 Reviewed By:
def validate_payment_nonce_uuid return success if @payment_nonce_uuid.blank? return error_with_identifier('invalid_api_params', 'ra_c_c_vpnu_1', ['invalid_payment_nonce_uuid'] ) unless Util::CommonValidateAndSanitize.is_s...
[ "def check_nonce(p0) end", "def valid_nonce?\n !request.check_nonce(response.basic).zero?\n end", "def validate_nonce(request, value, seconds_to_timeout=5*60)\n t = ActiveSupport::Base64.decode64(value).split(\":\").first.to_i\n nonce(t) == value && (t - Time.now.to_i).abs <= seconds_to_timeout\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieves cards that are in both deck and collection where deck qty != collection qty
def quantity_diff_query(coll_id, tracked_deck_id) Card.joins(:external_deck_instances).joins(:collection_card_instances) .where("collection_id = ? and external_deck_id = ? and external_deck_instances.quantity != collection_card_instances.quantity and collection_card_instances.quantity = 1"...
[ "def deck_not_collection_query(coll_id, tracked_deck_id)\n\t\tcards_in_collection = Card.joins(:collection_card_instances)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.where(\"collection_id = ?\", coll_id)\n\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t.select(\"cards.id\").to_sql\n\t\tCard.joins(:external_deck_instances)\n\t\t\t\t.where(\"ex...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieves cards that are in the deck but not collection
def deck_not_collection_query(coll_id, tracked_deck_id) cards_in_collection = Card.joins(:collection_card_instances) .where("collection_id = ?", coll_id) .select("cards.id").to_sql Card.joins(:external_deck_instances) .where("external_deck_id = ? and cards.id NOT IN (#{car...
[ "def non_trump_cards\n @cards.select {|c| c.suit != @trump_suit}\n end", "def not_in_deck(deck_id, cards, dataset)\n deck_cards = DeckCard.where(deck_id: deck_id)\n\n dataset\n .exclude(\n cards[:id] => deck_cards.select(:card_id),\n )\n end", "def all_not_wild\n res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Totals number of cards missing for tracked deck
def num_cards_owned(tracked_deck) quantity_same_cards = quantity_same_query(coll_id, tracked_deck_id(tracked_deck)) quantity_diff_cards = quantity_diff_query(coll_id, tracked_deck_id(tracked_deck)) same_card_count = quantity_same_cards.inject(0) do |quantity, card| quantity + card_quantity(card) end same_c...
[ "def total_number_of_cards_in(decks)\n cards = 0\n decks.each do |deck|\n cards += deck.cards.length\n end\n return cards\n end", "def cardsRemaining\n @deck.length\n end", "def count\n @deck.count\n end", "def count\n @deck.size\n end", "def report_card_count\n total = 0\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns user's collection ID
def coll_id current_user.collection.id end
[ "def get_collection_id\n @coll_id\n end", "def get_collection_id()\r\n return @coll_id\r\n end", "def collection_id\n path.split(\"/\").last\n end", "def site_collection_id\n return @site_collection_id\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns tracked deck ID
def tracked_deck_id(tracked_deck) tracked_deck.id end
[ "def get_deck_id\n if deck_id.nil?\n init_deck_id\n deck_id\n else\n deck_id\n end\n end", "def last_guessed_card\n current_round.guesses.last.card_id\nend", "def track(deck)\n saved_external_decks.create(external_deck_id: deck.id)\n end", "def card_id\n card.id\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns dust total for cards
def dust_total(cards) cards.inject(0) do |dust_total, card| dust_total + dust_value(card.rarity) end end
[ "def total\n total = 0\n\n collected_cards.each { |card| total = total + card.quantity }\n\n total\n end", "def craft(dust, cards)\n\t\tn = 0\n\t\tfor card in cards\n\t\t\tif !card.complete?\n\t\t\t\tmissing = card.numMissing\n\t\t\t\tif missing * card.craft_cost <= dust\n\t\t\t\t\tdust -= missing * car...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the dust value associated with card's rarity
def dust_value(card_rarity) case card_rarity when "Free" return 0 when "Common" return 40 when "Rare" return 100 when "Epic" return 400 when "Legendary" return 1600 end end
[ "def dust_total(cards)\n\t\tcards.inject(0) do |dust_total, card|\n\t\t\tdust_total + dust_value(card.rarity)\n\t\tend\n\tend", "def randomRarity\n\t\tr = Random.rand\n\t\tfor rarity in RARITIES\n\t\t\tif r < DISTRIBUTION[rarity]\n\t\t\t\treturn rarity\n\t\t\tend\n\t\tend \n\tend", "def cardValue(card)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the current month
def current_month Date.today.strftime("%B") end
[ "def current_month\n DateTime.now.strftime(\"%Y-%m-01\")\n end", "def current_month\n Time.now.strftime(\"%^b\")\n end", "def current_month\n find_switch :days\n end", "def month\n return @month\n end", "def month\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Resets the deck to its initial state
def reset! @cards = load_cards end
[ "def reset_deck\n @current_user.initialize_deck\n render :success\n end", "def handreset\n @cards = Array.new\n end", "def reset!\n @hands.each(&:discard!)\n @cards += @used\n @used = []\n end", "def reset\n # delete all old cards, then reload deck\n cards.each {|card|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /displays/1 GET /displays/1.json
def show @display = Display.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render :json => @display } end end
[ "def index\n @displays = Display.all\n end", "def show\n @experiment_display = ExperimentDisplay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @experiment_display }\n end\n end", "def show\n @experiment_hardware = Experiment...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /displays/new GET /displays/new.json
def new @display = Display.new respond_to do |format| format.html # new.html.erb format.json { render :json => @display } end end
[ "def new\n @experiment_display = ExperimentDisplay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @experiment_display }\n end\n end", "def new\n @display_name = DisplayName.new\n\n respond_to do |format|\n format.html # new.html.erb\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /displays/1 PUT /displays/1.json
def update @display = Display.find(params[:id]) respond_to do |format| if @display.update_attributes(params[:display]) format.html { redirect_to @display, :notice => 'Display was successfully updated.' } format.json { head :no_content } else format.html { render :action => "...
[ "def update_display(display_id, opts = {})\n put \"commandcenter/displays/#{display_id}\", opts\n end", "def update\n @experiment_display = ExperimentDisplay.find(params[:id])\n\n respond_to do |format|\n if @experiment_display.update_attributes(params[:experiment_display])\n for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /displays/1 DELETE /displays/1.json
def destroy @display = Display.find(params[:id]) @display.destroy respond_to do |format| format.html { redirect_to displays_url } format.json { head :no_content } end end
[ "def destroy\n @experiment_display = ExperimentDisplay.find(params[:id])\n @experiment_display.destroy\n\n respond_to do |format|\n format.html { redirect_to experiment_displays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @display = Display.find(params[:id])\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List the house contract based on the houseid/userid/roleId combination
def contracts #if isAuth(@userhouselink.house) # only house owner or admin can delete id = params[:id] print "contracts id=" + id.to_s #houseId_userId_roleNumber houseId,userId,role = id.to_s.split("_") print "houseId=" + houseId.to_s + ", userId=" + userId.to_s + ", role=" + role.to_...
[ "def list_contracts\n #contracts_list = Contract.find_by_id(id).location_a_id\n \n Contract.where(\"customer_id = \" + id.to_s )\n end", "def index\n @loanables = current_user.loanables.includes(:loan_contracts).all\n end", "def index\n\t\t@company = Company.find(params[:company_id])\n\t\t@user = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the applicableArchitectures property value. Contains properties for Windows architecture.
def applicable_architectures return @applicable_architectures end
[ "def applicable_architectures=(value)\n @applicable_architectures = value\n end", "def return_selectable_architectures()\n return ARCH_ALL\n end", "def all_architectures\n architectures + extra_architectures\n end", "def detect_architecture()\r\n\t\tprint_status(\"Attempting ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the applicableArchitectures property value. Contains properties for Windows architecture.
def applicable_architectures=(value) @applicable_architectures = value end
[ "def applicable_architectures\n return @applicable_architectures\n end", "def return_selectable_architectures()\n return ARCH_ALL\n end", "def architecture=(value)\n @architecture = value\n end", "def all_architectures\n architectures + extra_architectures\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the applicableDeviceTypes property value. Contains properties for Windows device type.
def applicable_device_types return @applicable_device_types end
[ "def applicable_device_types=(value)\n @applicable_device_types = value\n end", "def applicable_device_type\n return @applicable_device_type\n end", "def list_devicetypes\n Executor.execute(command_for('list', '-j', 'devicetypes')) do |json|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the applicableDeviceTypes property value. Contains properties for Windows device type.
def applicable_device_types=(value) @applicable_device_types = value end
[ "def applicable_device_type=(value)\n @applicable_device_type = value\n end", "def applicable_device_types\n return @applicable_device_types\n end", "def supported_devices=(devices)\n supported_devices = SUPPORTED_DEVICES[devices]\n settings['TARGETE...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the committedContainedApps property value. The collection of contained apps in the committed mobileAppContent of a windowsUniversalAppX app.
def committed_contained_apps return @committed_contained_apps end
[ "def contained_apps\n return @contained_apps\n end", "def committed_contained_apps=(value)\n @committed_contained_apps = value\n end", "def contained_apps=(value)\n @contained_apps = value\n end", "def managed_apps\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the committedContainedApps property value. The collection of contained apps in the committed mobileAppContent of a windowsUniversalAppX app.
def committed_contained_apps=(value) @committed_contained_apps = value end
[ "def contained_apps=(value)\n @contained_apps = value\n end", "def committed_contained_apps\n return @committed_contained_apps\n end", "def managed_apps=(value)\n @managed_apps = value\n end", "def contained_apps\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instantiates a new windowsUniversalAppX and sets the default values.
def initialize() super @odata_type = "#microsoft.graph.windowsUniversalAppX" end
[ "def initialize()\n super\n @odata_type = \"#microsoft.graph.windowsUniversalAppXContainedApp\"\n end", "def initialize(application_name)\n @application_name = application_name\n\n # Get the message id's for the Skype Control messages\n @api_discover_m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the identityName property value. The Identity Name.
def identity_name return @identity_name end
[ "def identity_name=(value)\n @identity_name = value\n end", "def identity\n if identity_attr = self.class.identity_attr\n send(identity_attr)\n else\n name\n end\n end", "def name\n \"identity\"\n end", "def identity(name = nil)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the identityName property value. The Identity Name.
def identity_name=(value) @identity_name = value end
[ "def set_name(vmname)\n execute(:set_name, VMID: vm_id, VMName: vmname)\n end", "def package_identity_name=(value)\n @package_identity_name = value\n end", "def set_Name(value)\n set_input(\"Name\", value)\n end", "def set_Identity(value)\n set_input(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the identityPublisherHash property value. The Identity Publisher Hash.
def identity_publisher_hash return @identity_publisher_hash end
[ "def identity_publisher_hash=(value)\n @identity_publisher_hash = value\n end", "def pub_hash\n pub\n end", "def verified_publisher_id\n return @verified_publisher_id\n end", "def subscriber_hash(email)\n # Simple hash of the email...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the identityPublisherHash property value. The Identity Publisher Hash.
def identity_publisher_hash=(value) @identity_publisher_hash = value end
[ "def identity_publisher_hash\n return @identity_publisher_hash\n end", "def publisher_id=(pub_id)\n @@publisher_id = pub_id\n end", "def publisher=(value)\n @publisher = value\n end", "def verified_publisher_id=(value)\n @verified_publ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the identityResourceIdentifier property value. The Identity Resource Identifier.
def identity_resource_identifier return @identity_resource_identifier end
[ "def identity_resource_identifier=(value)\n @identity_resource_identifier = value\n end", "def resource_id\n return @resource_id\n end", "def resource_identity\n new_resource.identity.to_s\n rescue => e\n \"unknown identity (due to #{e.class...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the identityResourceIdentifier property value. The Identity Resource Identifier.
def identity_resource_identifier=(value) @identity_resource_identifier = value end
[ "def resource_id=(value)\n @resource_id = value\n end", "def identity_resource_identifier\n return @identity_resource_identifier\n end", "def amazon_resource_id=(value)\n @amazon_resource_id = value\n end", "def target_resource_id=(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the identityVersion property value. The identity version.
def identity_version return @identity_version end
[ "def identity_version=(value)\n @identity_version = value\n end", "def version_id\n return @version_id\n end", "def version_number\n return @version_number\n end", "def version_id\n self.get_column(\"VersionId\")\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the identityVersion property value. The identity version.
def identity_version=(value) @identity_version = value end
[ "def version_id=(value)\n @version_id = value\n end", "def version=(value)\n @version = value\n end", "def version=(value)\n @version = value\n end", "def version_number=(value)\n @version_number = value\n end", "def versi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the isBundle property value. Whether or not the app is a bundle.
def is_bundle return @is_bundle end
[ "def bundled?\n $BUNDLE || ENV.key?(\"BUNDLE\")\n end", "def is_bundle=(value)\n @is_bundle = value\n end", "def bundle_exists?\n File.exists? self.bundle_dir\n end", "def bundler?\n enabled?(:bundler)\n end", "def bundle?\n @product_composition.human =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the isBundle property value. Whether or not the app is a bundle.
def is_bundle=(value) @is_bundle = value end
[ "def is_bundle\n return @is_bundle\n end", "def bundle=(value)\n @bundle = value\n end", "def bundled?\n $BUNDLE || ENV.key?(\"BUNDLE\")\n end", "def set_bundle(bundle, tags)\n args = [\"bundle=#{u(bundle)}\", \"tags=#{u(tags)}\"]\n get('tags/b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the minimumSupportedOperatingSystem property value. The minimum operating system required for a Windows mobile app.
def minimum_supported_operating_system return @minimum_supported_operating_system end
[ "def minimum_supported_operating_system=(value)\n @minimum_supported_operating_system = value\n end", "def mobile_os_minimum_version\n return @mobile_os_minimum_version\n end", "def minimum_required_os_version\n return @minimum_required_os_versi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the minimumSupportedOperatingSystem property value. The minimum operating system required for a Windows mobile app.
def minimum_supported_operating_system=(value) @minimum_supported_operating_system = value end
[ "def minimum_supported_windows_release=(value)\n @minimum_supported_windows_release = value\n end", "def minimum_supported_operating_system\n return @minimum_supported_operating_system\n end", "def mobile_os_minimum_version=(value)\n @mobile_os_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the old profile page had review filter on the main profile page. These are the params used to come across in the query string. Here I'm redirecting to the new profile reviews page, WITHOUT those parameters...I am not attempting to translate the old param values in the the new ones.
def redirect_old_review_filters old_params = [:min_rating, :N, :Ne, :Nf, :Nrc, :Ns, :page, :sort] if old_params.inject(false) { |memo, key| memo |= params.has_key?(key) } permanent_redirect_to :profile_mode => @profile_mode, :screen_name => params[:screen_name], :controller => 'profil...
[ "def posting_filter\nx\n review = ReviewType.find(params[\"review_type_id\"])\n\n if review.name != 'Placement'\n redirect_to(:action => 'post_review',\n :design_id => params[\"design_id\"],\n :review_type_id => params[\"review_type_id\"])\n else\n flash[:design_id] ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
params.require(:venue).permit(:name, :street, :city, :state, :country, :latitude, :longitude, :popularity_rating)
def venue_params params.require(:venue).permit(:name, :street, :city, :state, :country, :latitude, :longitude, :popularity_rating) end
[ "def venue_search_params\n params.permit(:venue_ids, :keyword)\n end", "def region_params\n params.require(:region).permit!\n end", "def match_state_params\n params.require(:match_state).permit(:title)\n end", "def user_params\n params.require(:restaurant).permit(:name, :owner, :phone, \n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initialiser. Cells are the cells in the object Children are other objects
def initialize(cells) @cells = cells @children = [] end
[ "def init_cells\n\t\t\traise \"#{self.class} has not implemented a cell initializer\"\n\t\tend", "def initialize(cell)\n super(cell)\n end", "def initialize_cells\n (0...@height * @width).each do |n|\n @cells[n / @width] ||= []\n @cells[n / @width][n % @width] = MazeCell.new(n % @width, n / @wi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
For every `redirect_from` entry, generate a redirect page
def generate_redirect_from(doc) doc.redirect_from.each do |path| doc.site.pages << RedirectPage.redirect_from(doc, path) end end
[ "def generate_redirect_from(doc)\n doc.redirect_from.each do |path|\n page = RedirectPage.redirect_from(doc, path)\n redirects[page.redirect_from] = page.redirect_to\n end\n end", "def generate_redirect_from(doc)\n doc.redirect_from.each do |path|\n page = RedirectPage.redir...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Responds to request with show_ok status and resource
def show_ok(resource:) render json: resource, status: :ok, include: show_includes end
[ "def show_ok\n controller.show_ok(resource: resource)\n end", "def ok\n respond_with :ok, status: :ok\n end", "def call\n return show_ok if resource_found?\n\n show_not_found\n end", "def update_ok(resource:)\n render json: resource, status: :ok\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
compare parent to both left, right kids, recursively checking down the tree
def child_compare(parent) unless parent.nil? if parent.left.nil? && parent.right.nil? nil elsif parent.right.nil? if parent.rating > parent.left.rating swap(parent.left, parent) end else if parent.rating > parent.left.rating || parent.rating > parent.right.rating if parent.left.ra...
[ "def child_compare(parent)\n\t\tunless parent.nil?\n\t\t\tif parent.left.nil? && parent.right.nil?\n\t\t\t\tnil\n\t\t\telsif parent.right.nil?\n\t\t\t\tif parent.value > parent.left.value\n\t\t\t\t\tswap(parent.left, parent)\n\t\t\t\tend\n\t\t\telse\t\t\n\t\t\t\tif parent.value > parent.left.value || parent.value >...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the AWS SQS Client
def sqs @sqs ||= Aws::SQS::Client.new end
[ "def sqs\n @sqs ||= Aws::SQS::Client.new\n end", "def aws_sns_client\n return @aws_sns_client if @aws_sns_client\n\n @aws_sns_client = Aws::SNS::Client.new(region: self.class.sms_aws_region)\n end", "def sqs\n @sqs ||= Chore::Queues::SQS.sqs_client\n end", "def new_sqs_cli...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the AWS SNS Client
def sns @sns ||= Aws::SNS::Client.new( http_idle_timeout: @sns_keep_alive_timeout, http_continue_timeout: @sns_continue_timeout ) end
[ "def aws_sns_client\n return @aws_sns_client if @aws_sns_client\n\n @aws_sns_client = Aws::SNS::Client.new(region: self.class.sms_aws_region)\n end", "def sns_client_config\n params = {\n region: options[:mq_aws_region],\n endpoint: options[:mq_aws_sns_endpoint],\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
METHOD to validate user operator
def valid_operator(user_operator) possible_operators = [ "add", "+", "subtract", "-", "multiply", "x", "*", "divide", "/" ] possible_operators.include?(user_operator) end
[ "def validate_data_validation_operator(v); end", "def validates_operator(operator, rhs, atts, opts=OPTS)\n validatable_attributes_for_type(:operator, atts, opts){|a,v,m| validation_error_message(m, operator, rhs) if v.nil? || !v.public_send(operator, rhs)}\n end", "def test_operator_valid\n a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
one represents the percentage of characters in the string that are lowercase letters, one the percentage of characters that are uppercase letters, and one the percentage of characters that are neither. You may assume that the string will always contain at least one character.
def letter_percentages(str) percentages = {} str_length = str.length.to_f percentages[:lowercase] = ((str.count('a-z') / str_length) * 100).round(1) percentages[:uppercase] = ((str.count('A-Z') / str_length) * 100).round(1) percentages[:neither] = 100 - percentages[:lowercase] - percentages[:uppercase] pe...
[ "def lettercaseRatio str\n n_up = 0\n str.split(\"\").each {|i| if i.upcase == i then n_up += 1 end}\n por_up = n_up / str.length.to_f * 100.0\n printf(\"lowercase: %.2f uppercase: %.2f\\n\",100.0 - por_up, por_up)\nend", "def letter_percentages(str)\n count_lowercase = 0\n count_uppercase = 0\n count_neit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
We skip check when: association isn't a `HasOne` or `HasMany` association has `through` option associated class doesn't exist
def preconditions %i[ has_one has_many ].include?(association.macro) && association.through_reflection.nil? && association.klass rescue StandardError false end
[ "def has_valid_association model, field\n (association = model.reflect_on_association(field)) &&\n association &&\n !association.options.has_key?(:through)\n end", "def unused_preload_associations_for?(klass, association)\n Bullet.collected_unused_eager_association_notifications.select do |noti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Boot Firefox, go to loginpage, wait for user to login, and return cookies
def cookies_from_selenium driver = Selenium::WebDriver.for :firefox driver.navigate.to "https://min.e-boks.dk/logon.aspx?logontype=oces" loop do break if driver.title =~ %r(^e-Boks ) sleep 1 end cookies = driver.manage.all_cookies driver.quit cookies end
[ "def login\n if TestChamber.user_cookies\n refresh_browser_cookies\n else\n ui_login\n end\n end", "def login\n @browser.login\n end", "def login\n @browser.click(@loginmgr.login_btn, :wait_for => :page)\n @browser.select_frame \"relative=top\"\n end", "def start...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Download all messages on a folder page.
def process_page(folderpage, folderpath, folderpath_hidden, agent) folderpage.search('//div[@id="messages"]/ul/li/dl').each do |msg| elm = msg.xpath('.//dt/label/input').first if elm["name"] != "did" $stderr.puts "Error. HTML may have changed, and script needs updating." $stderr.puts reason ...
[ "def download_messages(dir)\n @page = @agent.get(\"http://www.multimedia.movistar.es/do/mail/folder/view?page=0&order=ascending&field=arrival\")\n id = nil\n @page.parser.search('tr[@class=\"messagesList\"]').each do |node|\n begin\n id = node['id']\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /userfiles/1 DELETE /userfiles/1.json
def destroy @userfile.destroy respond_to do |format| format.html { redirect_to userfiles_url, notice: 'Userfile was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @user_file = UserFile.find(params[:id])\n @user_file.destroy\n\n respond_to do |format|\n format.html { redirect_to user_files_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_file.destroy\n respond_to do |format|\n format.html { redirect...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fills the object with data coming from the API Params: +data+:: +Hash+ of data coming from the API
def fill_with_data(data) if data.include? "id" @id = data["id"] end if data.include? "project" @project = data["project"] end if data.include? "customer" @customer = data["customer"] end if data.include? "token" @token = data["token"] end ...
[ "def fill_with_data(data)\n if data.include? \"id\"\n @id = data[\"id\"]\n end\n if data.include? \"project\"\n @project = data[\"project\"]\n end\n if data.include? \"event\"\n @event = data[\"event\"]\n end\n if data.include? \"request_url\"\n @reques...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the customer linked to the authorization request. Params: +options+:: +Hash+ of options
def customer(options = nil) request = Request.new(@client) path = "/authorization-requests/" + CGI.escape(@id) + "/customers" data = { } response = Response.new(request.get(path, data, options)) return_values = Array.new body = response.body body = body["cu...
[ "def customer(options = nil)\n request = Request.new(@client)\n path = \"/invoices/\" + CGI.escape(@id) + \"/customers\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = bo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a new authorization request for the given customer ID. Params: +customer_id+:: ID of the customer +options+:: +Hash+ of options
def create(customer_id, options = nil) request = Request.new(@client) path = "/authorization-requests" data = { "name"=> @name, "currency"=> @currency, "return_url"=> @return_url, "cancel_url"=> @cancel_url, "custom"=> @custom, 'customer_id'=>...
[ "def create_customer(options = {})\n post = {}\n\n add_customer_data(post, options)\n add_address_data(post, options)\n\n commit(:post, '/customers', post)\n end", "def create_customer(*args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n response = post(\"custo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find an authorization request by its ID. Params: +authorization_request_id+:: ID of the authorization request +options+:: +Hash+ of options
def find(authorization_request_id, options = nil) request = Request.new(@client) path = "/authorization-requests/" + CGI.escape(authorization_request_id) + "" data = { } response = Response.new(request.get(path, data, options)) return_values = Array.new body = re...
[ "def search_request_by_id(id)\n @search_requests[id]\n end", "def find(id,options={})\n options.reverse_merge! :from => collection_url\n request_options = options.slice(:query, :headers)\n \n url = build_url(options[:from],id)\n if result = handle_response(self.g...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Move the given register to temporary storage and rewrite reads from it to point to the new location.
def spill(reg) spill_move = Move.new(reg, SPILL_REG, true) @moves.each do |move| move.src = SPILL_REG if move.src == reg end @moves << spill_move end
[ "def mov_reg_to_addr addr, reg\n @mem[addr] = @reg[reg]\n end", "def mov_reg_addr_to_reg dst, src\n @reg[dst] = @mem[@reg[src]]\n end", "def with_reg(node)\n register = @registers.detect {|name, available| available}[0]\n @registers[register] = false\n code = print_node(node[:lvalue], self) + [...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Allocate storage for local variables on the stack.
def locals(&blk) @stack_usage ||= 0 num_locals = blk.arity # Allocate stack space locals = (0...num_locals).map do |i| offset = -(@stack_usage+i+1) PlusRegister.new j, (offset & 0xFFFF) end @stack_usage += num_locals SUB sp, num_locals yield *locals # Deallocate stack ...
[ "def local_variables() end", "def create_local_variables_map \n @local_variables = {};\n end", "def push_local\n <<-CODE\n next_int;\n stack_push(fast_fetch(c->locals, _int));\n CODE\n\n # \"next_int; stack_push(fast_fetch(cpu_current_locals(state, c), _int));\"\n end", "def push_varia...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given file, look up matching application
def select_app file_name ftype = file_type( file_name ).downcase @app_map[ ftype ] end
[ "def select_app file_name\n\t\tftype = file_type file_name\n\t\t@app_map[ ftype ]\n\t\t#this takes the file name and calls file type\n\t\t#receives the 'normalized' file extension\n\t\t#using it as a key into @app_map ro see which app to run\n\tend", "def select_app file_name \n ftype = file_type( file_name )...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initialize class, and set default strategy to :user
def initialize super @strategy = :user end
[ "def initialize(strategy)\n @strategy = strategy\n end", "def configure_user_search_strategy(strategy)\n @user_search_strategy =\n case strategy.to_s\n when \"default\"\n GitHub::Ldap::UserSearch::Default.new(self)\n when \"global_catalog\"\n GitHub::Ldap::UserSearc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the Twitter lookup strategy to :search or :user
def strategy=(strategy) case strategy when :user, :search @strategy = strategy end end
[ "def configure_user_search_strategy(strategy)\n @user_search_strategy =\n case strategy.to_s\n when \"default\"\n GitHub::Ldap::UserSearch::Default.new(self)\n when \"global_catalog\"\n GitHub::Ldap::UserSearch::ActiveDirectory.new(self)\n else\n GitHub::L...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a specified user from Twitter
def twitter_user @twitter_user ||= TwitterClient.new.user(@user) end
[ "def get_twitter_user\r\n begin\r\n\t return $client.user(twitter_id.to_i)\r\n\t rescue Twitter::Error\r\n\t return nil\r\n\t end\r\n end", "def get_user_detail_by_twitter_id(twitter_id)\n @user = User.find(:select=>\"*\",:conditions=>[\"twitter_id=#{twitter_id}\"])\n return @user\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parse out a percentage (as a float)
def parse(text) text.gsub(/[\s%]/, '').strip.to_f end
[ "def percentage_to_float(percentage_string, percentage_divider = 100, decimal_delimiter = \".\")\n string_value = filter_non_number_characters(percentage_string, decimal_delimiter)\n value = string_value.to_f / percentage_divider\n return value\nend", "def percent2PercentVal(text)\n return (text.sub(/,/,\"....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private method to load API service
def load_api_service @api_service = ApiService.new end
[ "def initialize\n @services = load\n end", "def api\n @api ||= PrismicService.init_api\n end", "def data_service\n DataServicesApi::Service.new(url: api_service_url)\n end", "def api\n\t\t@api ||= PrismicService.init_api\n\tend", "def load_cached_api\n api = nil\n\n if File.exists?(sel...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
For when Mailchimp is testing that our webhook works
def confirm_webhook render :json => "ok", :status => 200 end
[ "def webhook_test()\n\n query_parameters = {}\n query_parameters['apikey'] = @api_key\n query_parameters['apisecret'] = @api_secret\n\n resource_path = 'api/v2/webhook/test'\n get_request(resource_path, query_parameters, nil)\n end", "def test\n Rails.logger.debug \"Chargify Webhook...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
"type": "subscribe", "fired_at": "20090326 21:35:57", "data[id]": "8a25ff1d98", "data[list_id]": "a6b5da1054",
def customer_mailchimp_subscribed { :list_id => data['list_id'], :fired_at => params['fired_at'], :mailchimp_id => data['id'], :email => data['email'], :email_type => data['email_type'], :merges => data['merges'], :ip_opt ...
[ "def subscription_data\n {}\n end", "def http_raw_notify_data\n {\n \"id\"=>\"b9879d2b-052f-4a0a-8a3f-3e72049e4d19\", \n \"event\"=>\"invoice_paid\", \n \"payload\"=> invoice_data\n }.to_json\n end", "def customer_mailchimp_unsubscribed\n {\n :list_id => data['...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
"type": "unsubscribe", "fired_at": "20090326 21:40:57", "data[action]": "unsub", "data[reason]": "manual", "data[id]": "8a25ff1d98", "data[list_id]": "a6b5da1054",
def customer_mailchimp_unsubscribed { :list_id => data['list_id'], :fired_at => params['fired_at'], :mailchimp_id => data['id'], :email => data['email'], :email_type => data['email_type'], :merges => data['merges'], :ip_opt ...
[ "def unsubscribe(info)\n\t\tend", "def handle_unsubscribed(data)\n request_id, subscription_id = data\n\n trigger(:unsubscribed, request_id, subscription_id)\n end", "def unsubscribe_from_list(user, list)\n delete(\"/#{user}/#{list}/subscribers.json\")\n end", "def list_unsubscribe(*varia...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
"type": "profile", "fired_at": "20090326 21:31:21", "data[id]": "8a25ff1d98", "data[list_id]": "a6b5da1054",
def customer_mailchimp_profile_updated { :list_id => data['list_id'], :fired_at => params['fired_at'], :mailchimp_id => data['id'], :email => data['email'], :email_type => data['email_type'], :merges => data['merges'], :ip_opt...
[ "def trackgen_info;\treturn @json_data['trackgen_info'];\tend", "def parse_profile_data_json(profile_string)\n profile_hash_org = MultiJson.decode(profile_string)['profile-list']['researcher-profile']\n profile_hash = {\n :firstname => profile_hash_org['first-name'],\n :lastname => profile_ha...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
"type": "upemail", "fired_at": "20090326\ 22:15:09", "data[list_id]": "a6b5da1054", "data[new_id]": "51da8c3259",
def customer_mailchimp_email_updated { :list_id => data['list_id'], :fired_at => params['fired_at'], :new_mailchimp_id => data['id'], :new_email => data['new_email'], :old_email => data['old_email'], :human => "#{data['email']} updated th...
[ "def email_cleaned\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :campaign_id => data['campaign_id'],\n :email => data['email'],\n :reason => data['reason'],\n :human => \"#{data['email']} was cleaned fr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
"type": "cleaned", "fired_at": "20090326 22:01:00", "data[list_id]": "a6b5da1054", "data[campaign_id]": "4fjk2ma9xd", "data[reason]": "hard",
def email_cleaned { :list_id => data['list_id'], :fired_at => params['fired_at'], :campaign_id => data['campaign_id'], :email => data['email'], :reason => data['reason'], :human => "#{data['email']} was cleaned from Mailchimp ...
[ "def format_campaigns(data)\n Hash[data.map do |item|\n [item[0], Hash[\n 'clicks', item[1],\n 'cost', item[2],\n 'cpc', item[3],\n 'ctr', item[4]\n ]\n ]\n end]\n end", "def campaign_status\n {\n :list_id => data['list_id'],\n :cam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
"type": "campaign", "fired_at": "20090326 21:31:21", "data[id]": "5aa2102003", "data[subject]": "Test Campaign Subject", "data[status]": "sent", "data[reason]": "", "data[list_id]": "a6b5da1054"
def campaign_status { :list_id => data['list_id'], :campaign_id => data['id'], :subject => data['subject'], :status => data['status'], :reason => data['reason'], :human => "Campaign Status (ID: #{data['id']}) - Subject: '#{dat...
[ "def format_campaigns(data)\n Hash[data.map do |item|\n [item[0], Hash[\n 'clicks', item[1],\n 'cost', item[2],\n 'cpc', item[3],\n 'ctr', item[4]\n ]\n ]\n end]\n end", "def sent_campaign_list_simple(options = { start: 0, limit: 100 })\n list = sent_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns whether the commit that triggered this hook is the first commit on the branch.
def initial_commit? return @initial_commit unless @initial_commit.nil? @initial_commit = !Overcommit::Utils.execute(%w[git rev-parse HEAD~]).success? end
[ "def default_branch?\n event['ref'] == \"refs/heads/#{event['repository']['default_branch']}\"\n end", "def latest_commit?\n local = `cd #{@directory} && git log --pretty=%H -n 1`.chomp\n if `cd #{@directory} && git status`.chomp.match(/On branch (.*)\\n/)\n branch = $1\n else\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
method to create an array of event times. Will use this to create array of start_at times and endat times
def make_event_times_array(dates_array, hour, min) event_times = Array.new dates_array.each_index do |index| event_times[index] = create_event_time(dates_array[index],hour, min) end return event_times end
[ "def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method to combine :start_at and :end_at to make hash for each event and put them in an array.
def create_event_array(start_at_array, end_at_array, event_name, activity_id) events_array = Array.new start_at_array.each_index do |index| event_hash = Hash.new event_hash[:start_at] = start_at_array[index] event_hash[:end_at] = end_at_array[index] event_hash[:name] = event_name event_hash[:activi...
[ "def output_events\n @events.map do |event|\n adjusted_event = event.clone\n adjusted_event.at += @start_time\n adjusted_event\n end\n end", "def getevents\n start_time = Time.at(params[:start].to_i)\n end_time = Time.at(params[:end].to_i)\n events = []\n TimeBlock.wh...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /microposts POST /microposts.json
def create @micropost = current_user.microposts.build(micropost_params) respond_to do |format| if @micropost.save format.html { redirect_to root_url(:anchor => "ideas"), notice: 'Micropost was successfully created.' } format.json { render :show, status: :created, location: @micropost } ...
[ "def create\n @micropost = Micropost.new(micropost_params)\n\n if @micropost.save\n render json: @micropost\n else\n render json: @micropost.errors, status: :unprocessable_entity\n end\n end", "def create\n @micropost = current_user.microposts.new(micropost_params)\n\n if @micropost.s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates the lesson at which a student left off
def update_left_off(lesson_id) update_attribute(:left_off, lesson_id) end
[ "def use_advance_on_unchanged_progress\n previous_student = dup\n previous_student.assign_attributes(lesson: lesson_was, lesson_part: lesson_part_was)\n previous_student.advance.attributes.slice('lesson', 'lesson_part')\n end", "def kick_out\n @students = students.shift\n end", "def check_after_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }