query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
tap particular text if exist | def tap_alert_if_exist(text)
sleep 1.5 # wait for animation
if wait_true(timeout: 30, message: "failed to wait #{text} on alert with timeout") {
execute_script('$.mainApp().alert().buttons().length > 0') }
execute_script("$.mainApp().alert().buttons()['#{text}'].tap();")
end
end | [
"def tap_exact_text(text)\n driver.find(text).click\n rescue Appium::Core::Wait::TimeoutError => e\n raise(\"Could not find text \\\"#{text_val}\\\" on the current screen: #{e}\")\n end",
"def touch_txt_and_verify_title(txt_touch, text=nil)\n puts \"touch_txt_and_verify_title #{txt_touch}\"\n click_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /mm_teams GET /mm_teams.xml | def index
@mm_teams = MmTeam.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @mm_teams }
end
end | [
"def get_teams\n Resources::Team.parse(request(:get, \"Teams\"))\n end",
"def get_team_list ( page = 1 )\n get_api_resource \"#{@@api_base_url}teams/#{page}\"\n end",
"def get_teams\n @client.raw('get', '/config/teams')\n end",
"def index\n @teams = Team.find(:all)\n\n respond_to do |for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /mm_teams/new GET /mm_teams/new.xml | def new
@mm_team = MmTeam.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @mm_team }
end
end | [
"def new\n @team = @current_competition.teams.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /mm_teams POST /mm_teams.xml | def create
@mm_team = MmTeam.new(params[:mm_team])
respond_to do |format|
if @mm_team.save
format.html { redirect_to(@mm_team, :notice => 'Mm team was successfully created.') }
format.xml { render :xml => @mm_team, :status => :created, :location => @mm_team }
else
format.ht... | [
"def create_team()\n begin\n bodyParams = {\n 'public': true,\n 'name': \"Ruby Team\",\n # Add internal members using their extension ids\n # Get your user extension id by calling the /restapi/v1.0/account/~/extension endpoint!\n 'members': [{ 'id': \"590490017\"}, { 'id': \"595861017\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /mm_teams/1 PUT /mm_teams/1.xml | def update
@mm_team = MmTeam.find(params[:id])
respond_to do |format|
if @mm_team.update_attributes(params[:mm_team])
format.html { redirect_to(@mm_team, :notice => 'Mm team was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
... | [
"def update\n @team = subdomain.teams.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to(@team, :notice => 'Team was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /mm_teams/1 DELETE /mm_teams/1.xml | def destroy
@mm_team = MmTeam.find(params[:id])
@mm_team.destroy
respond_to do |format|
format.html { redirect_to(mm_teams_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @mm_team = MmTeam.find(params[:id])\n @mm_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_mm_teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team = subdomain.teams.find(params[:id])\n @team.destroy\n\n respond_to do |fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets flash message to be a warning | def flash_warning(warning)
flash[:warning] = warning
end | [
"def global_warning\n # NOTE (!) if you set this value and don't see it change in 10 minutes, CHECK YOUR SLAVE LAG. It reads from slaves.\n warning = EolConfig.global_site_warning\n flash.now[:error] = warning if warning\n end",
"def set_failure_notice\n if request.format == :html\n flash[:alert... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TODO working on creating stats by standards On the CUR section you were able to view how many times a specific type of breach occurred, could we have the same feature but rather than the breach, have it be a tally of the standards that happened in a conference for each individual kid? | def standards_counts
standards = {}
standards.default(0)
self.breaches.each do |b|
standards[b.subject] += 1
end
return standards
end | [
"def offense_counts; end",
"def offense_count; end",
"def claim_type_weight\n is_industry_code_configured = facility.industry_code_configured?\n remark_codes = []\n rcc = ReasonCodeCrosswalk.new(payer, nil, client, facility)\n if claim_level_eob?\n crosswalked_codes = rcc.get_all_codes_for_enti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculates the sum of base 10 values for the array of genes. | def value
genes.inject(0){ |memo, g| memo += g.to_i(16) }
end | [
"def sumDigitValues(arr)\n results = []\n arr.each do |i|\n sum = 0\n i.to_s.chars.each do |y|\n sum += y.to_i\n end\n results.unshift(sum)\n end\n results\nend",
"def sum \n @new_digits.map! do |number| \n if number >= 10 \n number.to_s.split('').map(&:to_i) \n el... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
creates a random set of genes | def randomize!(genecount = 10)
genecount.times.each { self << Chromosome.rand_hex }
self
end | [
"def RandomGenes\n @aGenes.map!{\n |x|\n b = Random.rand(32..127)\n x = b.chr\n }\n end",
"def random_genome\n random_options = @length.times.map { @random_option.call }\n Genome.new(random_options)\n end",
"def mutation\n nuevosGenes = Array.new(@gene... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
gene at the supplied index value | def [](index)
genes[index]
end | [
"def random_gene\n return @genes.at(random_index)\n end",
"def []=(index, value)\n genes[index] = value\n end",
"def next_gene\n return @cur_gene\n end",
"def get_gene_by_acc(acc)\n\t\t\tget_item_by_id(acc)\n\t\tend",
"def index\n @genes = Gene.all\n end",
"def search_gene\n @genedefini... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
length represents the length of the gene array. | def length
genes.length
end | [
"def length\n array.length\n end",
"def length; count end",
"def my_length(array)\n\tarray.length\nend",
"def size= length\n #This is a stub, used for indexing\n end",
"def size\n @array.length\n end",
"def length\n values.length\n end",
"def lengths\n\t\t#NArray.calcul... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set the gene at the supplied index value | def []=(index, value)
genes[index] = value
end | [
"def set(index, val)\n \n end",
"def index=(value)\n @index = value\n end",
"def set_at(index, value)\n raise \"The index #{index} is not in the range of the list\" unless in_limits?(index)\n\n pos = position_for_index(index)\n\n set_value(pos,value)\n end",
"def at(index)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Exchange genetic material with another chromosome. The strategy is to loop through the gene arrays of this and the other chromosome and randomly exchange at the gene level | def reproduce_with(other)
c = Chromosome.new
self.length.times do |i|
c << ((rand > 0.5) ? self[i] : other[i])
end
c
end | [
"def crossover chromosome\n gene_index = rand(@genes.length)\n new_genes1 = []\n new_genes2 = []\n @genes.each_with_index do |gene, index|\n if index >= gene_index\n new_genes1 << chromosome.genes[index]\n new_genes2 << @genes[index]\n else\n new_genes1 << @genes[index]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Change one of the genes to a random value. | def mutate
index = (rand * length).floor
genes[index] = Chromosome.rand_hex
end | [
"def mutate(genes_generator)\n i = rand(0..(genes.length - 1))\n @genes[i] = genes_generator.call(i)\n end",
"def mutation\n nuevosGenes = Array.new(@genes)\n nuevoGen = Gen.new\n nuevosGenes[rand(nuevosGenes.length)] = nuevoGen\n self.class.new(nuevosGenes)\n end",
"def re_expre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Class method to get the sidebar items from this module, in the context of the given controller instance. | def get_sidebar_items(controller)
return [] unless sidebar_proc
controller.instance_exec(&sidebar_proc)
end | [
"def index\n @origin_sidebar_items = Origin::SidebarItem.all\n end",
"def index\n @left_sidebars = LeftSidebar.all\n end",
"def sidebar\n @sidebar ||= begin\n sidebar = []\n load_config('sidebar').each { |k, attrs| sidebar << attrs.to_ostruct }\n sidebar.each do |attrs|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Class method to get the settings items from this module, in the context of the given controller instance. | def get_settings_items(controller)
return [] unless settings_proc
controller.instance_exec(&settings_proc)
end | [
"def settings\n @settings_manager\n end",
"def management_interface_settings\r\n ManagementInterfaceSettingsController.instance\r\n end",
"def alert_settings\r\n AlertSettingsController.instance\r\n end",
"def settings\n return @settings\n end",
"def list\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Defines a default doctype string that should be at the top of most plist files. Useful if we need to modify an invalid doctype string in memory. I'm looking at you, /System/Library/LaunchDaemons/org.ntp.ntpd.plist, you bastard. | def plist_xml_doctype
'<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
end | [
"def get_doctype()\n doctype = @defaultDoctype\n @@keymapping.each do |key,value|\n value.kind_of?(String) ? value = value.split : ''\n value.each do |keyword|\n @@metadata['title'].match(/#{keyword}/i) ? doctype = key : ''\n end\n end\n doctype.downcase\n end",
"def plist_xml_d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Read a plist, whether its format is XML or in Apple's "binary1" format, using the CFPropertyList gem. | def read_plist_file(file_path)
bad_xml_doctype = /^.*<!DOCTYPE plist PUBLIC -\/\/Apple Computer.*$/
# We can't really read the file until we know the source encoding in
# Ruby 1.9.x, so we use the magic number to detect it.
# NOTE: We need to use IO.read to be Ruby 1.8.x compatib... | [
"def read_plist_file(file_path)\n # We can't really read the file until we know the source encoding in\n # Ruby 1.9.x, so we use the magic number to detect it.\n # NOTE: We used IO.read originally to be Ruby 1.8.x compatible.\n if read_file_with_offset(file_path, binary_plist_magic_number.length... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method will write a plist file using a specified format (or XML by default) | def write_plist_file(plist, file_path, format='xml')
if format == 'xml'
plist_format = CFPropertyList::List::FORMAT_XML
else
plist_format = CFPropertyList::List::FORMAT_BINARY
end
begin
plist_to_save = CFPropertyList::List.new
... | [
"def write_plist_file(plist, file_path, format = :xml)\n begin\n plist_to_save = CFPropertyList::List.new\n plist_to_save.value = CFPropertyList.guess(plist)\n plist_to_save.save(file_path, to_format(format), :formatted => true)\n rescue IOError => e\n Puppet.err(_(\"Unab... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /foo13s/1 or /foo13s/1.json | def update
respond_to do |format|
if @foo13.update(foo13_params)
format.html { redirect_to @foo13, notice: "Foo13 was successfully updated." }
format.json { render :show, status: :ok, location: @foo13 }
else
format.html { render :edit, status: :unprocessable_entity }
form... | [
"def patch *args\n make_request :patch, *args\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch?; request_method == \"PATCH\" end",
"def update_aos_version(args = {}) \n put(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def up... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all the guard squads which is not yet annihilated or escaped. | def active_guard_squads
active_guard_squads = Array.new
guard_mission.squads.each do |squad|
active_guard_squads << squad if squad.entried and not squad.annihilated? and not squad.retreated_from_fortress
end
return active_guard_squads
end | [
"def trial_guard_squads\n guard_squads = Array.new\n trial_squads.each do |trial_squad|\n guard_squads << trial_squad unless trial_squad.intruder_flg\n end\n guard_squads\n end",
"def active_squads\n return active_guard_squads + active_intruder_squads\n end",
"def active_intruder_squads\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all the intruder squads which is not yet annihilated or escaped. | def active_intruder_squads
active_intruder_squads = Array.new
intruder_mission.squads.each do |squad|
active_intruder_squads << squad if squad.entried and not squad.annihilated? and not squad.retreated_from_fortress
end
return active_intruder_squads
end | [
"def active_squads\n return active_guard_squads + active_intruder_squads\n end",
"def trial_guard_squads\n guard_squads = Array.new\n trial_squads.each do |trial_squad|\n guard_squads << trial_squad unless trial_squad.intruder_flg\n end\n guard_squads\n end",
"def active_guard_squads\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all the squads which is not yet annihilated or escaped. | def active_squads
return active_guard_squads + active_intruder_squads
end | [
"def trial_guard_squads\n guard_squads = Array.new\n trial_squads.each do |trial_squad|\n guard_squads << trial_squad unless trial_squad.intruder_flg\n end\n guard_squads\n end",
"def active_intruder_squads\n active_intruder_squads = Array.new\n intruder_mission.squads.each do |squad|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all the guard squads from TrialSquad. | def trial_guard_squads
guard_squads = Array.new
trial_squads.each do |trial_squad|
guard_squads << trial_squad unless trial_squad.intruder_flg
end
guard_squads
end | [
"def active_guard_squads\n active_guard_squads = Array.new\n guard_mission.squads.each do |squad|\n active_guard_squads << squad if squad.entried and not squad.annihilated? and not squad.retreated_from_fortress\n end\n return active_guard_squads\n end",
"def starting_squads\n\n valid_squa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set max hp and max sp to hp and sp of trial mobs. | def initialize_trial_squads_status
trial_squads.each do |trial_squad|
trial_squad.trial_mobs.each do |trial_mob|
trial_mob.hp = trial_mob.max_hp
trial_mob.sp = trial_mob.max_sp
trial_mob.save
end
end
end | [
"def maxsp=(maxsp)\n @maxsp_plus += maxsp - self.maxsp\n @maxsp_plus = [[@maxsp_plus, -9999].max, 9999].min\n @sp = [@sp, self.maxsp].min\n end",
"def set_hp_to_max\n update(hp: max_hp)\n end",
"def maxhp=(new_maxhp)\n @maxhp_plus += new_maxhp - self.maxhp\n @maxhp_plus = [[@maxhp_pl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all the squads status from the latest TrialBattleTurn. | def update_trial_squads_status(trial_move_turn_id)
p trial_move_turn_id
trial_move_turns.reverse.each do |turn|
# p turn.id
# Seeking the latest trial_battle_set.
next if trial_move_turn_id < turn.id
next if turn.trial_battle_sets.blank?
# p turn
# Set hp and sp.
turn.... | [
"def active_guard_squads\n active_guard_squads = Array.new\n guard_mission.squads.each do |squad|\n active_guard_squads << squad if squad.entried and not squad.annihilated? and not squad.retreated_from_fortress\n end\n return active_guard_squads\n end",
"def active_intruder_squads\n active_in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return squads which were sorted by dex. | def dex_sorted_squads
return Tools.sort_by_dex(active_squads)
end | [
"def sortgoods\n @goods = @goods.flatten.sort { |x, y|\n $values[x[0].chr] <=> $values[y[0].chr]\n }\n end",
"def sort_bundles\n @combinations.sort_by { |combination| bundle_summation(combination) }\n end",
"def sort_stapols(a)\n a.sort_by {|e| e =~ PATTERNS['stapol']; [$1, $2.to_i, $3]}\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return fortress x size. | def fortress_x_size
return FortressCell.where("mini_map_id=?", mini_map.id).maximum('x')
end | [
"def fortress_y_size\n return FortressCell.where(\"mini_map_id=?\", mini_map.id).maximum('y')\n end",
"def in_pints\n @size / 96\n end",
"def size\n Register.alpha * p_square * (1.0 / registers_sum)\n end",
"def num_points\n @size * @size\n end",
"def bow_length\n sizes.inje... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return fortress y size. | def fortress_y_size
return FortressCell.where("mini_map_id=?", mini_map.id).maximum('y')
end | [
"def height\n dimensions()[:y]\n end",
"def ydim\n @ydim || xdim\n end",
"def height\n @max_y - @min_y\n end",
"def max_y_label_width_px\n return font_size if rotate_y_labels\n end",
"def price_y\r\n contents_height / 2 + line_height / 2\r\n end",
"def height\n bar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return center point of fortress. | def fortress_center_point
return Point.new((fortress_x_size / 2).truncate, (fortress_y_size / 2).truncate)
end | [
"def center\n Point.new(x: @x, y: @y)\n end",
"def get_center\n abs_size = get_absolute_size\n Vector.new(abs_size.x * 0.5, abs_size.y * 0.5)\n end",
"def getCenterInLonLat() ;\n bbox = getBBoxInLonLat() ;\n cx = (bbox.minPos().x() + bbox.maxPos().x()) / 2.0 ;\n cy = (bbox.minPos().y()... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return random inside cell of fortress. | def fortress_random_point
FortressCell.where("mini_map_id=? and symbol=?", mini_map.id, :concrete.to_s).sample
end | [
"def random_cell\n grid.sample.sample\n end",
"def random_cell\n\t\trow = rand(@rows)\n\t\tcolumn = rand(@grid[row].count)\n\t\tself[row, column]\n\tend",
"def random_cell\n row = rand(@rows)\n column = rand(@grid[row].count)\n puts column\n @grid[row][column]\n end",
"def random_cell\n ra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return fortress goal point. | def fortress_goal_point
trial_fortress_cells.each do |cell|
return Point.new(cell.x, cell.y) if cell.goal_flg
end
end | [
"def goal\n @internal_map.each_with_index do |x, i|\n if x == TARGET then \n return Point.new i % @w, (i/@w).to_i\n end\n end\n nil\n end",
"def get_point()\n bearing = rand(@bearing)\n distance = rand(@max_distance)\n Vincenty.destination(@origin[:lat], @origin[:long], b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return exit cells of fortress. | def fortress_exit_cells
FortressCell.where("mini_map_id = ? and (x = 0 or y = 0 or x = ? or y = ?) and symbol = ? and squad_id is null", mini_map.id, fortress_x_size, fortress_y_size, :concrete.to_s)
end | [
"def default_exit #:nodoc:\n @cells.reverse.each_with_index do |row, y|\n ry = @cells.length - y - 1\n row.reverse.each_with_index do |cell, x|\n rx = row.length - x - 1\n return [rx+1, ry] if @mask[rx, ry]\n end\n end\n [0, 0] # if every cell is masked, then 0,0 is as good as ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return trap which is deployed in this cell. | def fortress_cell_trap(point)
cell = FortressCell.where("mini_map_id=? and x=? and y=?", mini_map.id, point.x, point.y)
if cell.blank?
return nil
else
cell.first.trap
end
end | [
"def value\n @stack.last\n end",
"def pr_trap(one_trap)\r\n\ttss = \"\"\r\n\t\r\n\t# --------------------------\r\n\t# Print all trap information \r\n\t# --------------------------\r\n\ttss << \" --Trap from Unbrowse SNMP -------------------\\n\" \r\n\ttss << \" Trap ID : #{one_trap.ID}\\n\"\r\n\ttss << \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return true if guard squad is existing on goal cell. | def goal_cell_guarded?
guard_mission.squads.each do |squad|
return true if squad.current_point.equal?(fortress_goal_point)
end
return false
end | [
"def guard_defeated?\n return true if @goal_was_occupied\n guard_mission.squads.each do |squad|\n return false if not squad.annihilated? and not squad.retreated_from_fortress and squad.entried\n end\n return true\n end",
"def enemy_squad_in_battle_range?\n return false if @target_squad.nil?\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return true if all of guard squads are retreated or annihilated. | def guard_defeated?
return true if @goal_was_occupied
guard_mission.squads.each do |squad|
return false if not squad.annihilated? and not squad.retreated_from_fortress and squad.entried
end
return true
end | [
"def goal_cell_guarded?\n guard_mission.squads.each do |squad|\n return true if squad.current_point.equal?(fortress_goal_point)\n end\n return false\n end",
"def active_guard_squads\n active_guard_squads = Array.new\n guard_mission.squads.each do |squad|\n active_guard_squads << squad if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return true if all of intruder squads are retreated or annihilated. | def intruder_defeated?
intruder_mission.squads.each do |squad|
return false if not squad.annihilated? and not squad.retreated_from_fortress and squad.entried
end
return true
end | [
"def active_intruder_squads\n active_intruder_squads = Array.new\n intruder_mission.squads.each do |squad|\n active_intruder_squads << squad if squad.entried and not squad.annihilated? and not squad.retreated_from_fortress\n end\n return active_intruder_squads\n end",
"def sunk?\n if occupied... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /foo38s or /foo38s.json | def create
@foo38 = Foo38.new(foo38_params)
respond_to do |format|
if @foo38.save
format.html { redirect_to @foo38, notice: "Foo38 was successfully created." }
format.json { render :show, status: :created, location: @foo38 }
else
format.html { render :new, status: :unprocess... | [
"def post *args\n make_request :post, *args\n end",
"def post(data, tags_in = {}) ; post_to nil, data, tags_in end",
"def post(rectype,attribs,http)\r\n endpoint=\"#{URL_PREFIX}/t#{rectype}s.json\"\r\n req = Net::HTTP::Post.new(endpoint,initheader = {'Content-Type' =>'application/json'})\r\n req.body = a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /foo38s/1 or /foo38s/1.json | def update
respond_to do |format|
if @foo38.update(foo38_params)
format.html { redirect_to @foo38, notice: "Foo38 was successfully updated." }
format.json { render :show, status: :ok, location: @foo38 }
else
format.html { render :edit, status: :unprocessable_entity }
form... | [
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds CORRECT_POSITION pegs and returns positions that were guessed correctly | def feedback_position(guess)
correct_positions = Array.new(PEG_SPACES)
guess.each.with_index do |peg, slot|
if peg.eql? @answer[slot]
@guesses[@turns_passed].add_feedback_peg CORRECT_POSITION
guess[slot] = EMPTY
correct_positions[slot] = CORRECT_POSITION
end
end
corre... | [
"def guess_pos()\n sum = TEAM_REFILL_PLAYERS_POS_TO[PLAYER_POSITION_GK]\n + TEAM_REFILL_PLAYERS_POS_TO[PLAYER_POSITION_D]\n + TEAM_REFILL_PLAYERS_POS_TO[PLAYER_POSITION_M]\n + TEAM_REFILL_PLAYERS_POS_TO[PLAYER_POSITION_S]\n pos = rand(1..sum)\n ret = {\n PLAYER_POSITION_GK => 0,\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the given query's query_mode (!lg/!lm) without looking at subqueries. | def query_mode
node_text(node_tagged(:querymode, :exclude => :subquery))
end | [
"def subquery(from_mode, to_mode, query)\n if from_mode == :none\n return query\n else\n return ['in', 'certname',\n ['extract', 'certname',\n [\"select_#{to_mode}\", query]]]\n end\n end",
"def query_type\n return @query_type\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find all subqueries immediately under the current query, i.e. no subsubqueries. | def immediate_subqueries
my_nodes_tagged(:subquery)
end | [
"def subquery\n [\n [ :N, :subquery, [ :simple_subquery, :end_of_subquery ], :subQueryRep, :subQueryGen ], \n [ :M, :subquery, [ :simple_subquery, :order_by_clause, :end_of_subquery ], :subQueryRep, :subQueryGen ],\n\n [ :N, :end_of_subquery, [], :endOfSubqueryRep, :endOfSubqueryGen ],\n\n [ ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all nodes with the given tag in this query, i.e. not in subqueres. | def my_nodes_tagged(tag, options={})
options = options.dup
options[:exclude_descent] = :subquery
nodes_tagged(tag, options)
end | [
"def not_tagged_with(tags)\n tags = tags.is_a?(Array) ? TagList.new(tags.map(&:to_s)) : TagList.from(tags)\n \n sub = Tagging.select(\"#{Tagging.table_name}.taggable_id\").joins(:tag).\n where(:taggable_type => base_class.name, \"#{Tag.table_name}.name\" => tags)\n \n whe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the default position. | def set_default_position
if self.position.nil?
self.position = newsletter.blocs.count + 1
end
end | [
"def set_default_position\n if position.nil? && parent\n self.position = parent.position\n end\n super\n end",
"def setInitialPosition(x, y, head)\n \t\t@x = x\n \t\t@y = y\n \t\t@curr_dir = head\n \tend",
"def init_position\n @init_position\n end",
"def set_Position(val... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cards_in_category returns an array of cards from selected category. | def cards_in_category(sel_category)
@cards.select do |card|
card.category == sel_category
end
end | [
"def cards_in_category(cat)\n @cards.find_all { |card_in_deck| card_in_deck.category == cat}\n end",
"def retrieve_cards(category)\n self.unused_cards = Card.where(category: Category.find_by(name: category)).where.not(id: self.used_cards).pluck(:id).shuffle if self.unused_cards.empty?\n return ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /galactic_clusters GET /galactic_clusters.json | def index
@galactic_clusters = GalacticCluster.all
end | [
"def clusters\n begin\n clusters = PermissionsManager.get_family_clusters(current_user, clusters_params[:family_group_id])\n rescue\n render json: {}, status: 403\n return\n end\n render json: { 'clusters': clusters }, status: 200\n end",
"def get_al... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /galactic_clusters/1 GET /galactic_clusters/1.json | def show
@galactic_cluster = GalacticCluster.find(params[:id])
end | [
"def index\n @galactic_clusters = GalacticCluster.all\n end",
"def index\n @clusters = current_account.clusters\n end",
"def show\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cluster }\n end\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /galactic_clusters POST /galactic_clusters.json | def create
@galactic_cluster = GalacticCluster.new(galactic_cluster_params)
respond_to do |format|
if @galactic_cluster.save
format.html { redirect_to @galactic_cluster, notice: 'Galactic cluster was successfully created.' }
format.json { render :show, status: :created, location: @galacti... | [
"def create\n @artificial_construct = GalacticCluster.new(artificial_construct_params)\n\n respond_to do |format|\n if @artificial_construct.save\n format.html { redirect_to @artificial_construct, notice: 'Galactic cluster was successfully created.' }\n format.json { render :show, status: :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /galactic_clusters/1 PATCH/PUT /galactic_clusters/1.json | def update
respond_to do |format|
if @galactic_cluster.update(galactic_cluster_params)
format.html { redirect_to @galactic_cluster, notice: 'Galactic cluster was successfully updated.' }
format.json { render :show, status: :ok, location: @galactic_cluster }
else
format.html { ren... | [
"def update\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n if @cluster.update_attributes(params[:cluster])\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /galactic_clusters/1 DELETE /galactic_clusters/1.json | def destroy
@galactic_cluster.destroy
respond_to do |format|
format.html { redirect_to galactic_clusters_url, notice: 'Galactic cluster was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @cluster = Cluster.find(params[:id])\n @cluster.destroy\n\n respond_to do |format|\n format.html { redirect_to clusters_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @f5_cluster = F5Cluster.find(params[:id])\n @f5_cluster.destroy\n\n respond_to do |fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the current JWT auth object if it exists | def current_jwt_token
@jwt_auth ||= session[:jwt_auth] ? JwtToken.where(id: session[:jwt_auth]).first : nil
end | [
"def current_jwt_auth\n #\n @jwt_auth ||= (defined? session and session[:jwt_auth]) ? JwtToken.where(id: session[:jwt_auth]).first : nil\n end",
"def current_jwt_user\n #\n @jwt_user ||= (defined? session and session[:jwt_user]) ? JwtUser.where(id: session[:jwt_user]).first : nil\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current JWT auth object | def current_jwt_token=(jwt_auth)
session[:jwt_auth] = jwt_auth.nil? ? nil : jwt_auth.id
@jwt_auth = jwt_auth
end | [
"def current_jwt_auth=(jwt_auth)\n session[:jwt_auth] = jwt_auth.nil? ? nil : jwt_auth.id\n @jwt_auth = jwt_auth\n end",
"def current_jwt_auth=(jwt_auth)\n session[:jwt_auth] = jwt_auth.nil? ? nil : jwt_auth.id\n @jwt_auth = jwt_auth\n end",
"def set_auth_token\n\t\t\treturn if a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the current JWT context if it exists | def current_jwt_context
@jwt_context ||= session[:jwt_context]
end | [
"def current_jwt_token\n @jwt_auth ||= session[:jwt_auth] ? JwtToken.where(id: session[:jwt_auth]).first : nil\n end",
"def current_jwt_auth\n #\n @jwt_auth ||= (defined? session and session[:jwt_auth]) ? JwtToken.where(id: session[:jwt_auth]).first : nil\n end",
"def current_jwt_user\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current JWT context | def current_jwt_context=(jwt_context)
session[:jwt_context] = jwt_context
@jwt_context = jwt_context
end | [
"def current_jwt_context\n @jwt_context ||= session[:jwt_context]\n end",
"def current_jwt_token=(jwt_auth)\n session[:jwt_auth] = jwt_auth.nil? ? nil : jwt_auth.id\n @jwt_auth = jwt_auth\n end",
"def current_jwt_auth=(jwt_auth)\n session[:jwt_auth] = jwt_auth.nil? ? nil : jwt_auth.id\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current JWT account_id | def current_account_id=(account_id)
session[:account_id] = account_id
@account_id = account_id
end | [
"def account_id=(value)\n @account_id = value\n end",
"def authenticated_with=(account)\n if (accounts.member?(account))\n @authenticated_with_id = account.id\n else\n @authenticated_with_id = nil\n end\n \n end",
"def set_account_guid\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
XML on_create, on_delete handlers overload the xml_on_delete method since we may need to do some cleanup work in the [edit vlans] stanza | def xml_on_delete( xml )
return unless @under_vlans
return if @under_vlans.empty?
_xml_rm_under_vlans( xml, @under_vlans )
end | [
"def xml_callbacks\n @xmlcbs\n end",
"def _trigger_destroy_callback; end",
"def netdev_resxml_new( edit_xml )\n self.properties.each do |p| \n self.send(\"xml_change_#{p}\", edit_xml ) \n end\n end",
"def on_delete(&block)\n on('delete', &block)\n end",
"def add_xml_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provide either a Rack::Request or a Hash containing :key, :signature, :body, and :content_type (optional) | def initialize(request, client = Pusher)
@client = client
# For Rack::Request and ActionDispatch::Request
if request.respond_to?(:env) && request.respond_to?(:content_type)
@key = request.env['HTTP_X_PUSHER_KEY']
@signature = request.env["HTTP_X_PUSHER_SIGNATURE"]
@content_type... | [
"def construct_request_hash; end",
"def extract_params_from_request(rack_request)\n # Prevent cache bypass DOS attacks by only permitting :sig and :q\n bail(400, 'Query strings are not supported') if rack_request.params.any?\n\n # Take the last two path components of the request URI.\n # The second-to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns whether the WebHook is valid by checking that the signature matches the configured key & secret. In the case that the webhook is invalid, the reason is logged | def valid?(extra_tokens = nil)
extra_tokens = [extra_tokens] if extra_tokens.kind_of?(Hash)
if @key == @client.key
return check_signature(@client.secret)
elsif extra_tokens
extra_tokens.each do |token|
return check_signature(token[:secret]) if @key == token[:key]
end
... | [
"def check_signature(secret)\n digest = OpenSSL::Digest::SHA256.new\n expected = OpenSSL::HMAC.hexdigest(digest, secret, @body)\n if @signature == expected\n return true\n else\n Pusher.logger.warn \"Received WebHook with invalid signature: got #{@signature}, expected #{expected}\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Array of events (as Hashes) contained inside the webhook | def events
data["events"]
end | [
"def events\n @events ||= Array(context[:events]).reverse.map { |event| Concierge::SafeAccessHash.new(event) }\n end",
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end",
"def all(options = nil)\n request = Request... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks signature against secret and returns boolean | def check_signature(secret)
digest = OpenSSL::Digest::SHA256.new
expected = OpenSSL::HMAC.hexdigest(digest, secret, @body)
if @signature == expected
return true
else
Pusher.logger.warn "Received WebHook with invalid signature: got #{@signature}, expected #{expected}"
retu... | [
"def has_valid_signature?\n Adyen::HPP::Signature.verify(params, shared_secret)\n end",
"def signed_request_is_valid?(secret, signature, params)\n sig = base64_url_decode(signature)\n expected_sig = OpenSSL::HMAC.digest('SHA256', secret, params.tr(\"-_\", \"+/\"))\n return sig == ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The +sprite_piece+ method adds sprite_piecess to the sprite === Example === sprite :foo do sprite_piece 'buttons/btnblackdefault28.png', 'a.black.wf_button > span, button.black.wf_submit span' Arguments: [String] the path to sprite piece relatie to config.sprite_pieces_path [String] (optional) the css selector to use f... | def sprite_piece(path, css_class = nil, options = {})
css_class ||= File.basename(path, File.extname(path)).split('/').join('-')
@sprite_pieces.add(path, css_class, options)
end | [
"def piece_icons_path\n File.join(@resource_path, 'pieces')\n end",
"def add_piece(piece)\n @pieces << piece\n end",
"def draw_piece_with_custom(piece_image)\n img = part.draw_piece(piece_image, custom_image)\n dump('draw_piece_with_custom', img)\n img\n end",
"def draw_player_pieces arg... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the password reset | def set_password_reset
self.make_password_reset_code
end | [
"def send_reset_password_token\n set_reset_password_token\n end",
"def reset_password\n update_attribute(:password_reset_code, nil)\n @reset_password = true\n end",
"def reset_password\n self.update_attribute(:password_reset_code, nil)\n @reset_password = true\n end",
"def request_pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse NetID and UID from uid attributes | def parse_uids(uid_array, dn)
uid_dn = dn.split(',')[0].split('=')[1]
uid_alias = nil
uid_array.each do |uid|
if uid.match(uid_dn)
uid_dn = uid
else
uid_alias = uid
end
end
if uid_alias.nil?
uid_alias = uid_dn
end
return uid_dn, uid_alias
end | [
"def uidnumber\n parser_for(:user_uidnumber, user_attributes)\n end",
"def uid\n if attributes[:owner] && !attributes.key?(:uid)\n require 'etc'\n attributes[:uid] = Etc.getpwnam(attributes[:owner]).uid\n end\n attributes[:uid]\n end",
"def set_uid\n unless gn.blank? |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
True if presentation contains Narration | def narration_present?
content_types_xml = nil
pres_doc = @files.file.open '[Content_Types].xml' rescue nil
content_types_xml = Nokogiri::XML::Document.parse(pres_doc) if pres_doc
content = content_types_xml.xpath('//@Extension')
if content.to_s.include?('m4a')
@type = 'm4a'
@narration =... | [
"def isPresentation\n @RecordType == PRESENTATION\n end",
"def noun_phrase?\n content =~ /^NP/\n end",
"def narrative?\n\t\tself.status == \"Fictional Narrative\"\n\tend",
"def is_illustration?\n :illustration == self.media_type\n end",
"def morphotaxon?\n scientific_name =~ /... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Since the slides have to be manipulated to show correctly in Libre, the pptx has to be rebuild. | def rebuild_pptx
Zip::File.open(@files.to_s, Zip::File::CREATE) { |zipfile|
@slides.each do |f|
if f.changed
# Temporary file to store the manipulated xml
temp_file = Tempfile.new(f.slide_file_name)
# Store the manipulated xml inside the file
temp_file.write(f.r... | [
"def update_presentation_file(doc)\n # Write the new slides to presentation.xml\n @slides.reverse.each do |slide|\n rel_id = @relationship_manager.get_relationship_by_target(\"slides/#{::File.basename(slide[:old_path])}\")[:id]\n old_slide_node = doc.xpath(\".//p:sldId[@r:id='#{rel_id}']\").... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Do any attributes have unsaved changes? person.changed? => false person.name = 'bob' person.changed? => true | def changed?
!changed_attributes.empty?
end | [
"def changed?\n return true if attributes_changed?\n return true if associations_changed?\n false\n end",
"def dirty?\n @old_attributes != attributes\n end",
"def changed?\n eav_attributes.each do |attribute|\n return true if ( attribute.changed? || attribute.new_record? )\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List of attributes with unsaved changes. person.changed => [] person.name = 'bob' person.changed => ['name'] | def changed
changed_attributes.keys
end | [
"def changed\n fields = []\n ( self.class.attribute_tags_names.values.flatten + self.class.property_names - self.class.identity_names).each do |name|\n fields << name if send(name) != @loaded[name]\n end\n return fields\n end",
"def changed\n changed_attributes.keys.select { |at... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Initialize an ElevatorDispatcher. elevators Array, collection of elevators to apply strategies to request ElevatorRequest, request to get elevator for strategies Array, collection of strategies in the order they should be applied, strategies must respond to elevator(2) | def initialize(elevators, request, strategies: STRATAGIES)
@elevators = elevators
@request = request
@strategies = strategies
end | [
"def initialize(elevators, request)\n @elevators = elevators\n @request = request\n end",
"def initialize(elevator_dispatcher: ElevatorDispatcher,\n elevator_factory: Elevator,\n elevator_request_factory: ElevatorRequest,\n size: MIN_ELEVATO... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Elevator, returns the best elevator from the first strategy that returns an elevator | def next_elevator
strategies.map { |strategy| strategy.elevator(elevators, request) }.first
end | [
"def elevator\n elevators.sort_by { |e| e.stop_count }.first\n end",
"def FindClosestWithShortestListElevator (elevatorsList, userPosition)\n distance = @columnList[0]].floorList.size\n listLength = @columnList[0].floorList.size\n elevatorList.each {|elevator|\n if (ele... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build XML from transform object, build XML | def buildXML(transform_obj)
xml_string = '<PoortegoTransformResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="' + "#{ENV['POORTEGO_LOCAL_BASE']}/poortego/lib/core/poortego_transform/xml/PoortegoTransformResponse.xsd" + '">'
xml_string << '<ResponseData>'
... | [
"def to_xml\n builder.target!\n end",
"def generate_xml(objects)\n \txml = Builder::XmlMarkup.new\n objects.each do |o|\n generate_object(xml, o)\n end\n xml.xml\n end",
"def to_minilanguage xml\n# The document element is robot and its children are the top level transform... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tells if a provider was found for the given url. | def has_provider?( url )
@config.each do | options |
if ( url =~ options[ :pattern ])
return true
end
end
false
end | [
"def matches_provider?(url)\r\n self.class.matches_provider?(url)\r\n end",
"def find(url)\n @@urls.keys.each do |url_regexp|\n next unless url_regexp.match?(url)\n\n matching_provider = @@urls[url_regexp].detect { |p| p.include?(url) }\n\n # If we've found a matching pro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds providers of the given url. | def providers( url )
@config.each do | name, options |
if ( url =~ options[ :pattern ])
yield self._provider( name, options )
end
end
end | [
"def find(url)\n @@urls.keys.each do |url_regexp|\n next unless url_regexp.match?(url)\n\n matching_provider = @@urls[url_regexp].detect { |p| p.include?(url) }\n\n # If we've found a matching provider, return it right away!\n return matching_provider if matching_provider\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
attr_reader :pudginess makes the code below rendundant (it creates the same mehtod) | def pudginess
@pudginess
end | [
"def pudginess=(new_pudginess_value)\n @pudginess = new_pudginess_value\n end",
"def instance_variables() end",
"def class_variables() end",
"def droid; end",
"def class_variables; end",
"def ignored_instance_variables; end",
"def delegate_object_reader_method; end",
"def page_setup_pr; end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
attr_writer :pudginess makes the code below rendundant (it creates the same mehtod) | def pudginess=(new_pudginess_value)
@pudginess = new_pudginess_value
end | [
"def pudginess\n @pudginess\n end",
"def attr_writer(sym, *more) end",
"def gr_policy_setup\n begin\n # If there are no accessors for the model object's accessors,\n # they need to be defined so we can alias them\n define_attribute_methods\n rescue\n end\n \n if self.respond_to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /crunch_companies/1 GET /crunch_companies/1.json | def show
@crunch_company = CrunchCompany.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @crunch_company }
end
end | [
"def companies\n @companies = AccountingEntity.find(params[:id]).companies\n\n respond_to do |format|\n format.html { render \"companies/index.html\" } # show.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n if @companies\n ren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /crunch_companies/new GET /crunch_companies/new.json | def new
@crunch_company = CrunchCompany.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @crunch_company }
end
end | [
"def new\n @company = Company.new(:name => 'default')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /crunch_companies/1 PUT /crunch_companies/1.json | def update
@crunch_company = CrunchCompany.find(params[:id])
@fetch_crunch = Crunchbase::Company.get(@crunch_company.company_name)
@fetch_crunch_posts = @fetch_crunch.ipo
respond_to do |format|
if @crunch_company.update_attributes(params[:crunch_company])
@crunch_company.update_attribute(... | [
"def update\n @company_id = company_params[:company_id]\n @reponse = HTTParty.put(\"https://rails-api-ipo.herokuapp.com/api/v1/companies/#{@company_id}.json\",\n :body => {:company_name => company_params[:company_name]}.to_json,\n :headers => { 'Content-Type' => 'application/json' } )\n respond_to do... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /crunch_companies/1 DELETE /crunch_companies/1.json | def destroy
@crunch_company = CrunchCompany.find(params[:id])
@crunch_company.destroy
respond_to do |format|
format.html { redirect_to crunch_companies_url }
format.json { head :no_content }
end
end | [
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n \n render json: @company, status: :ok \n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @biz_company = BizCompany.find(params[:i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Une Array of [employe_nom, dateTime] | def initialize
@data = Array.new
# Obtenir toutes les feuilles de temps les employes de moins de 18 ans
minDate = Date::today().years_ago(18);
Feuille.
joins('inner join employes as empl on employe_id = empl.id').
where('empl.naissance > ?', minDate.to_formatted_s(:db)).each do | f |
... | [
"def dates\n @datapoints.collect { |point| point[0] }\n end",
"def array_time_helper(st, et)\n st_min = st%60\n st_hour = st/60\n et_min = et%60\n et_hour = et/60\n day = st_hour/24\n d = int_to_day(day)\n return [[d],st_hour%24*100+st_min, et_hour%24*100+et_min]\n \n end",
"def _ex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List of tests 1. Empty Eobqa create 2. Create with invalid data Check with nil total_fields Check with nil total_incorrect_fields Check with nil account_number Check Uniqueness of name 3. Check Eobqa count when we created and distroy Blank EOBQA | def test_blank_eobqa
eobqa = EobQa.new(:total_fields => 10, :total_incorrect_fields => 2)
assert_equal(false, eobqa.save)
end | [
"def test_completed_eob_by_qa\r\n qa = users(:qa01)\r\n processor = users(:processor01)\r\n eob_report1 = EobReport.create!(:verify_time => Time.now, :account_number => 123, :processor => processor.userid, :accuracy => 100,\r\n :qa => qa.userid, :batch_id => batches(:batch1), :batch_dat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
num1 The Integer which is going to be compared num2 The Integer which is also going to be compare max The Integer which temporarily is the largest of the two Example max_of_two(1, 2) => 2 Returns the largest number | def max_of_two(num1, num2)
max = num1
if num2 > num1
max = num2
end
return max
end | [
"def max_of_two(num1, num2)\n \n if num1 < num2\n return num2\n else \n return num1\n end\n end",
"def max_of_two(num1, num2)\n if num1 > num2\n return num1\n end\n return num2\nend",
"def max_of_two(number1, number2)\n if number1 > number2\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Asks a question without context awareness. Searches the knowledge base for a fact within timeframe of the present time, and asks a random question that can be asked about that fact. Also, creates a list of possible answers based on similar facts that occurred around that timeframe. | def askQuestion(timeframe=1*DAY_TO_SECONDS)
facts = @kb.getFacts(timeframe)
while facts.length > 0
fact = facts.sample
matched = []
@qat.each do |qat|
ismatch = qat.matches(fact)
matched.push(ismatch) if ismatch
end
qat,matchesArr = matched.sample
if not qat #... | [
"def coach_answers\n #[\"Fuck off!\", \"Sorry I'am busy!\", \"No time for you!\"].sample\n if @query == \"What time?\"\n return \"It's #{Time.now}\"\n else\n [\"Fuck off!\", \"Sorry I'am busy!\", \"No time for you!\"].sample\n end\n end",
"def ask_questions\n until game_over?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
give user created by google auth a session and redirect to user home page | def omniauth
@user = User.create_by_google_omniauth(auth)
session[:user_id] = @user.id
redirect_to user_path(@user)
end | [
"def google_sign_in(user)\n\t\t# Already created user from google acc\n\t\tsession[:user_id]=user.id\n\t\t# directed back to session_controller.\n\tend",
"def signed_on_to_google\n if current_member\n # result = google_api_request( 'plus', 'v1', 'people', 'get', { userId: current_member.uid })\n # if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /bids/1 DELETE /bids/1.json | def destroy
@bid = Bid.find(params[:id])
@bid.destroy
respond_to do |format|
format.html { redirect_to bids_url }
format.json { head :no_content }
end
end | [
"def destroy\n @bid = @swarm_request.bids.find(params[:id])\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to(swarm_request_bids_url(:swarm_request_id => @swarm_request.to_param)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bid = Bid.find(params[:id])\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update the query status | def update_query_status(total)
@query_status.last_twid = @last_twid
@query_status.last_run = Time.now.utc
@query_status.last_result_count = total
@query_status.save!
end | [
"def update_query(query,state)\n @queue.each do |q|\n if q.query == query\n puts \"update_query: #{query} (#{q.state}) -> (#{state})\" if @debug\n q.state = state\n break\n end\n end\n end",
"def update_status_check\n check_infos.pluck(:status).include?('fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add a conversion job to the queue | def add_to_queue(result)
@last_twid = @last_twid > result.id ? @last_twid : result.id
App.log.info("pushing job to queue #{@queue.name}:\n#{result.text}\n#{"-"*80}")
@queue.push(ConversionJob.new({
"queue_id" => @queue.id,
"twid" => result.id,
"from_user_id" => r... | [
"def queue_job; end",
"def add_job(job)\n @stream.add_message(job.to_message)\n job\n end",
"def queue(job)\n self.class.queue << job\n end",
"def check_for_job\n unless @queue\n App.log.info(\"nothing to do...so bored\")\n return\n end\n message = @queue.pop\n return unle... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Print summary of both values (first + second) | def calc_sum_two(first, second)
puts "the sum of #{first} and #{second} is #{first + second}"
end | [
"def calc_sum_two(first, second)\n puts \"The sum of #{first} and #{second} is #{first + second}\"\nend",
"def print_summary\n stats = [statistics[:total_code_loc], statistics[:total_spec_loc]]\n stats.push(stats[1].to_f / stats[0].to_f)\n \n puts \" Code LOC: %s Test LOC: %s ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Using variables passed in, generate user data file | def generate_user_data(userdata_dir, bootstrap_script, config)
ERB.new(
File.new(File.join(userdata_dir, bootstrap_script)).read, nil, '-'
).result(binding)
end | [
"def create_data(data)\n file_name = \"data_set_#{Time.now.getutc}\"\n output_file = File.new(\"data/#{file_name}.json\", \"w\")\n output_file.write(JSON.generate(data)) \n end",
"def data_filename; base_name + \".data\"; end",
"def user_data(instance)\n hostname = instance[\"hostname\"]\n # write ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if we allow clobbering and need to clobber | def check_clobber(opts, config)
fail Tapjoy::AutoscalingBootstrap::Errors::ClobberRequired if check_as_clobber(**opts, **config)
puts "We don't need to clobber"
end | [
"def clobber\n end",
"def overwrite_allowed?\r\n @@overwrite_allowed\r\n end",
"def clobber(*includes)\n Rake.application.IncludeClobberTargets(includes)\n end",
"def can_preserve_registers?\n false\n end",
"def disallow_overwrite!\r\n @@overwrite_allowed = false\r\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
See what version of the yaml we are running | def check_yaml_version(config)
# If we don't have one specified assume v1
config[:version] ? config[:version] : "1.0.0"
end | [
"def newer_yaml_version?(config)\n Tapjoy::AutoscalingBootstrap::Base.new.check_yaml_version(config).split(\".\").first.to_i >= 2\nend",
"def version\n puts PuppetDockerTools::Utilities.get_value_from_env('version', namespace: namespace, directory: directory, dockerfile: dockerfile)\n end",
"def docker... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Confirm config settings before running autoscaling code | def confirm_config(keypair:, zones:, security_groups:, instance_type:,
image_id:, iam_instance_profile:, prompt:, use_vpc: use_vpc,
vpc_subnets: nil, has_elb: has_elb, config:, termination_policies:,
**unused_values)
puts ' Preparing to configure the following autoscaling group:'
... | [
"def confirm_configuration\n confirm_step(:confirm_configuration)\n check_required\n end",
"def confirm_settings\n raise Error.new(\"Must specify a path to a local configuraiton file\") unless config\n raise Error.new(\"Must specify the IP of a Zabbix server\") unless serve... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if security group exists and create it if it does not | def sec_group_exists(groups)
groups.each do |group|
begin
puts "Verifying #{group} exists..."
group = Tapjoy::AutoscalingBootstrap::AWS::EC2.describe_security_groups(group)
rescue Aws::EC2::Errors::InvalidGroupNotFound => err
STDERR.puts "Warning: #{err}"
... | [
"def ensure_ec2_security_group(group_name)\n security_groups = @ec2.describe_security_groups()\n names = Array.new\n if !security_groups.nil? && !security_groups.securityGroupInfo.nil? && !security_groups.securityGroupInfo.item.nil?\n security_groups.securityGroupInfo.item.each {|grou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A document selector to identify the scope of the registration. If set to null the document selector provided on the client side will be used. | def document_selector
attributes.fetch(:documentSelector)
end | [
"def selector\n @selector ||= document.atomic_selector\n end",
"def selector\n @selector ||= climb({ \"_id\" => _root.id }) do |document, value|\n value[\"#{document.path}._id\"] = document.id; value\n end\n end",
"def selector\n parent.atomic_selector\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /minutes/1 GET /minutes/1.xml | def show
@minute = Minute.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @minute }
end
end | [
"def show\n @minutes_doc = MinutesDoc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @minutes_doc }\n end\n end",
"def new\n @minute = Minute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /minutes/new GET /minutes/new.xml | def new
@minute = Minute.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @minute }
end
end | [
"def new\n @minutes_doc = MinutesDoc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @minutes_doc }\n end\n end",
"def new\n @company_minute = CompanyMinute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /minutes/1 PUT /minutes/1.xml | def update
# checar params[:regenerateTasks]
@minute = Minute.find(params[:id])
respond_to do |format|
if @minute.update_attributes(params[:minute])
if params[:regenerateTasks]=="1"
@tasks = @minute.get_tasks_from_description(params[:minute][:content], current_user.id)
... | [
"def update\n @minute = Minute.find(params[:id])\n\n respond_to do |format|\n if @minute.update_attributes(params[:minute])\n format.html { redirect_to @minute, notice: 'Minute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /minutes/1 DELETE /minutes/1.xml | def destroy
@minute = Minute.find(params[:id])
@minute.destroy
respond_to do |format|
format.html { redirect_to(minutes_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @minutes_doc = MinutesDoc.find(params[:id])\n @minutes_doc.destroy\n\n respond_to do |format|\n format.html { redirect_to(minutes_docs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @minute = Minute.find(params[:id])\n @minute.destroy\n\n respond_to d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /notify_observers/1 GET /notify_observers/1.json | def show
@notify_observer = NotifyObserver.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @notify_observer }
end
end | [
"def show\n @notify_observer_property = NotifyObserverProperty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @notify_observer_property }\n end\n end",
"def new\n @notify_observer = NotifyObserver.new\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /notify_observers/new GET /notify_observers/new.json | def new
@notify_observer = NotifyObserver.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @notify_observer }
end
end | [
"def new\n @notify_observer_property = NotifyObserverProperty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @notify_observer_property }\n end\n end",
"def new\n @notify = Notify.new\n\n respond_to do |format|\n format.html # new.html.erb... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.