query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Detect rollovers and make it as if they never happened. This assumes it has been given a counter and that you're OK with getting possibly huge numbers. It also assumes that it's an increasing counter. | def unrollover(series, control, ignore=nil)
each_subseries_in series, control do |name, subseries|
if skip_name?(control, name)
subseries
else
new_subseries = {}
# track the previous value, once a rollover is detected, start adding it to new values
prev = subseries.first.last
last_in_previous_series = nil
# sort the timestamps again just to be sure, otherwise things will get very weird
subseries.keys.sort.each do |ts|
val = subseries[ts]
if prev > val
last_in_previous_series = prev
end
if last_in_previous_series
new_subseries[ts] = val + last_in_previous_series
else
new_subseries[ts] = val
end
prev = val
end
new_subseries
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def carry_over\n while clock.any? { |val| val < 0 }\n indx = clock.rindex(-1)\n clock[indx - 1] -= 1\n clock[indx] = n\n end\n end",
"def light_switcher(array, inc)\n counter = 0\n\n while counter < array.length\n array[counter] = !array[counter] if (counter + 1) % inc == 0\n counte... | [
"0.5880909",
"0.5363239",
"0.53617096",
"0.5265638",
"0.5263314",
"0.52372986",
"0.51046497",
"0.5099819",
"0.50879866",
"0.5076598",
"0.506393",
"0.50122535",
"0.49620333",
"0.49587047",
"0.49515224",
"0.49496844",
"0.49464017",
"0.49109864",
"0.48879218",
"0.4887779",
"0.48... | 0.0 | -1 |
Validates that the array index provided falls within the acceptable range or in the event we have received the special '' index defined in the JSON Pointer RFC we treat it as the last element. | def check_array_index(index, array_size)
return -1 if index == "-"
raise ObjectOperationOnArrayException unless index =~ /\A-?\d+\Z/
index = index.to_i
# There is a bug in the IETF tests that require us to allow patches to
# set a value at the end of the array. The final '<=' should actually be
# a '<'.
raise OutOfBoundsException unless (0 <= index && index <= array_size)
index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_index?(index)\n index >= 0 && index < self.length\n end",
"def valid_index_in?(array, index)\n index <= (array.length - 1) && index >= (0 - array.length)\n end",
"def valid_index?(array, index_number)\n if index_number >= 0 && index_number < array.length\n return true\n end\n... | [
"0.6854556",
"0.6778515",
"0.64840937",
"0.64587384",
"0.6175867",
"0.60964185",
"0.6094094",
"0.5861429",
"0.5861429",
"0.58475333",
"0.58275855",
"0.5651375",
"0.5617881",
"0.5595046",
"0.55722684",
"0.53619415",
"0.53255486",
"0.5313012",
"0.5285346",
"0.5279813",
"0.52418... | 0.70960903 | 0 |
Remove a hash key or index from the provided object. It is important to note that this behaves by adjusting the state of the provided object. It does not return the new object itself! | def rm_op(target_obj, key)
if target_obj.is_a?(Array)
raise InvalidIndexError unless key =~ /\A\d+\Z/
target_obj.delete_at(check_array_index(key, target_obj.size))
else
raise(MissingTargetException, key) unless target_obj.has_key?(key)
target_obj.delete(key)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(o)\n @hash.delete(o)\n self\n end",
"def delete(o)\n @hash.delete(o)\n self\n end",
"def remove(obj)\n hashed.each do |k,v|\n hashed.delete(k) if v == obj\n end\n list.reject! { |el| el == obj }\n end",
"def remove(hash, item)\n hash.delete(item)\nend",
"d... | [
"0.66159195",
"0.66159195",
"0.6555506",
"0.63776225",
"0.63776225",
"0.62921476",
"0.62809044",
"0.6216469",
"0.6216469",
"0.61825466",
"0.61616194",
"0.61462295",
"0.61294293",
"0.6116053",
"0.60960287",
"0.60853744",
"0.6030184",
"0.59440845",
"0.59353924",
"0.5933416",
"0... | 0.5723803 | 29 |
Write a method that finds the first `n` Fibonacci numbers recursively. | def fibs_rec(count)
return [0,1,1].take(count) if count < 3
prev_fibs = fibs_rec(count - 1)
prev_fibs + [prev_fibs[-2] + prev_fibs[-1]]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_fib_nth(n)\n if n == 0\n 1\n elsif n == 1\n 1\n else\n return (find_fib_nth(n - 2) + find_fib_nth(n - 1))\n end\nend",
"def fibo_finder(n)\n if n <= 1\n \tn\n else\n fibo_finder(n-1) + fibo_finder(n-2)\n end\nend",
"def fibo_finder(n) \n if n == 0\n return 0\n elsif n ==1\n ... | [
"0.8645783",
"0.86040217",
"0.85079396",
"0.8485469",
"0.8454698",
"0.83230335",
"0.83180165",
"0.8309572",
"0.8308574",
"0.8307081",
"0.83026034",
"0.82961744",
"0.8296057",
"0.8257003",
"0.8237993",
"0.8228553",
"0.821386",
"0.8193342",
"0.817825",
"0.8158673",
"0.81534326"... | 0.0 | -1 |
Write a method that returns the largest prime factor of a number | def largest_prime_factor(num)
return nil if num < 2
(1..num).inject do |acc, fact|
if num % fact == 0 && prime?(fact) && fact >= acc
fact
else
acc
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def largest_prime_factor(num)\n (2..num).reverse_each do |factor|\n if (num % factor == 0 && Prime.prime?(factor))\n return factor\n end\n end\nend",
"def largest_prime_factor(num)\n return num if prime?(num)\n\n prime_factors(num).max\nend",
"def largest_prime_factor(num)\n ... | [
"0.9066874",
"0.9057335",
"0.89896095",
"0.8985595",
"0.895942",
"0.8933407",
"0.8927283",
"0.89114064",
"0.8892004",
"0.8883424",
"0.8865651",
"0.88567936",
"0.884887",
"0.88184834",
"0.8817869",
"0.88175195",
"0.87884694",
"0.87761",
"0.87329096",
"0.871987",
"0.8713394",
... | 0.8495807 | 44 |
You are not required to implement this; it's here as a suggestion :) | def prime?(num)
return false if num < 2
(2...num).none? { |fact| num % fact == 0 }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def custom; end",
"def custom; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def anchored; end",
"def implementation; end",
"def implementation; end",
"def who_we_are\r\n end",
"def schubert; end",
"def internal... | [
"0.7553507",
"0.6552449",
"0.64689904",
"0.64689904",
"0.6330685",
"0.6330685",
"0.6330685",
"0.6330685",
"0.62413305",
"0.6235965",
"0.6235965",
"0.62254673",
"0.6177895",
"0.60686946",
"0.6011465",
"0.59913504",
"0.5986834",
"0.5986834",
"0.5981618",
"0.5937139",
"0.5912224... | 0.0 | -1 |
Returns the link to use for the given item. | def item_link(record)
doi_link = doi_generator(record)
# Return DOI link, in one exists
return doi_link if doi_link
# Query OpenURL resolve service for results
open_url_links = open_url_generator(record)
if open_url_links.size.positive?
# If there is only one result, return it
return open_url_links[0] if open_url_links.size == 1
# If there are multiple results, return a "Citation Finder" link
return citation_generator(record)
end
# Default -- return link to the catalog detail page
catalog_generator(record)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_to_item(item, options = {})\n case item\n when Collection\n collection_url(item, options)\n when Community\n community_url(item, options)\n when DataObject\n data_object_url(item.latest_published_version_in_same_language || item, options)\n when User\n user_url(item, opt... | [
"0.781411",
"0.76151764",
"0.76151764",
"0.7522602",
"0.74092823",
"0.73402494",
"0.7258155",
"0.72519565",
"0.72460693",
"0.72003204",
"0.7102176",
"0.6756451",
"0.66518635",
"0.66504794",
"0.6610305",
"0.6600688",
"0.6586953",
"0.65281564",
"0.6476347",
"0.64524966",
"0.644... | 0.76439923 | 1 |
Returns a single URL representing the link to the DOI, or nil if no DOI is available | def doi_generator(record)
doi_link = record.eds_document_doi
# Return DOI link, if available
return nil unless doi_link
Rails.logger.debug('QuickSearch::EbscoDiscoveryServiceApiArticleSearcher.item_link - DOI link found. Returning.')
doi_base_url = QuickSearch::Engine::EBSCO_DISCOVERY_SERVICE_API_ARTICLE_CONFIG['doi_link']
doi_base_url + doi_link
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_link(record)\n doi_link = doi_generator(record)\n\n # Return DOI link, in one exists\n return doi_link if doi_link\n\n # Query OpenURL resolve service for results\n open_url_links = open_url_generator(record)\n if open_url_links.size.positive?\n # If there is only one ... | [
"0.6834185",
"0.66077685",
"0.6520934",
"0.6131768",
"0.6128536",
"0.59237164",
"0.5920453",
"0.5911649",
"0.5898959",
"0.58986396",
"0.5774957",
"0.57382005",
"0.572961",
"0.5724482",
"0.57185555",
"0.56830966",
"0.5665729",
"0.5653783",
"0.56491643",
"0.56468666",
"0.564600... | 0.683144 | 1 |
Returns a list of URLs returned by an OpenURL resolver server, or an empty list if no URLs are found. | def open_url_generator(record)
open_url_link = open_url_resolve_link(record)
links = UmdOpenUrl::Resolver.resolve(open_url_link)
links
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def urls\n @urls ||= extract_urls('url')\n end",
"def urls\n info.map(&:value).select { |u| u.match %r{\\Ahttps?://} }\n end",
"def urls\n @urls ||= all_urls(sitemap)\n end",
"def get_urls_for_client_jars(existing, urls)\n []\n end",
"def get_urls_for_client_jars(existing, u... | [
"0.6629333",
"0.6364525",
"0.63235545",
"0.6304233",
"0.6304233",
"0.6267078",
"0.61588174",
"0.6017357",
"0.59950906",
"0.5962818",
"0.5952448",
"0.59423184",
"0.59388876",
"0.59278023",
"0.5923304",
"0.59088475",
"0.5904807",
"0.58916616",
"0.58654207",
"0.58644956",
"0.582... | 0.0 | -1 |
Returns a URL to a citation finder server, or nil if no citation finder is available | def citation_generator(record)
builder = open_url_builder(
record, QuickSearch::Engine::EBSCO_DISCOVERY_SERVICE_API_ARTICLE_CONFIG['citation_finder_link']
)
builder&.build
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url(argv)\n arg = argv[10..-1]\n find = BibDesk.search({:for => arg})\n unless find == []\n find[0].show\n BibDesk.activate\n else\n growl(\"File not found\", \"Cannot find citation #{ARGV[0]}\")\n end\nend",
"def get_url(doc, type)\n id = doc.id.to_s\n 'https://scholarworks.calstate.edu/... | [
"0.60441095",
"0.5485799",
"0.5341227",
"0.5206341",
"0.515315",
"0.5145521",
"0.5141138",
"0.51189613",
"0.5105977",
"0.51015425",
"0.5091534",
"0.50685287",
"0.5049609",
"0.50369316",
"0.5011652",
"0.5002354",
"0.4983312",
"0.49402496",
"0.49235016",
"0.49112737",
"0.490011... | 0.5037347 | 13 |
Returns an OpenUrlBuilder populated with information from the given record and link | def open_url_builder(record, link)
builder = UmdOpenUrl::Builder.new(link)
builder.issn(record.eds_issns&.first)
.volume(record.eds_volume)
.issue(record.eds_issue)
.start_page(record.eds_page_start)
.publication_date(record.eds_publication_date)
builder
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_url_builder(bib, link) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n best_type = WorldCat::Discovery::Bib.choose_best_type(bib)\n return nil unless best_type.is_a? WorldCat::Discovery::Article\n\n article = best_type\n\n builder = UmdOpenUrl::Builder.new(link)\n\n # Wo... | [
"0.68684393",
"0.65833557",
"0.6504217",
"0.58455217",
"0.575234",
"0.56111264",
"0.5555897",
"0.5471284",
"0.54687345",
"0.53691787",
"0.52947485",
"0.5280991",
"0.527344",
"0.52600193",
"0.52540606",
"0.5252965",
"0.5227426",
"0.52133274",
"0.5192239",
"0.5192239",
"0.51720... | 0.8599688 | 0 |
Returns the anonymous identifier only if this user is anonymous. | def anonymous_id
auth_data["anonymous"]["id"] if auth_data.present? && auth_data["anonymous"].is_a?(Hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_anonymous\n @user_id == Gss::Provider::IDENTITY_ANONYMOUS\n end",
"def anonymous?\n return identifier.nil?\n end",
"def anonymous?\n user.nil?\n end",
"def anonymous?\n user.nil? || as_anonymous?\n end",
"def anonymous?\n email == ANONYMOUS_EMAIL\n end",
"def an... | [
"0.7960044",
"0.75003487",
"0.74997944",
"0.7451466",
"0.74036497",
"0.7197135",
"0.7171097",
"0.7041648",
"0.6750272",
"0.6689367",
"0.665692",
"0.664826",
"0.65457326",
"0.65395445",
"0.6535311",
"0.6533024",
"0.6533024",
"0.6533024",
"0.6487335",
"0.64451915",
"0.6323889",... | 0.7715079 | 1 |
Request a password reset for this user | def request_password_reset
return false if email.nil?
Parse::User.request_password_reset(email)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_reset_request\n end",
"def request_password\n\t\t@user = User.find_by_email(params[:email])\n\t\tif @user == nil || @user == ''\n\t\t\tredirect_to \"/forgot_password\", :notice => \"Please enter a valid email\"\n\t\telse\n\t\t\t@random_string = (0...50).map { ('a'..'z').to_a[rand(26)] }.join\n\t\t\... | [
"0.7849505",
"0.7805792",
"0.76714545",
"0.7664341",
"0.765178",
"0.765178",
"0.765178",
"0.765178",
"0.765178",
"0.765178",
"0.765178",
"0.7624155",
"0.76036245",
"0.759376",
"0.759376",
"0.7593523",
"0.75510895",
"0.75459874",
"0.75216967",
"0.7502483",
"0.74904186",
"0.7... | 0.80101514 | 0 |
Login and get a session token for this user. | def login!(passwd = nil)
self.password = passwd || self.password
response = client.login(username.to_s, password.to_s)
apply_attributes! response.result
self.session_token.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login\n return @token if @token or @auth_method == :api_key\n request = Request.new(\"Post\", \"#{@config[:base_url]}/user/login\")\n\n request.add_multipart_body ({\n name: @config[:username],\n pass: @config[:password],\n form_id: \"user_login\",\n op: \"Log in\",\n... | [
"0.7776082",
"0.77452815",
"0.7292128",
"0.7241968",
"0.7234924",
"0.716501",
"0.71332926",
"0.713035",
"0.713035",
"0.7115456",
"0.7098674",
"0.7074188",
"0.7064542",
"0.7043011",
"0.7043011",
"0.7035423",
"0.70119405",
"0.7011364",
"0.6987522",
"0.6984552",
"0.6983719",
"... | 0.0 | -1 |
Invalid the current session token for this logged in user. | def logout
return true if self.session_token.blank?
client.logout session_token
self.session_token = nil
true
rescue => e
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalid_token\n\t\t\tredirect_to login_url\n\t\tend",
"def invalid_authenticity_request\n sign_out(current_user)\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n render error: 'invalid token', status: :unprocessable_entity\n end",
"def invalidate_token\n self... | [
"0.74372226",
"0.71668077",
"0.6737047",
"0.66067",
"0.660605",
"0.660605",
"0.6579886",
"0.6544262",
"0.6543031",
"0.6486431",
"0.6478342",
"0.6466649",
"0.64275044",
"0.64273816",
"0.636576",
"0.63552827",
"0.63500255",
"0.63466954",
"0.6296934",
"0.62694114",
"0.625378",
... | 0.0 | -1 |
If the current session token for this instance is nil, this method finds the most recent active Parse::Session token for this user and applies it to the instance. The user instance will now be authenticated and logged in with the selected session token. Useful if you need to call save or destroy methods on behalf of a logged in user. | def any_session!
unless @session_token.present?
_active_session = active_sessions(restricted: false, order: :updated_at.desc).first
self.session_token = _active_session.session_token if _active_session.present?
end
@session_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_user_token\n if user_signed_in?\n Session.active_sessions.find_by(id: request.headers['sid'], utoken: request.headers['utoken']).update(last_used_at: Time.zone.now)\n end\n end",
"def set_current_user(user)\n session[:user_token] = user.token\n end",
"def set_current_user\n # fo... | [
"0.69148386",
"0.6779664",
"0.6646953",
"0.6622206",
"0.6516608",
"0.650696",
"0.6485911",
"0.6478645",
"0.6343472",
"0.6336821",
"0.6329386",
"0.6309439",
"0.6309439",
"0.6309439",
"0.63087136",
"0.6279048",
"0.627794",
"0.627794",
"0.6275578",
"0.6275578",
"0.6245529",
"0... | 0.6088491 | 38 |
Store any pretty variables they now have | def store_variables( user_vars )
#Store the same varables or newly named ones
user_vars.each do |var|
if var =~ /^@__([A-Z0-9_]+)$/ #All caps are cookies
puts "Cookie #$1"
cookies[$1] = instance_variable_get(var)
elsif var =~ /^@__([A-Za-z0-9_]+)$/ #Sessions can have any kind of names
puts "Session #$1"
session[$1] = instance_variable_get(var)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prep_variables\n end",
"def variables; end",
"def variables; end",
"def pretty_print_instance_variables\n (instance_variables - pretty_print_ignore).sort\n end",
"def local_variables() end",
"def pretty_print_instance_variables\n %w(@nodes)\n end",
"def pretty_print_instance_... | [
"0.6196229",
"0.60611737",
"0.60611737",
"0.59619564",
"0.594544",
"0.5904819",
"0.5569568",
"0.5569568",
"0.5517472",
"0.5470998",
"0.5403261",
"0.5397652",
"0.5397652",
"0.5397652",
"0.5394423",
"0.5380893",
"0.5344959",
"0.532063",
"0.5297736",
"0.52956396",
"0.52921265",
... | 0.52422106 | 32 |
Pull any anything out of this hash and max vars with it Filter expects an array of arrays. The first element is the regex using in a gsub, the second element is what will be replaced, if a their element is found, it should be a symbol of :sub or :gsub, to tell me which to use | def pull_params( hash, naming = :any, per = false, *filter )
#Scope my regex
regex = nil
#Create a regex based on the naming convension the user wants
case naming
when :cap
regex = /^[A-Z].*[a-z].*/
when :upper
regex = /^[A-Z0-9_]+$/
when :lower
regex = /^[^A-Z]+$/
else #Default
regex = /.*/
end
#Create my variables that match my regex
hash.each do |k, v|
#Create the instance variable if we have a match
if k.to_s =~ regex
#If the user gave me a filter, apply the filter
filter.each do |f|
#Normalize the params the user might have given us
#Duck typing can make your code woddle a little!
v = v.to_s #Need to to do this to ensure things will work
f = [f] if !f.is_a? Array
reg = (f[0].is_a? Regexp)? f[0]: Regexp.new( f[0] )
#Apply the filter here
if f[2] == :sub
v.sub!(reg, f[1].to_s)
else
v.gsub!(reg, f[1].to_s)
end
end
#Convert value to a dash file if that makes sence to do
v_con = (v.class.to_s.downcase =~ /^hash/)? RestlessHash.new(v): v
#Generate the instance variable
if !per
instance_variable_set( "@_#{k}", v_con )
else
instance_variable_set("@__#{k}", v_con )
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contact_filter(arg)\r\n ph = wx = qq = nil\r\n $contact_map.each do |k, v|\r\n re = Regexp.new(v)\r\n ####################################\r\n if (k==1)\r\n if (arg =~ re)\r\n k0 = $1\r\n k1 = $2\r\n k2 = $3\r\n arg.gsub!(k0, \"\")\r\n if (k1 && k1.size > 4)\r... | [
"0.5948003",
"0.57482296",
"0.5733247",
"0.5657987",
"0.5647934",
"0.5644843",
"0.56237787",
"0.55350524",
"0.54394174",
"0.5432987",
"0.542903",
"0.54004097",
"0.5397552",
"0.5346654",
"0.53181875",
"0.53092337",
"0.5244174",
"0.52258676",
"0.5209175",
"0.516518",
"0.5150534... | 0.48024625 | 63 |
validates :status, presence: true validates :start_time, presence: true validates :end_time, presence: true validate :end_time_after_start_time | def end_time_after_start_time
return if end_time.blank? || start_time.blank?
if end_time < start_time
errors.add(:end_time, "must be after the start time")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_start_and_stop_time\n if active_time\n if active_start_time.nil? or active_stop_time.nil?\n errors.add(:active_time, \"start time or end time not set\")\n end\n end\n end",
"def validate(record)\n if !record.start_time.nil? && !record.end_time.nil? && record.start_time >= ... | [
"0.78268963",
"0.77957",
"0.76713693",
"0.76131785",
"0.7569122",
"0.7470949",
"0.74073976",
"0.7394125",
"0.7309684",
"0.72245497",
"0.7218699",
"0.7172854",
"0.7146024",
"0.7141043",
"0.71149075",
"0.7100005",
"0.7091129",
"0.7062418",
"0.7037734",
"0.7021366",
"0.7011817",... | 0.71828055 | 11 |
divers in this scheduled dives | def divers_scheduled()
sql = "SELECT *
FROM divers
INNER JOIN bookings
ON bookings.diver_id = divers.id
WHERE bookings.schedule_id = $1"
values = [@id]
result = SqlRunner.run(sql,values)
dives = Diver.new(result.first)
return dives
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def divorces(for_person)\n select_spouse_events('Divorce',for_person)\n end",
"def divs\n Div.where(\"chromosome = ? and position between ? and ?\",\n chromosome, start, stop)\n .order(\"position ASC\")\n end",
"def div_elements(identifier)\n platform.divs_for(identifier.cl... | [
"0.562946",
"0.5344765",
"0.5176089",
"0.5129529",
"0.5025057",
"0.49385437",
"0.48883364",
"0.48528704",
"0.485157",
"0.4839199",
"0.48307362",
"0.4824678",
"0.47858196",
"0.47444427",
"0.47302666",
"0.47285825",
"0.46936342",
"0.4679968",
"0.46769458",
"0.4672187",
"0.46512... | 0.5453191 | 1 |
dives in a schedule | def dives()
sql = "SELECT *
FROM dives
WHERE id = $1"
values = [@dive_id]
result = SqlRunner.run(sql,values)
dives = Dive.new(result.first)
return dives
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaulate_schedule\n 5\n end",
"def schedule\n # implemented by subclass\n end",
"def schedule\n unless (@schedule)\n schedule = []\n emails = @emails\n emails << 'n/a' if @emails.size.odd?\n\n top_row = emails[0...(emails.size/2)]\n (0...top_row.size).each do... | [
"0.68729246",
"0.6731445",
"0.66644466",
"0.664115",
"0.6638037",
"0.6577471",
"0.6547833",
"0.65272063",
"0.64921826",
"0.64394796",
"0.6433349",
"0.642416",
"0.62842804",
"0.6278047",
"0.62416714",
"0.62395126",
"0.62130296",
"0.62118167",
"0.619709",
"0.6170656",
"0.614308... | 0.0 | -1 |
see the bookings for this schedule | def bookings()
sql = "SELECT bookings.*
FROM bookings
WHERE bookings.schedule_id = $1"
values = [@id]
result = SqlRunner.run(sql,values)
bookings = Booking.map_items(result)
return bookings
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @booking = @boat.bookings.build(user: current_user)\n @booking.start_time = Time.zone.tomorrow + 9.hours\n @booking.end_time = Time.zone.tomorrow + 18.hours\n @booking.people_on_board = 1\n #TODO disable also booked(accepted) days\n end",
"def past\n @bookings = Booking.completed(cu... | [
"0.6827438",
"0.67954874",
"0.6795019",
"0.6709082",
"0.6526533",
"0.6445977",
"0.63905066",
"0.63387144",
"0.6305158",
"0.62859225",
"0.62859225",
"0.62859225",
"0.62859225",
"0.62859225",
"0.62859225",
"0.62859225",
"0.62859225",
"0.62859225",
"0.62859225",
"0.62859225",
"0... | 0.74490273 | 0 |
Ensure cancan validation on every controller method | def vote
@content = Content.find(params[:id])
authorize! :moderate, @content
@vote = Vote.cast_vote(@content.id, current_user.id, params[:vote].to_i)
if @vote.save
ModerationNotifications.vote(@vote, params[:vote].to_i).deliver
redirect_to :back
else
redirect_to :back, :notice => "An error occurred moderating this content #{@content.errors.full_messages}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enforce_access_controls(opts={})\n controller_action = params[:action].to_s\n delegate_method = \"enforce_#{controller_action}_permissions\"\n if self.respond_to?(delegate_method.to_sym, true)\n self.send(delegate_method.to_sym)\n else\n true\n end\n end",
"def verify_rights\n ... | [
"0.6790841",
"0.6759356",
"0.66979736",
"0.66916925",
"0.6592548",
"0.6518335",
"0.64903164",
"0.6481495",
"0.64428264",
"0.64176464",
"0.6386458",
"0.6372366",
"0.6342952",
"0.63218236",
"0.62768364",
"0.6269258",
"0.62544644",
"0.6248316",
"0.62478155",
"0.62175244",
"0.619... | 0.0 | -1 |
Get a position relative to this | def relative(xr, yr)
Position.new(x + xr, y + yr)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position\n @position\n end",
"def position\n return @position\n end",
"def position\n return @position\n end",
"def to_position\n self\n end",
"def position\n current.position\n end",
"def pos\n @layout[@pos - 1]\n end",
... | [
"0.750378",
"0.7400086",
"0.7400086",
"0.73205096",
"0.7169281",
"0.7132839",
"0.70506537",
"0.7010271",
"0.70013505",
"0.698476",
"0.6975451",
"0.69388616",
"0.6921009",
"0.68835586",
"0.6860218",
"0.67949945",
"0.6786206",
"0.67588156",
"0.67521083",
"0.67472345",
"0.672894... | 0.67631626 | 17 |
Create a new script output parser and set up the connection object that output is forwarded to this parser. benchmark Benchmark that generates the output to parse. connection Connection to the remote host where the benchmark is executed. attachment_dir A writable directory path as string where file attachments from AttachFileCommand are supposed to be stored. | def initialize(options)
raise "Need parameter :benchmark" unless options[:benchmark]
raise "Need parameter :connection" unless options[:connection]
@connection = options[:connection]
@benchmark = options[:benchmark]
if options[:attachment_dir] then
@attachment_dir = options[:attachment_dir][-1] == '/' ? options[:attachment_dir][0 ... -1] : options[:attachment_dir]
if !File.exists?(@attachment_dir) || !File.writable?(@attachment_dir) then
raise SecurityError, "attachment directory #{@attachment_dir} is not writable"
end
else
@attachment_dir = nil
end
@@log.level = Logger::DEBUG
@@log = options[:logger] if options[:logger]
@check_results = {}
@rule_results = {}
@total_time_units = 0
@done_time_units = 0
@total_time_units = @benchmark.duration()
@stdout_line_buffer = StdoutLineBuffer.new(connection)
@stdout_line_buffer.on_line do |msg|
consume_stdout(msg)
end
connection.on_stderr do|msg|
consume_stderr(msg)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(run, agent, asset, file)\n super(run)\n @file = file\n @asset = asset\n @agent = agent\n @protocol = \"http\" \n end",
"def initialize(output: nil, runner: nil, repeat_count: 1)\n @prelude = ''\n @loop_count = nil\n @jobs = []\n @... | [
"0.5294075",
"0.5034271",
"0.49044237",
"0.49003398",
"0.48208475",
"0.48073372",
"0.4789403",
"0.4776515",
"0.47467697",
"0.47311336",
"0.4686891",
"0.4638541",
"0.46372488",
"0.4635565",
"0.46267352",
"0.45793438",
"0.45743084",
"0.4567811",
"0.45663324",
"0.45538697",
"0.4... | 0.67712414 | 0 |
Called whenever a new line of output was received on the connection. line The newly received output line. | def consume_stdout(line)
@@log.warn {"incomplete line '#{line}' on stdout, not terminated by \\n"} if line[-1] != "\n"
if /^#{LINE_START}\s*([A-Za-z0-9_]+)\s*#{SEPARATOR}\s*([A-Za-z]+)\s*#{SEPARATOR}\s*([A-Za-z0-9_]+)\s*#{SEPARATOR}\s*(.*)$/.match(line) then
#parse check id
check = @benchmark.item_repository[$1] or process_unknown_check_id(line, $1)
severity = RuleSeverity::parse($2)
cmd_class = @@command_mapper[$3.upcase]
if cmd_class.nil? then
process_unknown_reply_command(line, check, severity, $3)
else
@@log.debug {"processing command #{cmd_class.name}: #{line}"}
process_command(cmd_class.new(check, severity, $4.split(SEPARATOR)))
end
else
process_unknown_output(line)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive_line line\n super(line)\n write_output\n end",
"def receive_line line\n child.on_output line\n end",
"def receive_line(line)\n Invoker::Logger.puts \"#{@command_label.color(color)} : #{line}\"\n end",
"def receive_data_line line\n end",
"def receive_line(line... | [
"0.785694",
"0.7655181",
"0.7572998",
"0.6810756",
"0.65599287",
"0.6453693",
"0.64532",
"0.64498836",
"0.6429527",
"0.64102864",
"0.6392914",
"0.6356274",
"0.6288009",
"0.62232745",
"0.61994106",
"0.61646855",
"0.61406153",
"0.6084261",
"0.60723704",
"0.6066357",
"0.6060301"... | 0.0 | -1 |
Get the current progress of the benchmark execution as a float value between 0 and 1. | def progress()
return 1.0 * @done_time_units / @total_time_units
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_progress\n result = self.progress_status\n (100 * result.values.count(true) / result.values.compact.count).to_s\n end",
"def progressValue\n return @progressValue\n end",
"def calc_progress\n p = 0.25\n unless self.compile_errors.nil?\n p = 0.5\n end\n\n if self.... | [
"0.7685575",
"0.7571294",
"0.73329896",
"0.71474093",
"0.7018687",
"0.70159715",
"0.7001581",
"0.69673824",
"0.68964916",
"0.68964916",
"0.68537945",
"0.6802191",
"0.67063135",
"0.6669093",
"0.66558164",
"0.65877736",
"0.6565959",
"0.65095127",
"0.649218",
"0.6481252",
"0.647... | 0.80225265 | 0 |
Get the estimated remaining time in seconds. This value is very inexact. | def remaining_time()
return @total_time_units - @done_time_units
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seconds_remaining\n ends_at ? (ends_at - started_at).round : 0\n end",
"def remaining\n [0, @duration - elapsed].max\n end",
"def remaining_minutes()\n current_time = Time.now\n start_time = Delay.find_newest_travel_time(stop_position.bus.id, current_time)\n predicted_time ... | [
"0.7876134",
"0.76737875",
"0.7423965",
"0.72912705",
"0.7260562",
"0.722769",
"0.71480256",
"0.71415865",
"0.7114354",
"0.70818406",
"0.70425844",
"0.6982978",
"0.6968481",
"0.69036996",
"0.68555534",
"0.684022",
"0.6763636",
"0.6747405",
"0.6742087",
"0.6736557",
"0.6731213... | 0.8225421 | 0 |
This method is called whenever data on stderr is encountered. Normally this should never happen, as all scripts are supposed to suppress output on stderr. | def consume_stderr(text)
@@log.warn {"Unexpected line on stderr: '#{text}'. Verify that scripts are not broken."}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stderr_received(data); end",
"def stderr(command, data)\n # called when the process writes to STDERR\n end",
"def without_stderr; end",
"def on_stderr(&block)\n\t\t@stderr_handler = block\n\tend",
"def stderr; end",
"def stderr; end",
"def stderr; end",
"def stderr; end",
"def re_stderr\n ... | [
"0.7732858",
"0.74955904",
"0.68360704",
"0.6723323",
"0.6640842",
"0.6640842",
"0.6640842",
"0.6640842",
"0.6587844",
"0.65369505",
"0.6440865",
"0.6416582",
"0.6384092",
"0.6344954",
"0.6329688",
"0.6101708",
"0.60599136",
"0.60304916",
"0.6018663",
"0.6005847",
"0.59973055... | 0.69669914 | 2 |
Called whenever a complete response line of a script has been read and the contained command was parsed successfully. | def process_command(cmd)
cmd.process(self)
result = cmd.result()
@@log.debug {"cmd: #{cmd.class.name}, check_id: #{cmd.check.id}"}
(@check_results[result.check] = [result] unless
@check_results[result.check]) or
@check_results[result.check] << result
process_check_finished_command(cmd) if cmd.class == CheckFinishedCommand
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpret_exit(command)\n @finished = true\n end",
"def on_complete(env)\n if respond_to? :parse\n env[:body] = parse(env[:body]) unless [204,304].index env[:status]\n end\n end",
"def listen_for_tagged_response(command)\n command.listen do |response|\n i... | [
"0.6110633",
"0.58953136",
"0.58776754",
"0.56706125",
"0.565753",
"0.5655606",
"0.55687696",
"0.5491655",
"0.54783803",
"0.54673445",
"0.5467192",
"0.545154",
"0.54175454",
"0.53958696",
"0.5388014",
"0.5372863",
"0.53395325",
"0.53262776",
"0.5301124",
"0.528158",
"0.527776... | 0.0 | -1 |
Called whenever a CheckFinishedCommand was encountered. | def process_check_finished_command(cmd)
#calculate progress percentage
check = cmd.result().check
@done_time_units += check.duration
@@log.info {"Check #{check.id} finished, progress is %.2f%" % [progress() * 100]}
@rule_results[check.id] = RuleResult.new(check, @check_results[check])
@check_completed_handler.call(@rule_results[check.id]) unless @check_completed_handler.nil?
#check if benchmark is finished
@finished_handler.call(@benchmark, @rule_results) if @finished_handler && @done_time_units == @total_time_units
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_check_completed(&block)\n @check_completed_handler = block\n end",
"def check_completed\n\t\tend",
"def finalize\n @checks.each {|check| check.finalize(self) }\n end",
"def done(command)\n end",
"def done\n @end_check.call if @end_check\n EM.cancel_timer(@timeout)\n EM.stop\n ... | [
"0.67140394",
"0.6221289",
"0.61990756",
"0.6140887",
"0.6135146",
"0.605641",
"0.5857513",
"0.58567894",
"0.5791028",
"0.5773192",
"0.5755967",
"0.5750167",
"0.571522",
"0.569279",
"0.56927675",
"0.5692209",
"0.56824315",
"0.5636856",
"0.5635345",
"0.5608834",
"0.5599333",
... | 0.70855105 | 0 |
Called whenever unknown output (that does not fit the specification, i.e. does not start with %%) is encountered on stdout. | def process_unknown_output(line)
@@log.warn {"Unexpected output line on stdout: '#{line}'. Verify that the scripts are not broken."}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expect_no_output(output)\n if output.respond_to?(:~)\n assert_matching_output('^((?!#{output}).)*$', all_output)\n else\n assert_no_partial_output(output, all_output)\n end\n end",
"def print_bad( str = '' )\n push_to_output_buffer( bad: str )\n end",
"def after_re... | [
"0.6222457",
"0.60838854",
"0.59840846",
"0.5953857",
"0.58812577",
"0.5798726",
"0.5779327",
"0.5725049",
"0.5708544",
"0.56777656",
"0.5662791",
"0.55946285",
"0.55684125",
"0.5545036",
"0.5545036",
"0.5545036",
"0.5545036",
"0.5545036",
"0.5545036",
"0.5535103",
"0.5534505... | 0.7419308 | 0 |
Called whenever an unknown check id was encountered. | def process_unknown_check_id(line, check_id_string)
raise ParseException, "Script replied with unknown check id #{$1}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ID_missing\n\t\t$log.warn \"TODO ID missing\"\n\tend",
"def on_unknown(&blk)\n @on_unknown = blk\n end",
"def process_unknown_reply_command(line, check, severity, cmd_string)\n @@log.warn {\"Command not found: '#{line}'.\"}\n end",
"def check!\n super()\n \n... | [
"0.64591885",
"0.5765597",
"0.5596036",
"0.5583231",
"0.5575746",
"0.55584633",
"0.54051524",
"0.5388319",
"0.5306597",
"0.5282998",
"0.5269713",
"0.52521354",
"0.52521354",
"0.52367973",
"0.5228834",
"0.5177664",
"0.5155566",
"0.51360965",
"0.5124274",
"0.51216763",
"0.51193... | 0.7317509 | 0 |
Called whenever an unknown reply command was encountered. | def process_unknown_reply_command(line, check, severity, cmd_string)
@@log.warn {"Command not found: '#{line}'."}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unrecognizedResponse( text )\n print \"Unrecognized Response : #{text}\"\n #say(\"For help, simply type: help\")\n end",
"def unknown_cmd(cmd)\n\t\t\t\t\"Unknown command: #{cmd}\"\n\t\t\tend",
"def abort_on_bad_reply(reply)\n if reply != 'ready'\n $LOG.error \"Illegal reply from ready comm... | [
"0.67032635",
"0.6642121",
"0.65788466",
"0.6564536",
"0.6428762",
"0.6275439",
"0.6104229",
"0.6079089",
"0.6039239",
"0.6005085",
"0.59791666",
"0.59428227",
"0.59416384",
"0.5887419",
"0.58562475",
"0.57624835",
"0.57464755",
"0.5745183",
"0.57293606",
"0.5718705",
"0.5694... | 0.75515413 | 0 |
Set a handler that is called whenever a check has completed. block The given block is supposed to accept one argument, that is a RuleResult instance of the justfinished check. | def on_check_completed(&block)
@check_completed_handler = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_finished(&block)\n @finished_handler = block\n end",
"def on_complete( &block )\n fail 'Block is mandatory!' if !block_given?\n @on_complete_blocks << block\n self\n end",
"def on_complete(&block)\n @handlers[:complete] = Array(@handlers[:complete]).compact + [block]\n ... | [
"0.6875737",
"0.6748816",
"0.6617961",
"0.65834767",
"0.6569107",
"0.6486009",
"0.63791203",
"0.6369021",
"0.6326393",
"0.6295573",
"0.61921406",
"0.6152267",
"0.60405374",
"0.59675395",
"0.5962336",
"0.59457487",
"0.59345335",
"0.59177434",
"0.5906686",
"0.59017164",
"0.5900... | 0.7610945 | 0 |
Set a handler that is called when the benchmark has completed. block The given block is supposed to accept two arguments, the first being the benchmark object, and the second an Array of RuleResult objects, one for each check completed. | def on_finished(&block)
@finished_handler = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_check_completed(&block)\n @check_completed_handler = block\n end",
"def after_run(&block)\n @after_run_block = block\n end",
"def on_finish &block\r\n @finish_block = block\r\n end",
"def on_test_result(&block)\n raise ArgumentError.new('must provide a block') unless block_g... | [
"0.64836514",
"0.63754183",
"0.6356524",
"0.6324774",
"0.6315357",
"0.6225201",
"0.61797535",
"0.6167392",
"0.61022276",
"0.6090156",
"0.60855323",
"0.60832185",
"0.60774916",
"0.6070461",
"0.60311604",
"0.59961486",
"0.59961486",
"0.5995707",
"0.5977006",
"0.5950448",
"0.590... | 0.65764725 | 0 |
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge [by myself, with: ]. 0. total Pseudocode make sure all pseudocode is commented out! Input: Input is a series of numbers Output: Sum of all the numbers Steps to solve the problem. Iterate through the array and add each number together until you are through the entire array. 1. total initial solution | def total(nums)
total = 0
nums.each do |i|
total += i
end
return total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_of_sums(array)\n sequence_total = 0\n sum = 0\n array.each do |n|\n sequence_total += n\n sum += sequence_total\n end\n sum\nend",
"def sum_numbers(numbers)\r\n # Your code here\r\n #initalize the sum\r\n sum = 0\r\n #iterate through every element of a given array\r\n numbers.each do |num... | [
"0.7175739",
"0.7052937",
"0.70461667",
"0.70308024",
"0.6961699",
"0.6941014",
"0.68872434",
"0.68798524",
"0.6863578",
"0.67859876",
"0.67826474",
"0.6777683",
"0.6724069",
"0.66760266",
"0.6668832",
"0.6657926",
"0.665545",
"0.66503704",
"0.6647705",
"0.6641013",
"0.662602... | 0.0 | -1 |
3. total refactored solution 4. sentence_maker pseudocode make sure all pseudocode is commented out! Input:array of individual strings Output: One grammatically correct string Steps to solve the problem. iterate through the array. Capitalize the first word. Add each word to the string with a space in between, and end the sentence with a period. 5. sentence_maker initial solution | def sentence_maker(words)
sentence = ''
i = 0
while i < words.length
if i == 0
sentence = sentence + words[i].to_s.capitalize + ' '
i += 1
elsif i == (words.length - 1)
sentence = sentence + words[i].to_s + '.'
i += 1
else
sentence = sentence + words[i].to_s + ' '
i += 1
end
end
p sentence
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentence_maker(array_of_strings)\n result = \"\"\n last_word = array_of_strings.pop\n array_of_strings.each do |word|\n result += word.to_s + \" \"\n end\n result += last_word + \".\"\n return result.capitalize!\nend",
"def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,ele... | [
"0.8392356",
"0.837075",
"0.83650535",
"0.83508086",
"0.83137023",
"0.8283128",
"0.8267853",
"0.82602155",
"0.8247509",
"0.823408",
"0.82159954",
"0.8215499",
"0.8211054",
"0.82000136",
"0.8198588",
"0.81984586",
"0.8185246",
"0.81827635",
"0.81558704",
"0.81558704",
"0.81558... | 0.7674496 | 75 |
Initialize pipe server === Parameters options[:pipe_name](String):: Name of pipe to connect to (required) === Block Given block gets called back for each request It should take two arguments: First argument is either :is_ready or :respond calls with :is_ready should return a boolean value set to true if there is a pending command calls with :respond should return the pending command Second argument contains the request data (only set with :respond) | def initialize(options = {}, &callback)
raise ArgumentError, "Missing required :pipe_name" unless @pipe_name = options[:pipe_name]
@callback = callback
@pipe_eventable = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n flags = ::Win32::Pipe::ACCESS_DUPLEX | ::Win32::Pipe::OVERLAPPED\n pipe = PipeServer.new(@pipe_name, 0, flags)\n res = true\n begin\n options = {:target => self,\n :request_handler => :request_handler,\n :request_query => :... | [
"0.72706616",
"0.66812456",
"0.6266908",
"0.6251831",
"0.5803167",
"0.57596797",
"0.56646085",
"0.5579752",
"0.5574804",
"0.5487225",
"0.5468949",
"0.5452877",
"0.54136825",
"0.5408296",
"0.5405408",
"0.53622913",
"0.5329538",
"0.5264342",
"0.52558315",
"0.5253279",
"0.523633... | 0.61887395 | 4 |
Starts the pipe server by creating an asynchronous named pipe. Returns control to the caller after adding the pipe to the event machine. === Return true:: If server was successfully started false:: Otherwise | def start
flags = ::Win32::Pipe::ACCESS_DUPLEX | ::Win32::Pipe::OVERLAPPED
pipe = PipeServer.new(@pipe_name, 0, flags)
res = true
begin
options = {:target => self,
:request_handler => :request_handler,
:request_query => :request_query,
:pipe => pipe}
@pipe_eventable = EM.watch(pipe, PipeServerHandler, options)
@pipe_eventable.notify_readable = true
rescue Exception => e
pipe.close rescue nil
RightScale::Log.error("Failed to start pipe server", e, :trace)
res = false
end
res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_pipe_server!\n _log :prepare_pipe_server!\n unless ::File.exist? file\n system(cmd = \"mkfifo #{file.inspect}\") or raise \"cannot run #{cmd.inspect}\"\n end\n end",
"def spawn_server\n\t\tself.reader, child_writer = IO.pipe\n\t\tchild_reader, self.writer = IO.pipe\... | [
"0.64551103",
"0.6016493",
"0.5940744",
"0.55280495",
"0.55242336",
"0.5466357",
"0.54264486",
"0.5417218",
"0.5399181",
"0.537258",
"0.5345837",
"0.53335893",
"0.52962637",
"0.5281875",
"0.52709806",
"0.52696866",
"0.5265459",
"0.5263788",
"0.5252339",
"0.5247617",
"0.524260... | 0.80235857 | 0 |
Stops the pipe server by detaching the eventable from the event machine. === Return true:: Always return true | def stop
@pipe_eventable.force_detach if @pipe_eventable
@pipe_eventable = nil
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop\n run_command(@stop_command)\n\n @in_stream.close\n\n maybe_thread = @thread.join(15)\n\n # The thread did not exit!\n return false if maybe_thread.nil?\n\n @pid = nil\n true\n end",
"def stop_server\n unless @servsocket.closed?\n detach\n ... | [
"0.64812905",
"0.64592403",
"0.6433648",
"0.63491774",
"0.6267295",
"0.61340237",
"0.6093545",
"0.60644627",
"0.6028331",
"0.5993647",
"0.598202",
"0.59787494",
"0.59787494",
"0.5956739",
"0.59293693",
"0.5893284",
"0.58794695",
"0.5877249",
"0.5877249",
"0.5877249",
"0.58772... | 0.852945 | 0 |
Ready to respond if the next action queue is empty, otherwise continue blocking client. === Parameters request_data(String):: request data === Returns result(Boolean):: true if response is ready | def request_query(request_data)
return @callback.call(:is_ready, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_next_request\n return if request_queue.empty?\n raise \"cannot make a request while in #{@state.inspect} state\" unless @state == :idle\n request, @in_flight = request_queue.shift\n send_data([request.size, request].pack('NA*'))\n @recv_buf = ''.force_encoding('BINARY')\... | [
"0.6164464",
"0.6076284",
"0.5903242",
"0.58992404",
"0.5875092",
"0.5869088",
"0.5827168",
"0.5817553",
"0.57762474",
"0.5767285",
"0.5748035",
"0.57124275",
"0.5704906",
"0.5699298",
"0.5684757",
"0.56536734",
"0.56533897",
"0.5609314",
"0.5603897",
"0.55924714",
"0.558772"... | 0.6530204 | 0 |
Handler for next action requests. Expects complete requests and responses to appear serialized as JSON on individual lines (i.e. delimited by newlines). note that JSON text escapes newline characters within string values and normally only includes whitespace for human readability. === Parameters request_data(String):: Request data === Returns response(String):: Request response | def request_handler(request_data)
# assume request_data is a single line with a possible newline trailing.
request = JSON.load(request_data.chomp)
if 2 == request.keys.size && request.has_key?(LAST_EXIT_CODE_KEY) && request.has_key?(LAST_ERROR_MESSAGE_KEY)
# pop the next action from the queue.
command = @callback.call(:respond, request)
return JSON.dump(NEXT_ACTION_KEY => command) + "\n";
end
raise ArgumentError, "Invalid request"
rescue Exception => e
return JSON.dump(:Error => "#{e.class}: #{e.message}", :Detail => e.backtrace.join("\n")) + "\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_request\n payload = @req.POST[\"payload\"]\n\n return rude_comment if payload.nil?\n\n puts payload unless $DEPLOYED # remove me!\n\n payload = JSON.parse(payload)\n# render_payload_to_hipchat(payload)\n @res.write THANK_YOU_COMMENT\n end",
"def handle_data(io, data)\n... | [
"0.58996034",
"0.57704365",
"0.5738895",
"0.5568037",
"0.5564336",
"0.550003",
"0.54905605",
"0.5456053",
"0.54340935",
"0.53813976",
"0.5373734",
"0.53543687",
"0.53253263",
"0.5319335",
"0.53137267",
"0.5297406",
"0.5280618",
"0.52646416",
"0.5218929",
"0.5200943",
"0.52002... | 0.7770117 | 0 |
Count the files (excluding dotfiles). | def files
@files = []
Find.find(@path) do |path|
if File.directory? path
if File.basename(path)[0] == ?.
Find.prune # don't look any further into this directory.
else
next
end
else
@files << path
end
end
@files.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CountFiles\n\t\tchildrenFiles = []\n\t\tcwd = File.dirname(__FILE__) # get parent directory from our script\n\t\tchildrenFiles = Dir.glob(cwd + '/**/*').select{ |e| File.file? e }\n\n\t\tchildrenFiles.each do |file|\n\t\t\tif File.extname(file).empty?\n\t\t\t\t@count += 1\n\t\t\t\t@files.push(file)\n\t\t\tend\... | [
"0.8418742",
"0.82622457",
"0.79766256",
"0.7683792",
"0.76683927",
"0.76581067",
"0.76497155",
"0.752279",
"0.74616313",
"0.7389206",
"0.7271898",
"0.72710097",
"0.7270138",
"0.7255475",
"0.71219593",
"0.708653",
"0.7042895",
"0.7037842",
"0.7037842",
"0.702064",
"0.692682",... | 0.6484297 | 40 |
Count the bytes. This wont be converted all the time. | def bytes
@bytes = 0
@files.each do |file|
@bytes += File.new("#{file}").size
end
@bytes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_bytes\n return @num_bytes\n end",
"def byte_size(); @data.byte_size + 4; end",
"def byte_size()\n if @record and RECORD_INFO[@record.type].size > 0 then\n RECORD_INFO[@record.type].size * @value.length\n el... | [
"0.7883742",
"0.7517564",
"0.740578",
"0.7355979",
"0.73155695",
"0.7164676",
"0.71642303",
"0.71642303",
"0.7126056",
"0.7108155",
"0.7043619",
"0.70149213",
"0.7008688",
"0.69555634",
"0.6945083",
"0.692349",
"0.692349",
"0.68619174",
"0.6830708",
"0.6808973",
"0.679572",
... | 0.6818326 | 19 |
Flattens self in place as flatten. If no changes are made, returns nil, otherwise self. Adapted from rubinius' | def flatten_with_optional_argument!(level=-1)
level = Backports.coerce_to_int(level)
return flatten_without_optional_argument! if level < 0
out = []
ret = recursively_flatten_finite(self, out, level)
replace(out) if ret
ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten!\n self.replace(flatten)\n end",
"def flatten\n self.class.new.flatten_merge(self)\n end",
"def flatten\n self.class.new.flatten_merge(self)\n end",
"def flatten!\n nil\n end",
"def flatten!() end",
"def my_flatten!\n self.replace(my_flatten)\n end",
"def flatten() end",... | [
"0.786189",
"0.7712196",
"0.7712196",
"0.74510145",
"0.7382781",
"0.73121434",
"0.7289986",
"0.728871",
"0.7117395",
"0.6994519",
"0.6924575",
"0.6766238",
"0.6689898",
"0.66696334",
"0.66499597",
"0.66413665",
"0.6621404",
"0.66148067",
"0.6612795",
"0.6611957",
"0.66102856"... | 0.6285318 | 32 |
Helper to recurse through flattening Adapted from rubinius'; recursion guards are not needed because level is finite | def recursively_flatten_finite(array, out, level)
ret = nil
if level <= 0
out.concat(array)
else
array.each do |o|
if ary = Backports.is_array?(o)
recursively_flatten_finite(ary, out, level - 1)
ret = self
else
out << o
end
end
end
ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_controlled_flatten(level = nil)\n flattened = []\n\n self.each do |ele|\n if ele.is_a?(Array) && level != 0\n flattened += (level.nil? ? ele.my_controlled_flatten : ele.my_controlled_flatten(level - 1))\n else\n flattened << ele\n end\n end\n\n flattened\n end",
"... | [
"0.7458064",
"0.7457945",
"0.7239421",
"0.705624",
"0.7037995",
"0.6807385",
"0.6807385",
"0.6805337",
"0.6789537",
"0.6768442",
"0.6610994",
"0.66093296",
"0.65411764",
"0.6525697",
"0.64957213",
"0.63556284",
"0.63021183",
"0.62627584",
"0.62613887",
"0.62388664",
"0.623886... | 0.71421987 | 4 |
Using :REQUEST_URI includes query string | def call new_env
old = new_env['REQUEST_URI']
new = new_env['REQUEST_URI'].gsub(DOTS_AND_SLASHES, '/'.freeze).gsub(DOTS, '.'.freeze)
if new != old
DA99.redirect new, 301
else
@app.call new_env
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_string\n @env['QUERY_STRING'].present? ? @env['QUERY_STRING'] : (@env['REQUEST_URI'].split('?', 2)[1] || '')\n end",
"def get_query_string\n qs = @req.env['QUERY_STRING']\n # Lighty's fcgi-bindings use its 404 handler and it doesn't provide QUERY_STRING\n if qs.blank?... | [
"0.7494905",
"0.7220029",
"0.70632565",
"0.6666053",
"0.6557989",
"0.65236455",
"0.6520755",
"0.63555264",
"0.6341342",
"0.6330364",
"0.6313633",
"0.6309711",
"0.62531793",
"0.6242024",
"0.615233",
"0.6082594",
"0.60798955",
"0.6012728",
"0.60032475",
"0.6003214",
"0.60013187... | 0.5859043 | 31 |
Prueba para generargrafica def grafico(format) graph = Graph(%w[a b c d e]) graph.series [1,2,3,4,5], "foo" graph.series [11,22,70,2,19], "bar" return graph end | def listado
#@lista = Asignacion.listado_array
@lista = Campo.find(:all, :include => [:area => [:contrato => [:empresa]]], :conditions => {:codigo => ""}) #
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_graph\n end",
"def realizar_grafico_gas()\n @tipo = \"gas\"\n data = ParteDiario.produccion_mensual_gas(@fecha)\n g = self.init_graph(\"Producción de Gas en #{I18n.l(@fecha, :format => \"%B %Y\")}\")\n fecha_ini = @fecha.beginning_of_month\n fecha_fin = @fecha.end_of_month\n dia... | [
"0.64499384",
"0.63551694",
"0.6315204",
"0.6300356",
"0.598575",
"0.5877948",
"0.58670676",
"0.58077055",
"0.5785057",
"0.57087094",
"0.56782764",
"0.56778634",
"0.5590581",
"0.5586891",
"0.5541206",
"0.55254596",
"0.5517805",
"0.551299",
"0.5507737",
"0.54924667",
"0.546509... | 0.0 | -1 |
GET /pruebas/1 GET /pruebas/1.xml | def show
@prueba = Prueba.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @prueba }
format.js # { render :xml => @prueba, render :layout => false }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @parametro = Parametro.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @parametro }\n end\n end",
"def show\n @parametro = Parametro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n... | [
"0.6590973",
"0.6588595",
"0.65456223",
"0.6544379",
"0.6521946",
"0.6508811",
"0.6475086",
"0.64566386",
"0.6450411",
"0.6439414",
"0.6438243",
"0.6431648",
"0.64254653",
"0.64234763",
"0.64160734",
"0.64019376",
"0.64013726",
"0.6399302",
"0.63720626",
"0.6364891",
"0.63495... | 0.0 | -1 |
GET /pruebas/new GET /pruebas/new.xml | def new
@prueba = Prueba.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @prueba }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @proceso = Proceso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @proceso }\n end\n end",
"def new\n @pessoa = Pessoa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pessoa }\n ... | [
"0.7698743",
"0.76103073",
"0.76103073",
"0.7589086",
"0.7588488",
"0.7553127",
"0.75488496",
"0.7523295",
"0.7498921",
"0.74841934",
"0.74781865",
"0.74544674",
"0.74501956",
"0.7434663",
"0.7430861",
"0.7428242",
"0.7425078",
"0.74170196",
"0.74085134",
"0.7407569",
"0.7402... | 0.7715164 | 0 |
POST /pruebas POST /pruebas.xml | def create
@prueba = Prueba.new(params[:prueba])
respond_to do |format|
if @prueba.save
flash[:notice] = 'Prueba was successfully created.'
format.html { redirect_to(@prueba) }
format.xml { render :xml => @prueba, :status => :created, :location => @prueba }
else
format.html { render :action => "new" }
format.xml { render :xml => @prueba.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"d... | [
"0.65994185",
"0.6504881",
"0.63779986",
"0.6323995",
"0.6107935",
"0.6025093",
"0.60160106",
"0.5940838",
"0.5891894",
"0.58835375",
"0.58355147",
"0.5817296",
"0.5810805",
"0.5803866",
"0.5793822",
"0.57883054",
"0.57811135",
"0.57572216",
"0.57460284",
"0.57393384",
"0.573... | 0.6 | 7 |
PUT /pruebas/1 PUT /pruebas/1.xml | def update
@prueba = Prueba.find(params[:id])
respond_to do |format|
if @prueba.update_attributes(params[:prueba])
flash[:notice] = 'Prueba was successfully updated.'
format.html { redirect_to(@prueba) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @prueba.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def res... | [
"0.67008746",
"0.66303796",
"0.62807894",
"0.61078656",
"0.6099457",
"0.6010254",
"0.5958908",
"0.5877804",
"0.5870939",
"0.5865865",
"0.58637595",
"0.584684",
"0.5831544",
"0.5825246",
"0.58242583",
"0.58143836",
"0.58097994",
"0.58065253",
"0.57992667",
"0.57988226",
"0.578... | 0.5830843 | 13 |
DELETE /pruebas/1 DELETE /pruebas/1.xml | def destroy
@prueba = Prueba.find(params[:id])
@prueba.destroy
respond_to do |format|
format.html { redirect_to(pruebas_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete()\n response = send_post_request(@xml_api_del... | [
"0.6820414",
"0.68096876",
"0.6800665",
"0.6782463",
"0.6743761",
"0.6737073",
"0.6731767",
"0.672669",
"0.67203796",
"0.671943",
"0.67189497",
"0.67164403",
"0.6715717",
"0.6707961",
"0.66773605",
"0.6666298",
"0.66616905",
"0.6655484",
"0.6645146",
"0.66425395",
"0.6632552"... | 0.6791116 | 3 |
if the current user owns this plant, then allow edit page to render otherwise, throw error and do not render page | def edit
# grab garden's id and set it equal to this_garden
@this_garden = @garden.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n @place = Place.find(params[:id])\n\n if @place.user != current_user\n return render text: 'Not Allowed', status: :forbidden\n end\n end",
"def edit\n require_user\n end",
"def view_edit\n\t\trequest_user(params[:id])\n\t\ttarget_user = @user\n\t\tif current_user.id != target_user.... | [
"0.73114884",
"0.73007125",
"0.72806424",
"0.71731484",
"0.7135878",
"0.7130344",
"0.7078685",
"0.70405436",
"0.70327824",
"0.69967103",
"0.69801587",
"0.6972694",
"0.6972146",
"0.6929407",
"0.6901032",
"0.68992627",
"0.6897831",
"0.6883677",
"0.6877566",
"0.6877215",
"0.6874... | 0.0 | -1 |
Encode a string for use in the hiearchical part of an URL | def path_encode(path)
Addressable::URI.escape(path.encode(Encoding::UTF_8))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_encode(string) \r\n encoded_string = ''\r\n string.each_char do |char|\r\n char = (\"%%%02X\" % char.ord) if char.match(/[A-Za-z0-9]/) == nil\r\n encoded_string << char\r\n end\r\n return encoded_string\r\n end",
"def url_encode(string) \r\n encoded_string = ''\r\n string.each... | [
"0.81301135",
"0.81301135",
"0.8057654",
"0.8035598",
"0.7925443",
"0.78617686",
"0.7661116",
"0.7510625",
"0.7498583",
"0.7437869",
"0.7418544",
"0.7332518",
"0.7297094",
"0.7282284",
"0.7263719",
"0.72438824",
"0.722558",
"0.7091865",
"0.70509225",
"0.7050698",
"0.7025167",... | 0.7186565 | 17 |
Method pour ma page contact | def contact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contactus\r\n end",
"def contactus\n end",
"def contact\n\n end",
"def contact\n\n end",
"def contact \n\n end",
"def contact; end",
"def contacts\r\n\r\n end",
"def contact\n @title = \"contact\"\n end",
"def contact\n # STUB\n end",
"def contact\n\t\t@contact\n\tend",
"def co... | [
"0.79826427",
"0.7722118",
"0.75517446",
"0.75517446",
"0.73635113",
"0.7309826",
"0.6936979",
"0.6892353",
"0.6888302",
"0.6744418",
"0.6744418",
"0.66987216",
"0.6612104",
"0.6582481",
"0.654406",
"0.651951",
"0.65026367",
"0.65024054",
"0.64170754",
"0.6386166",
"0.6375733... | 0.7661102 | 15 |
messages sent: ratio > self diameter > wheel wheel is an external (i.e. not 'self') object | def gear_inches
# ... a few lines of scary math
foo = some_intermediate_result * wheel.diameter
# ... more lines of scary math
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gear_inches\n ratio * wheel.diameter\n # otherwise written as: self.send('ratio') * wheel.send('diameter') \"send ratio message to self. send diameter message to wheel' \nend",
"def weight\n decay_conversation # fade the conversation since the last time we spoke\n incoming_weight + outgoing_weight\... | [
"0.7190339",
"0.5343995",
"0.5312463",
"0.5277525",
"0.5276805",
"0.51964474",
"0.5180273",
"0.50880337",
"0.50801617",
"0.50801617",
"0.5050524",
"0.5050524",
"0.5029268",
"0.5008619",
"0.50085527",
"0.49974743",
"0.49962634",
"0.49962634",
"0.49003544",
"0.49003544",
"0.490... | 0.4436901 | 98 |
relies on Gear responding to ``wheel`` and on ``wheel`` responding to ``diameter``. A random line deep in ``gear_inches`` shouldn't have this dependency. You can pull out ``diameter`` into a method though: | def gear_inches
#... a few lines of scary math
foo = some_intermediate_result * diameter
#... more lines of scary math
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diameter(wheel)\n wheel.rim + (wheel.tire * 2)\nend",
"def diameter(wheel)\n wheel.rim + (wheel.tire * 2)\nend",
"def diameter(wheel)\n wheel.rim + (wheel.tire * 2)\n end",
"def diameter (wheel)\n wheel.rim + (wheel.tire * 2)\n end",
"def gear_inches\n ratio * wheel.diameter\n end",
"de... | [
"0.67670274",
"0.67670274",
"0.66887945",
"0.66800797",
"0.659575",
"0.659575",
"0.659575",
"0.65868384",
"0.6581475",
"0.6532813",
"0.65072936",
"0.6487571",
"0.62813807",
"0.61443174",
"0.60880375",
"0.60880375",
"0.6039399",
"0.6017154",
"0.594587",
"0.59143186",
"0.591431... | 0.52010167 | 48 |
area of rightangled spherical triangle with legs l1,l2 | def sterad_triangle_rangled(l1,l2)
beta=acot(sin(l1)/tan(l2))
gamma=acot(sin(l2)/tan(l1))
beta+gamma-PI/2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length\n Math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))\n end",
"def area\r\n return (( (@p1.x*(@p2.y - @p3.y)) + (@p2.x*(@p3.y - @p1.y)) + (@p3.x*(@p1.y - @p2.y)) )/2.0).abs\r\n end",
"def area_of_right_angled_triangle(base,height)\n\treturn ((base.to_f * height.to_f)/2)\t\nend",
"def area\n ... | [
"0.6639093",
"0.6580014",
"0.6538692",
"0.65385026",
"0.65069884",
"0.6464502",
"0.63564885",
"0.6344242",
"0.63203543",
"0.6300216",
"0.6217458",
"0.61359113",
"0.611132",
"0.60955936",
"0.6081933",
"0.60765004",
"0.60742754",
"0.60378826",
"0.6033498",
"0.6024975",
"0.60080... | 0.6885608 | 0 |
Returns a version if the package is installed or nil if it is not. | def installed_version
logger.trace("#{new_resource} checking package version")
current_installed_version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def installed_version\n res = Chef::Resource::Package.new('chefdk', run_context)\n prov = Chef::Provider::Package::Dpkg.new(res, run_context)\n ver = prov.load_current_resource.version.first\n return false if ver.nil?\n ver = ver.split('-').first\n ver == package_metadata[... | [
"0.75573564",
"0.75407237",
"0.74860585",
"0.7082901",
"0.69511867",
"0.69171774",
"0.68633497",
"0.67873013",
"0.67646736",
"0.6716293",
"0.6700933",
"0.667004",
"0.6662957",
"0.6621772",
"0.66131735",
"0.6599108",
"0.64610565",
"0.6444819",
"0.644093",
"0.6418541",
"0.64112... | 0.73848104 | 3 |
Pour mettre dans le rescue des scripts (cf. manuel) | def error e
log("ERREUR: #{e.message}")
log("BACKTRACE ERREUR: #{e.backtrace.join("\n")}")
self << {error: e.message, backtrace: e.backtrace}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def catch_exceptions; end",
"def exceptions; end",
"def script_error(path, error); end",
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def fatal; end",
"def run_failed; end",
"def exceptions\n end",
"def exit_exception; end",
... | [
"0.69483703",
"0.67506504",
"0.66861576",
"0.6623031",
"0.64892274",
"0.64702064",
"0.64493513",
"0.63347024",
"0.63323724",
"0.63242507",
"0.63242507",
"0.63242507",
"0.63242507",
"0.63242507",
"0.62801975",
"0.6277879",
"0.6263464",
"0.6228222",
"0.6228102",
"0.62196916",
"... | 0.0 | -1 |
show_vm_status, given a vmname return the operational status of the vm | def show_vm_status(vmname)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...show vm name=#{vmname}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("show vm name=#{vmname}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/ Status = /)
current[:vmstatus]=line.split('=')[1].strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(vm_name)\n `VBoxManage showvminfo #{vm_name}` =~ /^State:\\s+(.*)$/ ? $1 : 'unknown'\n end",
"def get_fusion_vm_status(options)\n exists = check_fusion_vm_exists(options)\n if exists == true\n vm_list = get_running_fusion_vms(options)\n if vm_list.to_s.match(/#{options['name']}/)\n ... | [
"0.7385424",
"0.6872151",
"0.671085",
"0.6604291",
"0.6406779",
"0.63778913",
"0.6361378",
"0.6277617",
"0.6230678",
"0.62197685",
"0.61146784",
"0.6112327",
"0.6073505",
"0.60619324",
"0.6040316",
"0.60241264",
"0.60094064",
"0.5994303",
"0.5970101",
"0.5961953",
"0.5873461"... | 0.7922266 | 0 |
start_vm, given a vmname issue a start request | def start_vm(vmname)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...show vm name=#{vmname}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("start vm name=#{vmname}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(vmname, action = 'start')\n uri = @uri + \"/#{vmname}/#{action}?api-version=#{api_version}\"\n uri\n end",
"def start_virtual_machine(vm_name, cloud_service_name)\n vm = get_virtual_machine(vm_name, cloud_service_name)\n if vm\n if vm.status == 'ReadyRole'\n ... | [
"0.7623508",
"0.75745964",
"0.73229814",
"0.69571924",
"0.68713003",
"0.6819297",
"0.6808858",
"0.6713028",
"0.65990335",
"0.65887254",
"0.64648324",
"0.6455957",
"0.6374107",
"0.60550964",
"0.5939625",
"0.5906119",
"0.5825033",
"0.5696787",
"0.56705207",
"0.5602506",
"0.5591... | 0.7030295 | 3 |
stop_vm, given a vmname issue a stop request | def stop_vm(vmname)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...show vm name=#{vmname}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("stop vm name=#{vmname}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(vmname, action = 'stop')\n uri = @uri + \"/#{vmname}/#{action}?api-version=#{api_version}\"\n uri\n end",
"def shutdown_virtual_machine(vm_name, cloud_service_name)\n vm = get_virtual_machine(vm_name, cloud_service_name)\n if vm\n if ['StoppedVM','StoppedDealloc... | [
"0.8124793",
"0.71586",
"0.7123269",
"0.69770044",
"0.6948418",
"0.68810815",
"0.6878489",
"0.6870904",
"0.67801166",
"0.67615944",
"0.6656751",
"0.6642754",
"0.6612544",
"0.63410157",
"0.6325739",
"0.63045114",
"0.6172192",
"0.6167256",
"0.61023283",
"0.60806334",
"0.6052235... | 0.72931844 | 1 |
suspend_vm, given a vmname issue a suspend request | def suspend_vm(vmname)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...show vm name=#{vmname}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("suspend vm name=#{vmname}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suspend\n execute(\"controlvm\", @uuid, \"savestate\")\n end",
"def suspend\n unless exists?\n return Response.new :code => 1, :message => 'VM does not exist'\n end\n\n running_response = running?\n return running_response unless running_response.successful?\n\n un... | [
"0.7195513",
"0.7154525",
"0.68758833",
"0.66966033",
"0.6683045",
"0.66580874",
"0.65891886",
"0.6565251",
"0.62748146",
"0.6226513",
"0.6206421",
"0.6109166",
"0.60125536",
"0.59925336",
"0.5972419",
"0.5939872",
"0.59157944",
"0.58965695",
"0.5891921",
"0.582865",
"0.58229... | 0.7217651 | 0 |
resume_vm, given a vmname issue a resume request | def resume_vm(vmname)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...show vm name=#{vmname}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("resume vm name=#{vmname}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resume\n execute(:resume_vm, VmId: vm_id)\n end",
"def resume_vm\n respond_to do |format|\n logger.debug \"\\n resume? \\n \"\n result = @vm.resume_vm\n # TODO! check if really resumed\n format.html { \n flash[:notice] = result[:message].html_safe \n redirect... | [
"0.82736033",
"0.7322948",
"0.7304304",
"0.7019609",
"0.69786257",
"0.6760467",
"0.66818887",
"0.66468555",
"0.6594945",
"0.6572614",
"0.65466124",
"0.65466124",
"0.6441366",
"0.62992996",
"0.6293288",
"0.6253045",
"0.6227527",
"0.6225401",
"0.6220006",
"0.6220006",
"0.621124... | 0.7585025 | 1 |
restart_vm, given a vmname issue a restart request | def restart_vm(vmname)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...show vm name=#{vmname}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("restart vm name=#{vmname}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restart(vmname, action = 'restart')\n uri = @uri + \"/#{vmname}/#{action}?api-version=#{api_version}\"\n uri\n end",
"def restart_virtual_machine(vm_name, cloud_service_name)\n vm = get_virtual_machine(vm_name, cloud_service_name)\n if vm\n path = \"/services/hosteds... | [
"0.8255079",
"0.7781577",
"0.6798083",
"0.67550224",
"0.67239904",
"0.6616325",
"0.65610075",
"0.65316993",
"0.65093005",
"0.6456282",
"0.63136846",
"0.63058144",
"0.630409",
"0.6289159",
"0.62611204",
"0.62474674",
"0.6241697",
"0.6227462",
"0.61697346",
"0.6155714",
"0.6094... | 0.75441766 | 2 |
kill_vm, given a vmname issue a kill request | def kill_vm(vmname)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...show vm name=#{vmname}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("kill vm name=#{vmname}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(vmname, action = 'stop')\n uri = @uri + \"/#{vmname}/#{action}?api-version=#{api_version}\"\n uri\n end",
"def stop_kvm(name)\n unless(system(\"virsh destroy #{name}\"))\n raise \"Failed to stop node: #{name}\"\n end\nend",
"def kill\n send(:kill)\n end",
"def delete_... | [
"0.64809036",
"0.64779955",
"0.6326229",
"0.6210181",
"0.61776525",
"0.6168055",
"0.6134325",
"0.6130764",
"0.60822105",
"0.6001033",
"0.588609",
"0.5885593",
"0.5866139",
"0.58626163",
"0.5831058",
"0.5816414",
"0.5796483",
"0.5790788",
"0.57855725",
"0.5779751",
"0.5779722"... | 0.7101539 | 0 |
list_vm, display all vm's | def list_vm(vmname)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
if not vmname
Chef::Log.debug("#{conn_opts[:host]}...list vm")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("list vm")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/ id:/)
puts line.split(':')[2].strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
else
Chef::Log.debug("#{conn_opts[:host]}...show vm name=#{vmname}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("show vm name=#{vmname}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
elsif line.match(/ /)
puts line
end
end
end
return current
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vboxmanage_list_vms\n vms = Mash.new\n if vbox_host?\n so_cmd = \"VBoxManage list --sorted vms\"\n logger.trace(so_cmd)\n so = shell_out(so_cmd)\n\n if so.exitstatus == 0\n # parse the output\n so.stdout.lines.each do |line|\n case line\n when /^\"(\\S*... | [
"0.75395256",
"0.7267834",
"0.7202923",
"0.70640266",
"0.7034999",
"0.6935802",
"0.68703806",
"0.68699396",
"0.6866923",
"0.6838651",
"0.6825735",
"0.6804323",
"0.6728526",
"0.67280614",
"0.66776943",
"0.66466916",
"0.6624265",
"0.6586437",
"0.65718687",
"0.6565662",
"0.65628... | 0.6521959 | 23 |
list_serverpool, display all server pool's | def list_serverpool(pool)
current = {:errormsg => "", :status => "", :time => "", :poolstatus => ""}
conn_opts=get_cli_connection
if not pool
Chef::Log.debug("#{conn_opts[:host]}...list serverpool")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("list serverpool")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/ id:/)
puts line.split(':')[2].strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
else
Chef::Log.debug("#{conn_opts[:host]}...show serverpool name=#{pool}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("show serverpool name=#{pool}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
elsif line.match(/ /)
puts line
end
end
end
return current
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_pools\n handle_action_exceptions(__method__) do\n cmd_line = ['listpools']\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end",
"def list_server_pools(opts = {})\n data, _status_code, _headers = list_server_pools_with_http_info... | [
"0.7276005",
"0.71998584",
"0.6932435",
"0.68644",
"0.68644",
"0.6798639",
"0.6706525",
"0.65496606",
"0.6518983",
"0.6495636",
"0.6437786",
"0.63493705",
"0.63198507",
"0.6183825",
"0.6112153",
"0.611006",
"0.606969",
"0.6025849",
"0.60175276",
"0.5991437",
"0.5977154",
"0... | 0.68721044 | 3 |
remove_vdisk, delete vdisk diskmapping | def remove_vdisk(vdiskid)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...delete VmDiskMapping id=#{vdiskid}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("delete VmDiskMapping id=#{vdiskid}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_virtual_machine_disk(disk_name)\n Loggerx.info \"Deleting Disk \\\"#{disk_name}\\\". \"\n path = \"/services/disks/#{disk_name}\"\n request = ManagementHttpRequest.new(:delete, path)\n request.call\n end",
"def delete_from_disk; end",
"def removeDiskByFile(backingFil... | [
"0.66782725",
"0.65803504",
"0.65326935",
"0.64877456",
"0.64546585",
"0.64455295",
"0.639712",
"0.63726467",
"0.6303822",
"0.62889886",
"0.6259857",
"0.62353885",
"0.6200356",
"0.61448026",
"0.6106348",
"0.60912186",
"0.6088341",
"0.60207045",
"0.5989467",
"0.5981013",
"0.59... | 0.7170692 | 0 |
edit_vm, edit VM cpu and memory | def edit_vm(vmname, memory, memorylimit, cpucount, cpucountlimit)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...edit vm name=#{vmname},#{memory},#{memorylimit},#{cpucount},#{cpucountlimit}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("edit vm name=#{vmname} memory=#{memory} memorylimit=#{memorylimit} cpucount=#{cpucount} cpucountlimit=#{cpucountlimit}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customize_vm(v)\n mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 8\n cpus = 4\n v.customize [\"modifyvm\", :id, \"--memory\", mem]\n v.customize [\"modifyvm\", :id, \"--cpus\", cpus]\nend",
"def change_vbox_vm_cpu(client_name,client_cpus)\n message = \"Setting:... | [
"0.7649945",
"0.6995787",
"0.6984173",
"0.68102217",
"0.67358285",
"0.65843666",
"0.6520696",
"0.6456978",
"0.6394078",
"0.6315861",
"0.62783486",
"0.6224423",
"0.62033343",
"0.6189491",
"0.6076558",
"0.5912086",
"0.58789617",
"0.5860363",
"0.58479923",
"0.58246064",
"0.58168... | 0.749203 | 1 |
migrate_vm, migrate VM to another server | def migrate_vm(vmname, server)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...migrate vm name=#{vmname},destServer=#{server}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("migrate vm name=#{vmname} destServer=#{server}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migrate_vm_to_host(_pool_name, _vm_name, _dest_host_name)\n\n #v1 virtualbox support is all localhost so this is an exception\n raise(\"#{self.class.name} does not implement migrate_vm_to_host\")\n end",
"def migrate_vm_to_host(_pool_name, _vm_name, _dest_host_name)\n raise(... | [
"0.7260614",
"0.7040503",
"0.69233423",
"0.6915524",
"0.68338716",
"0.6539078",
"0.6347858",
"0.62054855",
"0.6130587",
"0.61263317",
"0.61196476",
"0.6087889",
"0.6009636",
"0.5978481",
"0.5970836",
"0.59168607",
"0.5906612",
"0.58988875",
"0.58171046",
"0.5801381",
"0.58007... | 0.7596 | 0 |
add_vnic, add vnic on vm | def add_vnic(vmname, network, vnicname)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...create vnic name=#{vnicname},#{network},#{vmname}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("create vnic name=#{vnicname} network=#{network} on vm name=#{vmname}")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_nonbridged_network_to_vbox_vm(client_name,nic_name)\n message = \"Adding:\\t\\tNetwork \"+nic_name+\" to \"+client_name\n if nic_name.match(/vboxnet/)\n command = \"VBoxManage modifyvm #{client_name} --hostonlyadapter1 #{nic_name} ; VBoxManage modifyvm #{client_name} --nic1 hostonly\"\n else\n com... | [
"0.70360756",
"0.69572914",
"0.69297415",
"0.67140675",
"0.6648451",
"0.66365653",
"0.6634253",
"0.6547243",
"0.6362518",
"0.6289497",
"0.6273505",
"0.61110365",
"0.60775024",
"0.59993416",
"0.5981071",
"0.59646523",
"0.5940365",
"0.59297943",
"0.59281456",
"0.59280735",
"0.5... | 0.8113808 | 0 |
send_message, send a vm message to a vm | def send_message(vmname, key, message)
current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
conn_opts=get_cli_connection
Chef::Log.debug("#{conn_opts[:host]}...sendvmmessage vm name=#{vmname},#{key},#{message}")
Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
output = ssh.exec!("sendvmmessage vm name=#{vmname} key=#{key} message=#{message} log=no")
output.each_line do |line|
if line.match(/Status:/)
current[:status]=line.split[1].strip
elsif line.match(/Time:/)
line["Time: "]=""
current[:time]=line.strip
elsif line.match(/Error Msg:/)
line["Error Msg: "]=""
current[:errormsg]=line.strip
end
end
end
return current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_message(message); end",
"def send_message(message); end",
"def send_to_vm(command)\n socket = UNIXSocket.new(socket_file)\n socket.puts(command)\n socket.close\n end",
"def send_message(message)\n @networking.send_message(message)\n end",
"def send_message(msg); end",
"def send... | [
"0.68990844",
"0.68990844",
"0.68529683",
"0.6768067",
"0.67219454",
"0.6656693",
"0.65894586",
"0.6564428",
"0.64584166",
"0.64271015",
"0.63615316",
"0.6357262",
"0.6347533",
"0.630116",
"0.62703276",
"0.6246985",
"0.61931205",
"0.61928105",
"0.6119899",
"0.60766447",
"0.60... | 0.70758975 | 0 |
Instantiates a new node. The value is optional so that a new tree containing no value can be instantiated. | def initialize(value, hash_value = nil)
store_in_self(value, hash_value) if value
@left = EmptyNode.new
@right = EmptyNode.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_node(value)\n node = Node.new(value)\n end",
"def create_node(value)\n Node.new(value)\n end",
"def make_node(value)\n klass = class_for_value(value)\n value = RDF::Node.new if value.nil?\n node = node_cache[value] if node_cache[value]\n node ||= klass.from_uri(value,... | [
"0.8532878",
"0.8462501",
"0.71669257",
"0.705038",
"0.7019258",
"0.7013704",
"0.70037425",
"0.69995826",
"0.69861215",
"0.69474703",
"0.6891806",
"0.6856283",
"0.6853599",
"0.68307453",
"0.6794939",
"0.6792922",
"0.6790843",
"0.67797506",
"0.67616934",
"0.6738958",
"0.671668... | 0.7104193 | 3 |
For Enumerable, yields each item in the set (in hash order). | def each(&block)
left.each(&block)
yield value
right.each(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(&block)\n to_set.each(&block)\n end",
"def each_set\n \n end",
"def to_set\n require 'set' unless defined?(::Set)\n each.to_set\n end",
"def each\n @mset.each_pair do |key, group| \n group.to_a.each do |value|\n yield [key, value]\n end\n ... | [
"0.77801365",
"0.6717393",
"0.66571605",
"0.6574226",
"0.6499033",
"0.617826",
"0.6166892",
"0.60907847",
"0.6021093",
"0.59288657",
"0.59099406",
"0.5878173",
"0.582833",
"0.58223796",
"0.5811216",
"0.5799178",
"0.57988536",
"0.57577866",
"0.57431996",
"0.57264924",
"0.57232... | 0.0 | -1 |
NOTE: Also hardcoded into the run loop PLACE command. Please see below | def initialize(x,y,facing)
if (x.to_i >= 0 && x.to_i <= @@grid_x && y.to_i >= 0 && y.to_i <= @@grid_y && facing =~ /NORTH|SOUTH|EAST|WEST/) then
@x = x.to_i
@y = y.to_i
case facing
when "NORTH"
@facing = :north
when "SOUTH"
@facing = :south
when "EAST"
@facing = :east
when "WEST"
@facing = :west
end
else
raise ArgumentError
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def place(place)\n # extract position x & y\n place_options = place.gsub(\"PLACE \", \"\").split(\",\")\n place_robot([place_options[0].to_i, pl... | [
"0.5713681",
"0.5713681",
"0.5713681",
"0.5713681",
"0.5713681",
"0.5713681",
"0.5713681",
"0.5713681",
"0.5713681",
"0.5693348",
"0.5630026",
"0.5514512",
"0.54773134",
"0.53788656",
"0.5366652",
"0.535925",
"0.5333104",
"0.53276116",
"0.53147143",
"0.53051645",
"0.5300543",... | 0.0 | -1 |
Creates a new TimerIdConv which will hold objects for +timeout+ seconds. | def initialize(timeout=600)
@holder = NameTimerHolder.new(timeout)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_timeout_timer_whilst_in_state(timer_id, timeout_in)\n raise ArgumentError, 'Block required' unless block_given?\n\n timers[timer_id] << EventMachine::Timer.new(timeout_in) do\n yield\n end\n connection.unsafe_once_state_changed { clear_timers timer_id }\n end",
... | [
"0.6553527",
"0.5923149",
"0.5869781",
"0.57937413",
"0.5746316",
"0.573799",
"0.56315553",
"0.56218165",
"0.5557013",
"0.55530113",
"0.55458474",
"0.55179477",
"0.5471175",
"0.5471175",
"0.54675746",
"0.5444024",
"0.54190177",
"0.5406552",
"0.5349587",
"0.53297293",
"0.53282... | 0.6796822 | 0 |
GET /words GET /words.json | def index
@words = Word.where(:user => current_user).desc(:_id).page(params[:page])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @words = Word.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @words }\n end\n end",
"def index\n @words = Word.order(:word).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @words... | [
"0.7646058",
"0.758053",
"0.7313904",
"0.7193288",
"0.7060774",
"0.7027788",
"0.6966537",
"0.69062674",
"0.6873473",
"0.68303937",
"0.68303937",
"0.6758945",
"0.6742166",
"0.6738051",
"0.67166394",
"0.67075986",
"0.6698073",
"0.6697915",
"0.66631776",
"0.665449",
"0.66490006"... | 0.0 | -1 |
GET /words/1 GET /words/1.json | def show
check_access
@big_word = @word.hiragana if @word.hiragana and !@word.hiragana.empty?
@big_word = @word.katakana if @word.katakana and !@word.katakana.empty?
@big_word = @word.kanji if @word.kanji and !@word.kanji.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @words = Word.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @words }\n end\n end",
"def index\n @words = Word.order(:word).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @words... | [
"0.7429448",
"0.7319466",
"0.70108694",
"0.6972863",
"0.6967815",
"0.6967815",
"0.6967815",
"0.6967815",
"0.69490016",
"0.6882972",
"0.6844286",
"0.6784204",
"0.67738223",
"0.6706241",
"0.666595",
"0.66490847",
"0.66206956",
"0.66147673",
"0.6596243",
"0.65929395",
"0.6562485... | 0.0 | -1 |
POST /words POST /words.json | def create
@word = Word.new(word_params)
@word.user = current_user
respond_to do |format|
if @word.save
handle_tags
format.html { redirect_to @word, notice: 'Word was successfully created.' }
format.json { render action: 'show', status: :created, location: @word }
else
format.html { render action: 'new' }
format.json { render json: @word.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @word = Word.new(word_params)\n\n respond_to do |format|\n if @word.save\n format.html { redirect_to @word, notice: 'Word was successfully created.' }\n format.json { render :show, status: :created }\n else\n format.html { render :new }\n format.json do\n ... | [
"0.701951",
"0.6971202",
"0.6970911",
"0.6970911",
"0.69315785",
"0.69315785",
"0.69315785",
"0.6914584",
"0.6909396",
"0.6851759",
"0.68365884",
"0.6751805",
"0.6673099",
"0.6633248",
"0.6611147",
"0.6595743",
"0.65697485",
"0.6568253",
"0.6557965",
"0.65224755",
"0.648457",... | 0.6502593 | 20 |
PATCH/PUT /words/1 PATCH/PUT /words/1.json | def update
check_access
tags_before_change = @word.tags
respond_to do |format|
if @word.update(word_params)
handle_tags(tags_before_change)
format.html { redirect_to @word, notice: 'Word was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @word.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @word = Word.find(params[:id])\n\n respond_to do |format|\n\n if @word.update_attributes(params[:word])\n format.json { head :no_content }\n else\n format.json { render :json => @word.errors,\n :status => :unprocessable_entity }\n end\n... | [
"0.7473359",
"0.70335865",
"0.70335865",
"0.70335865",
"0.70335865",
"0.6884363",
"0.6868115",
"0.68399197",
"0.6775183",
"0.6774792",
"0.6758274",
"0.6703362",
"0.6703362",
"0.6703362",
"0.6703362",
"0.6703362",
"0.6688719",
"0.66033036",
"0.658778",
"0.658285",
"0.65544474"... | 0.645292 | 27 |
DELETE /words/1 DELETE /words/1.json | def destroy
check_access
@word.destroy
respond_to do |format|
format.html { redirect_to words_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @word = Word.find(params[:id])\n @word.destroy\n\n respond_to do |format|\n format.html { redirect_to words_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @word = Word.find(params[:id])\n @word.destroy\n\n respond_to do |format|\n format.h... | [
"0.7469168",
"0.7469168",
"0.7469168",
"0.7469168",
"0.7469168",
"0.7408195",
"0.72745264",
"0.7247305",
"0.71623814",
"0.71300924",
"0.71300924",
"0.71300924",
"0.71300924",
"0.71300924",
"0.71300644",
"0.7058892",
"0.7017916",
"0.70020777",
"0.68930566",
"0.6877212",
"0.686... | 0.74860764 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_word
@word = Word.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def word_params
params.require(:word).permit(:english, :french, :hiragana, :katakana, :kanji, :tags, :tags_list)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
use GPS to turn otherwise continue forward | def drive(cmd)
if @steer.include?(cmd)
@orientation = @gps.turn(cmd)
else
move
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_by_route(forward = true)\n return unless exist_train_route?\n depart_from_station\n\n train_start_speed_kmh = 5\n train_regular_speed_kmh = 60\n\n move train_start_speed_kmh\n move train_regular_speed_kmh\n move train_start_speed_kmh\n\n arrive_to_station forward\n brake\n en... | [
"0.6521563",
"0.61347",
"0.60456866",
"0.59747046",
"0.59660125",
"0.5937897",
"0.5921694",
"0.58272815",
"0.5817334",
"0.5809067",
"0.5802375",
"0.5801811",
"0.57925206",
"0.5744175",
"0.57361525",
"0.57133585",
"0.56974256",
"0.5694827",
"0.5683237",
"0.5676252",
"0.5674987... | 0.59365755 | 6 |
Adds geography type for migrations. So you can add column to a table like: create_table :locations do |t| ... t.geography :geog, type: 'LINESTRING' ... end | def geography(name, options = {})
column(name, :geography, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geometry_simplified_type(sql_type)\n case sql_type\n when /geography\\(point/i then :point\n when /geography\\(linestring/i then :line_string\n when /geography\\(polygon/i then :polygon\n when /geography\\(multipoint/i then :multi_point\n when /geography\\(multilinestr... | [
"0.7165757",
"0.6651972",
"0.6316512",
"0.61641634",
"0.6131447",
"0.60807025",
"0.60560805",
"0.60503495",
"0.6038485",
"0.60013986",
"0.5830263",
"0.57894826",
"0.5731434",
"0.570452",
"0.568239",
"0.5681567",
"0.56663483",
"0.56319326",
"0.5581478",
"0.5581476",
"0.5527782... | 0.69964933 | 1 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
if name_hash.size == 0
return nil
end
name_hash.each { |key, value|
lowest_key = key
name_hash.each { |k, v|
if v < name_hash[lowest_key]
lowest_key = k
end
}
return lowest_key
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n... | [
"0.88230467",
"0.877954",
"0.8779329",
"0.8747364",
"0.8690746",
"0.8657826",
"0.8654798",
"0.8618082",
"0.859029",
"0.8573832",
"0.85692596",
"0.8553887",
"0.8532013",
"0.8532013",
"0.8520662",
"0.8495162",
"0.8477513",
"0.8477513",
"0.846735",
"0.8451164",
"0.84508044",
"... | 0.0 | -1 |
Update volumes associated with the workset | def update_volumes(username, token, workset_name, volume_ids)
#<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
#<volumes xmlns="http://registry.htrc.i3.illinois.edu/entities/workset">
# <volume>
# <id>9999999</id>
# </volume>
# <volume>
# <id>3333333</id>
# </volume>
# </volumes>
volumes_xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
"<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">";
for id in volume_ids
volumes_xml += "<volume><id>#{id}</id></volume>"
end
volumes_xml += "</volumes>"
# curl -v --data @new_volumes.xml -X PUT \
# -H "Content-Type: application/vnd.htrc-volume+xml" \
# -H "Accept: application/vnd.htrc-volume+xml" \
# http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred
url = URI.parse("#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes")
http = Net::HTTP.new(url.host, url.port)
if Rails.env.development?
http.set_debug_output($stdout)
end
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Put.new(url.request_uri)
request["Content-Type"] = "application/vnd.htrc-volume+xml"
request.add_field("Authorization", "Bearer #{token}")
request.body = volumes_xml
response = http.request(request)
#xml = response.body
case response
when Net::HTTPUnauthorized then
raise Exceptions::SessionExpiredError.new("Session expired. Please login again")
when Net::HTTPSuccess then
# Do nothing
else
raise Exceptions::SystemError.new("Error retrieving worksets (HTTP #{response.code})")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_volume_info\n\t\t#\t\t@pool = Pool.find(self.pool_id)\n\t\t#\t\t@host = Host.find(@pool.host_id)\n\t\t#\n\t\t#\t\tconnection = ConnectionsManager.instance\n\t\t#\t\tconnection_hash = connection.get(@host.name)\n\t\t#\t\tconn = connection_hash[:conn]\n\n\t\t# get pool reference in order to get a referenc... | [
"0.65517706",
"0.64007646",
"0.60917",
"0.59644204",
"0.5922522",
"0.56233275",
"0.5622133",
"0.5583129",
"0.5583129",
"0.55569774",
"0.55470556",
"0.5544918",
"0.5514595",
"0.54992104",
"0.5495715",
"0.54932356",
"0.5456983",
"0.54481936",
"0.5435265",
"0.5428914",
"0.542721... | 0.6323087 | 2 |
Create or update volumes associated with the workset | def create_update_volumes(username, token, workset_name, volume_ids)
#<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
#<volumes xmlns="http://registry.htrc.i3.illinois.edu/entities/workset">
# <volume>
# <id>9999999</id>
# </volume>
# <volume>
# <id>3333333</id>
# </volume>
# </volumes>
volumes_xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
"<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">";
for id in volume_ids
volumes_xml += "<volume><id>#{id}</id></volume>"
end
volumes_xml += "</volumes>"
# curl -v --data @new_volumes.xml -X PUT \
# -H "Content-Type: application/vnd.htrc-volume+xml" \
# -H "Accept: application/vnd.htrc-volume+xml" \
# http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred
url = URI.parse("#{APP_CONFIG['registry_url']}/worksets/#{workset_name}")
http = Net::HTTP.new(url.host, url.port)
if Rails.env.development?
http.set_debug_output($stdout)
end
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Put.new(url.path)
request["Content-Type"] = "application/vnd.htrc-volume+xml"
request.add_field("Authorization", "Bearer #{token}")
request.body = volumes_xml
response = http.request(request)
#xml = response.body
case response
when Net::HTTPUnauthorized then
raise Exceptions::SessionExpiredError.new("Session expired. Please login again")
when Net::HTTPSuccess then
# Do nothing
else
raise Exceptions::SystemError.new("Error retrieving worksets (HTTP #{response.code})")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_volumes\n # managing planned volumes is currently only needed in Windows and only if\n # this is not a reboot scenario.\n if !RightScale::Platform.windows? || RightScale::InstanceState.reboot?\n boot\n else\n RightScale::AuditProxy.create(@agent_identity, 'Planned volume management'... | [
"0.6334457",
"0.62510824",
"0.6199592",
"0.61320317",
"0.6096459",
"0.609424",
"0.60863876",
"0.6035304",
"0.6017542",
"0.60071594",
"0.5911742",
"0.58008444",
"0.57579714",
"0.57524824",
"0.5687162",
"0.5660852",
"0.5629482",
"0.5611734",
"0.56053007",
"0.55878526",
"0.55653... | 0.62800264 | 1 |
List worksets accessible by the specified user | def list_worksets (username, token, include_public)
Rails.logger.debug "list_public_worksets #{username}"
url = URI.parse("#{APP_CONFIG['registry_url']}/worksets?public=#{include_public}")
http = Net::HTTP.new(url.host, url.port)
if Rails.env.development?
http.set_debug_output($stdout)
end
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url.request_uri)
request.add_field("Authorization", "Bearer #{token}")
request.add_field("Accept", "application/vnd.htrc-workset+xml")
response = http.request(request)
Rails.logger.debug "Response Code: #{response.code}"
case response
when Net::HTTPUnauthorized then
raise Exceptions::SessionExpiredError.new("Session expired. Please login again")
when Net::HTTPSuccess then
# Do nothing
else
raise Exceptions::SystemError.new("Error retrieving worksets (HTTP #{response.code})")
end
response_xml = response.body
#Rails.logger.debug response_xml
worksets = Array.new
doc = REXML::Document.new(response_xml)
doc.elements.each('worksets/workset/metadata') { |metadata|
hash = Hash.new
hash['name'] = metadata.elements['name'].text
hash['description'] = metadata.elements['description'].text
hash['author'] = metadata.elements['author'].text
if (hash['author'] == username)
worksets.unshift(hash)
else
worksets.push(hash)
end
}
id = 1
worksets.each { |w|
w['id'] = id;
id = id+1
}
return worksets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @user_workspaces = UserWorkspace.owned_by(current_user)\n end",
"def index\n if user_signed_in?\n @workout_sets = WorkoutSet.includes(:type).page(params[:page]).per(12).where(type: Type.where(name:\"Set\").take.id).where.not(id: current_user.workout_sets.order(id: :desc).includes(:type).e... | [
"0.6852174",
"0.62984174",
"0.6260676",
"0.62303203",
"0.6186306",
"0.61783016",
"0.6007866",
"0.597914",
"0.5943096",
"0.5914245",
"0.59062344",
"0.5879733",
"0.5869595",
"0.5861803",
"0.58052635",
"0.58019954",
"0.5772268",
"0.5762581",
"0.5760923",
"0.57339746",
"0.5706222... | 0.69587594 | 0 |
Get the attributes of the specified workset | def get_workset (token, author, workset_name)
Rails.logger.debug "get_workset #{author}, #{workset_name}"
#curl -v -X GET -H "Accept: application/vnd.htrc-workset+xml" \
# http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1?user=fred
url = URI.parse("#{APP_CONFIG['registry_url']}/worksets/#{workset_name}?author=#{author}")
http = Net::HTTP.new(url.host, url.port)
if Rails.env.development?
http.set_debug_output($stdout)
end
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url.request_uri)
request.add_field("Authorization", "Bearer #{token}")
request.add_field("Accept", "application/vnd.htrc-workset+xml")
response = http.request(request)
#Rails.logger.debug "Response Code: #{response.code}"
case response
when Net::HTTPUnauthorized then
raise Exceptions::SessionExpiredError.new("Session expired. Please login again")
when Net::HTTPSuccess then
# Do nothing
else
raise Exceptions::SystemError.new("Error retrieving worksets (HTTP #{response.code})")
end
response_xml = response.body
#Rails.logger.debug response_xml
doc = REXML::Document.new(response_xml)
workset = Hash.new
doc.elements.each("/workset/metadata") { |metadata|
workset['name'] = metadata.elements['name'].text
workset['description'] = metadata.elements['description'].text
workset['author'] = metadata.elements['author'].text
}
return workset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def attribute_sets\n return @attribute_sets\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n model_attri... | [
"0.6255697",
"0.5942913",
"0.5915832",
"0.5915832",
"0.5915832",
"0.5915832",
"0.5915832",
"0.5915832",
"0.5897695",
"0.5823894",
"0.5823894",
"0.58013755",
"0.5778106",
"0.5771485",
"0.5770939",
"0.5768157",
"0.5768157",
"0.5768157",
"0.57372814",
"0.57312495",
"0.5721052",
... | 0.5330648 | 59 |
Get the volume IDs for the specified workset | def get_workset_volumes (author, token, workset_name)
Rails.logger.debug "get_workset_volumes #{author}, #{workset_name}"
url = URI.parse("#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes?author=#{author}")
http = Net::HTTP.new(url.host, url.port)
if Rails.env.development?
http.set_debug_output($stdout)
end
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url.request_uri)
request.add_field("Authorization", "Bearer #{token}")
request.add_field("Accept", "application/vnd.htrc-workset+xml")
response = http.request(request)
case response
when Net::HTTPUnauthorized then
raise Exceptions::SessionExpiredError.new("Session expired. Please login again")
when Net::HTTPSuccess then
# Do nothing
else
raise Exceptions::SystemError.new("Error retrieving worksets (HTTP #{response.code})")
end
#Rails.logger.debug "Response Code: #{response.code}"
volumes = response.body
ids = volumes.split(" ")
return ids
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_set_ids(work)\n case work\n when ActiveFedora::Base\n ::FileSet.search_with_conditions(id: work.member_ids).map(&:id)\n when Valkyrie::Resource\n Hyrax.custom_queries.find_child_file_set_ids(resource: work)\n end\n end",
"def volumes\n service.list_pool_volu... | [
"0.68846786",
"0.6159225",
"0.6096111",
"0.59927696",
"0.58635706",
"0.584757",
"0.5758373",
"0.575381",
"0.57364285",
"0.57197005",
"0.5687518",
"0.56846106",
"0.5627",
"0.562527",
"0.5618621",
"0.5557972",
"0.553989",
"0.55064875",
"0.5491552",
"0.5395174",
"0.5389767",
"... | 0.689014 | 0 |
Delete the specified workset | def delete_workset (token, workset_name)
Rails.logger.debug "delete_workset #{workset_name}"
url = URI.parse("#{APP_CONFIG['registry_url']}/worksets/#{workset_name}")
http = Net::HTTP.new(url.host, url.port)
if Rails.env.development?
http.set_debug_output($stdout)
end
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Delete.new(url.request_uri)
request.add_field("Authorization", "Bearer #{token}")
request.add_field("Accept", "application/vnd.htrc-workset+xml")
response = http.request(request)
case response
when Net::HTTPUnauthorized then
raise Exceptions::SessionExpiredError.new("Session expired. Please login again")
when Net::HTTPSuccess then
# Do nothing
else
raise Exceptions::SystemError.new("Error deleting workset (HTTP #{response.code})")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @workout_set = WorkoutSet.find(params[:id])\n @workout_set.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_sets_url }\n format.json { head :no_content }\n end\n end",
"def cmd_db_set_del_from(*args)\n\t\t\tset_id = args[0]\n\t\t\tif is_valid_set?(set_id... | [
"0.66973084",
"0.66434056",
"0.6595161",
"0.6398401",
"0.6398401",
"0.63134164",
"0.6297709",
"0.6169932",
"0.6148339",
"0.6139992",
"0.6125524",
"0.60873747",
"0.60836273",
"0.6043736",
"0.6023636",
"0.60230935",
"0.601725",
"0.6006979",
"0.59798664",
"0.5978087",
"0.596489"... | 0.7114385 | 0 |
POST /twins POST /twins.xml | def create
@twin = Twin.new(params[:twin])
respond_to do |format|
if @twin.save
flash[:notice] = 'Twin was successfully created.'
format.html { redirect_to(edit_twin_path(@twin)) }
format.xml { render :xml => @twin, :status => :created, :location => @twin }
else
format.html { render :action => "new" }
format.xml { render :xml => @twin.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_twit(twit)\n RestClient.post configuration.base_url + '/twits',\n { twit: twit }.to_json,\n content_type: :json,\n accept: :json\n end",
"def create\n @twet = current_user.twets.build(twet_params)\n\n respond_to do |format|\n... | [
"0.66213024",
"0.5983735",
"0.5913399",
"0.58668935",
"0.579634",
"0.5775943",
"0.5742516",
"0.57386297",
"0.56879306",
"0.56662583",
"0.5627109",
"0.5597883",
"0.55938154",
"0.5556845",
"0.5554842",
"0.5542818",
"0.55268586",
"0.5513821",
"0.55013686",
"0.54819244",
"0.54747... | 0.5536778 | 16 |
PUT /twins/1 PUT /twins/1.xml | def update
@twin = Twin.find(params[:id])
respond_to do |format|
if @twin.update_attributes(params[:twin])
flash[:notice] = 'Twin was successfully updated.'
@function_1 = WhatFunction.find @twin.left_function_id
@function_2 = WhatFunction.find @twin.right_function_id
@language_1 = ProgrammingLanguage.find_by_id @function_1.programming_language_id
@language_2 = ProgrammingLanguage.find_by_id @function_2.programming_language_id
format.html { redirect_to equiv_path(@language_1.name, @function_1.name,@language_2.name,@function_2.name) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @twin.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(tweet)\n client.update tweet\n end",
"def twitt\n if PLANETOID_CONF[:twitter][:users][:send_twitts]\n twit=Twitter::Base.new(Twitter::HTTPAuth.new(PLANETOID_CONF[:twitter][:user], PLANETOID_CONF[:twitter][:password]))\n twit.update \"#{PLANETOID_CONF[:twitter][:users][:prefix]} #{self... | [
"0.6210003",
"0.60753644",
"0.6008568",
"0.6000098",
"0.59428906",
"0.592802",
"0.5847079",
"0.58320785",
"0.5809008",
"0.58066636",
"0.5803324",
"0.5735829",
"0.57119334",
"0.57119334",
"0.571145",
"0.56907123",
"0.56892276",
"0.5688245",
"0.5660585",
"0.56075275",
"0.559328... | 0.0 | -1 |
Helper methods to display friendly name instead of select value | def student_exchange_student_select_friendly(student)
if student.exchange_student.to_i == 0
'No'
else student.exchange_student.to_i == 1
'Sí'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choice_field_name(value)\n \"#{name}___#{value}\"\n end",
"def dropdown_display_name\n \"#{name} (#{email.presence || 'no email'}, user ##{id})\"\n end",
"def name_for_select_for_facture\n @name_for_select = self.factcat.name + \" - \" + self.name\n end",
"def display_name\n \t\"#{na... | [
"0.7627874",
"0.7620164",
"0.75378734",
"0.7469014",
"0.73962986",
"0.7237788",
"0.7237788",
"0.7237788",
"0.72247946",
"0.7207788",
"0.71544206",
"0.7136134",
"0.7136134",
"0.71180785",
"0.71180785",
"0.71180785",
"0.7116962",
"0.7106956",
"0.7106956",
"0.70202696",
"0.69574... | 0.0 | -1 |
Helper method for building rails helper select from constants declared in the model | def type_of_student_select_type
[
['Diurno', Student::TYPE_OF_STUDENT_DAY],
['Nocturno', Student::TYPE_OF_STUDENT_NIGHT],
['Virtual', Student::TYPE_OF_STUDENT_VIRTUAL],
['Esperando diploma', Student::TYPE_OF_STUDENT_DIPLOMA_PENDING],
['Graduado', Student::TYPE_OF_STUDENT_GRADUATE]
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_select(arel)\n if select_values.any?\n arel.project(*arel_columns(select_values.uniq))\n else\n arel.project(\"\\\"#{klass.table_name}\\\".\\\"tableoid\\\"::regclass as \\\"type\\\"\") if @klass.using_multi_table_inheritance?\n arel.project(@klass.arel_table[Arel.star])\n ... | [
"0.6908511",
"0.6589131",
"0.6407895",
"0.62138146",
"0.6143517",
"0.6140356",
"0.6057643",
"0.5939523",
"0.5914877",
"0.5881175",
"0.58785653",
"0.5853708",
"0.5847783",
"0.5790804",
"0.57772094",
"0.57405335",
"0.57353854",
"0.565485",
"0.5612625",
"0.5583092",
"0.5569115",... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.