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 |
|---|---|---|---|---|---|---|
Explicitly set the name of a queue for the given method route Ex. queue_for :created, "derp.derp" queue_for :updated, "foo.bar" | def queue_for(method, queue_name)
@_queue_names ||= {}
@_queue_names[method] = queue_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue_for(clazz, method)\n ClassAndMethodRouting.queue_for(clazz, method)\n end",
"def method_name(queue)\n queue.split(\"__\").last\n end",
"def set_queue\n self.add_queue(queue_name) do |metadata, payload|\n log.info(\"Message received with the routing key: #{metad... | [
"0.6981014",
"0.68962336",
"0.6525915",
"0.6506201",
"0.6461485",
"0.645893",
"0.63431305",
"0.6225817",
"0.62112796",
"0.6160546",
"0.6122204",
"0.6091297",
"0.6089492",
"0.6051676",
"0.6035763",
"0.6011947",
"0.60045457",
"0.5979919",
"0.5968651",
"0.5962902",
"0.59467983",... | 0.8305483 | 0 |
Explicitly set the whole routing key to use for a given method route. | def routing_key_for(method, routing_key_name)
@_routing_key_names ||= {}
@_routing_key_names[method] = routing_key_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key(method)\n @_key = method\n end",
"def key_method method\n @key_method = method\n validates_presence_of method\n validates_length_of method, minimum: 1\n define_method(:key) { prepare_key(self.send method) }\n end",
"def routeable(method, opts={})\n ctrlr_m = me... | [
"0.69384617",
"0.6651482",
"0.63513935",
"0.63444024",
"0.6307341",
"0.6268025",
"0.6026637",
"0.5884365",
"0.57612115",
"0.5741135",
"0.57030064",
"0.5680921",
"0.567883",
"0.56576055",
"0.5643051",
"0.5601336",
"0.5593304",
"0.5539606",
"0.5539606",
"0.5539606",
"0.5531875"... | 0.7632306 | 0 |
top rated solution on codewars | def add_binary_top(a,b)
(a+b).to_s(2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anchored; end",
"def alg; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def solution4(input)\n end",
"def king_richard_iii; end",
"def villian; end",
"def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\ne... | [
"0.61666954",
"0.60340935",
"0.5975901",
"0.5975901",
"0.5975901",
"0.5975901",
"0.5975901",
"0.5954942",
"0.58058673",
"0.5724072",
"0.5719678",
"0.5715734",
"0.5715734",
"0.5715734",
"0.5715734",
"0.56933963",
"0.5669441",
"0.5639921",
"0.55732507",
"0.556404",
"0.5560631",... | 0.0 | -1 |
Instantiate a new resource type with the given parameters. | def instantiate(params)
instance = Instance.new( *interpolate(params), @parent )
# instance.apply_resource_type # TODO: do we need apply_security_scheme?
instance
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_resource(type, title, parameters = {})\n parameters = parameters.merge(:name => title)\n resource = Puppet::Type.type(type.to_sym).new(parameters)\n catalog.add_resource(resource)\n resource\n end",
"def resource type, labels = {}\n Resource.new.tap do |r|\n r.type = type\... | [
"0.76849955",
"0.73631656",
"0.7278977",
"0.71374035",
"0.7045993",
"0.7015812",
"0.6947854",
"0.69027716",
"0.68373656",
"0.6716825",
"0.6695796",
"0.66533244",
"0.66483086",
"0.66313326",
"0.6626307",
"0.66015065",
"0.65786743",
"0.6543751",
"0.6538809",
"0.64925677",
"0.64... | 0.70916575 | 4 |
Use callbacks to share common setup or constraints between actions. | def set_concepto
@concepto = Concepto.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 |
Only allow a list of trusted parameters through. | def concepto_params
params.require(:concepto).permit(:clave, :description, :capitulo_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69490993",
"0.6812977",
"0.6801889",
"0.67950445",
"0.6745037",
"0.6740698",
"0.65270424",
"0.6519444",
"0.6492448",
"0.6430671",
"0.6430671",
"0.6430671",
"0.63992614",
"0.6355569",
"0.6354901",
"0.63456345",
"0.63430274",
"0.63376623",
"0.6327184",
"0.6327184",
"0.632718... | 0.0 | -1 |
Update Keywords if needed by adding it from tags in forms | def set_page_defaults
@site_defaults = SiteConfiguration.all
@page_title ||= 'Aeromotion Pages'
@seo_keywords ||= 'Aeromotion, Tutorials, Workouts, Best Trainings, Free Videos, Personal, Best'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keywords_attributes=(new_keywords)\n keywords.clear\n\n (new_keywords || []).each do |word|\n keywords.build(:word => word)\n end\n end",
"def index_keywords!\n update_attribute(:_keywords, set_keywords)\n end",
"def update_tag_keyword(keyword,tags_set=[],args={})\n @tag_keyword[key... | [
"0.6670302",
"0.62784904",
"0.62550527",
"0.610361",
"0.6043887",
"0.5984678",
"0.58891",
"0.5854891",
"0.57896894",
"0.5763776",
"0.57595944",
"0.5712599",
"0.5695622",
"0.56488657",
"0.56357926",
"0.5614026",
"0.5610397",
"0.5608313",
"0.5605238",
"0.5605238",
"0.5598555",
... | 0.0 | -1 |
all methods defined below will be private | def validate_marital_status(val)
unless @valid_marital_statuses.include?(val)
raise "Invalid value: #{val}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def private_method\n end",
"def internal; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def private_method; end",
"def internal_methods; end",
"def methods() end",
"def implementation; end",
"def implementation; end",
"def pu... | [
"0.883418",
"0.8352764",
"0.7879943",
"0.78659123",
"0.78659123",
"0.78659123",
"0.78659123",
"0.7794014",
"0.76174736",
"0.7615882",
"0.7503469",
"0.7503469",
"0.74436724",
"0.74436724",
"0.7321059",
"0.7321059",
"0.72571087",
"0.7196324",
"0.71493256",
"0.7031893",
"0.69764... | 0.0 | -1 |
=begin input: float, output: string. rules: use two digit numbers with leading zeros when formatting minutes and seconds. Use constant to represent degree symbol. if num greater than 360... DS: string algo: define a method called dms, takes one float number parameter num init lv angle, set to empty string turn float num into a string, partition at the '.' angle << num[0], also DEGREE minutes_seconds_ary = ((num[1].to_f 60.0) / 10(num[1].size).to_f).to_s.partition('.') take num at index 0, append to angle plus ' symbol angle << ((minutes_seconds_ary[1].to_f 60.0) / 10(num[1].size).round).to_s, plus seconds symbol return angle =end | def dms(num)
angle_str = %()
num_ary = num.to_s.partition('.')
#degree
angle_str << (num_ary[0] + DEGREE)
minutes_seconds_ary = ((num_ary[-1].to_f * 60.0) / 10**(num_ary[-1].size).to_f).to_s.partition('.')
#minutes
if minutes_seconds_ary[0].size <= 1
angle_str << ('0' + minutes_seconds_ary[0] + "'")
else
angle_str << minutes_seconds_ary[0] + "'"
end
# seconds
seconds = ((minutes_seconds_ary[-1].to_f * 60)/(10**(minutes_seconds_ary[-1].size))).round.to_s
if seconds.size <= 1
angle_str << ('0' + seconds)
else
angle_str << seconds
end
angle_str + %("\"")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dms(angle)\n# How does LS round them?\n# Also we have to make sure that minutes and seconds esp are either *60 if < than 60, otherwise 0.\n if angle < 0\n degrees = 360 + angle\n elsif angle >= 0 && angle < 360\n degrees = angle.floor\n else\n degrees = angle.floor - 360\n end\n\n minutes =... | [
"0.811914",
"0.7688109",
"0.7490294",
"0.7240925",
"0.6438802",
"0.6285384",
"0.62104726",
"0.61305416",
"0.61305416",
"0.60969335",
"0.6086194",
"0.5946115",
"0.59192365",
"0.5828534",
"0.5799975",
"0.57745075",
"0.57702416",
"0.57607013",
"0.5759594",
"0.57516843",
"0.57483... | 0.8862008 | 0 |
OCSP response stapling information. | def ocsp_response
@ocsp_response ||= if (ocsp_response = @node.at('ocspStapling/ocspResponse'))
OCSPResponse.new(ocsp_response)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def... | [
"0.5713922",
"0.5713922",
"0.5713922",
"0.5713922",
"0.5713922",
"0.57137907",
"0.57137907",
"0.57137907",
"0.57137907",
"0.57137907",
"0.57137907",
"0.57137907",
"0.57137907",
"0.5713761",
"0.57137346",
"0.57137346",
"0.57137346",
"0.57137346",
"0.57137346",
"0.57137346",
"0... | 0.7117692 | 0 |
Get content about rent process and show it to user | def new
@page = Page.find_by_title('Huren bij Xposers')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rent\n @page = Pwb::Page.find_by_slug \"rent\"\n @page_title = @current_agency.company_name\n # @content_to_show = []\n if @page.present?\n @page_title = @page.page_title + \" - \" + @current_agency.company_name\n # TODO: - allow addition of custom content\n # @page.ord... | [
"0.5986838",
"0.5825962",
"0.57980335",
"0.5725084",
"0.5708898",
"0.5703657",
"0.5692648",
"0.5672974",
"0.5642449",
"0.5637775",
"0.5626918",
"0.56148046",
"0.5552034",
"0.55179405",
"0.5501017",
"0.54672235",
"0.5382549",
"0.53643584",
"0.5350572",
"0.53368783",
"0.5324507... | 0.0 | -1 |
Register new rental and emails user | def create
@rent = @artwork.rents.new
if @rent.confirm(current_user)
Kunstmail.rent(current_user, @artwork).deliver
redirect_to root_url, notice: "Check your email for further instructions"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n existing_user = User.find_by(email_id: params[:user][:email_id])\n if existing_user != nil\n if existing_user.is_realtor == true\n redirect_to login_path, notice: 'You are already registered as an Realtor'\n else\n existing_user.is_realtor = true\n existing_user.pa... | [
"0.68424815",
"0.67359847",
"0.6661093",
"0.6655047",
"0.6631085",
"0.6596117",
"0.6583677",
"0.65198594",
"0.64620304",
"0.6457709",
"0.64526325",
"0.64458776",
"0.64231634",
"0.64189416",
"0.6413707",
"0.6392294",
"0.6354494",
"0.63520336",
"0.6331025",
"0.6329924",
"0.6314... | 0.62248 | 32 |
=begin CONFIRM SALES RELATED =end | def confirm_production_repair_result
@production_repair_result = ProductionRepairResult.find_by_id params[:production_repair_result_id]
# add some defensive programming.. current user has role admin, and current_user is indeed belongs to the company
@production_repair_result.confirm( current_user )
@object = @production_repair_result
@parent = @object.template_sales_item
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirm_sales_order\n @sales_order = SalesOrder.find_by_id params[:sales_order_id]\n # add some defensive programming.. current user has role admin, and current_user is indeed belongs to the company \n @sales_order.confirm( current_user ) \n end",
"def sell_confirmed\n end",
"def confirm_order... | [
"0.6186503",
"0.61625737",
"0.6122685",
"0.59879845",
"0.5955981",
"0.5955405",
"0.5941831",
"0.59390265",
"0.5933362",
"0.583504",
"0.5790174",
"0.5776659",
"0.5765615",
"0.5760621",
"0.57591045",
"0.57415",
"0.5684254",
"0.5667012",
"0.56591976",
"0.56505203",
"0.56490207",... | 0.5717416 | 16 |
Returns an ASCII or hashed filename that do not exists yet in the given subdirectory | def disk_filename(filename, directory=nil)
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
ascii = ''
if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50
ascii = filename
else
ascii = Digest::MD5.hexdigest(filename)
# keep the extension if any
ascii << $1 if filename =~ %r{(\.[a-zA-Z0-9]+)$}
end
directory = directory.to_s
result =
loop do
s3obj = RedmicaS3::Connection.object(File.join(directory, "#{timestamp}_#{ascii}"))
if s3obj.exists?
timestamp.succ!
else
# Avoid race condition: Create an empty S3 object
s3obj.put
break File.basename(s3obj.key)
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_free_name filename\n base_filename = filename ||= @filename\n\n number = 1\n\n while File.exist? filename do\n filename = \"#{base_filename}.#{number}\"\n number += 1\n end\n\n filename\n end",
"def get_unique_file_name fname\n 100.times do |i|\n suffix = \"%03d\" % i\n ... | [
"0.6211263",
"0.61882174",
"0.6068681",
"0.6015111",
"0.5866165",
"0.5837125",
"0.5821857",
"0.58096826",
"0.57766235",
"0.57672167",
"0.57667696",
"0.5764727",
"0.5760986",
"0.5745331",
"0.57257015",
"0.5723154",
"0.57134527",
"0.57032204",
"0.568573",
"0.568529",
"0.5669709... | 0.530597 | 65 |
Copies the temporary file to its final location and computes its MD5 hash | def files_to_final_location
if @temp_file
self.disk_directory = target_directory
self.disk_filename = Attachment.disk_filename(filename, disk_directory)
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)") if logger
sha = Digest::SHA256.new
if @temp_file.respond_to?(:read)
buffer = ""
while (buffer = @temp_file.read(8192))
sha.update(buffer)
end
else
sha.update(@temp_file)
end
self.digest = sha.hexdigest
end
if content_type.blank? && filename.present?
self.content_type = Redmine::MimeType.of(filename)
end
# Don't save the content type if it's longer than the authorized length
if self.content_type && self.content_type.length > 255
self.content_type = nil
end
if @temp_file
raw_data =
if @temp_file.respond_to?(:read)
@temp_file.rewind
@temp_file.read
else
@temp_file
end
RedmicaS3::Connection.put(self.diskfile, self.filename, raw_data,
(self.content_type || 'application/octet-stream'),
{digest: self.digest}
)
end
ensure
@temp_file = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n Digest::MD5.hexdigest(abs_filepath)[0..5]\n end",
"def md5; Digest::MD5.file(fname).hexdigest; end",
"def create_md5(file, new_file)\n stdout = `md5 -q \"#{file}\" > \"#{new_file}.tif.md5\"`\n puts stdout\nend",
"def file_md5\n Digest::MD5.file(self).hexdigest\n end",
"def digest\... | [
"0.6927792",
"0.6898701",
"0.6628717",
"0.6586476",
"0.6566919",
"0.6516795",
"0.6424904",
"0.6371402",
"0.6345634",
"0.6327153",
"0.63042724",
"0.62904793",
"0.62884724",
"0.6284855",
"0.6250928",
"0.62365437",
"0.6213313",
"0.6158754",
"0.6142212",
"0.6121433",
"0.61095977"... | 0.56158894 | 53 |
Returns the full path the attachment thumbnail, or nil if the thumbnail cannot be generated. | def thumbnail(options = {})
return if !readable? || !thumbnailable?
size = options[:size].to_i
if size > 0
# Limit the number of thumbnails per image
size = (size / 50.0).ceil * 50
# Maximum thumbnail size
size = 800 if size > 800
else
size = Setting.thumbnails_size.to_i
end
size = 100 unless size > 0
target = thumbnail_path(size)
diskfile_s3 = diskfile
begin
Redmine::Thumbnail.generate(diskfile_s3, target, size, is_pdf?)
rescue => e
Rails.logger.error "An error occured while generating thumbnail for #{diskfile_s3} to #{target}\nException was: #{e.message}"
return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thumb_image_path\n begin\n self.attachment.url(:thumb) ? self.attachment.url(:thumb) : \"/public/no-image.png\"\n rescue\n \"/public/no-image.png\"\n end\n end",
"def thumbnail\n unless @thumbnail_url\n BabboBackend.get.request_thumbnail_url_for_identifier(@productIden... | [
"0.7820355",
"0.7723328",
"0.748421",
"0.7377993",
"0.72754675",
"0.7239288",
"0.7186934",
"0.7162568",
"0.7160545",
"0.69872826",
"0.6987037",
"0.6986065",
"0.698517",
"0.69777006",
"0.6955584",
"0.6947559",
"0.6936676",
"0.69139504",
"0.6831298",
"0.6812293",
"0.6798306",
... | 0.5983245 | 93 |
Returns true if the file is readable | def readable?
disk_filename.present? && self.s3_object(false).exists?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_readable?(path)\n File.exists? path and File.readable? path\n end",
"def is_readable?\n return @readable\n end",
"def readable?(path)\n info = Private.info_with(path, GLib::G_FILE_ATTRIBUTE_ACCESS_CAN_READ)\n GLib.g_file_info_get_attribute_boolean(info, GLib::G_FILE_ATTRIBUTE_A... | [
"0.8212343",
"0.8161086",
"0.78762025",
"0.77147126",
"0.76957786",
"0.7691621",
"0.761723",
"0.7590317",
"0.73902774",
"0.7337719",
"0.72673255",
"0.7266669",
"0.72391534",
"0.72068334",
"0.7107648",
"0.70344156",
"0.70265645",
"0.6982086",
"0.69439274",
"0.68249595",
"0.681... | 0.66972655 | 24 |
Moves an existing attachment to its target directory | def move_to_target_directory!
return if new_record? || !readable?
src = diskfile
self.disk_directory = target_directory
dest = diskfile
return if src == dest
if !RedmicaS3::Connection.move_object(src, dest)
Rails.logger.error "Could not move attachment from #{src} to #{dest}"
return
end
update_column :disk_directory, disk_directory
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_to_path(target_path)\n move_to(cotta.dir(target_path))\n end",
"def move_to!(dest)\n Pow(dest).parent.create_directory\n move_to(dest)\n end",
"def move_file\n\n end",
"def move_to(target)\n target.parent.mkdirs\n factory.system.move_dir(@path, target.path)\n end",... | [
"0.6403506",
"0.6348001",
"0.6257209",
"0.6237689",
"0.6198515",
"0.6142221",
"0.6127432",
"0.6096149",
"0.60808796",
"0.6074945",
"0.60710275",
"0.59910333",
"0.5947841",
"0.5944923",
"0.5939825",
"0.5934065",
"0.59334517",
"0.5912414",
"0.5912376",
"0.58944285",
"0.5880901"... | 0.74365443 | 0 |
Updates attachment digest to SHA256 | def update_digest_to_sha256!
return unless readable?
object = self.s3_object
sha = Digest::SHA256.new
sha.update(object.get.body.read)
new_digest = sha.hexdigest
unless new_digest == object.metadata['digest']
object.copy_from(object,
content_disposition: object.content_disposition,
content_type: object.content_type,
metadata: object.metadata.merge({'digest' => new_digest}),
metadata_directive: 'REPLACE'
)
end
unless new_digest == self.digest
update_column :digest, new_digest
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @digest = args[:digest] if args.key?(:digest)\n end",
"def update!(**args)\n @sha256_fingerprint = args[:sha256_fingerprint] if args.key?(:sha256_fingerprint)\n end",
"def digest\n OpenSSL::Digest::SHA256.file(path).hexdigest\n end",
"def update_d... | [
"0.68261296",
"0.65919334",
"0.64462334",
"0.6438088",
"0.63679403",
"0.62825465",
"0.62335134",
"0.62332696",
"0.6175101",
"0.61477673",
"0.6091481",
"0.60665935",
"0.6051113",
"0.60375136",
"0.6027281",
"0.60187125",
"0.59736866",
"0.5967593",
"0.5942377",
"0.5942377",
"0.5... | 0.7091695 | 0 |
Physically deletes the file from the file system | def delete_from_disk!
if disk_filename.present?
diskfile_s3 = diskfile
Rails.logger.debug("Deleting #{diskfile_s3}")
RedmicaS3::Connection.delete(diskfile_s3)
end
Redmine::Thumbnail.batch_delete!(
thumbnail_path('*').sub(/\*\.thumb$/, '')
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_file\n File.unlink file\n end",
"def delete_file\n File.unlink file\n end",
"def destroy_file\n File.delete full_file_path\n rescue\n end",
"def del\n File.delete(@file)\n end",
"def delete\n @file = nil\n # file.delete\n end",
"def delete!\n ... | [
"0.8291966",
"0.8291966",
"0.8290286",
"0.8187562",
"0.8182364",
"0.8110053",
"0.8081748",
"0.8028514",
"0.78758156",
"0.78121144",
"0.76438564",
"0.7617306",
"0.7608394",
"0.76077527",
"0.75995857",
"0.7590742",
"0.7566985",
"0.75545263",
"0.74984485",
"0.7456708",
"0.744165... | 0.0 | -1 |
Extract the connection string for the rabbitmq service from the service information provided by Cloud Foundry in an environment variable. | def amqp_url
if not ENV['VCAP_SERVICES']
return {
:host => "localhost",
:port => 5672,
:username => "guest",
:password => "guest",
:vhost => "/",
}
end
services = JSON.parse(ENV['VCAP_SERVICES'], :symbolize_names => true)
url = services.values.map do |srvs|
srvs.map do |srv|
if srv[:label] =~ /^rabbitmq-/
srv[:credentials]
srv[:credentials][:heartbeat] = 20
return srv[:credentials]
else
[]
end
end
end.flatten!.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def amqp_url\n if not ENV['VCAP_SERVICES']\n return {\n :host => \"172.16.32.11\",\n :port => 5672,\n :username => \"guest\",\n :password => \"guest\",\n :vhost => \"/\",\n }\n end\n\n services = JSON.parse(ENV['VCAP_SERVICES'], :symbolize_names => true)\n url = service... | [
"0.744864",
"0.64117",
"0.60329986",
"0.5871954",
"0.58560705",
"0.57894254",
"0.57065386",
"0.5627882",
"0.55615014",
"0.5546482",
"0.5546482",
"0.55334806",
"0.55314684",
"0.55079055",
"0.5474078",
"0.54584104",
"0.544193",
"0.54413456",
"0.542486",
"0.542486",
"0.54162025"... | 0.7228656 | 1 |
Opens a client connection to the RabbitMQ service, if one isn't already open. This is a class method because a new instance of the controller class will be created upon each request. But AMQP connections can be longlived, so we would like to reuse the connection across many requests. | def client
unless $client
u = amqp_url
conn = Bunny.new(u)
conn.start
$client = conn.create_channel
# We only want to accept one un-acked message
$client.prefetch(1)
end
$client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client\n set_connection unless @client\n @client\n end",
"def connect\n @client = @client_class.new\n @client.connect\n \n begin\n yield\n ensure\n @client.close\n ActiveRecord::Base.verify_active_connections... | [
"0.6548404",
"0.64997256",
"0.64857477",
"0.60641325",
"0.5975623",
"0.5912363",
"0.59114003",
"0.5911384",
"0.58854485",
"0.58396304",
"0.58234626",
"0.5794034",
"0.57795596",
"0.57611126",
"0.5743635",
"0.5731797",
"0.57183796",
"0.5711126",
"0.56997025",
"0.5653327",
"0.56... | 0.6635481 | 0 |
Return the "nameless exchange", predefined by AMQP as a means to send messages to specific queues. Again, we use a class method to share this across requests. | def nameless_exchange
$nameless_exchange ||= client.default_exchange
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exchange\n @exchange ||= Exchange.new(@channel, :direct, AMQ::Protocol::EMPTY_STRING, :key => name)\n end",
"def exchange\n @exchange ||= channel.fanout(QUEUE_NAME)\n end",
"def exchange_naming\n @exchange_naming ||= if @worker_class\n Hightops::Naming::CommonExchange.new\n ... | [
"0.71571606",
"0.69197667",
"0.69132215",
"0.6878598",
"0.67331624",
"0.66694117",
"0.6640302",
"0.65081716",
"0.6435617",
"0.63132995",
"0.63131285",
"0.6174846",
"0.6174287",
"0.61472934",
"0.61418843",
"0.61348796",
"0.6104031",
"0.60709494",
"0.60395527",
"0.60332364",
"0... | 0.6661251 | 6 |
Return a queue named "messages". This will create the queue on the server, if it did not already exist. Again, we use a class method to share this across requests. | def messages_queue
$messages_queue ||= client.queue("messages", :durable => true, :auto_delete => false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_message_counting_queue\n\t\t@queue ||= begin\n\t\t\tself.log.debug \"Creating the message-counting queue.\"\n\t\t\tchannel = Symphony::Queue.amqp_channel\n\t\t\tchannel.queue( self.task_class.queue_name, passive: true, prefetch: 0 )\n\t\tend\n\n\t\tunless @queue.channel.open?\n\t\t\tself.log.info \"Message... | [
"0.6965326",
"0.6934442",
"0.6900829",
"0.68643856",
"0.669572",
"0.6582891",
"0.6572753",
"0.64675933",
"0.6448573",
"0.64448285",
"0.6387933",
"0.6336",
"0.6335639",
"0.6327123",
"0.63090515",
"0.6302529",
"0.62941766",
"0.6272013",
"0.6270611",
"0.619088",
"0.616224",
"0... | 0.71517956 | 0 |
If all gates are hidden, the sation must be hidden, if one is visible, station must be visible. | def check_station_visibility
station.update(hidden: station.access_control_gates.where.not(id: id).pluck(:hidden).push(hidden).uniq.all?) if hidden_changed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hidden?\n not visible\n end",
"def hidden?\n hidden_at?\n end",
"def hidden?\n hidden_at?\n end",
"def hidden?\n hidden_at?\n end",
"def is_hidden?\n\t\tself.hidden\n\tend",
"def visible=(vis)\n if vis\n show\n else\n hide\n end\n en... | [
"0.59830505",
"0.5975337",
"0.5975337",
"0.5975337",
"0.58056545",
"0.57636184",
"0.5762808",
"0.5742529",
"0.57018614",
"0.5693261",
"0.5692501",
"0.56769437",
"0.5599049",
"0.5597899",
"0.556726",
"0.5563838",
"0.5563838",
"0.5510256",
"0.55089086",
"0.5505045",
"0.55018234... | 0.7611455 | 0 |
Create a status record if one does not exist | def check_create_status
if self.v_status.nil?
status = VStatus.new
status.v_project = self
status.v_user_data = self.v_user_data
self.v_status = status
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_status(Status status)\n Status.create(group_id: @group_id, status: status)\n end",
"def status\n s = statuses.find(:first, :order => \"updated_at DESC\")\n if s.nil?\n s = statuses.create :organization_quarter_status_type_id => OrganizationQuarterStatusType.find_or_create_by_title(\"Nee... | [
"0.7206832",
"0.64852256",
"0.6247204",
"0.6198068",
"0.6172983",
"0.617294",
"0.61392707",
"0.61080515",
"0.60675484",
"0.6065306",
"0.60581666",
"0.60264796",
"0.60083133",
"0.5981415",
"0.5973524",
"0.5959304",
"0.59199077",
"0.59189254",
"0.59189254",
"0.59052587",
"0.587... | 0.7056659 | 1 |
Now that I've added a is_not_user?/may_not_be_user? method to simply_authorized using this cleaner and clearer method. used in roles_controller | def may_not_be_user_required
current_user.may_not_be_user?(@user) || access_denied(
"You may not be this user to do this", user_path(current_user))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_authorized?(user)\n user == current_user || is_admin?\n end",
"def authorized?(user)\n true\n end",
"def authorize_user\n # simple authorization: kick out anonymous users from backend actions\n=begin\n if !current_user\n redirect_back_or_default(home_page) and return if action_name... | [
"0.75830764",
"0.7553303",
"0.72632784",
"0.7240715",
"0.7225903",
"0.719599",
"0.718179",
"0.71809864",
"0.7178979",
"0.7178643",
"0.7157452",
"0.71340257",
"0.7113883",
"0.71114707",
"0.71047413",
"0.71047413",
"0.7077355",
"0.7076527",
"0.7057629",
"0.7044429",
"0.7043815"... | 0.0 | -1 |
GET /maintenance_schedules/1 GET /maintenance_schedules/1.xml | def show
@maintenance_schedule = MaintenanceSchedule.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @maintenance_schedule }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @schedules = Schedule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @schedules }\n end\n end",
"def maintenance_list(statuspage_id)\n request :method => :get,\n :url => @url + 'maintenance/list/' + statuspage_id\n end... | [
"0.6799355",
"0.67379797",
"0.66771525",
"0.6662656",
"0.661458",
"0.65610164",
"0.6522342",
"0.6514605",
"0.64728725",
"0.6445298",
"0.6423056",
"0.63741785",
"0.6374074",
"0.6298707",
"0.62879014",
"0.62817985",
"0.62353796",
"0.6233531",
"0.6213049",
"0.6212554",
"0.619498... | 0.74508256 | 0 |
GET /maintenance_schedules/new GET /maintenance_schedules/new.xml | def new
@maintenance_schedule = MaintenanceSchedule.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @maintenance_schedule }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.xml { render :xml => @schedule }\n end\n end",
"def new\n @schedule = Schedule.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @schedule }\n end\n end",
"def new\n @schedule = Schedule.n... | [
"0.7685377",
"0.7409408",
"0.7407814",
"0.73829937",
"0.73501813",
"0.72707444",
"0.7183455",
"0.6852251",
"0.6832066",
"0.6758014",
"0.66073716",
"0.6599364",
"0.65242624",
"0.65040135",
"0.64763653",
"0.6439372",
"0.6435777",
"0.64250743",
"0.6356924",
"0.6353907",
"0.63486... | 0.79876274 | 0 |
POST /maintenance_schedules POST /maintenance_schedules.xml | def create
@maintenance_schedule = MaintenanceSchedule.new(params[:maintenance_schedule])
respond_to do |format|
if @maintenance_schedule.save
format.html { redirect_to(@maintenance_schedule, :notice => 'Maintenance schedule was successfully created.') }
format.xml { render :xml => @maintenance_schedule, :status => :created, :location => @maintenance_schedule }
else
format.html { render :action => "new" }
format.xml { render :xml => @maintenance_schedule.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maintenance_schedule(statuspage_id, maintenance_name, maintenance_details, infrastructure_affected,\n date_planned_start, time_planned_start, date_planned_end, time_planned_end,\n automation = \"0\", all_infrastructure_affected = \"0\",\n ... | [
"0.7592277",
"0.61357504",
"0.60902613",
"0.6038409",
"0.6036109",
"0.6004008",
"0.5988473",
"0.5984874",
"0.59486353",
"0.59261113",
"0.59167206",
"0.5914411",
"0.59142184",
"0.5912462",
"0.5911313",
"0.5902852",
"0.5888488",
"0.58406913",
"0.5836415",
"0.58203983",
"0.58186... | 0.70385146 | 1 |
PUT /maintenance_schedules/1 PUT /maintenance_schedules/1.xml | def update
@maintenance_schedule = MaintenanceSchedule.find(params[:id])
respond_to do |format|
if @maintenance_schedule.update_attributes(params[:maintenance_schedule])
format.html { redirect_to(@maintenance_schedule, :notice => 'Maintenance schedule was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @maintenance_schedule.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @schedule = Schedule.find(params[:id])\n\n respond_to do |format|\n if @schedule.update_attributes(params[:schedule])\n format.html { redirect_to(@schedule, :notice => 'Schedule was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render ... | [
"0.66244733",
"0.6582157",
"0.65461344",
"0.6512493",
"0.6391176",
"0.63862675",
"0.63702404",
"0.6367937",
"0.63517505",
"0.6341044",
"0.62997496",
"0.62910575",
"0.62886566",
"0.6260788",
"0.62589717",
"0.6247493",
"0.6247493",
"0.6247493",
"0.6247493",
"0.6247493",
"0.6247... | 0.719088 | 0 |
DELETE /maintenance_schedules/1 DELETE /maintenance_schedules/1.xml | def destroy
@maintenance_schedule = MaintenanceSchedule.find(params[:id])
@maintenance_schedule.destroy
respond_to do |format|
format.html { redirect_to(maintenance_schedules_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @schedule.destroy\n\n respond_to do |format|\n format.html { redirect_to(schedules_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @schedule = Schedule.find(params[:id])\n @schedule.destroy\n\n respond_to do |format|\n format.html { redirect_to(sched... | [
"0.71289223",
"0.711882",
"0.711882",
"0.711882",
"0.69836265",
"0.69667125",
"0.6863063",
"0.67685264",
"0.6731389",
"0.6713114",
"0.6693143",
"0.66671944",
"0.66583836",
"0.66100526",
"0.6592417",
"0.6592277",
"0.6559888",
"0.655949",
"0.65569353",
"0.6556303",
"0.6544897",... | 0.7805734 | 0 |
Returns [ "system_sys/ingeconf/.", ... ] | def get_scms(system)
Dir.glob("#{system}/*/.").
reject {|d| /(build|admin|CVS|telium_platform|u32_platform)/ =~ d }.
reject {|d| /ssade\// =~ d }.
# "the basename of the dirname":
# we first drop "/." using dirname, then only use last component
map {|v| File.basename(File.dirname(v)) }
# same with regex:
# map {|v| /.*?([^\/]+)(\/?.?)$/ =~ v && $1 }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paths\n Array(config.path).map(&:to_s)\n end",
"def list_path\n File.expand_path(\"../config/domains.txt\", File.dirname(__FILE__))\n end",
"def desired_contents\n @environments.map {|env| env.dirname }\n end",
"def getConfigPath\n if @conf[:config_name].index('/')\n retur... | [
"0.64382106",
"0.6112599",
"0.6111854",
"0.6070428",
"0.60597396",
"0.6038927",
"0.59924155",
"0.5984867",
"0.5970387",
"0.59595084",
"0.5950088",
"0.59435534",
"0.5933283",
"0.5887004",
"0.58679944",
"0.58664936",
"0.58411294",
"0.5838853",
"0.58301604",
"0.5820462",
"0.5819... | 0.5726123 | 32 |
Check that all arguments are probabilites i.e. the are numbers between 0.0 and 1.0 | def assert_probability *args
assert_floatable(*args)
args.each do |var|
assert do
var >= 0.0 &&
var <= 1.0
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validates_probability_constraints\n if project_state\n if (project_state.name == 'lead') && (probability >= 1.0)\n errors.add(:base,\n \"Probability of #{probability} is not allowed for the project state #{project_state.name}\")\n end\n\n if (project_state.name == 'of... | [
"0.66886836",
"0.61350894",
"0.61068773",
"0.60648835",
"0.59587735",
"0.59119785",
"0.588656",
"0.57861376",
"0.5775112",
"0.5772532",
"0.5768143",
"0.57274085",
"0.57232666",
"0.56961894",
"0.5673697",
"0.5658413",
"0.56407744",
"0.56374884",
"0.56367",
"0.56323916",
"0.562... | 0.76469076 | 0 |
Checks that all arguments are float or can be converted to a float. | def assert_floatable *args
args.each do |var|
assert do
var.not_nil? && var.is_a?(Numeric)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def are_floats?(x,y)\n return x.is_a?(Float) && y.is_a?(Float)\n end",
"def float3?(input)\n Float(input) rescue false\nend",
"def float?\n !!Float(self)\n rescue ArgumentError, TypeError\n false\n end",
"def expect_float(value, field, subfield)\n return true if value.... | [
"0.7191555",
"0.7092259",
"0.7052646",
"0.6985228",
"0.69429123",
"0.6911194",
"0.68796366",
"0.6865836",
"0.68004644",
"0.6793842",
"0.6787838",
"0.67493224",
"0.6737424",
"0.6661897",
"0.6661897",
"0.6627653",
"0.6617286",
"0.6613689",
"0.6613377",
"0.6606092",
"0.65955573"... | 0.74273723 | 0 |
Checks that all arguments are symbols. | def assert_symbol *args
args.each{|a| assert{a.is_a?(Symbol)}}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def only_symbols?(*args)\n symbols = args.select { |_| _.is_a? Symbol }\n if symbols.length == args.length\n return true\n end\n false\n end",
"def no_symbols?(*args)\n symbols = args.select { |_| _.is_a? Symbol }\n if symbols.length > 0\n return false\n end\n true\n end",
"... | [
"0.77265733",
"0.74199957",
"0.6752929",
"0.6687441",
"0.6634704",
"0.62949455",
"0.6239125",
"0.6207252",
"0.61717194",
"0.61463135",
"0.6138728",
"0.6074802",
"0.6074802",
"0.58708584",
"0.58428615",
"0.5813767",
"0.57811606",
"0.5779471",
"0.57729316",
"0.5757847",
"0.5747... | 0.74488574 | 1 |
Checks that all arguments are a Proc object or +nil+. | def assert_proc_or_nil *args
args.each{|a| assert{a.nil? || a.is_a?(Proc)}}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_proc?(p)\n p.is_a?(Proc) || p.is_a?(Method)\n end",
"def any_args?\n @any_args\n end",
"def any_args?\n @any_args\n end",
"def callable_with?(args, callable=nil)\n signatures = @func.dispatcher.to_type\n callables = signatures.is_a?(Puppet::Pops::Types::PVariantType) ... | [
"0.6297956",
"0.6170972",
"0.6170972",
"0.5925793",
"0.57466346",
"0.56804603",
"0.56517655",
"0.564564",
"0.56393903",
"0.56253296",
"0.56065905",
"0.55867416",
"0.5580973",
"0.5560038",
"0.5558509",
"0.5510403",
"0.5493208",
"0.5493208",
"0.5469272",
"0.5432577",
"0.5421892... | 0.7289663 | 0 |
chf edit 20160627 it takes too long to load the full page of all transfers after doing this stuff. note redirect_to :back will be deprecated in rails 5 | def accept
@proxy_deposit_request.transfer!(params[:reset])
if params[:sticky]
current_user.can_receive_deposits_from << @proxy_deposit_request.sending_user
end
redirect_to :back, notice: "Transfer complete"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def student_transfer2\n flash[:notice] = t('batch_transfer')\n redirect_to transfer_batch_transfer_path(@batch)\n end",
"def transfers\n @transfers = TransferHelper.transfers_for_user(user:current_user)\n\n render :partial => 'home/transfers'\n end",
"def inventory_transfer2\n flash[:success] ... | [
"0.64794594",
"0.63546926",
"0.617864",
"0.6164741",
"0.61556786",
"0.61556786",
"0.61556786",
"0.6128049",
"0.6128049",
"0.6085847",
"0.6017177",
"0.6017177",
"0.6017177",
"0.6017177",
"0.59669363",
"0.5957006",
"0.5954926",
"0.5943125",
"0.59204555",
"0.5885888",
"0.5879737... | 0.55651855 | 58 |
GET /urls GET /urls.json | def index
@urls = Url.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @urls = Url.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @urls }\n end\n end",
"def index\n @urls = @site.urls.paginate(:page => params[:page])\n render json: @urls\n end",
"def url_list\n urls = current_user.mini_urls\n ... | [
"0.72622925",
"0.70533806",
"0.6914229",
"0.6791078",
"0.6790144",
"0.6723092",
"0.6704383",
"0.66312903",
"0.6551795",
"0.65379965",
"0.6494516",
"0.64851487",
"0.64801353",
"0.6451444",
"0.6408628",
"0.64008194",
"0.63861555",
"0.6346339",
"0.63178754",
"0.6289575",
"0.6287... | 0.62464184 | 24 |
GET /urls/1 GET /urls/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @urls = Url.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @urls }\n end\n end",
"def index\n @urls = ShortenedUrl.order(\"updated_at ASC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { re... | [
"0.6885968",
"0.66887754",
"0.66787374",
"0.66593164",
"0.6529249",
"0.6509962",
"0.64914274",
"0.6448754",
"0.64453053",
"0.6409037",
"0.64083",
"0.6267918",
"0.6236266",
"0.6223829",
"0.6216287",
"0.62162524",
"0.620276",
"0.6169882",
"0.6138518",
"0.6119957",
"0.61180186",... | 0.0 | -1 |
POST /urls POST /urls.json | def create
@url = Url.new(url_params)
respond_to do |format|
if @url.save
format.html { redirect_to @url, notice: 'Url was successfully created.' }
format.json { render action: 'show', status: :created, location: @url }
wordcount
else
format.html { render action: 'new' }
format.json { render json: @url.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n params[:url_list].each do |url|\n WebUrl.new(:url => url).save\n end\n render :json=>params[:url_list].to_json\n end",
"def create_api\n\n @url = Url.new(:url => params[:url])\n\n if @url.save\n url_hash = Hash.new\n\n url_hash[:short_url] = root_url.to_s() + \"urls_ap... | [
"0.66614103",
"0.6225674",
"0.62237",
"0.6133381",
"0.6110082",
"0.60986954",
"0.60519725",
"0.60070646",
"0.5954528",
"0.59431005",
"0.5926763",
"0.58907574",
"0.5872233",
"0.58240664",
"0.58098954",
"0.57900316",
"0.57866234",
"0.5748828",
"0.57442534",
"0.571095",
"0.57022... | 0.58478326 | 13 |
Use callbacks to share common setup or constraints between actions. | def set_url
@url = Url.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def url_params
params.require(:url).permit(:url)
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 |
GET /employees_roles GET /employees_roles.json | def index
@employees_role = EmployeesRole.new()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_roles\n @roles = @user.roles.pluck(:name)\n render json: @roles\n end",
"def get_roles_list()\n\n query_parameters = {}\n query_parameters['apiKey'] = @api_key\n query_parameters['apiSecret'] = @api_secret\n\n resource_path = 'identity/v2/manage/role'\n get_request(re... | [
"0.7573759",
"0.70972234",
"0.7097008",
"0.7073955",
"0.70428145",
"0.7024727",
"0.6975401",
"0.6956922",
"0.6892282",
"0.688904",
"0.6878822",
"0.6861661",
"0.68243915",
"0.6807193",
"0.6805941",
"0.6790079",
"0.6789559",
"0.67667943",
"0.6763699",
"0.6755896",
"0.6697902",
... | 0.6228877 | 71 |
POST /employees_roles POST /employees_roles.json | def create
@employees_role = EmployeesRole.create(employees_role_params)
redirect_to employees_roles_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_employee_role(body:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v1/me/roles'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => ... | [
"0.7080383",
"0.68218297",
"0.6687899",
"0.6650206",
"0.6552826",
"0.6469759",
"0.6410619",
"0.6390163",
"0.63549286",
"0.63196176",
"0.6303331",
"0.63011956",
"0.62763643",
"0.6245801",
"0.6241004",
"0.62396085",
"0.62288684",
"0.62150186",
"0.61875415",
"0.61672366",
"0.614... | 0.7312509 | 0 |
DELETE /employees_roles/1 DELETE /employees_roles/1.json | def destroy
@employees_role.disable!
redirect_to employees_roles_path, :alert => "Employees_Roles disabled."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @company = Company.find(params[:company_id])\n @role = Role.find(params[:id])\n @role.destroy\n \n respond_to do |format|\n format.html { redirect_to company_roles_path(@company) }\n format.json { head :no_content }\n end\n end",
"def destroy\n chef_server_rest.delete... | [
"0.71176326",
"0.70981854",
"0.7010913",
"0.7004338",
"0.69940305",
"0.6977842",
"0.69690055",
"0.69353807",
"0.6933423",
"0.6915135",
"0.69101447",
"0.6894705",
"0.68750685",
"0.68716884",
"0.6841944",
"0.6835002",
"0.68312514",
"0.6824029",
"0.68176633",
"0.6806977",
"0.679... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def employees_role_params
params.require(:employees_role).permit!
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 |
clean up the filters so only valid ones exist | def clean_filters
cleaned_filters = {}
self.filters.each do |name, value|
if (self.filter_options[name.to_sym][:fields].detect{|f| f[:value] == value } rescue false)
cleaned_filters[name.to_sym] = value
end
end
self.filters = cleaned_filters
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_filters\n params = instance_values.symbolize_keys\n filters = clean_params(params)\n validate_filters(filters)\n end",
"def remove_filters!\n @filters = []\n end",
"def filters; end",
"def filters; end",
"def set_filters\n @filters = ''\n @filters.concat(\"status:'Avail... | [
"0.794043",
"0.7490198",
"0.7308222",
"0.7308222",
"0.71641165",
"0.71485585",
"0.7070446",
"0.7038898",
"0.7034479",
"0.6862236",
"0.68190986",
"0.67827415",
"0.67598474",
"0.67598474",
"0.67598474",
"0.67114085",
"0.67074555",
"0.67074555",
"0.6700287",
"0.66866624",
"0.667... | 0.8127907 | 0 |
Now capture maximum stack depth reached | def max_depth &blk
xmax = 0
loop do
begin
xmax = [xmax, yield].max
rescue HaltState
raise StopIteration
end
end
xmax
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_level_depth\n MAXIMUM_LEVEL_DEPTH\n end",
"def my_depth\n 1\n end",
"def depth=(_arg0); end",
"def stack; end",
"def stack; end",
"def stack_depth\n @stack.size\n end",
"def depth; end",
"def max_nesting=(depth)\n #This is a stub, used for indexing\n... | [
"0.67450094",
"0.668409",
"0.66827315",
"0.6663168",
"0.6663168",
"0.6590127",
"0.65386474",
"0.6512906",
"0.64937514",
"0.6424617",
"0.6372019",
"0.6370233",
"0.626721",
"0.62181246",
"0.6193175",
"0.61604714",
"0.6135609",
"0.61037326",
"0.6102831",
"0.6093379",
"0.6084884"... | 0.5959136 | 22 |
Should not be same stack depth, must be smaller | def test_fact_aps_should_result_smaller_max_depth_for_tail_call
vi = mkvi src_fact_aps; ti = mkti src_fact_aps
vmax = max_depth { vi.step; vi.frames.length }
tmax = max_depth { ti.step; ti.frames.length }
assert tmax < vmax, "Expected #{tmax} to be less than #{vmax}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stack; end",
"def stack; end",
"def depth; end",
"def depth=(_arg0); end",
"def my_depth\n 1\n end",
"def recursive => nil",
"def nesting() end",
"def to_stack; end",
"def depth_min; depths.min end",
"def deepest_cause; end",
"def test_inorder_stack_no_change\n a = [1, 2, 3, 4]\n... | [
"0.69032776",
"0.69032776",
"0.67008334",
"0.6506748",
"0.64947563",
"0.6449063",
"0.6427461",
"0.6276969",
"0.60935307",
"0.60789",
"0.6013681",
"0.59305847",
"0.58943874",
"0.5877971",
"0.58657676",
"0.58018625",
"0.5788122",
"0.5749958",
"0.5745213",
"0.5733999",
"0.573105... | 0.0 | -1 |
simple block: TODO: Must handle toplevel block | def test_simple_block_will_tail_call
src =<<-EOC
defn t() {
defn g() { 2;9}
{3;%g}
}
%t
EOC
vi = mkvi src; ti = mkti src
vmax = max_depth { vi.step; vi.frames.length }
tmax = max_depth { ti.step; ti.frames.length }
assert tmax < vmax, "Expected #{tmax} to be less than #{vmax}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035",
"0.74986035"... | 0.0 | -1 |
test return via tail call | def test_will_return_via_tail_call
src =<<-EOC
defn g() {9}
defn f(x) {
zero?(:x) && return %g
%g + 9
}
EOC
vi = mkvi src+"\nf(0)\n";ti = mkti src+"\nf(0)\n"
assert (vi.run == 9) && (ti.run == 9), "Expected both optimized and non_optiized to return9, but one of them did not"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_ending(_result)\n end",
"def demonstrate_early_return\n return\n puts \"You will never see this, because we never get here.\"\nend",
"def call\n [false, yield]\n rescue halt => e\n [true, e.payload[0]]\n end",
"def success?() end",
"def exit(res=0) end",... | [
"0.6785964",
"0.6284976",
"0.624223",
"0.62293106",
"0.6119412",
"0.6087102",
"0.60093004",
"0.59873486",
"0.5900966",
"0.58965045",
"0.5880964",
"0.5872966",
"0.58577317",
"0.58067894",
"0.57845235",
"0.57704794",
"0.57646817",
"0.5745195",
"0.5735738",
"0.57289803",
"0.5717... | 0.6735239 | 1 |
Should tail call within nonlambda bodies E.g. toplevel blocks, conditionals | def test_does_not_convert_lambdacalls_to_tailcalls_for_top_level_constructs
tcompile 'defn g() {9}; {1; %g}'
tail_found = false
lambdacall_found = false
visit_tree @tc.ast, lambdacall: ->(x) { lambdacall_found = true }, tailcall: ->(x) { tail_found = true }
assert !tail_found, "Expected to not find any :tailcalls, but did"
assert lambdacall_found, "Expected to find a :lambdacall node"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_top_level_conditionals_should_not_have_tail_calls\n tcompile 'zero?(0) && %g'\n tail_found = false\n lambdacall_found = false\n visit_tree @tc.ast, lambdacall: ->(x) { lambdacall_found = true }, tailcall: ->(x) { tail_found = true }\n assert !tail_found, \"Expected to not find any :tailca... | [
"0.7241717",
"0.690801",
"0.64395726",
"0.63621336",
"0.6343288",
"0.62677443",
"0.6192723",
"0.61860776",
"0.6120529",
"0.6111363",
"0.6101398",
"0.609224",
"0.60827696",
"0.6073877",
"0.60052836",
"0.60052836",
"0.60052836",
"0.5989503",
"0.5989185",
"0.59751594",
"0.596835... | 0.68060917 | 2 |
Should not have any tail calls for toplevel conditionals, either. | def test_top_level_conditionals_should_not_have_tail_calls
tcompile 'zero?(0) && %g'
tail_found = false
lambdacall_found = false
visit_tree @tc.ast, lambdacall: ->(x) { lambdacall_found = true }, tailcall: ->(x) { tail_found = true }
assert !tail_found, "Expected to not find any :tailcalls, but did"
assert lambdacall_found, "Expected to find a :lambdacall node"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def naked_top_level?; end",
"def naked_top_level; end",
"def test_non_tail_position_blocks_cannot_have_tailcalls\n tails_found = 0\n tcompile 'defn foo() {{9; %g}; 99}'\n visit_tree @tc.ast, tailcall:->(x) {tails_found += 1 }\n assert tails_found.zero?, \"Expected to not find any tail calls, but fo... | [
"0.7108519",
"0.6499122",
"0.6320789",
"0.61334276",
"0.61334276",
"0.61334276",
"0.60807234",
"0.6032399",
"0.6032399",
"0.6032399",
"0.5990137",
"0.5982177",
"0.5982177",
"0.5909732",
"0.59077466",
"0.58573425",
"0.580224",
"0.5733866",
"0.5727014",
"0.566493",
"0.56537306"... | 0.71061885 | 1 |
Cannot have tail calls in blocks that are not the tail position inside lambdas. Must refrain from promoting anything in block or conditional into tailcall. | def test_non_tail_position_blocks_cannot_have_tailcalls
tails_found = 0
tcompile 'defn foo() {{9; %g}; 99}'
visit_tree @tc.ast, tailcall:->(x) {tails_found += 1 }
assert tails_found.zero?, "Expected to not find any tail calls, but found #{tails_found} instead"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_does_not_convert_lambdacalls_to_tailcalls_for_top_level_constructs\n tcompile 'defn g() {9}; {1; %g}'\n tail_found = false\n lambdacall_found = false\n visit_tree @tc.ast, lambdacall: ->(x) { lambdacall_found = true }, tailcall: ->(x) { tail_found = true }\n assert !tail_found, \"Expected t... | [
"0.6700456",
"0.6526589",
"0.6526163",
"0.6451164",
"0.6203788",
"0.6100986",
"0.6070055",
"0.6023657",
"0.59866434",
"0.5948143",
"0.59413046",
"0.59318626",
"0.58681124",
"0.58627313",
"0.58618885",
"0.5852341",
"0.5849713",
"0.584776",
"0.58378494",
"0.58378494",
"0.582796... | 0.6599951 | 1 |
GET /tutorials GET /tutorials.json | def index
@search = Tutorial.search(params[:q])
@tutorials = @search.result.where(suggestion: false).page(params[:page]).per(5).order('created_at DESC')
@suggestions = @search.result.where(suggestion: true).page(params[:page]).per(5).order('created_at DESC')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tutorials }\n end\n end",
"def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html\n format.json do\n render json: @tutor... | [
"0.76766384",
"0.7651599",
"0.73566383",
"0.72547084",
"0.67954177",
"0.67954177",
"0.67930365",
"0.67930365",
"0.67266923",
"0.6671137",
"0.6664682",
"0.6612035",
"0.6605375",
"0.65844387",
"0.6584147",
"0.65572023",
"0.6529032",
"0.65067923",
"0.64678335",
"0.6459095",
"0.6... | 0.0 | -1 |
GET /tutorials/1 GET /tutorials/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tutorials }\n end\n end",
"def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html\n format.json do\n render json: @tutor... | [
"0.7621065",
"0.758367",
"0.7509276",
"0.7332348",
"0.69647455",
"0.69647455",
"0.67902",
"0.67004806",
"0.66976464",
"0.6686013",
"0.66804034",
"0.66611755",
"0.6650495",
"0.66296536",
"0.66223055",
"0.66203606",
"0.66203606",
"0.6610281",
"0.65733653",
"0.6518051",
"0.65089... | 0.0 | -1 |
POST /tutorials POST /tutorials.json | def create
@tutorial = Tutorial.new(tutorial_params)
respond_to do |format|
if @tutorial.save
format.html { redirect_to @tutorial, notice: 'Tutorial was successfully created.' }
format.json { render action: 'show', status: :created, location: @tutorial }
else
format.html { render action: 'new' }
format.json { render json: @tutorial.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @tutorials = Tutorial.all\n @tutorial = Tutorial.new(tutorial_params)\n\n if @tutorial.save\n render json: @tutorial\n else\n render json: @tutorial.errors.full_messages, status:400\n end\n end",
"def create\n @tutorial = current_user.tutorials.create(tutorial_... | [
"0.76698226",
"0.7308089",
"0.6955424",
"0.6955424",
"0.68650454",
"0.68634087",
"0.67928624",
"0.6764526",
"0.66929144",
"0.66929144",
"0.66369426",
"0.6636901",
"0.66156876",
"0.65631616",
"0.6539225",
"0.6455816",
"0.6441011",
"0.6339235",
"0.6326344",
"0.62354505",
"0.622... | 0.68600416 | 6 |
PATCH/PUT /tutorials/1 PATCH/PUT /tutorials/1.json | def update
respond_to do |format|
if @tutorial.update(tutorial_params)
format.html { redirect_to @tutorial, notice: 'Tutorial was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @tutorial.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @tutorial = Tutorial.find(params[:id])\n\n respond_to do |format|\n if @tutorial.update_attributes(params[:tutorial])\n format.html { redirect_to @tutorial, notice: 'Tutorial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren... | [
"0.66692483",
"0.66692483",
"0.66230613",
"0.66168857",
"0.66019565",
"0.64313674",
"0.64128816",
"0.62854636",
"0.62485856",
"0.617944",
"0.6116152",
"0.6110436",
"0.6091951",
"0.60826355",
"0.60359186",
"0.6025176",
"0.60157734",
"0.59678245",
"0.5939726",
"0.5926772",
"0.5... | 0.6698879 | 0 |
DELETE /tutorials/1 DELETE /tutorials/1.json | def destroy
@tutorial.destroy
respond_to do |format|
format.html { redirect_to tutorials_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @tutorial = Tutorial.find(params[:id])\n @tutorial.destroy\n render json: @tutorial\n end",
"def destroy\n @tutorial = Tutorial.find(params[:id])\n @tutorial.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorials_url }\n format.json { head :no_content ... | [
"0.77756006",
"0.77635777",
"0.76979846",
"0.7655823",
"0.7637724",
"0.7615782",
"0.7406003",
"0.7403622",
"0.7369901",
"0.7306867",
"0.7271038",
"0.72081655",
"0.72025627",
"0.71776426",
"0.7145344",
"0.71135455",
"0.7080351",
"0.70493287",
"0.7030867",
"0.70085275",
"0.6996... | 0.78816277 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_tutorial
@tutorial = Tutorial.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 tutorial_params
params.require(:tutorial).permit(:title, :functionality, :learning_language_ids, :body, :suggestion)
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.69802505",
"0.6781974",
"0.67470175",
"0.67430073",
"0.67350477",
"0.6593221",
"0.6504263",
"0.64988977",
"0.6481794",
"0.64800006",
"0.64568025",
"0.64411247",
"0.6379476",
"0.63765615",
"0.6368045",
"0.6320141",
"0.6300363",
"0.6300057",
"0.62952244",
"0.6294712",
"0.629... | 0.0 | -1 |
Right now we have /v2/exercises and /v2/exercises/:track_id. Let's tweak the /v2/exercises to take an optional parameter ?tracks=a,b,c and if that parameter is passed, only return the data for those tracks. | def test_that_you_may_filter_to_single_track
getting '/v2/exercises?tracks=fruit'
returns_tracks %w( fruit )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:track_id]\n @track = Track.find(params[:track_id])\n @events = Event.where(track_id: params[:track_id]).where(event_type: 'track')\n else\n @events = Event.all\n end\n end",
"def search_track(opts = {}, &block)\n if opts.is_a? String\n query = opts\n ... | [
"0.606591",
"0.57334566",
"0.5726674",
"0.56712407",
"0.558732",
"0.55744505",
"0.5491342",
"0.54742",
"0.5463494",
"0.5418604",
"0.5404517",
"0.54043984",
"0.53959787",
"0.5373809",
"0.5305484",
"0.52836776",
"0.5282571",
"0.5272556",
"0.52332693",
"0.52332693",
"0.52280957"... | 0.7185951 | 0 |
def initialize( credit_card_processor ) | def renew_business_subscription( user, package, business, credit_card)
charge_and_subscribe user, package, business, nil, credit_card
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(card_number_or_token, card_expiry_month = nil, card_expiry_year = nil, card_cvc = nil)\n if card_expiry_month == nil\n @card_token = card_number_or_token\n else\n @card_number = card_number_or_token\n @card_expiry_month = card_expiry_month\n @card_expiry_year = ... | [
"0.70009565",
"0.694839",
"0.68983704",
"0.6884361",
"0.68617547",
"0.6840973",
"0.6826779",
"0.6819645",
"0.6773246",
"0.67632383",
"0.6742972",
"0.673884",
"0.6732884",
"0.6672971",
"0.6658415",
"0.66534555",
"0.6631368",
"0.6629951",
"0.6596177",
"0.6596177",
"0.6596177",
... | 0.0 | -1 |
Debit the label's account, and each parent up the tree. | def debit_sign_up user, transaction_event, label
return if label.nil?
# It's ok if the balance goes negative, we want the sign up either way. This is an atomic update
Label.update_all("available_balance = available_balance - package_signup_rate", {id: label.id})
label.reload
ce = CreditEvent.create(label_id: label.id,
user_id: user.id,
charge_amount: (-1) * label.package_signup_rate,
post_available_balance: label.available_balance,
note: "Business sign up",
action: "sign up",
transaction_event_id: transaction_event.id)
debit_sign_up(user, transaction_event, label.parent)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debit\n @debit ||= begin\n @debit = if parent\n expenses.debit.sum(:transaction_amount)\n else\n children.inject(0) { |total, child| total += child.debit }\n end\n end\n end",
"def unbranch\n @child\n end",
"def down\n @level += 1\n add_newline\n ... | [
"0.6143413",
"0.5633018",
"0.55283314",
"0.54975086",
"0.52922297",
"0.5230875",
"0.5215906",
"0.5189633",
"0.51758176",
"0.5163152",
"0.5151609",
"0.51502055",
"0.5149883",
"0.51460785",
"0.5141521",
"0.51234025",
"0.51225007",
"0.5096106",
"0.509563",
"0.5074093",
"0.502501... | 0.62035877 | 0 |
Each month, debit the label for each active subscription. Care has been taken so that this job, which usually runs from a cron > rake task, can safely be rerun in case an error occurs. | def debit_monthly_subscriptions
ccp = CreditCardProcessor.new(@label)
# subscriptions dont start for atleast a month after being created.
# filter out any recently billed subscriptions. This allows a job to rerun safely if an error occurs.
@label.subscriptions.where('created_at < ? and label_last_billed_at <= ?', 1.month.ago, 1.month.ago).where(status: :success).each do |subscription|
if ccp.valid_recurring( subscription )
debit_monthly_subscription @label, subscription
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def month_label\n \"#{label}\"\n end",
"def perform\n @previousMonth = (Date.today - 1.months).strftime(\"%Y-%m\")\n\n \t# Only exec with subscription status is active\n # Subscription subscription_type == 1 is free trial\n # If user upgrade subscription, and then subscription_type update to 2 is i... | [
"0.5627847",
"0.554653",
"0.55419827",
"0.5530015",
"0.5518673",
"0.5309939",
"0.52983016",
"0.5261452",
"0.5261452",
"0.52268386",
"0.5170234",
"0.5152929",
"0.50666344",
"0.50568134",
"0.50348157",
"0.50147647",
"0.5014254",
"0.49698037",
"0.49676493",
"0.49538717",
"0.4953... | 0.72310346 | 0 |
Obtiene el numero de repeticiones del conjunto de datos por caracter Y carga los datos al objeto Information del array | def get_Table(value, elements)
#arr_data = values.clone #recivimos el arreglo de elementos y copiamos
countArray = Array.new()
array = value.split("")
for i in 0..(elements.length - 1)
elements[i].setTimes(array.count(elements[i].getCode()))##Cargamos los datos al objeto Inormation
end
return elements
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asignador\n alum = []\n line = read_alumnos\n line.each do |alumno|\n contador = 0\n arr = alumno.split(' ')\n arr.each do |x|\n contador += 1 if x == 'A'\n end\n alum << Alumnos.new(arr[0], arr[1], arr[2], arr[3], contador)\n end\n alum\nend",
"def nombres_comunes\n datos = eval(... | [
"0.5802085",
"0.5763871",
"0.56955564",
"0.5683279",
"0.55540043",
"0.5542687",
"0.55140877",
"0.545684",
"0.545295",
"0.54402584",
"0.53586465",
"0.53525424",
"0.53054714",
"0.5277477",
"0.52665687",
"0.5254182",
"0.5229877",
"0.5223083",
"0.52073264",
"0.52040786",
"0.52017... | 0.5728942 | 2 |
GET /armas/1 GET /armas/1.json | def show
@arma = Arma.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @aroma = Aroma.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aroma }\n end\n end",
"def show\n @ramal = Ramal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render... | [
"0.71906567",
"0.6847012",
"0.6815357",
"0.66430825",
"0.66130096",
"0.65958613",
"0.6588227",
"0.6536431",
"0.6484815",
"0.6477601",
"0.6453134",
"0.6451618",
"0.64361244",
"0.6421455",
"0.6420411",
"0.6410161",
"0.6408766",
"0.64047074",
"0.6392062",
"0.63905627",
"0.638023... | 0.6253763 | 44 |
GET /armas/new GET /armas/new.json | def new
@arma = Arma.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @arma }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @aroma = Aroma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @aroma }\n end\n end",
"def new\n @manga = Manga.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manga }\n end\n end"... | [
"0.7549714",
"0.7383404",
"0.7377255",
"0.7367986",
"0.730991",
"0.72938913",
"0.72883743",
"0.72838646",
"0.72799796",
"0.7267717",
"0.72607434",
"0.72563845",
"0.72356594",
"0.7224617",
"0.7216198",
"0.7216198",
"0.7216198",
"0.7209998",
"0.7201315",
"0.71820986",
"0.717998... | 0.74300873 | 1 |
POST /armas POST /armas.json | def create
@arma = Arma.new(params[:arma])
respond_to do |format|
if @arma.save
format.html { redirect_to @arma, notice: 'Arma was successfully created.' }
format.json { render json: @arma, status: :created, location: @arma }
else
format.html { render action: "new" }
format.json { render json: @arma.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @armazena = Armazena.new(armazena_params)\n\n respond_to do |format|\n if @armazena.save\n format.html { redirect_to @armazena, notice: 'Armazena was successfully created.' }\n format.json { render :show, status: :created, location: @armazena }\n else\n format.html... | [
"0.6315217",
"0.63119906",
"0.6170182",
"0.6012161",
"0.59608924",
"0.592838",
"0.5910538",
"0.5907308",
"0.5897372",
"0.58575916",
"0.5857578",
"0.5840712",
"0.58275205",
"0.5826234",
"0.5800352",
"0.57831806",
"0.57798153",
"0.576889",
"0.57540303",
"0.57385564",
"0.5730596... | 0.6746256 | 0 |
PUT /armas/1 PUT /armas/1.json | def update
@arma = Arma.find(params[:id])
respond_to do |format|
if @arma.update_attributes(params[:arma])
format.html { redirect_to @arma, notice: 'Arma was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @arma.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
... | [
"0.62828606",
"0.62345004",
"0.6135801",
"0.60945356",
"0.600059",
"0.59718084",
"0.59200907",
"0.5910291",
"0.58377844",
"0.58332145",
"0.5823986",
"0.5819997",
"0.5819997",
"0.58075976",
"0.57939506",
"0.57937175",
"0.5772021",
"0.57697093",
"0.5755873",
"0.57325506",
"0.57... | 0.62137115 | 2 |
DELETE /armas/1 DELETE /armas/1.json | def destroy
@arma = Arma.find(params[:id])
@arma.destroy
respond_to do |format|
format.html { redirect_to armas_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def del... | [
"0.7387626",
"0.7325976",
"0.70670795",
"0.7022399",
"0.69331324",
"0.6904006",
"0.6823416",
"0.68159956",
"0.6815535",
"0.6791774",
"0.675919",
"0.675789",
"0.6756564",
"0.6753797",
"0.67472506",
"0.6733369",
"0.671898",
"0.6717733",
"0.6716567",
"0.6712523",
"0.67095405",
... | 0.6899469 | 6 |
Initialize a new instance. | def initialize
@hash = lens_keys.map { |k| [k, nil] }.to_h.with_indifferent_access
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize\n init\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n ... | [
"0.8421217",
"0.8421217",
"0.8369548",
"0.8332979",
"0.83191633",
"0.83191633",
"0.83191633",
"0.83191633",
"0.83191633",
"0.83191633",
"0.8306204",
"0.8198475",
"0.8196622",
"0.8015988",
"0.8015988",
"0.8015988",
"0.8015988",
"0.8015988",
"0.8015988",
"0.8015988",
"0.8015988... | 0.0 | -1 |
Retrieve lens by key. | def [](key)
key = key_for(key, false)
@hash[key] if key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(key)\n get_all(key).first\n end",
"def [](key)\n key = convert_key(key)\n regular_reader(key)\n end",
"def get(key)\n @manager.retrieve(key)\n end",
"def [](*key)\n get(*key)\n end",
"def [](key)\n fetch(key)\n end",
"def read(key)\n perform_read(:r... | [
"0.66972464",
"0.66490626",
"0.65541035",
"0.65483165",
"0.65420663",
"0.64959085",
"0.64853114",
"0.64756656",
"0.6335023",
"0.6335023",
"0.6335023",
"0.6335023",
"0.63267547",
"0.62444645",
"0.62404275",
"0.6240061",
"0.62381667",
"0.621151",
"0.6187879",
"0.61837876",
"0.6... | 0.0 | -1 |
Set lens by key. | def []=(key, entry)
key = key_for(key) unless valid_key?(key)
@hash[key] = entry if key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lset(key, index, value); end",
"def lset(key, index, value); end",
"def lset(key, index, value)\n send_command([:lset, key, Integer(index), value])\n end",
"def key=(key); end",
"def set(key, val = nil)\n @statistics[:set] += 1\n with_branch_for(key) do |branch|\n branch.se... | [
"0.67129654",
"0.67129654",
"0.6519039",
"0.63984656",
"0.62730616",
"0.62324435",
"0.62141365",
"0.62141365",
"0.6107315",
"0.6085474",
"0.6068545",
"0.6061341",
"0.60493135",
"0.6044077",
"0.6044077",
"0.6040151",
"0.5997749",
"0.5981817",
"0.59637684",
"0.5940847",
"0.5928... | 0.0 | -1 |
depends_on "cmake" => :build | def install
# ENV.deparallelize # if your formula fails when building in parallel
# Remove unrecognized options if warned by configure
# system "./configure", "--disable-debug",
# "--disable-dependency-tracking",
# "--disable-silent-rules",
# "--prefix=#{prefix}"
# system "cmake", ".", *std_cmake_args
# system "make", "install" # if this fails, try separate make/make install steps
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def package_depends_on\n depends_on\n end",
"def install\n# Dependency tracking only, uncomment this section only if you know what you\n# are doing!\n#\n# mkdir 'build'\n# cd 'build' do\n# system \"cmake .. #{std_cmake_parameters}\"\n# system \"make package\"\n# end\nend",
"def ... | [
"0.6862918",
"0.67779785",
"0.6605081",
"0.6427604",
"0.6401638",
"0.6370821",
"0.62428576",
"0.6164104",
"0.6164104",
"0.6134335",
"0.6026515",
"0.6026515",
"0.6026515",
"0.594891",
"0.59437174",
"0.5839825",
"0.5780695",
"0.5748207",
"0.57473993",
"0.57118607",
"0.56998265"... | 0.0 | -1 |
Save auto scale group | def group_save(group)
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_save\n api.group_save(self)\n end",
"def auto_scaling_group_name\n data.auto_scaling_group_name\n end",
"def save_groups\n self.groups.each { |c| if c.destroy_association? then c.destroy else c.save end }\n self.added_groups.each { |c| c.save unless c.nil? } unless... | [
"0.63678324",
"0.57937557",
"0.57171226",
"0.5675286",
"0.5606568",
"0.55539775",
"0.55265784",
"0.55089664",
"0.55089664",
"0.5476972",
"0.5460333",
"0.5449027",
"0.54341185",
"0.540207",
"0.53455514",
"0.5318177",
"0.5265907",
"0.5244669",
"0.52410775",
"0.5230672",
"0.5198... | 0.6210058 | 1 |
Reload the group data from the API | def group_reload(group)
if(group.persisted?)
result = request(
:method => :get,
:path => "/groups/#{group.id}",
:expects => 200
)
grp = result.get(:body, :group)
group.load_data(
:name => grp.get('groupConfiguration', :name),
:minimum_size => grp.get('groupConfiguration', 'minEntities'),
:maximum_size => grp.get('groupConfiguration', 'maxEntities'),
:desired_size => grp.get(:state, 'desiredCapacity'),
:current_size => grp.get(:state, 'activeCapacity'),
:servers => grp.get(:state, :active).map{|s| AutoScale::Group::Server.new(self, :id => s[:id])}
).valid_state
else
group
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_reload\n api.group_reload(self)\n end",
"def fetch_group_data\n response = fetch_data(@@SETTINGS.group_tab)\n unless response.nil?\n adjust_groups response\n end\n end",
"def refresh_ce_group!\n self.save! if refresh_ce_group\n end",
"def refresh\n fetch_... | [
"0.81318593",
"0.703726",
"0.6859572",
"0.6815805",
"0.6695819",
"0.6631904",
"0.6581476",
"0.656722",
"0.6537091",
"0.6537091",
"0.64264214",
"0.64112556",
"0.64005286",
"0.6383394",
"0.63491476",
"0.63233507",
"0.6278371",
"0.62172574",
"0.61674315",
"0.6104667",
"0.6093864... | 0.7543723 | 1 |
Delete auto scale group | def group_destroy(group)
if(group.persisted?)
request(
:path => "/groups/#{group.id}",
:method => :delete,
:expects => 204
)
true
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_asg name\n auto_scaling = new_auto_scaling\n groups = auto_scaling.groups\n raise \"unable to delete asg, #{name}. asg not found!\" if groups[name].nil? \n\n asg = groups[name]\n\n puts \"deleting asg, #{asg.name}\"\n asg.delete({:force => true})\n delete_launch_configs\nend",
"def del... | [
"0.6906662",
"0.68263584",
"0.6776696",
"0.6706074",
"0.6706074",
"0.65363663",
"0.64924675",
"0.63809776",
"0.6305741",
"0.6263097",
"0.6256154",
"0.62538105",
"0.6232756",
"0.61864233",
"0.6177051",
"0.6145282",
"0.61311674",
"0.6118659",
"0.6112829",
"0.6092973",
"0.605613... | 0.0 | -1 |
Return all auto scale groups | def group_all(options={})
result = request(
:method => :get,
:path => '/groups',
:expects => 200
)
result.fetch(:body, 'groups', []).map do |lb|
Group.new(
self,
:id => lb[:id],
:name => lb.get(:state, :name),
:current_size => lb.get(:state, 'activeCapacity'),
:desired_size => lb.get(:state, 'desiredCapacity')
).valid_state
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_groups\n @@client.describe_auto_scaling_groups.auto_scaling_groups\n end",
"def autoscaling_instances\n autoscaling_group.auto_scaling_instances\n end",
"def autoscaling_instances\n autoscaling_group.auto_scaling_instances\n end",
"def getAsgs()\n options = Hash.new\n asgs ... | [
"0.70269644",
"0.6789279",
"0.6789279",
"0.66555667",
"0.64899504",
"0.6219308",
"0.6133411",
"0.6043947",
"0.60395217",
"0.59962046",
"0.5972055",
"0.5927886",
"0.5867459",
"0.5840454",
"0.58295584",
"0.5819522",
"0.5819522",
"0.5819522",
"0.57992727",
"0.5747224",
"0.574454... | 0.539694 | 45 |
Actions to not authorized users | def user_not_authorized
#flash[:alert] = "You are not cool enough to do this - go back from whence you came."
redirect_to root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unauthorized\n end",
"def unauthorized_user!\n if @user != current_user\n redirect_to root_path, status: :unauthorized, alert: 'You can only perform this action on your own user!'\n end\n end",
"def authorize_unauthenticated_user\n target_action = params[:controller] + '#' + params[:action]... | [
"0.7613339",
"0.7581469",
"0.756388",
"0.7373604",
"0.72696954",
"0.71314347",
"0.71256775",
"0.70912206",
"0.70816797",
"0.7051413",
"0.70486206",
"0.6971704",
"0.69712406",
"0.6966304",
"0.69630015",
"0.69587594",
"0.6951655",
"0.6947262",
"0.69447285",
"0.6943064",
"0.6942... | 0.65635943 | 60 |
Sets the default options for the scope specified by `name` | def list_default_options(name, options = {})
write_inheritable_attribute(:list_options, {}) if list_options.nil?
list_options[name] = Facade.options[:default_options].merge(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_default_options\n end",
"def default_options=(opts); end",
"def merge_default_options(name, type, options = {})\n list_options[name][type].merge(options)\n\t\tend",
"def reset!\n @options = Name.defaults.dup\n end",
"def set_default(name, options = {})\n value = options... | [
"0.676358",
"0.6623187",
"0.6401575",
"0.63101536",
"0.6235039",
"0.61169153",
"0.60953236",
"0.60657513",
"0.6007901",
"0.6007901",
"0.5992962",
"0.5937585",
"0.59060174",
"0.58734804",
"0.58436984",
"0.58228767",
"0.5811458",
"0.57931924",
"0.57927626",
"0.57927626",
"0.578... | 0.63188994 | 3 |
Used to build up find conditions | def list_conditions
@list_conditions ||= FilterFoo.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_find_conditions\n segments = conditions.collect{|c| c.to_find_conditions }.compact\n return nil if segments.length == 0\n cond = \"(\" + segments.collect{|s| s.first }.join(\" #{logical_join} \") + \")\"\n cond = \"NOT #{cond}\" if negative?\n \n values ... | [
"0.7750529",
"0.73080724",
"0.6943984",
"0.6943984",
"0.69348395",
"0.6831513",
"0.68062663",
"0.68055755",
"0.67975813",
"0.6724154",
"0.6724154",
"0.6719735",
"0.66896504",
"0.6653267",
"0.6626202",
"0.66193515",
"0.65248454",
"0.65248454",
"0.6521814",
"0.6506107",
"0.6462... | 0.0 | -1 |
Calls the normal AR Find. | def list_all(name, options)
records = find(:all, :limit => options[:limit], :offset => options[:offset])
if options[:skip_count]
record_count = records.size
else
record_count = count
end
return records, record_count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(*args)\n ids = args.__find_args__\n raise_invalid if ids.any?(&:nil?)\n for_ids(ids).execute_or_raise(ids, args.multi_arged?)\n end",
"def find(*args)\n records = super\n @after.call(records) if @after\n records\n end",
"def find\n fail NotImplemented... | [
"0.68188155",
"0.6641349",
"0.654066",
"0.65130997",
"0.6494829",
"0.64695895",
"0.64359516",
"0.6426932",
"0.6382272",
"0.6382272",
"0.63601744",
"0.626543",
"0.6230573",
"0.6226791",
"0.61963767",
"0.6192396",
"0.6178923",
"0.61661744",
"0.6158785",
"0.61300707",
"0.6088858... | 0.0 | -1 |
Throws InvalidListOptions if options were passed that shouldn't have been. | def sanitize_options(options)
options.keys.each do |key|
unless Facade.options[:valid_find_options].include?(key) || Facade.options[:valid_list_options].include?(key)
raise InvalidListOptions, "Bad key passed: #{key}"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_arguments!(list)\n chk_idx = list.find_index do |item|\n item.start_with?(\"-\")\n end\n if chk_idx\n marker = list.find_index do |item|\n item == \"--\"\n end\n if marker.nil? || chk_idx.to_i < marker\n raise ArgumentError... | [
"0.60217386",
"0.5918961",
"0.5694803",
"0.56383955",
"0.5546811",
"0.5538718",
"0.5532386",
"0.5525195",
"0.550749",
"0.550749",
"0.550749",
"0.550749",
"0.550749",
"0.550749",
"0.550749",
"0.550749",
"0.550749",
"0.550749",
"0.550749",
"0.5477994",
"0.54726887",
"0.543106... | 0.6877995 | 0 |
Merge options for a specified name and type into the defaults and return the result. | def merge_default_options(name, type, options = {})
list_options[name][type].merge(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_defaults(options = {})\n defaults = {}\n # defaults[:character_name] = @charater_name if @charater_name\n defaults[:region] = @region if @region\n defaults[:caching] = @caching if @caching\n defaults[:cache_timeout] = @cache_timeout if @c... | [
"0.6763694",
"0.66728336",
"0.6660936",
"0.6320446",
"0.6311713",
"0.6286139",
"0.62812316",
"0.62222826",
"0.6202263",
"0.6159285",
"0.61196816",
"0.61132604",
"0.6086944",
"0.6043457",
"0.6018442",
"0.5958097",
"0.5932961",
"0.5932961",
"0.5873984",
"0.5847051",
"0.58383256... | 0.8110009 | 0 |
Determines the :order value that gets passed to find. | def get_list_order(sort, dir)
if sort
column_order_mapping = get_sext_constant('SEXT_COLUMN_ORDER_MAPPING')
# Lookup and use the designated ordering if defined in the model.
if column_order_mapping && column_order_mapping.has_key?(sort.to_sym)
sort = column_order_mapping[sort.to_sym]
# Use the passed in value if it looks complete with table name.
elsif !sort.include?('.')
sort = [self.table_name, sort].join('.')
end
dir ||= "ASC"
order = sort + " " + dir
else
order = get_sext_constant('SEXT_DEFAULT_SORT')
end
return order
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order\n @order ||= detect_order(params[:order]) || default_order\n end",
"def order\n @order || \"99_99\"\n end",
"def to_find_order\n @conditions.to_find_order\n end",
"def order\n return @order\n end",
"def to_find_order\n if @order.blank... | [
"0.7320525",
"0.7025892",
"0.6825588",
"0.6706693",
"0.66573995",
"0.66351026",
"0.65140915",
"0.65077263",
"0.64128774",
"0.6310201",
"0.6220841",
"0.61830634",
"0.6150113",
"0.61313784",
"0.61237025",
"0.61145365",
"0.6073884",
"0.60714823",
"0.604582",
"0.60305685",
"0.601... | 0.5360437 | 87 |
Returns the default options | def list_options
read_inheritable_attribute(:list_options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_options\n DEFAULT_OPTIONS\n end",
"def default_options\n @default_options ||= {}\n end",
"def default_options\n { }\n end",
"def default_options\n option_type_config_for :default\n end",
"def default_options; end",
"def default_options; end",
"def... | [
"0.8982515",
"0.85776526",
"0.8546139",
"0.8536403",
"0.85106725",
"0.85106725",
"0.85106725",
"0.8499063",
"0.8497954",
"0.8497954",
"0.8419924",
"0.8419924",
"0.8419924",
"0.83733994",
"0.83624744",
"0.8357197",
"0.82903224",
"0.81847525",
"0.81025225",
"0.8043845",
"0.8000... | 0.0 | -1 |
Does this questionnaire contain true/false questions? | def true_false_questions?
for question in questions
if question.true_false
return true
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def true_false_questions?\n questions.each {|question| return true if question.type == \"Checkbox\" }\n false\n end",
"def accurate?(bools)\n self.answers.map(&:correct) == bools\n end",
"def has_questions?\n all_questions.any?\n end",
"def asks_mentor_questions?\n !mentor_questions.emp... | [
"0.81814826",
"0.7937805",
"0.7718431",
"0.74691224",
"0.7414392",
"0.7267982",
"0.72587055",
"0.7108089",
"0.6977733",
"0.69633234",
"0.6924816",
"0.69076",
"0.68839586",
"0.6853858",
"0.6846446",
"0.6827125",
"0.6693314",
"0.6689697",
"0.6688145",
"0.661745",
"0.6606379",
... | 0.8456944 | 0 |
validate the entries for this questionnaire | def validate_questionnaire
if max_question_score < 1
errors.add(:max_question_score, "The maximum question score must be a positive integer.")
end
if min_question_score >= max_question_score
errors.add(:min_question_score, "The minimum question score must be less than the maximum")
end
results = Questionnaire.where(["id <> ? and name = ? and instructor_id = ?", id, name, instructor_id])
errors.add(:name, "Questionnaire names must be unique.") if results != nil and results.length > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_entry params\n @quiz_entry = QuizEntry.new params[:quiz_entry]\n @quiz_entry.valid? # Build errors\n\n params[:answers] ||= []\n params[:answers].each do |answer|\n @quiz_entry.answer_entries.build :answer_id => answer\n end\n\n @quiz_entry.quiz.questions.each do |questio... | [
"0.75722075",
"0.7473526",
"0.71061856",
"0.6753984",
"0.6740886",
"0.6328018",
"0.62869096",
"0.6265097",
"0.6255514",
"0.61619836",
"0.6133373",
"0.6085529",
"0.60642105",
"0.60595024",
"0.6048596",
"0.60276264",
"0.6007795",
"0.59937245",
"0.5977655",
"0.5948401",
"0.59326... | 0.7070859 | 3 |
Translation of CommonLisp code | def solve
1.upto(100).inject(:*).to_s.split('').map{|x| x.to_i}.inject(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lang(orig); end",
"def tr_s(p0, p1) end",
"def _lex_trans_targs; end",
"def _lex_trans_targs; end",
"def _lex_trans_targs; end",
"def _lex_trans_targs; end",
"def tr(p0, p1) end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg0); end",
"def lex_en_interp_string=(_arg... | [
"0.5733104",
"0.5729288",
"0.57260764",
"0.57260764",
"0.57260764",
"0.57260764",
"0.57031924",
"0.56993705",
"0.56993705",
"0.56993705",
"0.56439537",
"0.56439537",
"0.56439537",
"0.56439537",
"0.56269896",
"0.56269896",
"0.56269896",
"0.5622827",
"0.5599281",
"0.5599281",
"... | 0.0 | -1 |
Produces a speech from V For Vendetta. | def speech
fetch('v_for_vendetta.speeches')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def speech; end",
"def speak\n object_instance = object_instances.last\n Liquid::Template.parse(text_to_voice).render(object_instance.try(:attributes))\n end",
"def song(verse_a, verse_b)\np \"#{verse_a} #{verse_b}\"\nend",
"def create_speech(*options)\n CreateSpeech.new(self, options).run\... | [
"0.6464186",
"0.5780375",
"0.57137156",
"0.5661812",
"0.5639414",
"0.54925907",
"0.54823005",
"0.54450345",
"0.54207647",
"0.54061383",
"0.5394538",
"0.53883016",
"0.5357197",
"0.53524727",
"0.5351263",
"0.53418714",
"0.5319124",
"0.5303272",
"0.5272527",
"0.5261624",
"0.5257... | 0.76637614 | 0 |
Produces a quote from V For Vendetta. | def quote
fetch('v_for_vendetta.quotes')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def marvin_quote; end",
"def king_richard_iii_quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; ... | [
"0.6398001",
"0.5817355",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"0.5687348",
"... | 0.74163526 | 0 |
Download a recording of a webinar downloading the webinar records via the download url is only possible if: you enable redirection you use the JWT access token will not work with the Oauth token. This is a known bug in the API. | def meeting_recordings_download_file(download_url)
raise "You must use JWT client" unless self.class == Zoom::Clients::JWT
file=Tempfile.create
file.binmode
response = HTTParty.get("#{download_url}?access_token=#{access_token}",
stream_body: true,
follow_redirects: true
) do |fragment|
if fragment.code == 200
file.write(fragment)
elsif fragment.code != 302
raise StandardError, "Non-success status code while streaming #{fragment.code}"
end
end
file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(recording, filename = nil)\n \n # If no filename is given, we default to <title>_<recstartts>.<extension>\n if filename.nil?\n filename = recording.title + \"_\" +\n recording.myth_nondelimited_recstart + File.extname(recording.filename) \n end\n\n Fil... | [
"0.6099939",
"0.6029227",
"0.595342",
"0.5923552",
"0.58909374",
"0.588413",
"0.5815108",
"0.57964456",
"0.5755457",
"0.5736824",
"0.5724132",
"0.5716938",
"0.5714595",
"0.5707191",
"0.5705633",
"0.5700611",
"0.56973696",
"0.56591284",
"0.5654231",
"0.5643808",
"0.5617047",
... | 0.77112764 | 0 |
Never trust parameters from the scary internet, only allow the white list through. | def phone_call_params
params.require(:phone_call).permit(:domain, :user_id, :from_ip, :from_url, :from_phone, :is_processed, :note)
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 |
Used to perform a mouse down on this view in the remote application | def mouse_down()
mouse_down_at :center, :center
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mouse_down locator\r\n command 'mouseDown', locator\r\n end",
"def mouse_down locator\r\n command 'mouseDown', locator\r\n end",
"def right_click()\n right_mouse_down\n right_mouse_up\n stall :right_click\n end",
"def click()\n mouse_down\n mous... | [
"0.72893816",
"0.72893816",
"0.71459734",
"0.70248765",
"0.68114823",
"0.6753573",
"0.66153777",
"0.6611777",
"0.6490401",
"0.6459126",
"0.64460313",
"0.6442179",
"0.64028645",
"0.6337108",
"0.6327643",
"0.6245845",
"0.6236439",
"0.6236439",
"0.6236439",
"0.62057585",
"0.6180... | 0.7069864 | 3 |
Used to perform a mouse up on this view in the remote application | def mouse_up()
mouse_up_at :center, :center
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mouse_up *args; end",
"def mouse_up locator\r\n command 'mouseUp', locator\r\n end",
"def mouseUp event\n return if viewAtPoint(convertPoint(event.locationInWindow, fromView:nil)).nil?\n super(event) \n end",
"def onLButtonUp(flags, x, y, view)\n end",
"def mouseup(btn = 'left')\n co... | [
"0.74409336",
"0.70411247",
"0.7015006",
"0.68757945",
"0.66723114",
"0.66310817",
"0.65456325",
"0.643381",
"0.64202833",
"0.6317513",
"0.6235888",
"0.6089067",
"0.6086203",
"0.60452515",
"0.5999381",
"0.59874123",
"0.5944232",
"0.5944232",
"0.59237576",
"0.5908306",
"0.5902... | 0.7168414 | 1 |
Used to perform a mouse down with right button on this view in the remote application | def right_mouse_down()
right_mouse_down_at :center, :center
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_click()\n right_mouse_down\n right_mouse_up\n stall :right_click\n end",
"def right_click(name, *args)\n widget(name, *args).right_click\n end",
"def mouseButton()\n @view__.mouseButton\n end",
"def mousedown(btn = 'left')\n compatible_call... | [
"0.8220887",
"0.71045494",
"0.6909964",
"0.68614495",
"0.67855126",
"0.67848325",
"0.6757193",
"0.6700054",
"0.6669304",
"0.6649842",
"0.65229195",
"0.65229195",
"0.6459944",
"0.64044327",
"0.6401079",
"0.6364125",
"0.6337989",
"0.6335398",
"0.6329051",
"0.63116217",
"0.62975... | 0.7414242 | 1 |
Used to perform a mouse up with right button on this view in the remote application | def right_mouse_up()
right_mouse_up_at :center, :center
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_click()\n right_mouse_down\n right_mouse_up\n stall :right_click\n end",
"def onRButtonUp(flags, x, y, view)\n end",
"def right_mouse_down()\n right_mouse_down_at :center, :center\n end",
"def onLButtonUp(flags, x, y, view)\n end",
"def mous... | [
"0.7615465",
"0.7209488",
"0.6829979",
"0.67707485",
"0.6718878",
"0.66101974",
"0.6556208",
"0.65283513",
"0.64247715",
"0.64025277",
"0.6345036",
"0.62631476",
"0.6256526",
"0.6186642",
"0.61424077",
"0.61206996",
"0.6113832",
"0.6061944",
"0.60308164",
"0.60274345",
"0.600... | 0.7255497 | 1 |
Used to perform a double click on this view in the remote application | def double_click()
double_click_at :center, :center
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_click locator\r\n command 'doubleClick', locator\r\n end",
"def doubleclick(btn)\n not_supported \"anything other than left clicking\" unless btn == 'left'\n execute_applescript(%Q`\n tell application \"Extra Suites\"\n ES click mouse with double click\n end tell\n... | [
"0.75741035",
"0.7281992",
"0.7211197",
"0.71802217",
"0.7144681",
"0.69739574",
"0.69424194",
"0.69363093",
"0.68716615",
"0.681438",
"0.67492074",
"0.66316587",
"0.66234213",
"0.6425598",
"0.64248294",
"0.6347549",
"0.6313054",
"0.6244711",
"0.62425816",
"0.6210441",
"0.619... | 0.7012492 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.