query stringlengths 7 6.41k | document stringlengths 12 28.8k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 5 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Moves the text cursor to the specified position in the given input element or textarea. This method will fail if the specified element isn't an input element or textarea. | def set_cursor_position locator, position
command 'setCursorPosition', locator, position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_to_element(element)\n driver.execute_script('arguments[0].scrollIntoView(true)', element)\n end",
"def move_caret_to_mouse\n # Test character by character\n 1.upto(self.text.length) do |i|\n if @window.mouse_x < x + FONT.text_width(text[0...i])\n self.caret_pos = self.selection... | [
"0.5737054",
"0.5690897",
"0.5686064",
"0.5686064",
"0.5540334",
"0.55158687",
"0.5475659",
"0.5445528",
"0.54310524",
"0.5392322",
"0.53905773",
"0.53389335",
"0.5309308",
"0.5301979",
"0.5290331",
"0.52765924",
"0.52651703",
"0.5264895",
"0.52563196",
"0.522613",
"0.5187994... | 0.5751592 | 0 |
Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10). Setting this value to 0 means that we'll send a "mousemove" event to every single pixel in between the start location and the end location; that can be very slow, and may cause some browsers to force the JavaScript to ti... | def set_mouse_speed pixels
command 'setMouseSpeed', pixels
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mousemove_relative(x, y)\n @logger.info(\"mousemove not supported\")\n end",
"def move(x:, y:, steps: 1)\n from_x = @x\n from_y = @y\n @x = x\n @y = y\n\n steps.times do |i|\n new_x = from_x + ((@x - from_x) * ((i + 1) / steps.to_f))\n new_y = from_y + ((@y - from_y... | [
"0.55520976",
"0.53963435",
"0.53243816",
"0.5292193",
"0.52682006",
"0.52484757",
"0.51959443",
"0.5171521",
"0.5144172",
"0.5103676",
"0.50555176",
"0.50542754",
"0.5039077",
"0.49192286",
"0.48991948",
"0.48554626",
"0.48400736",
"0.48159108",
"0.47878376",
"0.47598165",
"... | 0.59022546 | 0 |
Press the shift key and hold it down until doShiftUp() is called or a new page is loaded. | def shift_key_down
command 'shiftKeyDown'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_key_up\r\n command 'shiftKeyUp'\r\n end",
"def shift_down\n if GameWindow.instance.button_down?(Gosu::KbRightShift) || GameWindow.instance.button_down?(Gosu::KbLeftShift)\n true\n else\n false\n end\n end",
"def ctrl_w() send_keys(:ctrl_w) end",
"def shift\n ... | [
"0.7590204",
"0.6493804",
"0.61667556",
"0.6057411",
"0.59113073",
"0.5875903",
"0.5875903",
"0.58300763",
"0.5730001",
"0.57031566",
"0.56700045",
"0.56697965",
"0.5658143",
"0.5642233",
"0.56276506",
"0.56259835",
"0.55793124",
"0.55793124",
"0.5566451",
"0.55504555",
"0.55... | 0.7425063 | 1 |
Release the shift key. | def shift_key_up
command 'shiftKeyUp'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_key_down\r\n command 'shiftKeyDown'\r\n end",
"def releaseKey(key)\n\t\t@keysPressed.delete(key)\n\tend",
"def shift\n conn.lpop key\n end",
"def release_keysequence(keysequence, delay = 0.012)\n XDo::FFILib.xdo_keysequence_up @_xdo_pointer, @_window, keysequence,\n ... | [
"0.67046523",
"0.62143505",
"0.6198159",
"0.60833585",
"0.60808146",
"0.6000871",
"0.589238",
"0.58811814",
"0.57741237",
"0.57379013",
"0.5606869",
"0.5606869",
"0.5571487",
"0.5475465",
"0.5427318",
"0.5427318",
"0.5419669",
"0.5419669",
"0.53687334",
"0.5358958",
"0.529877... | 0.69267005 | 0 |
This command is a synonym for store_expression. | def store expression, variable_name
command 'store', expression, variable_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_expression expression, variable_name\r\n command 'storeExpression', expression, variable_name\r\n end",
"def store_eval script, variable_name\r\n command 'storeEval', script, variable_name\r\n end",
"def eval_expression\n eval(expression, binding)\n end",
"def expression; end",
"d... | [
"0.8634716",
"0.6388004",
"0.61340773",
"0.60463214",
"0.60207146",
"0.60176015",
"0.59880316",
"0.59880316",
"0.59457415",
"0.58091915",
"0.5729557",
"0.56832665",
"0.5637354",
"0.56163424",
"0.55896956",
"0.55484414",
"0.5484326",
"0.547495",
"0.54747874",
"0.5416711",
"0.5... | 0.8262684 | 1 |
Writes a message to the status bar and adds a note to the browserside log. +context+ is the message sent to the browser. +log_level_threshold+ can be +nil+, :debug, :info, :warn or :error. | def set_context context, log_level_threshold = nil
if log_level_threshold
command 'setContext', context, log_level_threshold.to_s
else
command 'setContext', context
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warning(context, options = nil)\n options = options.merge(level: 'warning')\n log(context, options)\n end",
"def log(context, msg)\n @log << \"#{context}: #{msg}\"\n end",
"def notify(message)\n status_bar = @builder['statusbar']\n status_bar.push(status_bar.g... | [
"0.5786788",
"0.5582664",
"0.5557157",
"0.50940627",
"0.49781993",
"0.48721188",
"0.48417515",
"0.48007002",
"0.47826996",
"0.47050846",
"0.46999088",
"0.46941087",
"0.4640209",
"0.4624585",
"0.46027303",
"0.45997378",
"0.45621648",
"0.45511734",
"0.4550646",
"0.4541792",
"0.... | 0.6215824 | 1 |
Waits for a new page to load. You can use this command instead of the +and_wait+ suffixes, +click_and_wait+, +select_and_wait+, +type_and_wait+ etc. (which are only available in the JS API). Selenium constantly keeps track of new pages loading, and sets a +newPageLoaded+ flag when it first notices a page load. Running ... | def wait_for_page_to_load timeout
command 'waitForPageToLoad', timeout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_page_load\n @browser.wait_for_load\n end",
"def wait(timeout=10)\n Selenium::WebDriver::Wait.new(:timeout => timeout)\n end",
"def wait_loading\n puts \"[BrowserOperator] wait_loading\" << '..' * 10\n browser.div(:id, 'pageLoading').wait_while_present()\n end",
"def wait_... | [
"0.65442324",
"0.64719754",
"0.6388002",
"0.6318073",
"0.62589437",
"0.6146749",
"0.6137664",
"0.60708106",
"0.6063093",
"0.60538274",
"0.60408294",
"0.6012535",
"0.6002208",
"0.59765744",
"0.59114164",
"0.59082437",
"0.59002745",
"0.5842679",
"0.5834417",
"0.5781306",
"0.574... | 0.7731514 | 1 |
check connection to Selenium RC | def check_connection
one_wait = 5
max_wait = 15
request = Net::HTTP::Get.new('/selenium-server/')
wait = 0;
while (wait < max_wait)
begin
response = Net::HTTP.start(@host, @port) {|http|
http.request(request)
}
break if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def selenium_env?\n true\nend",
"def check_connection\n one_wait = 5\n max_wait = 5\n request = Net::HTTP::Get.new('/')\n wait = 0;\n while (wait < max_wait)\n begin\n response = Net::HTTP.start(@url.host, @url.port) {|http|\n http.request(request)... | [
"0.630713",
"0.6283249",
"0.6240378",
"0.62243265",
"0.6214046",
"0.6088339",
"0.608336",
"0.60715514",
"0.6028589",
"0.59923273",
"0.59914804",
"0.5983569",
"0.59712005",
"0.59671694",
"0.59448576",
"0.5896287",
"0.58333963",
"0.5810538",
"0.5808582",
"0.5798259",
"0.5796514... | 0.79851687 | 0 |
wait for page to load and verify text | def wait_for_page_and_verify_text(text)
@selenium.wait_for_page_to_load(120000)
check_page_and_verify_text(text)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_page_and_verify_text(text)\n #check_page(@selenium.find_element(:id, \"body\").text)\n verify_text(text)\n end",
"def wait_page_load(criteria,value,expected_element_text,seconds_wait)\r\n\t \t\ttext_on_page = @driver.find_element(criteria.to_sym, value).text\r\n\t \t\twait_for(seconds_wai... | [
"0.78336734",
"0.73089623",
"0.7136873",
"0.7093599",
"0.70578",
"0.7016747",
"0.69566554",
"0.6863478",
"0.67435616",
"0.673521",
"0.673521",
"0.66841877",
"0.66180944",
"0.66152716",
"0.65859807",
"0.6542829",
"0.6514236",
"0.6514236",
"0.65136313",
"0.6485004",
"0.64152056... | 0.86563647 | 0 |
check the page for any abnormalities and verify text | def check_page_and_verify_text(text)
#check_page(@selenium.find_element(:id, "body").text)
verify_text(text)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_page(page)\n validator = MarkupValidator.new\n results = validator.validate_text(page)\n return unless results.errors.length > 0\n results.errors.each do |err|\n fail(\"Error #{err.message} on page #{page.current_url}\")\n end\nend",
"def check_page(page)\n # -- if error is found, it wi... | [
"0.695017",
"0.68800837",
"0.6849128",
"0.67428565",
"0.6643247",
"0.66249406",
"0.65778935",
"0.6534989",
"0.6519632",
"0.64491427",
"0.6311761",
"0.6300621",
"0.6258856",
"0.62335503",
"0.6215988",
"0.6199817",
"0.6123763",
"0.60646707",
"0.5976177",
"0.585029",
"0.5847198"... | 0.7796433 | 0 |
Returns the roles associated with this user | def roles
client.user_roles(id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roles\r\n @roles ||= user_roles.map(&:name)\r\n end",
"def roles\n roles_from_users\n end",
"def the_roles\n roles.each.map{|_r| User::ROLES[_r.to_sym] }\n end",
"def roles\n users.map { |item| item['roles'] }.flatten.uniq\n end",
"def roles\n User.valid_roles\n end"... | [
"0.7938685",
"0.79179275",
"0.7800574",
"0.7796106",
"0.7716763",
"0.76074106",
"0.7597818",
"0.74161816",
"0.73145646",
"0.7272813",
"0.723718",
"0.72232074",
"0.7221851",
"0.7189618",
"0.71150357",
"0.7105865",
"0.706569",
"0.70304334",
"0.7020986",
"0.6979606",
"0.6966958"... | 0.8289946 | 1 |
end initialize randomly determine if this room will have an enemy | def assign_enemy
@has_enemy = rand(1..2)==1 ? true : false
#need an enemy value for the room.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enemy_spawned\n enemy_chance = ENEMY_CHANCE_BASE + (@dungeon.level + ENEMY_CHANCE_MOD)\n enemy_chance > rand(100)\n end",
"def initialize\n\t\t@enemy = Faker::Name.name\n\tend",
"def populate_room\n unless @dungeon.first_room\n @enemy = Zarta::Enemy.new(@dungeon) if enemy_spawned\n... | [
"0.69565105",
"0.6906241",
"0.6625656",
"0.63867354",
"0.63012457",
"0.6231034",
"0.6211345",
"0.6169772",
"0.6159238",
"0.61444336",
"0.60514855",
"0.6046907",
"0.6016638",
"0.60012096",
"0.59872174",
"0.5908169",
"0.58994263",
"0.5892252",
"0.5884431",
"0.5868357",
"0.58171... | 0.8208505 | 0 |
counts tickets using ticket info array | def count_tickets
tickets = self.tickets
total_tickets = tickets.count
return total_tickets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ticket_count()\n sql = \"SELECT * FROM tickets WHERE customer_id = $1\"\n values = [@id]\n SqlRunner.run(sql, values).count\n end",
"def ticket_status_count\n @ticket_status_count ||= begin\n counts = { \"a\" => 0, \"t\" => 0, \"f\" => 0 }\n counts.merge! assigned_tickets.joins(... | [
"0.7177721",
"0.7157538",
"0.6958222",
"0.6901622",
"0.68093836",
"0.6690278",
"0.66766125",
"0.6598204",
"0.6578278",
"0.6473234",
"0.6434859",
"0.63869476",
"0.6377115",
"0.636177",
"0.6310528",
"0.6284032",
"0.62742954",
"0.6266023",
"0.6170504",
"0.61330384",
"0.6131447",... | 0.7386948 | 0 |
finds films a customer has tickets for | def find_films_for_each_customer()
sql = "SELECT films.*
FROM films
INNER JOIN tickets
ON tickets.film_id = films.id
WHERE customer_id = $1"
values = [@id]
films = SqlRunner.run(sql, values)
result = films.map {|film| Film.new(film)}
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def films()\n sql = \"SELECT films.* FROM films INNER JOIN tickets ON films.id = tickets.film_id WHERE tickets.cust_id = $1\"\n values = [@id]\n films = SqlRunner.run(sql, values)\n return films.map{|film| Film.new(film)}\n end",
"def films()\n sql = \"SELECT films.* FROM films INNER JOIN... | [
"0.7041169",
"0.701063",
"0.6978453",
"0.6934411",
"0.693054",
"0.6916352",
"0.6895286",
"0.6894089",
"0.68539536",
"0.68207324",
"0.6804413",
"0.66908926",
"0.665471",
"0.6647484",
"0.6644531",
"0.65750116",
"0.64996165",
"0.6306582",
"0.62558943",
"0.6215381",
"0.6206336",
... | 0.73953915 | 0 |
this finds the prices for films for a given customer and deducts the total from the customers funds | def remaining_funds()
films = self.find_films_for_each_customer()
film_fees = films.map{|film| film.price}
combined_fees = film_fees.sum
return @funds - combined_fees
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def charge_customer()\n array = find_films()\n # charge = ticket_cost\n for film in array\n result = @funds - film.price\n @funds = result\n end\n update\n end",
"def buy()\n #films the customer has tickets to\n all_films = films()\n #sum the films (as there can be more than o... | [
"0.7474738",
"0.69729006",
"0.67230946",
"0.62753093",
"0.621499",
"0.6142677",
"0.6037939",
"0.60324466",
"0.59905887",
"0.59789115",
"0.59513146",
"0.59442306",
"0.58459556",
"0.58428806",
"0.5828465",
"0.58105665",
"0.5749559",
"0.57456857",
"0.57196444",
"0.5707163",
"0.5... | 0.7547074 | 0 |
GET /distbutors GET /distbutors.json | def index
@distbutors = Distbutor.page(params[:page])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end",
"def show\n @distraction = Distrac... | [
"0.62634605",
"0.61989284",
"0.6035241",
"0.5979277",
"0.5971823",
"0.59544146",
"0.5891396",
"0.58873403",
"0.5730069",
"0.5730069",
"0.5672024",
"0.5668034",
"0.5627325",
"0.5575577",
"0.55638367",
"0.5561043",
"0.5556489",
"0.55507624",
"0.55352765",
"0.55317676",
"0.55277... | 0.6895203 | 0 |
Fill billing address on payment tab | def fill_billing_address(billing_address)
add_credit_card_form.bl_street_addr_input.set billing_address[:street]
add_credit_card_form.bl_city_input.set billing_address[:city]
# display state option
if page.has_css?('.stateSelect', wait: TimeOut::WAIT_SMALL_CONST)
page.execute_script("$('#stateSel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_in_buyer_stripe_form(obj = billing_address_example_data)\n fill_in('account[billing_address][name]', with: obj[:first_name])\n fill_in('account[billing_address][address1]', with: obj[:street_address])\n fill_in('account[billing_address][address2]', with: obj[:extra_address])\n fill_in('account[billing... | [
"0.7463737",
"0.73818403",
"0.7241998",
"0.723517",
"0.7148776",
"0.71184134",
"0.7043155",
"0.6992645",
"0.68744665",
"0.6874304",
"0.6826245",
"0.6780723",
"0.6763353",
"0.6748353",
"0.6735298",
"0.6735298",
"0.6727876",
"0.6727876",
"0.6727876",
"0.67195237",
"0.6714171",
... | 0.80183905 | 0 |
Add credit card on payment tab Return review tab | def add_credit_card(credit_card, billing_address = nil)
add_credit_card_form.card_number_input.set credit_card[:card_number]
add_credit_card_form.name_on_card_input.set credit_card[:card_name]
# display expiration month option
page.execute_script("$('#vin_PaymentMethod_creditCard_expirationDate_Month')... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_credit_card(name = 'LTRC DN', cardnumber = '5111005111051128', exp_month = '01', exp_year = '2017', cvv = '123', country = 'US')\n wait_for_ajax\n # open add new credit card popup\n billing_section.add_new_credit_card_lnk.click\n\n wait_for_ajax\n # fill information\n add_new_credit_c... | [
"0.6897703",
"0.68912905",
"0.68727607",
"0.67950857",
"0.67049307",
"0.66833454",
"0.656524",
"0.6540334",
"0.6536022",
"0.65015244",
"0.6495551",
"0.64735353",
"0.64356935",
"0.64125687",
"0.6409902",
"0.6390594",
"0.6376964",
"0.6376964",
"0.63540894",
"0.6342632",
"0.6334... | 0.7846991 | 0 |
Order jobs by: their stage number their allow_failure status their original order | def apply
jobs.sort_by.with_index { |job, ix| order(job, ix) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_checks_on_new_jobs\n @total_jobs_hash = @total_jobs.index_by(&:id)\n @checks.sort_by! do |check|\n if check.job.split_parent_job_id.present? || check.job.parent_job_id.present?\n split_image_values = check.job.initial_image_name.split('.').first.split('_').from(1)\n @compare_job ... | [
"0.62496305",
"0.61569655",
"0.6081873",
"0.5985731",
"0.5839663",
"0.56682956",
"0.5542638",
"0.54588515",
"0.54560703",
"0.54460883",
"0.5430229",
"0.54204166",
"0.5398697",
"0.5327998",
"0.52838296",
"0.5238117",
"0.52352196",
"0.52217776",
"0.5207978",
"0.52036643",
"0.52... | 0.67354697 | 0 |
Wraps content words in individual spans. | def spanitize(content)
content.split(" ").map { |s| "<span>#{s}</span>" }.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_in_spans(**options)\n safe_join(options.fetch(:value, []).map { |v| content_tag(:span, html_escape(v)) })\n end",
"def wrap( content )\n content\n end",
"def span_wrap tag, text\n \"<span class='#{tag}' markdown='1'>#{text}</span>\"\nend",
"def wrap\n @text\n end",
"def words\n ... | [
"0.6453105",
"0.6385358",
"0.62999296",
"0.62721914",
"0.6076125",
"0.60640967",
"0.58964074",
"0.58885306",
"0.5692121",
"0.56615716",
"0.56406766",
"0.5631153",
"0.5605348",
"0.5601667",
"0.5601264",
"0.5580383",
"0.55583394",
"0.55454296",
"0.5544432",
"0.55317855",
"0.553... | 0.65256125 | 0 |
READ CSV DATA Method to get the data from a csv in hash map | def get_csv_data(csv_data)
csv_file = nil
#Get the path and name of the CSV file
if csv_data.to_s.include? '.csv'
csv_file = File.join(File.dirname(__FILE__), "../venture/config/csv_data/#{csv_data}")
elsif (
csv_file = File.join(File.dirname(__FILE__), "../venture/config/csv_data/#{csv_data}.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_csv(file)\n data = CSV.read(file, {encoding: \"UTF-8\", headers: true, header_converters: :symbol, converters: :all})\n hashed_data = data.map { |d| d.to_hash } \n \n puts \"CSV Loaded...\"\n\n return hashed_data\n end",
"def get_csv_data(infile)\n csv_data = CSV.read infile\n header... | [
"0.7417968",
"0.72490907",
"0.72490907",
"0.7213275",
"0.71767604",
"0.7123355",
"0.70743215",
"0.7051665",
"0.697614",
"0.6874475",
"0.681373",
"0.67446506",
"0.67120284",
"0.67027617",
"0.6691012",
"0.6689355",
"0.66708124",
"0.6616215",
"0.6603404",
"0.653157",
"0.65192586... | 0.7975117 | 0 |
FILTER CSV DATA (HASH MAP FILTER) Allows you to filter a hash map from csv data | def get_data_by_filters(filters, csv)
filters_a = filters.to_s.split(',')
csv_tmp = Array.new
csv_tmp = csv
for i in 0..(filters_a.size - 1)
filter = filters_a[i].to_s.downcase.strip
filter_data = get_filter_data filter
#The array is cleaned
data_filtered = Array.new
csv_tm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefilter_csv_data(raw_csv_data)\n # De-dup emails absolutely\n csv_data = raw_csv_data.uniq{|row| row[:email]}\n\n # Remove data with duplicate names scoped in company and address (parameterized)\n #csv_data.uniq{|row| \"#{row[:first_name]} #{row[:last_name]} #{row[:company]} #{row[:addres... | [
"0.6322489",
"0.6280653",
"0.6217684",
"0.60133225",
"0.59794575",
"0.58892584",
"0.5803522",
"0.5799369",
"0.57303035",
"0.56759834",
"0.56759834",
"0.56759834",
"0.5597768",
"0.5558027",
"0.55175036",
"0.5508664",
"0.5507356",
"0.5499295",
"0.5477099",
"0.5471953",
"0.54608... | 0.6452923 | 0 |
Runs a job and updates the +last_run_at+ field. | def run!
PeriodicJob.log_error "Executing job id #{self.id}, #{self.to_s}..."
begin
self.last_run_at = Time.now
self.next_run_at = nil
self.save
command = self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, Rails.root.to_s)
puts command
eval(command)
self.last_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run!\n TaskServerLogger.instance.error \"Executing job id #{self.id}, #{self.to_s}...\"\n begin\n self.last_run_at = Time.zone.now\n self.next_run_at = nil\n self.save\n eval(self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, RAILS_ROOT))\n self.last_run_result = \"OK\"\... | [
"0.7211853",
"0.63806945",
"0.62906766",
"0.60734063",
"0.6009462",
"0.59831697",
"0.5980262",
"0.59266365",
"0.58394057",
"0.5718038",
"0.55837923",
"0.55430067",
"0.5506809",
"0.54610294",
"0.5419358",
"0.5409527",
"0.5385332",
"0.5309621",
"0.5297598",
"0.5290517",
"0.5290... | 0.68404543 | 1 |
POST /world_instances POST /world_instances.json | def create
world_name = params["name"]
superclass_uri = params["type-parent"]
container_uri = params["location-parent"]
description = params["description"]
if params.has_key?(:options)
options = {protected: false, locked: false}
options[:protected] = true if (params["options"].include?("... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @world_region = WorldRegion.new(world_region_params)\n\n respond_to do |format|\n if @world_region.save\n format.html { redirect_to @world_region, notice: 'World region was successfully created.' }\n format.json { render :show, status: :created, location: @world_region }\n ... | [
"0.62200654",
"0.606405",
"0.5965815",
"0.58907104",
"0.58460814",
"0.5845035",
"0.5787671",
"0.57634324",
"0.57342815",
"0.57021827",
"0.56860375",
"0.566433",
"0.56354827",
"0.5526175",
"0.5477664",
"0.5467237",
"0.5433888",
"0.5413798",
"0.5384082",
"0.53668237",
"0.533280... | 0.6729135 | 0 |
PATCH/PUT /world_instances/1 PATCH/PUT /world_instances/1.json | def update
respond_to do |format|
if @world_instance.update(world_instance_params)
format.html { redirect_to @world_instance, notice: 'World instance was successfully updated.' }
format.json { render :show, status: :ok, location: @world_instance }
else
format.html { render :edit ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update!(**args)\n @instances = args[:instances] if args.key?(:instances)\n @parameters = args[:parameters] if args.key?(:parameters)\n end",
"def update\n respond_to do |format|\... | [
"0.61995953",
"0.6135081",
"0.6067482",
"0.60623163",
"0.60295266",
"0.6027825",
"0.5984719",
"0.5972078",
"0.5853953",
"0.579697",
"0.5763218",
"0.5728873",
"0.5702792",
"0.56962323",
"0.568443",
"0.5683357",
"0.5679044",
"0.56556773",
"0.5655598",
"0.56532097",
"0.56518537"... | 0.72476095 | 0 |
DELETE /world_instances/1 DELETE /world_instances/1.json | def destroy
@world_instance.destroy
respond_to do |format|
format.html { redirect_to world_instances_url, notice: 'World instance was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @resource.destroy\n @myWorld = World.where(:title => @user[:email])\n worldID = @myWorld[0].id\n invoke(\"Resource destroyed: \" + @resource.title, @user[:email], \"admin\", worldID)\n respond_to do |format|\n format.html { redirect_to resources_url, notice: 'Resource was successf... | [
"0.6947151",
"0.68925005",
"0.6871639",
"0.68688583",
"0.68147826",
"0.6753604",
"0.66819865",
"0.66485727",
"0.66289926",
"0.66065156",
"0.6598677",
"0.6580668",
"0.65695715",
"0.65672123",
"0.65670717",
"0.65354246",
"0.65161675",
"0.64934194",
"0.6490549",
"0.648567",
"0.6... | 0.77915865 | 0 |
Capacity is the desired number of samples a buffer will hold. This can be user dictated via config if a feature wants. This value will be forcibly capped by the max_capacity | def capacity
raise NotImplementedError.new("TransactionSampleBufferBase subclasses must provide a capacity override")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capacity\n @capacity\n end",
"def capacity\n @capacity ||= DEFAULT_CAPACITY\n end",
"def capacity\n data[:capacity]\n end",
"def input_capacity\n typical_input_capacity\n end",
"def capacity=(value)\n @capacity = value\n end",
"def available_i... | [
"0.72650856",
"0.72281146",
"0.70058465",
"0.69601595",
"0.68685365",
"0.6824391",
"0.6810686",
"0.6744432",
"0.6648285",
"0.6466202",
"0.6442263",
"0.643262",
"0.6420256",
"0.6420256",
"0.6355884",
"0.63441414",
"0.63323355",
"0.63323355",
"0.63313586",
"0.6328554",
"0.62938... | 0.7964951 | 0 |
Our default truncation strategy is to keep max_capacity worth of the longest samples. Override this method for alternate behavior. | def truncate_samples
@samples.sort!{|a,b| a.duration <=> b.duration}
@samples.slice!(0..-(max_capacity + 1))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truncate(max)\n resize([max, self.length].min)\n end",
"def truncate(max)\n length = Math.min(max, length)\n self\n end",
"def reduce_max_size\n @max_size /= 2\n end",
"def truncate(max, omission = '...')\n (length > max ? self[0...max] + omission : self)\n end",
"def length_... | [
"0.65088516",
"0.63382155",
"0.61215913",
"0.5840665",
"0.5728863",
"0.56309325",
"0.56064284",
"0.55611795",
"0.5530185",
"0.5523246",
"0.5455481",
"0.5452657",
"0.54229337",
"0.54226035",
"0.54155016",
"0.54083043",
"0.54032636",
"0.540153",
"0.5399925",
"0.5399512",
"0.539... | 0.7334056 | 0 |
If a buffer needs to modify an added sample, override this method. Bounds checking, allowing samples and truncation belongs elsewhere. | def add_sample(sample)
@samples << sample
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_sample?(sample)\n true\n end",
"def add_sample(sample)\n samples << sample\n end",
"def postprocess_sampled_data(data, desired_samples, drawing_area_width)\n if data.length > desired_samples\n resample_data(data, desired_samples)\n end\n \n data\n end",
... | [
"0.5963213",
"0.56874555",
"0.56216115",
"0.55630696",
"0.55279404",
"0.5517108",
"0.55160487",
"0.5475028",
"0.54514503",
"0.53746283",
"0.53689736",
"0.5332063",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.53288... | 0.5775565 | 1 |
Take a DepositItemInput and make a UCI record out of it. Note that if you pass existing UCI data in, it will be retained if Elements doesn't override it. NOTE: UCI in this context means "UC Ingest" format, the internal metadata format for eScholarship. | def uciFromInput(input, ark)
uci = Nokogiri::XML("<uci:record xmlns:uci='http://www.cdlib.org/ucingest'/>").root
# Top-level attributes
uci[:id] = ark.sub(%r{ark:/?13030/}, '')
uci[:dateStamp] = DateTime.now.iso8601
uci[:peerReview] = input['isPeerReviewed'] ? "yes" : "no"
uci[:state] = 'new'
uci[:state... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upc\n upc_code = params[:upc]\n redirect_to root_url, alert: 'Not a valid UPC' and return unless upc_code\n @item = Item.code_find_or_create_by(upc_code)\n redirect_to root_url, alert: 'No product matches found' and return unless @item.errors.empty?\n redirect_to add_item_to_cart_path(@item.id) ... | [
"0.5255674",
"0.5139402",
"0.50545406",
"0.5048498",
"0.48972556",
"0.48949417",
"0.48896214",
"0.48467955",
"0.4815196",
"0.48040518",
"0.48013783",
"0.47662178",
"0.47616273",
"0.47544327",
"0.46931592",
"0.4686183",
"0.4678388",
"0.4678388",
"0.46566775",
"0.46551114",
"0.... | 0.5917898 | 0 |
=> [3, 5, 7] REVERSE RANGE CHALLENGE Write a method reverse_range(min, max) that takes in two numbers min and max. The function should return an array containing all numbers from min to max in reverse order. The min and max should be excluded from the array | def reverse_range(min, max) # Define method
i = max - 1 # Because we are trying to reverse the order of array we have to start with the max value; minus one because it does not include min or max
new_array = [] # Create an empty array to shovel values into
while i > min # We have to start from the max va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_range(min, max)\n reversed = [] \n \n index = max - 1 \n \n while index > min \n reversed << index \n index -= 1\n end \n \n return reversed \n \nend",
"def reverse_range(min, max)\n newArr = []\n i = max - 1\n while i >= min +1\n newArr << i\n i ... | [
"0.89516217",
"0.8909612",
"0.8899485",
"0.8897072",
"0.87962884",
"0.8792103",
"0.8769101",
"0.87444884",
"0.8699591",
"0.8693999",
"0.85637313",
"0.7295437",
"0.7295437",
"0.7207642",
"0.71983993",
"0.7163555",
"0.711424",
"0.71120095",
"0.71120095",
"0.710353",
"0.70958763... | 0.89373326 | 1 |
Is this a RHELcompatible OS with a minimum major version number of `version` | def el_min_version?(version)
self.rhel_family? && FB::Version.new(self['platform_version']) >= self._canonical_version(version)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def major_version(version = nil)\n version ||= installed_version?\n return \"0\" if version.nil?\n\n version.sub(/(\\.\\d+)+$/, '')\n end",
"def major(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*(\\d+)\\.\\d+\\.\\d+/\n res\n end",
"def major ; version... | [
"0.7731996",
"0.7731392",
"0.7710112",
"0.76567256",
"0.76567256",
"0.73321724",
"0.73151785",
"0.71896255",
"0.71794736",
"0.71794736",
"0.7167988",
"0.7146111",
"0.7146111",
"0.7146111",
"0.71318275",
"0.7128724",
"0.7121457",
"0.7121457",
"0.7103959",
"0.7102385",
"0.70955... | 0.8040562 | 0 |
Is this a RHELcompatible OS with a maximum major version number of `version` | def el_max_version?(version)
self.rhel_family? && FB::Version.new(self['platform_version']) <= self._canonical_version(version)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def el_min_version?(version)\n self.rhel_family? && FB::Version.new(self['platform_version']) >= self._canonical_version(version)\n end",
"def major(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*(\\d+)\\.\\d+\\.\\d+/\n res\n end",
"def major_version(version = nil... | [
"0.7908768",
"0.778943",
"0.7641181",
"0.75656223",
"0.74951726",
"0.73930484",
"0.73029363",
"0.72966486",
"0.72966486",
"0.7276666",
"0.72604084",
"0.7234367",
"0.7230939",
"0.7185924",
"0.7123798",
"0.7100777",
"0.70891786",
"0.70891786",
"0.7075512",
"0.7075512",
"0.70752... | 0.78176755 | 1 |
Takes one or more AWS account IDs as strings and return true if this node is in any of those accounts. | def in_aws_account?(*accts)
return false if self.quiescent?
return false unless self['ec2']
accts.flatten!
accts.include?(self['ec2']['account_id'])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users_include?(*user_ids)\n user_ids.map { |user_id| @users.include?(user_id) }.all?\n end",
"def contains(uid)\n #This doesn't work in ruby 1.8.5\n #return self[\"USERS/ID[.=#{uid}]\"] != nil\n\n id_array = retrieve_elements('USERS/ID')\n return id_array != ni... | [
"0.6463729",
"0.5934939",
"0.5934939",
"0.58159834",
"0.5791001",
"0.57766926",
"0.57446176",
"0.5658904",
"0.5648091",
"0.5631529",
"0.5608362",
"0.56019205",
"0.5571382",
"0.5539207",
"0.55386674",
"0.5517688",
"0.54203606",
"0.5391145",
"0.5376663",
"0.5371528",
"0.5369195... | 0.7621516 | 0 |
is this device a SSD? If it's not rotational, then it's SSD expects a short device name, e.g. 'sda', not '/dev/sda', not '/dev/sda3' | def device_ssd?(device)
unless node['block_device'][device]
fail "fb_helpers: Device '#{device}' passed to node.device_ssd? " +
"doesn't appear to be a block device!"
end
node['block_device'][device]['rotational'] == '0'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_device_name(volume_attachments, first_device_name_letter)\n (first_device_name_letter..'z').each do |char|\n # Some kernels remap device names (from sd* to vd* or xvd*).\n device_names = [\"/dev/sd#{char}\", \"/dev/vd#{char}\", \"/dev/xvd#{char}\"]\n # Bosh Agent will lookup fo... | [
"0.64648587",
"0.6390836",
"0.6318847",
"0.6230825",
"0.6149251",
"0.6143996",
"0.61226445",
"0.6002282",
"0.5961526",
"0.5947527",
"0.58912826",
"0.58758265",
"0.58645123",
"0.5856323",
"0.5852366",
"0.5843651",
"0.57776934",
"0.57702684",
"0.57570446",
"0.57345617",
"0.5692... | 0.67621386 | 0 |
On Linux and Mac, as of Chef 13, FS and FS2 were identical and in Chef 14, FS2 is dropped. For FreeBSD and other platforms, they become identical in late 15 and FS2 is dropped in late 16 So we always try 2 and fail back to 1 (if 2 isn't around, then 1 is the new format) This will return modern filesystem data, where it... | def filesystem_data
self['filesystem2'] || self['filesystem']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filesystem_type(host)\n case host['platform']\n when %r{aix}\n 'jfs2'\n when %r{el-|centos|fedora|sles|debian|ubuntu}\n 'ext3'\n else\n # TODO: Add Solaris and OSX support, as per PUP-5201 and PUP-4823\n fail_test(\"Unable to determine a standard filesystem table type for #{host... | [
"0.6409167",
"0.6298371",
"0.62385446",
"0.6204947",
"0.6158275",
"0.60359377",
"0.5938951",
"0.5910641",
"0.58961666",
"0.58135825",
"0.5793706",
"0.5763402",
"0.56151956",
"0.5602559",
"0.5602408",
"0.55545163",
"0.55434644",
"0.5538523",
"0.55028903",
"0.54697496",
"0.5460... | 0.6442593 | 0 |
returns the versionrelease of an rpm installed, or nil if not present | def rpm_version(name)
if (self.centos? && !self.centos7?) || self.fedora? || self.redhat8? || self.oracle8? || self.redhat9?
# returns epoch.version
v = Chef::Provider::Package::Dnf::PythonHelper.instance.
package_query(:whatinstalled, name).version
unless v.nil?
v.sp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def el_version\n if File.exists?('/etc/fedora-release')\n nil\n elsif File.exists?('/etc/redhat-release')\n rpm = Pkg::Util::Tool.find_tool('rpm', :required => true)\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{rpm} -q --qf \\\"%{VERSION}\\\" $(#{rpm} -q --whatprovides /etc/red... | [
"0.73902994",
"0.69928986",
"0.6868143",
"0.6667904",
"0.66559",
"0.6363557",
"0.63081396",
"0.6286012",
"0.6278648",
"0.6278648",
"0.6228528",
"0.6159336",
"0.61371917",
"0.6126809",
"0.6117446",
"0.6108582",
"0.6106775",
"0.605658",
"0.60458213",
"0.6038254",
"0.6030145",
... | 0.73622614 | 1 |
Safely dig through the node's attributes based on the specified `path`, with the option to provide a default value in the event the key does not exist. | def attr_lookup(path, delim: '/', default: nil)
return default if path.nil?
node_path = path.split(delim)
# implicit-begin is a function of ruby2.5 and later, but we still
# support 2.4, so.... until then
node_path.inject(self) do |location, key|
if key.respond_to?(:to_s) && locat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_attribute(path, default = nil)\n node.dig(*path.split('.')) || default\nend",
"def get_attribute_from_path(obj, attribute_path, default=nil)\n for attr in attribute_path.split(\".\") do\n case obj\n when Hash\n obj = !obj[attr.to_sym].nil? ? obj[attr.to_sym] : obj[attr]\n ... | [
"0.73300654",
"0.6849942",
"0.57888705",
"0.5745849",
"0.5479487",
"0.5461313",
"0.54462945",
"0.54340315",
"0.5425057",
"0.5383187",
"0.5359801",
"0.5353659",
"0.53333986",
"0.5269127",
"0.52258873",
"0.5223862",
"0.5156812",
"0.5145474",
"0.5112456",
"0.5112202",
"0.5099680... | 0.6996469 | 1 |
We can change interface configs if nw_changes_allowed? or we are operating on a DSR VIP | def interface_change_allowed?(interface)
method = node['fb_helpers']['interface_change_allowed_method']
if method
return method.call(node, interface)
else
return self.nw_changes_allowed? ||
['ip6tnl0', 'tunlany0', 'tunl0'].include?(interface) ||
interface.match(Rege... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @network_interfaces = args[:network_interfaces] if args.key?(:network_interfaces)\n end",
"def config_update( name )\n @ndev_res.update name\n @@netdev.edit_config( @ndev_res, \"xml\" )\n end",
"def update_network_interfaces(name, address)\n default_nm = '255.255.2... | [
"0.6173955",
"0.60474354",
"0.5944021",
"0.5873205",
"0.5819781",
"0.5768081",
"0.57122844",
"0.570934",
"0.57059175",
"0.56624365",
"0.565729",
"0.5625125",
"0.55513424",
"0.5550935",
"0.5538155",
"0.55335784",
"0.5512803",
"0.55036944",
"0.5495416",
"0.54888123",
"0.5476123... | 0.68822914 | 0 |
Gives total lesson time in hours | def lesson_length
seconds = self.end_at - self.start_at
seconds / 3600.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hours() 60 * minutes end",
"def hours\n self.to_i * 3_600\n end",
"def hours\n return \"There are #{self * (60 * 60)} seconds in #{self} hours\"\n end",
"def total_hours\n ('%.02f' % ((ends_at - starts_at) / 1.hour)).to_f\n end",
"def hours\n self * SECONDS_IN_HOUR\n end",
"def hours\... | [
"0.74050367",
"0.72218186",
"0.7165386",
"0.7143947",
"0.7096685",
"0.7079745",
"0.7073863",
"0.707299",
"0.70044774",
"0.69709665",
"0.69577",
"0.6931018",
"0.68911767",
"0.68692887",
"0.6864626",
"0.6863891",
"0.6857693",
"0.68430966",
"0.6816562",
"0.6813651",
"0.6813651",... | 0.75305045 | 0 |
The position of the task in the board list determines its priority This method sets the position of the task in the list (acts_as_list gem) According to the index passed by the ajax call. | def set_position(index)
first_item_position = board.tasks.by_status(self.status)[index].position
insert_at(first_item_position)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_position\n\n puts params[:tasks].to_json\n\n @tasksvalues = params[:tasks].values.map do |task|\n @task = Task.find_by(id: task[:id])\n @task.update(position:task[:position])\n end\n\n\n\n end",
"def update_position\n if self.simple_acts_as_list_scope.length == 0\n self.po... | [
"0.5924361",
"0.56312937",
"0.5601406",
"0.55601424",
"0.5548982",
"0.5534822",
"0.5512286",
"0.5488283",
"0.54663444",
"0.5423879",
"0.5382966",
"0.5339327",
"0.53325564",
"0.5332331",
"0.5320368",
"0.5319066",
"0.53031844",
"0.527709",
"0.5270131",
"0.5269593",
"0.52648896"... | 0.7345166 | 0 |
GET /list_items GET /list_items.xml | def index
@list = List.find(params[:list_id])
@list_items = @list.list_items.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @list_items }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n respond_with @items\n end",
"def items\n # Since we'r... | [
"0.73681515",
"0.7245629",
"0.7172651",
"0.7144363",
"0.7072838",
"0.70601827",
"0.699434",
"0.69893384",
"0.69827557",
"0.69751376",
"0.68912953",
"0.68452215",
"0.68293315",
"0.6819314",
"0.6806944",
"0.67967117",
"0.6751051",
"0.67395335",
"0.67359596",
"0.67359596",
"0.66... | 0.7516307 | 0 |
GET /list_items/1 GET /list_items/1.xml | def show
@list = List.find(params[:list_id])
@list_item = @list.list_items.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @list_item }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n... | [
"0.74913013",
"0.6927452",
"0.6771285",
"0.6749842",
"0.6674167",
"0.65780854",
"0.652523",
"0.6520168",
"0.64768356",
"0.6455133",
"0.6449316",
"0.64414245",
"0.6434415",
"0.6417664",
"0.6415853",
"0.6414747",
"0.64140445",
"0.63829",
"0.635195",
"0.63431084",
"0.63274163",
... | 0.71897435 | 1 |
Each subarray will have strings which are anagrams of each other Time Complexity: O(n) if you pretend line 12 is a simple mathematically based hashing function, probably O (n n log n) as for each string you have to sort the string to get a key for the hash. Space Complexity: O(n) worst case is one string to one key, wh... | def grouped_anagrams(strings)
string_hash = {}
strings.each do |string|
key = string.split("").sort.join # probably an O(n log n) operation, I couldn't find an integer based hashing function i liked
string_hash[key] ||= [] # trying this thing out
string_hash[key] << string
end
return string_has... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_anagrams(arr)\n hash = Hash.new { |h, k| h[k] = [] }\n arr.each do |str|\n hash[str.chars.sort] << str\n end\n\n hash.values.map(&:sort)\nend",
"def anagrams(array_of_words)\n ana_hash = Hash.new { |hash, key| hash[key] = [] }\n array_of_words.each { |word| ana_hash[word.split(\"\").sort.join]... | [
"0.79885423",
"0.7935334",
"0.7923127",
"0.7874945",
"0.7807073",
"0.7719393",
"0.7689198",
"0.76115584",
"0.7574334",
"0.7565763",
"0.755894",
"0.755675",
"0.7552811",
"0.7519341",
"0.7513236",
"0.7502722",
"0.74964917",
"0.7465122",
"0.7446689",
"0.744336",
"0.74047935",
... | 0.7949817 | 1 |
This method will return the true if the table is still a valid sudoku table. Each element can either be a ".", or a digit 19 The same digit cannot appear twice or more in the same row, column or 3x3 subgrid Time Complexity: I want to say this is O(1) since the number of elements in a 3x3 grid you have to check is alway... | def valid_sudoku(table)
sudoku_box_hash = { [0, 0] => {}, [0, 1] => {}, [0, 2] => {},
[1, 0] => {}, [1, 1] => {}, [1, 2] => {},
[2, 0] => {}, [2, 1] => {}, [2, 2] => {}}
sudoku_row_hash = { 1 => {}, 2 => {}, 3 => {},
4 => {}, 5 => {}, 6 => {},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_sudoku(table)\n # edge cases\n return false if table.nil? || table.size != 9 || table[0].size != 9\n # 3 new storages will count number of occurances of each element for columns, rows and sub-boxes\n rows = Array.new(9)\n i = 0\n while i < rows.size\n rows[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=... | [
"0.8122185",
"0.8087225",
"0.80445236",
"0.8037947",
"0.8000477",
"0.7858658",
"0.7618002",
"0.751144",
"0.74835074",
"0.71662134",
"0.6996734",
"0.6786182",
"0.6760026",
"0.6748393",
"0.6654424",
"0.6517259",
"0.6499932",
"0.64429265",
"0.6407294",
"0.64067",
"0.6398252",
... | 0.8228795 | 0 |
DELETE /sales/1 DELETE /sales/1.json | def destroy
@sale = Sale.find(params[:id])
@sale.destroy
respond_to do |format|
format.html { redirect_to sales_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @sale.destroy\n respond_to do |format|\n format.html { redirect_to sales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sale = Sale.find(params[:id])\n @sale.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_url }\n f... | [
"0.75238115",
"0.7519581",
"0.7519581",
"0.72468376",
"0.7210167",
"0.71714795",
"0.71714795",
"0.71714795",
"0.71714795",
"0.71714795",
"0.71714795",
"0.71714795",
"0.71714795",
"0.71714795",
"0.7148764",
"0.713443",
"0.7107516",
"0.70768994",
"0.7074153",
"0.7073332",
"0.70... | 0.75418174 | 0 |
Yields all the permutations of self into block. | def permute(&block)
case size
when 0 then yield []
when 1 then yield self
when 2
yield self
yield self.reverse
else
0.upto(size-1) do |i|
a = dup
c = a.slice!(i)
a.permute do |p|
yield p.dup.unshift(c)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_permutations\n perms = permutations\n perms = perms.shuffle.take(1) if @single_perm || ENV['FAST_TESTS']\n\n perms.each do |p|\n yield(p)\n WebMock.reset!\n end\n end",
"def permutation(length = size, &block)\n return enum_for(:permutation, length) if not block_g... | [
"0.69165623",
"0.6744315",
"0.63351053",
"0.62013185",
"0.61836386",
"0.61515087",
"0.6100307",
"0.6084606",
"0.6048573",
"0.59515905",
"0.5943673",
"0.5883916",
"0.58373123",
"0.58193165",
"0.58012384",
"0.5791618",
"0.57832944",
"0.5714496",
"0.5706052",
"0.57050174",
"0.56... | 0.7230013 | 0 |
GET /tagging_select_tos GET /tagging_select_tos.json | def index
@tagging_select_tos = TaggingSelectTo.all
if @tagging_select_tos.empty?
TaggingSelectTo.create(name: 'Sajjad-Murtaza-Testing-Taggable')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @tagging_select_to = TaggingSelectTo.new(tagging_select_to_params)\n\n respond_to do |format|\n if @tagging_select_to.save\n format.html { redirect_to tagging_select_tos_path }\n format.json { render :show, status: :created, location: @tagging_select_to }\n else\n ... | [
"0.6625833",
"0.6104351",
"0.58236516",
"0.5726449",
"0.5707796",
"0.5703381",
"0.5579196",
"0.5537875",
"0.55160606",
"0.54729",
"0.5452605",
"0.5436956",
"0.5436956",
"0.54151636",
"0.54143935",
"0.5405076",
"0.5376123",
"0.53718185",
"0.5320589",
"0.52716565",
"0.526671",
... | 0.67894167 | 0 |
POST /tagging_select_tos POST /tagging_select_tos.json | def create
@tagging_select_to = TaggingSelectTo.new(tagging_select_to_params)
respond_to do |format|
if @tagging_select_to.save
format.html { redirect_to tagging_select_tos_path }
format.json { render :show, status: :created, location: @tagging_select_to }
else
format.htm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tagging_select_tos = TaggingSelectTo.all\n if @tagging_select_tos.empty?\n TaggingSelectTo.create(name: 'Sajjad-Murtaza-Testing-Taggable')\n end\n end",
"def tagging_select_to_params\n params.require(:tagging_select_to).permit(:name)\n end",
"def set_tagging_select_to\n ... | [
"0.70922923",
"0.649447",
"0.6199583",
"0.5868507",
"0.55591655",
"0.54892397",
"0.53707653",
"0.52069837",
"0.51950353",
"0.5185502",
"0.5159103",
"0.5159103",
"0.51436543",
"0.5136004",
"0.50788724",
"0.5058716",
"0.50396377",
"0.50187314",
"0.49941844",
"0.49847722",
"0.49... | 0.73850346 | 0 |
PATCH/PUT /tagging_select_tos/1 PATCH/PUT /tagging_select_tos/1.json | def update
respond_to do |format|
if @tagging_select_to.update(tagging_select_to_params)
format.html { redirect_to @tagging_select_to, notice: 'Tagging select to was successfully updated.' }
format.json { render :show, status: :ok, location: @tagging_select_to }
else
format.html ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def create\n @tagging_select_to = TaggingSelectTo.new(tagging_select_to_params)\n\n respond_to do |format|\n if @tagging_select_to.save\n format.html { redirect_to tagging_select_tos_path }\n... | [
"0.5837907",
"0.5675519",
"0.5596343",
"0.55959094",
"0.549714",
"0.5481679",
"0.54743373",
"0.54601854",
"0.5432531",
"0.5416601",
"0.53992194",
"0.5393969",
"0.53887045",
"0.5381043",
"0.53787017",
"0.5370408",
"0.53614634",
"0.53505164",
"0.53388655",
"0.533556",
"0.532215... | 0.67469025 | 0 |
DELETE /tagging_select_tos/1 DELETE /tagging_select_tos/1.json | def destroy
@tagging_select_to.destroy
respond_to do |format|
format.html { redirect_to tagging_select_tos_url, notice: 'Tagging select to was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @tagging.destroy\n respond_to do |format|\n format.html { redirect_to taggings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tagging = Tagging.fi... | [
"0.68601376",
"0.65920043",
"0.6550066",
"0.6502049",
"0.6449415",
"0.64215285",
"0.6378379",
"0.63627017",
"0.636218",
"0.63561",
"0.6351577",
"0.6345666",
"0.63378906",
"0.63337964",
"0.63175327",
"0.6313219",
"0.6311535",
"0.6311226",
"0.6299295",
"0.6288399",
"0.6286303",... | 0.75845844 | 0 |
def greatest_factor(num) i = num 1 while i > 0 return i if num % i == 0 i = 1 end i end | def greatest_factor(num)
(2...num).reverse_each { |i| return i if num % i == 0}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greatest_factor(num)\n\n return num / 2\n\nend",
"def largest_prime_factor(num)\n (1..num).reverse_each do |factor|\n if num % factor == 0 && prime?(factor)\n return factor\n end\n end\nend",
"def largest_prime_factor(num)\n i = num - 1\n\n while i > 1 \n if is_prime?(i) && num % i == 0\... | [
"0.85741186",
"0.84822124",
"0.84734887",
"0.8472704",
"0.8405489",
"0.8399634",
"0.83548445",
"0.8351933",
"0.8349145",
"0.8347489",
"0.83375645",
"0.8337106",
"0.83363426",
"0.83282256",
"0.8323962",
"0.82846737",
"0.82792395",
"0.8270532",
"0.822819",
"0.8191237",
"0.81531... | 0.93649787 | 0 |
This overrides default save_entity (defined in RegisterMethods) and adds the inferred jurisdiction_code, unless it is overridden in entity_info | def save_entity(entity_info)
return if entity_info.blank?
default_options = {:jurisdiction_code => inferred_jurisdiction_code}
super(default_options.merge(entity_info))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n if @entity\n before_save\n @entity.save\n end\n self\n end",
"def _save\n raise NotImplementedError, 'override #_save in a subclass'\n end",
"def save\n raise NotImplementedError\n end",
"def save\n self.metadata[:type] = :metagenome if !metadata[:tax... | [
"0.55526155",
"0.5528686",
"0.5524536",
"0.55146414",
"0.54882145",
"0.54624605",
"0.54255515",
"0.5425525",
"0.53551114",
"0.52607256",
"0.52552086",
"0.52481186",
"0.52364814",
"0.5210222",
"0.51979923",
"0.51948625",
"0.5172679",
"0.5154451",
"0.5128875",
"0.5122893",
"0.5... | 0.8446863 | 0 |
EOL: this method was previously also checking: || include_eager_select?(options, joined_tables) | def references_eager_loaded_tables?(options)
joined_tables = joined_tables(options)
include_eager_order?(options, nil, joined_tables) || include_eager_conditions?(options, nil, joined_tables)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include_eager_conditions?(options)\n # look in both sets of conditions\n conditions = [scope(:find, :conditions), options[:conditions]].inject([]) do |all, cond|\n case cond\n when nil then all\n when Array then all << cond.first\n else all << cond\n end\n e... | [
"0.69874036",
"0.6904944",
"0.67060846",
"0.6422002",
"0.63992643",
"0.6140148",
"0.61125284",
"0.61125284",
"0.60921144",
"0.59842724",
"0.5962169",
"0.5929013",
"0.5911884",
"0.58883256",
"0.5885971",
"0.5875612",
"0.582514",
"0.5817943",
"0.5805094",
"0.5783552",
"0.576795... | 0.80248296 | 0 |
this is special kind of method that is used in layout template. it gets correct partial for the layout depending on context. | def get_content_for_layout()
get_partial(@type)
# if @type == "home"
# get_partial('home')
# elsif @type == "page"
# get_partial('page')
# elsif @type == "article"
# get_partial('article')
# elsif @type == "category"
# get_partial('category')
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_partial(context, options, &block); end",
"def render_with_layout_and_partials(format)\n # looking for system mail.\n template = MailEngine::MailTemplate.where(:path => \"#{controller_path}/#{action_name}\", :format => format, :locale => I18n.locale, :partial => false, :for_marketing => false... | [
"0.706628",
"0.6885645",
"0.67656595",
"0.67634654",
"0.6710283",
"0.6710283",
"0.6710283",
"0.6710283",
"0.66359925",
"0.66131175",
"0.6587355",
"0.6571997",
"0.65533507",
"0.6532503",
"0.63788545",
"0.6357265",
"0.6286693",
"0.6264173",
"0.62509847",
"0.62193024",
"0.621558... | 0.7323358 | 0 |
define a keyword to skip the sheet upload" | def keyword_to_skip(keyword_name)
kw = Keyword.find_by_name(keyword_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_be_skipped?(word)\n reject?(word) || hashtag?(word) || uri?(word) || mention?(word)\n end",
"def skip_actions; end",
"def skip &block\n annotate block do |c|\n c unless @item_rep.name == :wordcount\n end\nend",
"def skip\n end",
"def skip\n end",
"def skip!\n @skip ... | [
"0.57791114",
"0.567176",
"0.56295663",
"0.56086713",
"0.56086713",
"0.5521256",
"0.54990757",
"0.5498019",
"0.5457367",
"0.54508346",
"0.5446129",
"0.5419818",
"0.5403558",
"0.5350712",
"0.5344656",
"0.5343738",
"0.52921486",
"0.5287246",
"0.5282029",
"0.5282029",
"0.5266414... | 0.5718274 | 1 |
def bitwise_and(num1, num2) puts "num1 = " + num1.to_s(2) puts "num2 = " + num2.to_s(2) puts "base 10 & = " + (num1 & num2).to_s(10) puts "base 2 & = " + (num1 & num2).to_s(2) end | def bitwise_and(num1, num2)
bnum1 = num1.to_s(2)
bnum2 = num2.to_s(2)
band = (num1 & num2).to_s(2)
puts "num1 = " + ( ' ' * bnum2.length ) + num1.to_s(2)
puts "num2 = " + ( ' ' * bnum1.length ) + num2.to_s(2)
puts "b2& = " + ( ' ' * ([bnum1.length, bnum2.length].max ) + band)
# puts "base 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bitwise_and(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif val == b[index]\n\t\t\tresult.concat '1'\n\t\telse\n\t\t\tresult.concat '0'\n\t\tend\n\tend\n\treturn result\nend",
"def bitwise_xor(num1, num2)\n bnum1 = num1.to_s(2)\n bnum2 = num2.to_s(2)\n band = (num1 | num2).to_... | [
"0.78859276",
"0.7717622",
"0.66721344",
"0.6488093",
"0.6440578",
"0.63982505",
"0.6397612",
"0.6263405",
"0.6255527",
"0.6242118",
"0.62236214",
"0.6220425",
"0.62080175",
"0.61478835",
"0.611702",
"0.6105664",
"0.61038685",
"0.6096713",
"0.60895616",
"0.6038395",
"0.600803... | 0.937498 | 0 |
Return the base of a path The 'base' here means the portion of the basename before the extension. | def base()
sub_ext('').basename.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_path\n @base_path ||= Dir.pwd\n end",
"def base_path\n @base_path ||= server_path(File.expand_path(Dir.pwd))\n end",
"def base\n File.basename @filename, extension_with_delimiter\n end",
"def base_path path=nil\n if path\n @base_path = path\n end\n @base_pat... | [
"0.74745333",
"0.742273",
"0.7410979",
"0.7403777",
"0.7384916",
"0.72389424",
"0.72376144",
"0.7234708",
"0.7222469",
"0.72050786",
"0.71746284",
"0.71538174",
"0.71474844",
"0.7137092",
"0.7124422",
"0.7124422",
"0.70651734",
"0.7056925",
"0.7041405",
"0.69552046",
"0.69213... | 0.79545283 | 0 |
Override ActiveRecord::Core::ClassMethodscached_find_by_statement `.find_by` not use caching | def cached_find_by_statement(key, &block)
ActiveRecord::StatementCache.create(connection, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by()\n\n end",
"def find_by_sql(sql)\n raise \"not implemented\"\n end",
"def execute_find(raw = false)\n get_records\n cached = AridCache::CacheProxy::Result.new\n\n if !records.is_a?(Enumerable) || (!records.empty? && !records.first.is_a?(::ActiveRecord::Base))\n ... | [
"0.72358453",
"0.6870087",
"0.6779436",
"0.66328907",
"0.65448064",
"0.6391681",
"0.63457483",
"0.62718374",
"0.6224275",
"0.61801624",
"0.61801624",
"0.6170054",
"0.61586505",
"0.6157591",
"0.6153274",
"0.60969555",
"0.60969555",
"0.60943407",
"0.6061849",
"0.60610247",
"0.6... | 0.7276167 | 0 |
test_oi_category_selection Description: This method does the functional testing of the oi_category_selection method from the OI Instruction Controller class | def test_io_category_selection
categories = ['Board Preparation', 'Placement',
'Routing', 'Fabrication Drawing',
'Nomenclature', 'Assembly Drawing',
'Other']
# Try accessing from an account that is not a PCB Designer and
# verify th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_feature_for_category\r\n\t\tfeatures = Feature.for_category(categories(:root).id, 99)\r\n\r\n\t\tassert_equal(2, features.length)\r\n\t\tassert_equal(true, features.include?(products(:persian)))\r\n\t\tassert_equal(true, features.include?(products(:cow2)))\r\n\r\n\t\tfeatures = Feature.for_category(catego... | [
"0.6159697",
"0.6121553",
"0.6109961",
"0.61050713",
"0.6050262",
"0.59318423",
"0.5913041",
"0.589557",
"0.588123",
"0.5817813",
"0.5737933",
"0.57141",
"0.5670626",
"0.56403756",
"0.55908376",
"0.5588808",
"0.5502979",
"0.5473487",
"0.5470811",
"0.5427661",
"0.5418104",
"... | 0.7933748 | 0 |
test_section_selection Description: This method does the functional testing of the section_selection method from the OI Instruction Controller class | def test_section_selection
# Try accessing from an account that is not a PCB Designer and
# verify that the user is redirected.
get(:section_selection,
{ :id => @board_prep.id, :design_id => @mx234a.id },
pat_dfm_session)
assert_redirected_to(:controller => 'tracker', :action => 'inde... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def section\n section_test.section\n end",
"def assert_section (selected)\n is_nil = selected === nil\n @assertions.each do |section,tests|\n now = Time.now\n if section === selected or is_nil then\n puts 'Testing ' + section\n tests.each do |test|\n @... | [
"0.6841492",
"0.67223203",
"0.6290562",
"0.623527",
"0.6116589",
"0.5965091",
"0.59279114",
"0.58901155",
"0.5863963",
"0.58354694",
"0.5829924",
"0.57749844",
"0.5761754",
"0.57307285",
"0.5727075",
"0.57064474",
"0.5703775",
"0.56948864",
"0.568129",
"0.5634366",
"0.561321"... | 0.74733424 | 0 |
test_process_assignments Description: This method does the functional testing of the | def test_process_assignments
board_prep_sections = [oi_category_sections(:board_prep_1),
oi_category_sections(:board_prep_2),
oi_category_sections(:board_prep_3)]
section_ids = board_prep_sections.collect { |s| s.id }
team_member_list = [@s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_assignments(user)\n # A user can manage an Assignment if they have the\n # can_manage_assignments? permission in any of the CourseOfferings of\n # the Course that the assignment belongs to.\n #\n # TODO This may need improvement.\n can :manage, Assignment do |assignment|\n course... | [
"0.6459815",
"0.6316795",
"0.61676776",
"0.61282265",
"0.60985446",
"0.58879894",
"0.5867649",
"0.5842562",
"0.58248323",
"0.5806834",
"0.5797749",
"0.5794961",
"0.5794961",
"0.5794961",
"0.5794961",
"0.5794961",
"0.5760024",
"0.5683397",
"0.5625491",
"0.5575681",
"0.5547382"... | 0.6767746 | 0 |
test_process_assignment_details Description: This method does the functional testing of the | def test_task_assignment
board_prep_sections = [oi_category_sections(:board_prep_1),
oi_category_sections(:board_prep_2),
oi_category_sections(:board_prep_3)]
section_ids = board_prep_sections.collect { |s| s.id }
team_member_list = [@siva_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_process_assignments\n \n board_prep_sections = [oi_category_sections(:board_prep_1),\n oi_category_sections(:board_prep_2),\n oi_category_sections(:board_prep_3)]\n section_ids = board_prep_sections.collect { |s| s.id }\n team_member_li... | [
"0.67055166",
"0.61792755",
"0.60794455",
"0.59472847",
"0.58578086",
"0.58466375",
"0.57890767",
"0.5770384",
"0.5729329",
"0.5682453",
"0.5673812",
"0.5661049",
"0.56528574",
"0.563056",
"0.5623086",
"0.5607764",
"0.5607616",
"0.55951285",
"0.5565419",
"0.55369407",
"0.5527... | 0.65888274 | 1 |
test_report_card_list Description: This method does the functional testing of the report card list view. | def test_report_card_list
get(:report_card_list,
{ :id => @board_prep.id, :design_id => @mx234a.id },
scott_designer_session)
assert_equal(@mx234a.id, assigns(:design).id)
assert_equal(@board_prep.id, assigns(:category).id)
assert_nil(assigns(:assignments_list))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deck_has_cards\n assert_equal [@card_1, @card_2, @card_3], @deck.cards\n end",
"def cardlist\n if params.has_key?(:nocache) || !flash.empty? || stale?(:last_modified => @cardset.last_edit_log.updated_at, :etag => \"cardset_#{@cardset.id}_cardlist\")\n respond_to do |format|\n format.h... | [
"0.5846489",
"0.58184975",
"0.5715349",
"0.56638736",
"0.56466544",
"0.56362575",
"0.56354636",
"0.552045",
"0.54872024",
"0.54784036",
"0.5396856",
"0.5375988",
"0.5368743",
"0.5368743",
"0.5313435",
"0.53019434",
"0.53002983",
"0.52925974",
"0.52864707",
"0.5280211",
"0.527... | 0.6882792 | 0 |
test_create_assignment_report Description: This method does the functional testing of the create assignment report view. | def test_create_assignment_report
first_report = oi_assignment_reports(:first)
# Try accessing from an account that is not a PCB Designer and
# verify that the user is redirected.
get(:create_assignment_report, { :id => oi_assignment_reports(:first) }, lee_hweng_session)
assert_redirected_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_view_assignment_report\n \n first_assignment = oi_assignments(:first)\n \n # Try accessing from an account that is not a PCB Designer and\n # verify that the user is redirected.\n get(:view_assignment_report, { :id => first_assignment }, siva_designer_session)\n assert_redirected_to(:... | [
"0.6981552",
"0.64904445",
"0.6470197",
"0.6369361",
"0.62846583",
"0.62846583",
"0.6195638",
"0.61498445",
"0.6143314",
"0.6131525",
"0.6127125",
"0.6093784",
"0.6082833",
"0.6043959",
"0.60354584",
"0.6031244",
"0.6025659",
"0.6022759",
"0.59975857",
"0.59962714",
"0.599592... | 0.7563527 | 0 |
test_static_view Description: This method does the functional testing of the static_view view. | def test_static_view
first_assignment = oi_assignments(:first)
# Try accessing from an account that is not a PCB Designer and
# verify that the user is redirected.
get(:static_view, { :id => first_assignment }, siva_designer_session)
assert_redirected_to(:controller => 'tracker', :action ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_index \n get :index\n assert_response :success\n assert_template 'index'\n end",
"def test_index \n get :index\n assert_response :success\n assert_template 'index'\n end",
"def test_should_show_index\n login_as :admin\n\n get :index\n assert_response ... | [
"0.620146",
"0.6173631",
"0.61484206",
"0.59964097",
"0.5978809",
"0.59613407",
"0.5932028",
"0.59311694",
"0.5916225",
"0.5893453",
"0.5809368",
"0.5800353",
"0.57798797",
"0.5766727",
"0.57615876",
"0.57615876",
"0.5761294",
"0.5752731",
"0.57192093",
"0.5706943",
"0.569331... | 0.6990885 | 0 |
test_view_assignment_report Description: This method does the functional testing of the view assignment report view. | def test_view_assignment_report
first_assignment = oi_assignments(:first)
# Try accessing from an account that is not a PCB Designer and
# verify that the user is redirected.
get(:view_assignment_report, { :id => first_assignment }, siva_designer_session)
assert_redirected_to(:controller =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_assignment_report\n \n first_report = oi_assignment_reports(:first)\n \n # Try accessing from an account that is not a PCB Designer and\n # verify that the user is redirected.\n get(:create_assignment_report, { :id => oi_assignment_reports(:first) }, lee_hweng_session)\n assert... | [
"0.67401147",
"0.622488",
"0.61929166",
"0.6048909",
"0.5982111",
"0.58500254",
"0.58500254",
"0.5776563",
"0.5731412",
"0.568352",
"0.56371826",
"0.5625055",
"0.55252844",
"0.54299563",
"0.53632176",
"0.5355442",
"0.5316235",
"0.52715546",
"0.5243433",
"0.5243433",
"0.524343... | 0.7340644 | 0 |
based on the reference spec in lib/rpmvercmp.c in rpm 4.9.0 | def rpmvercmp(x, y)
# easy! :)
return 0 if x == y
if x.nil?
x = ""
end
if y.nil?
y = ""
end
# not so easy :(
#
# takes 2 strings like
#
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rpm_version(name)\n if (self.centos? && !self.centos7?) || self.fedora? || self.redhat8? || self.oracle8? || self.redhat9?\n # returns epoch.version\n v = Chef::Provider::Package::Dnf::PythonHelper.instance.\n package_query(:whatinstalled, name).version\n unless v.nil?\n ... | [
"0.63795966",
"0.62147635",
"0.61626464",
"0.61626464",
"0.61104226",
"0.6106799",
"0.6083635",
"0.6077758",
"0.6024959",
"0.60186243",
"0.60100156",
"0.60028785",
"0.59957945",
"0.59578854",
"0.59387094",
"0.5937774",
"0.5911235",
"0.5895849",
"0.5877471",
"0.5854041",
"0.58... | 0.63841134 | 0 |
Rough RPM::Version rpm_version_cmp equivalent except much slower :) partial lets epoch and version segment equality be good enough to return equal, eg: 2:1.21 == 2:1.2 2:1.21 == 2: | def compare_versions(y, partial = false)
x = self
# compare epoch
if (x.e.nil? == false && x.e > 0) && y.e.nil?
return 1
elsif x.e.nil? && (y.e.nil? == false && y.e > 0)
return -1
elsif x.e.nil? == false && y.e.nil? == false
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rpmvercmp(x, y)\n # easy! :)\n return 0 if x == y\n\n if x.nil?\n x = \"\"\n end\n\n if y.nil?\n y = \"\"\n end\n\n # not so easy :(\n #\n # takes 2 strings like\n ... | [
"0.68930626",
"0.6777023",
"0.66131496",
"0.658415",
"0.65485173",
"0.6538966",
"0.6520678",
"0.6511816",
"0.63691634",
"0.6321949",
"0.628066",
"0.626531",
"0.62384665",
"0.6185876",
"0.61678445",
"0.61628306",
"0.61530167",
"0.6127873",
"0.6123939",
"0.6079843",
"0.60696566... | 0.71972096 | 0 |
Test if another RPMDependency satisfies our requirements | def satisfy?(y)
unless y.is_a?(RPMDependency)
raise ArgumentError, "Expecting an RPMDependency object"
end
x = self
# Easy!
if x.name != y.name
return false
end
# Partial compare
#
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def =~(other)\n unless Gem::Dependency === other\n return unless other.respond_to?(:name) && other.respond_to?(:version)\n other = Gem::Dependency.new other.name, other.version\n end\n\n return false unless name === other.name\n\n reqs = other.requirement.requirements\n\n return false unle... | [
"0.7186977",
"0.70694053",
"0.6906571",
"0.68474925",
"0.6784584",
"0.667682",
"0.6645595",
"0.6627601",
"0.66122615",
"0.6579966",
"0.643627",
"0.6425606",
"0.6317606",
"0.6298653",
"0.6295924",
"0.6294732",
"0.6243786",
"0.61787283",
"0.61519796",
"0.61489576",
"0.6130937",... | 0.7707219 | 0 |
Lookup package_name and return a descending array of package objects | def lookup(package_name)
pkgs = @rpms[package_name]
if pkgs
pkgs.sort.reverse
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_package_by_name(name)\n @packages[name]\n end",
"def search_for_description pkgname, packages = []\n cache_key = \"description_package_#{pkgname.downcase}\"\n description_package = Rails.cache.fetch(cache_key, :expires_in => 12.hours) do\n if packages.blank?\n package... | [
"0.7300775",
"0.7257258",
"0.70202047",
"0.69410783",
"0.68412924",
"0.67444324",
"0.6609925",
"0.65386343",
"0.653666",
"0.65336734",
"0.6526174",
"0.6486079",
"0.6486079",
"0.64606327",
"0.6380588",
"0.6360088",
"0.63586986",
"0.63584906",
"0.6318584",
"0.6305778",
"0.62259... | 0.7955433 | 0 |
Lists the names of the store this user is entitled to read or write to. | def store_names
names = @store_names.dup
names << "users" unless names.include?("users")
names
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_store_names\n\n if @user.admin?\n find_all_storenames\n else\n @permissions.keys.sort\n end\n end",
"def find_all_storenames\n\n WiStore.find(:all).collect do |store|\n store.name\n end\n end",
"def index\n @stores = current_account.stores.find(... | [
"0.7399919",
"0.6922078",
"0.6532522",
"0.6490655",
"0.63840324",
"0.63617325",
"0.62848675",
"0.6239569",
"0.62273854",
"0.622369",
"0.6205164",
"0.60669655",
"0.6049849",
"0.6042551",
"0.60425305",
"0.60425305",
"0.60425305",
"0.60425305",
"0.60425305",
"0.6031795",
"0.5974... | 0.69922507 | 1 |
Returns the permission for the given store. | def permission (store_name)
return RWD_STORE_PERMISSION if @user.admin?
return RWD_STORE_PERMISSION if store_name == 'users'
@permissions[store_name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_permissions (user, store_name)\n s = \"\"\n [ :read, :write, :delegate ].each do |action|\n s << action.to_s[0, 1] \\\n if @auth_system.authorized?(user, store_name, action)\n end\n s\n end",
"def find_permissions\n\n return nil if @user.admin?\n\n groupna... | [
"0.6499601",
"0.6216662",
"0.55079794",
"0.54641545",
"0.5447283",
"0.5420848",
"0.5382845",
"0.53765523",
"0.53488135",
"0.5347169",
"0.5325485",
"0.52896684",
"0.528886",
"0.52618",
"0.52474105",
"0.52408576",
"0.52322125",
"0.523144",
"0.5229859",
"0.51618344",
"0.51603085... | 0.7805503 | 0 |
Returns the workitems for the given store. | def workitems (store_name=nil)
return load_user_workitems if store_name == 'users'
return (@workitems[store_name] || []) if store_name
# then return all the workitems the user has access to
wis = load_user_workitems
@store_names.inject(wis) do |r, sname|
r += (@workitems[sname] || [])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_store_items(opts = {})\n data, _status_code, _headers = get_store_items_with_http_info(opts)\n return data\n end",
"def each (&block)\n\n return unless block\n\n wis = Workitem.find_by_store_name(@store_name)\n\n wis.each { |wi| block.call(wi) }\n end",
"def get_wms_store... | [
"0.6577767",
"0.6322996",
"0.6125597",
"0.5964179",
"0.59063333",
"0.5893999",
"0.5842434",
"0.571832",
"0.5678437",
"0.5545342",
"0.55338",
"0.5500814",
"0.54911095",
"0.54763865",
"0.5455842",
"0.5428017",
"0.54177606",
"0.54126227",
"0.5400239",
"0.53830254",
"0.53824455",... | 0.804833 | 0 |
Returns the list of store[ names]s to which the user can delegate. If a workitem is passed, makes sure to remove the workitem current store name from the resulting list. | def delegation_targets (workitem=nil)
names = @store_names.find_all { |n| permission(n).may_delegate? }
names.delete(workitem.store_name) if workitem
names
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def workitems (store_name=nil)\n\n return load_user_workitems if store_name == 'users'\n return (@workitems[store_name] || []) if store_name\n\n # then return all the workitems the user has access to\n\n wis = load_user_workitems\n\n @store_names.inject(wis) do |r, sname|\n r += (@workitems[sna... | [
"0.6875334",
"0.6045649",
"0.6026068",
"0.56866467",
"0.5318249",
"0.5267477",
"0.5237851",
"0.5135215",
"0.5087775",
"0.5026814",
"0.5006327",
"0.497881",
"0.49108797",
"0.4821121",
"0.47736892",
"0.4773425",
"0.4773425",
"0.4730687",
"0.4725012",
"0.47026858",
"0.46875027",... | 0.77069974 | 0 |
Given a search string, returns all the matching workitems (in the stores in which the user can read). | def search (query_string)
OpenWFE::Extras::Workitem.search(query_string, store_names).find_all do |wi|
@user.admin? or (
wi.store_name != 'users' || wi.participant_name == @user.name)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(search_string)\n root = EmployeeFolder.root\n result = []\n key = search_string.downcase\n Dir.glob(\"#{root}/*/*\") do |folder|\n next unless Dir.exist? folder\n next unless folder[key]\n\n employee_spec = parse_dir folder\n next if project? employee_spec\n\n result... | [
"0.6381887",
"0.62826955",
"0.6244389",
"0.61944616",
"0.60290784",
"0.5967592",
"0.5943505",
"0.593287",
"0.5931565",
"0.59101796",
"0.5901961",
"0.5880442",
"0.5867845",
"0.586291",
"0.58337057",
"0.58210737",
"0.5818531",
"0.5802142",
"0.5801932",
"0.57808614",
"0.576399",... | 0.67167896 | 0 |
Returns all the store names (according to the 'wi_stores' table) | def find_all_storenames
WiStore.find(:all).collect do |store|
store.name
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_store_names\n\n if @user.admin?\n find_all_storenames\n else\n @permissions.keys.sort\n end\n end",
"def get_wms_stores workspace = nil\n ws = workspace.nil?? get_workspaces : [get_workspace(workspace)]\n cs = []\n ws.each{ |w| cs += w.wms_stores if w.wms_... | [
"0.71889263",
"0.688306",
"0.64553434",
"0.6337646",
"0.6303855",
"0.61992735",
"0.6159913",
"0.61306286",
"0.6119914",
"0.60766655",
"0.6008347",
"0.6000676",
"0.59800816",
"0.5974715",
"0.59460187",
"0.59197265",
"0.58701867",
"0.5842894",
"0.5842894",
"0.5842894",
"0.58428... | 0.8794882 | 0 |
Returns the mapping "storename" > Permission instance | def find_permissions
return nil if @user.admin?
groupnames = Group.find_groups(@user)
StorePermission.find_all_by_groupname(groupnames).inject({}) do
|result, permission|
result[permission.storename] = permission
result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permission (store_name)\n\n return RWD_STORE_PERMISSION if @user.admin?\n return RWD_STORE_PERMISSION if store_name == 'users'\n @permissions[store_name]\n end",
"def permissions = {}",
"def permission_mapping\n super.merge(\n {\n 'index_role_screen' => 'index',\n 'index_rol... | [
"0.677501",
"0.6169189",
"0.6016778",
"0.5778898",
"0.5659508",
"0.56052434",
"0.5601946",
"0.5568518",
"0.55033296",
"0.5458634",
"0.5458634",
"0.54528016",
"0.54023063",
"0.53707504",
"0.5334834",
"0.53318614",
"0.5313097",
"0.52998924",
"0.52880937",
"0.52857155",
"0.52756... | 0.6694527 | 1 |
Companion function to the !roles command used to generate the embeds for each group | def generate_embed(index)
embed = Discordrb::Webhooks::Embed.new
embed.color = 0xFFD700
# If index for a role group is given, generate embed for that group
if index > 0
group = AssignableRoleGroup.all[index - 1]
embed.author = {
name: "Group: #{group.name}",
icon_url... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roles_to_embed *roles\n raise \"Must be implemented by embed storage to generate a set of roles to embed\"\n end",
"def groups\n roles\n end",
"def show_roles(roles, editable: false, only_speaker: false, show_registration: false)\n if only_speaker \n roles = roles.select{|r| r.speak... | [
"0.7119568",
"0.6027745",
"0.5926707",
"0.57730526",
"0.56533283",
"0.56523526",
"0.55967224",
"0.55532175",
"0.5518457",
"0.5500429",
"0.54974747",
"0.5497411",
"0.5494413",
"0.54918516",
"0.5464567",
"0.54566014",
"0.543802",
"0.54372394",
"0.5430615",
"0.541105",
"0.540867... | 0.7491963 | 0 |
GET /score_evaluations GET /score_evaluations.json | def index
@score_evaluations = ScoreEvaluation.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @score_evaluations }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @score_evaluation = ScoreEvaluation.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @score_evaluation }\n end\n end",
"def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student... | [
"0.70963204",
"0.7001828",
"0.6768023",
"0.67598486",
"0.67183495",
"0.6691511",
"0.66504794",
"0.66358405",
"0.663198",
"0.6578833",
"0.65650374",
"0.65650374",
"0.65650374",
"0.65650374",
"0.65650374",
"0.64273256",
"0.64253145",
"0.6393016",
"0.63750654",
"0.62790066",
"0.... | 0.7937988 | 0 |
GET /score_evaluations/1 GET /score_evaluations/1.json | def show
@score_evaluation = ScoreEvaluation.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @score_evaluation }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @score_evaluations = ScoreEvaluation.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @score_evaluations }\n end\n end",
"def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluatio... | [
"0.7758526",
"0.73732257",
"0.70204735",
"0.6716154",
"0.66650575",
"0.663015",
"0.6580333",
"0.6580333",
"0.6580333",
"0.6580333",
"0.6580333",
"0.6572777",
"0.65650946",
"0.65452427",
"0.6541506",
"0.6540212",
"0.64819765",
"0.64585924",
"0.64346033",
"0.63955975",
"0.63431... | 0.7525323 | 1 |
GET /score_evaluations/new GET /score_evaluations/new.json | def new
@score_evaluation = ScoreEvaluation.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @score_evaluation }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @enrolled_score = EnrolledScore.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @enrolled_score }\n end\n end",
"def new\n @scoring_method = ScoringMethod.new\n\n respond_to do |format|\n format.html # new.html.erb... | [
"0.7627355",
"0.757976",
"0.7560061",
"0.7560061",
"0.7487279",
"0.72648525",
"0.72530866",
"0.7227352",
"0.7157638",
"0.7148147",
"0.7145764",
"0.71226704",
"0.7105994",
"0.7081638",
"0.7004847",
"0.6993702",
"0.69931126",
"0.69393915",
"0.69366086",
"0.6908612",
"0.68849134... | 0.8273216 | 0 |
POST /score_evaluations POST /score_evaluations.json | def create
@score_evaluation = ScoreEvaluation.new(params[:score_evaluation])
respond_to do |format|
if @score_evaluation.save
format.html { redirect_to @score_evaluation, :notice => t('selecao_admin.flash_messages.successfully_created.', :model => @score_evaluation.class.model_name.h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # ToDo: 名前の変更\n score = params[:score]\n \n\n if @evaluation.update_attributes(score: score)\n render :show, status: :ok, location: @evaluation\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end",
"def create\n @evaluations = Evaluatio... | [
"0.7332654",
"0.67077494",
"0.6616827",
"0.64930874",
"0.64740974",
"0.64423674",
"0.6432431",
"0.637621",
"0.63749444",
"0.6361069",
"0.63250655",
"0.62867385",
"0.62867385",
"0.62663",
"0.62436855",
"0.62362534",
"0.62195516",
"0.6217482",
"0.6213327",
"0.615658",
"0.614815... | 0.68660045 | 1 |
DELETE /score_evaluations/1 DELETE /score_evaluations/1.json | def destroy
@score_evaluation = ScoreEvaluation.find(params[:id])
@score_evaluation.destroy
respond_to do |format|
format.html { redirect_to score_evaluations_url }
format.json { head :no_content }
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { h... | [
"0.73572135",
"0.73572135",
"0.7300002",
"0.7240983",
"0.72230655",
"0.71482706",
"0.7110597",
"0.7079376",
"0.70701236",
"0.70690894",
"0.70690894",
"0.70690894",
"0.70690894",
"0.70687413",
"0.7065726",
"0.7065726",
"0.7065726",
"0.7065726",
"0.7065726",
"0.7065726",
"0.706... | 0.74119717 | 0 |
GET /today_activities/1 GET /today_activities/1.xml | def show
@today_activity = TodayActivity.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @today_activity }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activities\n get_call(\"1/activities.json\")\n end",
"def activities(params = {})\n scope 'default'\n get('activities/', params)\n end",
"def recent_activities\n get(\"/user/#{@user_id}/activities/recent.json\")\n end",
"def recent_activities()\n get(\"/user/#{@user_id}/... | [
"0.73294634",
"0.7149871",
"0.7085055",
"0.70748377",
"0.7040429",
"0.7039494",
"0.69966096",
"0.69966096",
"0.69782054",
"0.67987555",
"0.67987555",
"0.6772547",
"0.66820544",
"0.6679438",
"0.6602559",
"0.6597832",
"0.6584657",
"0.6570117",
"0.65365404",
"0.65365404",
"0.649... | 0.72362953 | 1 |
GET /today_activities/new GET /today_activities/new.xml | def new
@today_activity = TodayActivity.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @today_activity }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @activity = Activity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @activity }\n end\n end",
"def new\n @activity = Activity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @activ... | [
"0.72711295",
"0.72711295",
"0.72711295",
"0.7268141",
"0.72278106",
"0.70316213",
"0.70222986",
"0.6999209",
"0.699162",
"0.6908136",
"0.68990225",
"0.68770003",
"0.6799573",
"0.6799573",
"0.6744312",
"0.6713452",
"0.67091805",
"0.67066514",
"0.6685236",
"0.6669365",
"0.6653... | 0.78723276 | 0 |
POST /today_activities POST /today_activities.xml | def create
@today_activity = TodayActivity.new(params[:today_activity])
respond_to do |format|
if @today_activity.save
flash[:notice] = 'TodayActivity was successfully created.'
format.html { redirect_to(@today_activity) }
format.xml { render :xml => @today_activity, :status => :... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n data = reload(get_series('activities'), str(Date.strptime(params[:activity].values.join(\"-\"))))\n saved = false\n get_series('activities').each do |s|\n puts \"Updating series=#{s}\"\n data[s].each do |day|\n @activity = for_date(day['dateTime'])\n @activity.send(s.p... | [
"0.62320113",
"0.60473484",
"0.60353965",
"0.5974586",
"0.5961937",
"0.5950495",
"0.59354126",
"0.5923211",
"0.5879357",
"0.5876503",
"0.58538103",
"0.5826054",
"0.5824398",
"0.58243537",
"0.5814983",
"0.57971054",
"0.5758822",
"0.57548803",
"0.5734489",
"0.5684397",
"0.56716... | 0.663838 | 0 |
PUT /today_activities/1 PUT /today_activities/1.xml | def update
@today_activity = TodayActivity.find(params[:id])
respond_to do |format|
if @today_activity.update_attributes(params[:today_activity])
flash[:notice] = 'TodayActivity was successfully updated.'
format.html { redirect_to(@today_activity) }
format.xml { head :ok }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @activity = Activity.find(params[:id])\n \n respond_to do |format|\n if @activity.update_attributes(params[:activity])\n format.html { redirect_to activities_path }\n format.xml { render :nothing => true }\n else\n format.html { render :action => \"edit\" }\n ... | [
"0.631074",
"0.607107",
"0.6034178",
"0.60261756",
"0.6022064",
"0.5983958",
"0.59805375",
"0.5972873",
"0.59531415",
"0.59507155",
"0.59136194",
"0.58991814",
"0.58951575",
"0.5884823",
"0.58019334",
"0.5793046",
"0.57847863",
"0.57422596",
"0.5723481",
"0.5698547",
"0.56886... | 0.6804169 | 0 |
DELETE /today_activities/1 DELETE /today_activities/1.xml | def destroy
@today_activity = TodayActivity.find(params[:id])
@today_activity.destroy
respond_to do |format|
format.html { redirect_to(today_activities_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @evactivity = Evactivity.find(params[:id])\n @evactivity.destroy\n\n respond_to do |format|\n format.html { redirect_to(evactivities_url) }\n format.xml { head :ok }\n end\n end",
"def delete_activity(db, act_id)\n\tdb.execute(\"DELETE FROM activities WHERE id=?\", [act_id])... | [
"0.66917735",
"0.6593528",
"0.6591737",
"0.6578982",
"0.65553606",
"0.65204775",
"0.65204775",
"0.65204775",
"0.65204775",
"0.6473795",
"0.6459832",
"0.6441286",
"0.6338811",
"0.62965286",
"0.6288732",
"0.6274719",
"0.62332684",
"0.622137",
"0.61857164",
"0.61740637",
"0.6173... | 0.71921545 | 0 |
In the following 6 digit number: 283910 91 is the greatest sequence of 2 digits. Complete the solution so that it returns the largest five digit number found within the number given.. The number will be passed in as a string of only digits. It should return a five digit integer. The number passed may be as large as 100... | def solution(digits)
digits.scan(/\d{5}/).max.to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(digits)\n greatest = 0\n (0..(digits.size - 1)).each do |pos|\n num = digits[pos..pos+5].to_i\n greatest = num if num > greatest\n end\n greatest \nend",
"def solution(digits)\n digits.split('').each_cons(5).max.join.to_i\nend",
"def solution(digits)\n\tstop = digits.length - 4\n\tgo =... | [
"0.83006096",
"0.785736",
"0.7820732",
"0.778584",
"0.7728957",
"0.7593007",
"0.75362617",
"0.7466691",
"0.74362713",
"0.7419624",
"0.73802584",
"0.73550844",
"0.73188853",
"0.73064935",
"0.7212375",
"0.7205079",
"0.7204353",
"0.7165965",
"0.7152583",
"0.71505404",
"0.7138082... | 0.83084786 | 0 |
Rock Paper Scissors Let's play! You have to return which player won! In case of a draw return Draw!. Examples: rps('scissors','paper') // Player 1 won! rps('scissors','rock') // Player 2 won! rps('paper','paper') // Draw! My code: | def rps(p1, p2)
if p1 == "scissors" && p2 == "paper"
return "Player 1 won!"
elsif p1 == "scissors" && p2 == "rock"
return "Player 2 won!"
elsif p1 == "scissors" && p2 == "scissors"
return "Draw!"
end
if p1 == "paper" && p2 == "paper"
return "Draw!"
elsif p1 == "paper" && p2 == "rock"
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rps(p1, p2)\n return 'Player 1 won!' if p1 == 'scissors' && p2 == 'paper'\n return 'Player 1 won!' if p1 == 'paper' && p2 == 'rock'\n return 'Player 1 won!' if p1 == 'rock' && p2 == 'scissors'\n return 'Draw!' if p1 == p2\n # Otherwise player 2 wins...\n 'Player 2 won!'\nend",
"def rps(choice)\n choic... | [
"0.7909239",
"0.7767667",
"0.7549004",
"0.7447289",
"0.7404648",
"0.73192704",
"0.7290745",
"0.72346854",
"0.7197022",
"0.71951705",
"0.71461445",
"0.7145533",
"0.71226215",
"0.7109055",
"0.71026695",
"0.7096357",
"0.70457935",
"0.70231926",
"0.7000322",
"0.6953865",
"0.69460... | 0.8137535 | 0 |
GET /auto1h_fold_changes/1 GET /auto1h_fold_changes/1.xml | def show
@auto1h_fold_change = Auto1hFoldChange.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @auto1h_fold_change }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @auto1h_fold_change = Auto1hFoldChange.find(params[:id])\n\n respond_to do |format|\n if @auto1h_fold_change.update_attributes(params[:auto1h_fold_change])\n format.html { redirect_to(@auto1h_fold_change, :notice => 'Auto1h fold change was successfully updated.') }\n format.xm... | [
"0.66975474",
"0.63715464",
"0.6345822",
"0.60864514",
"0.60087264",
"0.57884383",
"0.57838863",
"0.57491595",
"0.5675938",
"0.5662908",
"0.55488575",
"0.55389583",
"0.54748243",
"0.54565024",
"0.5376001",
"0.53462684",
"0.5249507",
"0.52120405",
"0.52045774",
"0.5199062",
"0... | 0.68709546 | 0 |
GET /auto1h_fold_changes/new GET /auto1h_fold_changes/new.xml | def new
@auto1h_fold_change = Auto1hFoldChange.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @auto1h_fold_change }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @hetero1h_fold_change = Hetero1hFoldChange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hetero1h_fold_change }\n end\n end",
"def new\n @auto24h_fold_change = Auto24hFoldChange.new\n\n respond_to do |format|\n format.html # n... | [
"0.69216496",
"0.67254597",
"0.66003704",
"0.61234367",
"0.60837746",
"0.6052604",
"0.604529",
"0.5884453",
"0.58323526",
"0.57824755",
"0.577326",
"0.56456065",
"0.5607873",
"0.5531151",
"0.5477435",
"0.543659",
"0.5433517",
"0.5428538",
"0.5402589",
"0.5397345",
"0.5373941"... | 0.75340813 | 0 |
POST /auto1h_fold_changes POST /auto1h_fold_changes.xml | def create
@auto1h_fold_change = Auto1hFoldChange.new(params[:auto1h_fold_change])
respond_to do |format|
if @auto1h_fold_change.save
format.html { redirect_to(@auto1h_fold_change, :notice => 'Auto1h fold change was successfully created.') }
format.xml { render :xml => @auto1h_fold_chang... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @auto1h_fold_change = Auto1hFoldChange.find(params[:id])\n\n respond_to do |format|\n if @auto1h_fold_change.update_attributes(params[:auto1h_fold_change])\n format.html { redirect_to(@auto1h_fold_change, :notice => 'Auto1h fold change was successfully updated.') }\n format.xm... | [
"0.6669969",
"0.61592245",
"0.6146433",
"0.57850224",
"0.5746697",
"0.5727979",
"0.5665986",
"0.5624672",
"0.5528979",
"0.5212441",
"0.5196037",
"0.51373094",
"0.51309395",
"0.5124373",
"0.5124307",
"0.5124254",
"0.49629757",
"0.48081446",
"0.47723004",
"0.47159457",
"0.47105... | 0.63633174 | 1 |
PUT /auto1h_fold_changes/1 PUT /auto1h_fold_changes/1.xml | def update
@auto1h_fold_change = Auto1hFoldChange.find(params[:id])
respond_to do |format|
if @auto1h_fold_change.update_attributes(params[:auto1h_fold_change])
format.html { redirect_to(@auto1h_fold_change, :notice => 'Auto1h fold change was successfully updated.') }
format.xml { head :... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @hetero1h_fold_change = Hetero1hFoldChange.find(params[:id])\n\n respond_to do |format|\n if @hetero1h_fold_change.update_attributes(params[:hetero1h_fold_change])\n format.html { redirect_to(@hetero1h_fold_change, :notice => 'Hetero1h fold change was successfully updated.') }\n ... | [
"0.6806152",
"0.6460156",
"0.60975254",
"0.60180956",
"0.59429765",
"0.59218717",
"0.58927643",
"0.5807008",
"0.54730195",
"0.5468437",
"0.54474705",
"0.53939223",
"0.5383452",
"0.52899224",
"0.5144697",
"0.5093051",
"0.50664556",
"0.50269735",
"0.5022232",
"0.4989123",
"0.49... | 0.73654467 | 0 |
DELETE /auto1h_fold_changes/1 DELETE /auto1h_fold_changes/1.xml | def destroy
@auto1h_fold_change = Auto1hFoldChange.find(params[:id])
@auto1h_fold_change.destroy
respond_to do |format|
format.html { redirect_to(auto1h_fold_changes_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @auto24h_fold_change = Auto24hFoldChange.find(params[:id])\n @auto24h_fold_change.destroy\n\n respond_to do |format|\n format.html { redirect_to(auto24h_fold_changes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hetero1h_fold_change = Hetero1hFoldChange.f... | [
"0.6999659",
"0.69996226",
"0.65494996",
"0.6258215",
"0.58834153",
"0.58636796",
"0.5760584",
"0.5737086",
"0.5615536",
"0.5603464",
"0.55823964",
"0.55224675",
"0.54767346",
"0.5435245",
"0.54351914",
"0.53915316",
"0.53686434",
"0.5356971",
"0.53467727",
"0.5346028",
"0.53... | 0.75717944 | 0 |
~ Validation ............................................................... ~ Constants ................................................................ ~ Hooks .................................................................... ~ Class methods ............................................................ ~ Instance m... | def clone(book, chapter)
ch_mod = InstChapterModule.new
ch_mod.inst_chapter_id = chapter.id
ch_mod.inst_module_id = self.inst_module_id
ch_mod.module_position = self.module_position
ch_mod.save
inst_sections.each do |section|
inst_section = section.clone(book, ch_mod)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone(inst_book)\n ch = InstChapter.new\n ch.inst_book_id = inst_book.id\n ch.name = self.name\n ch.short_display_name = self.short_display_name\n ch.position = self.position\n ch.save\n\n inst_chapter_modules.each do |chapter_module|\n inst_chapter_module = chapter_module.clone(inst_... | [
"0.7890258",
"0.6462407",
"0.621236",
"0.6099441",
"0.6005311",
"0.6005311",
"0.6005311",
"0.5979878",
"0.5948332",
"0.59145516",
"0.59145516",
"0.59145516",
"0.58370215",
"0.58052343",
"0.58052343",
"0.57945704",
"0.5776038",
"0.5721032",
"0.57147",
"0.57038325",
"0.56764686... | 0.7693855 | 1 |
gets all the exercises in one module | def get_exercises_list
exercises_list = []
inst_sections.each do |inst_section|
exercises_ids = inst_section.inst_book_section_exercises.collect(&:inst_exercise_id).compact
exercises_objs = InstExercise.where(id: exercises_ids)
exercises_list.concat exercises_objs.collect(&:short_name)
end... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bk_sec_exercises()\n InstBookSectionExercise.includes(:inst_exercise)\n .joins(:inst_section)\n .where(inst_sections: {inst_chapter_module_id: self.id})\n end",
"def index\n @programme_exercises = ProgrammeExercise.all\n end",
"def index\n @api_v1_exercises = Api::V1::Exercise.all\... | [
"0.68270224",
"0.63926715",
"0.63837355",
"0.6327996",
"0.6315433",
"0.6277688",
"0.62363505",
"0.6235913",
"0.6233418",
"0.62311316",
"0.617177",
"0.5988263",
"0.5979324",
"0.58786833",
"0.58611494",
"0.57945496",
"0.57819676",
"0.57789344",
"0.57742757",
"0.573673",
"0.5695... | 0.74532676 | 0 |
get all of the inst_book_section_exercise instances associated with this module | def get_bk_sec_exercises()
InstBookSectionExercise.includes(:inst_exercise)
.joins(:inst_section)
.where(inst_sections: {inst_chapter_module_id: self.id})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_exercises_list\n exercises_list = []\n inst_sections.each do |inst_section|\n exercises_ids = inst_section.inst_book_section_exercises.collect(&:inst_exercise_id).compact\n exercises_objs = InstExercise.where(id: exercises_ids)\n exercises_list.concat exercises_objs.collect(&:short_nam... | [
"0.73905605",
"0.61486846",
"0.6032731",
"0.58753085",
"0.58352643",
"0.568193",
"0.56593484",
"0.5606959",
"0.5599002",
"0.5564633",
"0.55466497",
"0.55225277",
"0.5483004",
"0.54768443",
"0.54677606",
"0.5445167",
"0.54239225",
"0.540966",
"0.5392279",
"0.5383424",
"0.53695... | 0.7846473 | 0 |
get all exercise progresses for the exercises in this module for the specified user | def get_exercise_progresses(user_id)
OdsaExerciseProgress.joins(inst_book_section_exercise: [:inst_section])
.where(inst_sections: {inst_chapter_module_id: self.id}, user_id: user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @user = User.find(params[:user_id])\n @exercises = @user.exercises.all\n end",
"def index\n @user = User.find(current_user.id)\n @exercises = Exercise.all\n end",
"def get_exercises_list\n exercises_list = []\n inst_sections.each do |inst_section|\n exercises_ids = inst_sec... | [
"0.62693167",
"0.5825106",
"0.5666747",
"0.5660282",
"0.5629161",
"0.55948055",
"0.553738",
"0.5506217",
"0.54563826",
"0.5438358",
"0.54136205",
"0.5322686",
"0.5318455",
"0.5294175",
"0.52817625",
"0.52794385",
"0.52567387",
"0.5256051",
"0.5254691",
"0.5232709",
"0.5173285... | 0.79263496 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.