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 |
|---|---|---|---|---|---|---|
PUT /contests/1 PUT /contests/1.json | def update
@contest = Contest.find(params[:id])
respond_to do |format|
if @contest.update_attributes(params[:contest])
format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @contest.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @contest = Contest.find_by(path: params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to contest_path(@contest.path)+'/upload' }\n #format.json { head :no_content }\n else\n format.html { render action: ... | [
"0.7452851",
"0.7441542",
"0.74279934",
"0.74279934",
"0.7191935",
"0.71750563",
"0.7164745",
"0.7117877",
"0.705355",
"0.70395637",
"0.7026145",
"0.69851846",
"0.6976812",
"0.69482785",
"0.6924179",
"0.69112897",
"0.67661893",
"0.67661893",
"0.6714746",
"0.6714746",
"0.67147... | 0.7452833 | 1 |
DELETE /contests/1 DELETE /contests/1.json | def destroy
@contest = Contest.find(params[:id])
@contest.destroy
respond_to do |format|
format.html { redirect_to contests_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @contest.destroy\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to conte... | [
"0.80896854",
"0.8085642",
"0.8085642",
"0.8085642",
"0.8085642",
"0.7983932",
"0.79219407",
"0.7868613",
"0.7868047",
"0.78431594",
"0.7790738",
"0.77683955",
"0.77683955",
"0.77683955",
"0.77602553",
"0.76734424",
"0.76611394",
"0.75796723",
"0.7568219",
"0.74781656",
"0.74... | 0.80987906 | 0 |
display item (table?); using pp for now | def display
tp self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_item(item)\n content = item.value\n\n case item.type\n when :string, :float, :integer then print content\n when :ident then print value_of(content)\n when :separator then print \"\\t\" if content == ','\n end\n end",
"def printItem\n print ... | [
"0.67880785",
"0.67837137",
"0.66429377",
"0.6555104",
"0.6516959",
"0.64961517",
"0.6445398",
"0.6391008",
"0.63856924",
"0.63517743",
"0.6317242",
"0.627326",
"0.6262532",
"0.6250214",
"0.6245793",
"0.6237567",
"0.6222604",
"0.6211834",
"0.62082374",
"0.6202485",
"0.6187261... | 0.650081 | 5 |
a = [ ["A", "a", 1], ["A", "b", 2], ["B", "a", 1] ] | def a_to_h(x)
h={}
x.map do |nested|
key = nested.shift
h[key] ||= {}
h[key].merge!({ nested.shift => nested.shift })
end
h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_array(arr)\n seen = Hash.new(0)\n\n arr.each do |nested|\n nested.each do |el|\n seen[el] += el\n end\n end\n\n seen.values.sort\nend",
"def count_elements(array)\n counted = []\n array.each do |item|\n item[:count] = array.count(item)\n counted << item\n end\n return counted.... | [
"0.5823824",
"0.5710211",
"0.5574855",
"0.5564136",
"0.5523655",
"0.5518094",
"0.55072254",
"0.55001783",
"0.5479294",
"0.5429977",
"0.54248565",
"0.5421832",
"0.54084086",
"0.5372916",
"0.5364902",
"0.5364141",
"0.5346516",
"0.5333161",
"0.5330878",
"0.53095067",
"0.53028744... | 0.0 | -1 |
Instantiates a new windowsInformationProtectionAppLockerFile and sets the default values. | def initialize()
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize()\n super\n @odata_type = \"#microsoft.graph.windowsInformationProtection\"\n end",
"def initialize(filename, input_password = nil)\n coercer = [:to_path, :to_str, :path].find{|meth| filename.respond_to? meth}\n @filename = coercer ? filename.send(coe... | [
"0.56734645",
"0.5613976",
"0.55921304",
"0.5409846",
"0.518795",
"0.514682",
"0.51402634",
"0.5128975",
"0.5095909",
"0.50901663",
"0.5070106",
"0.5069948",
"0.50631166",
"0.505309",
"0.5037985",
"0.50288457",
"0.49725112",
"0.49650657",
"0.4963868",
"0.49631327",
"0.4962377... | 0.0 | -1 |
Gets the displayName property value. The friendly name | def display_name
return @display_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_name\n @json['profile']['displayName'] rescue nil\n end",
"def display_name\n @hash['display_name']\n end",
"def displayName\n dn = @params['dn']\n if dn\n dn.first\n else\n nil\n end\n end",
"def displayname\n\t\treturn self[:displayNa... | [
"0.82337064",
"0.795735",
"0.7839586",
"0.78065765",
"0.7806451",
"0.77698493",
"0.7765308",
"0.775597",
"0.77517235",
"0.7717962",
"0.76269656",
"0.760335",
"0.7492642",
"0.7485111",
"0.74450517",
"0.74404174",
"0.7385288",
"0.7385288",
"0.7313179",
"0.71649307",
"0.7107345"... | 0.7849892 | 43 |
Sets the displayName property value. The friendly name | def display_name=(value)
@display_name = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_name=(value)\n @display_name = value\n end",
"def display_name=(value)\n @display_name = value\n end",
"def display_name=(name)\n @display_name ||= name\n end",
"def name=(display_name)\r\n... | [
"0.7613551",
"0.757038",
"0.7354022",
"0.7291347",
"0.7151003",
"0.7139605",
"0.71238244",
"0.7092179",
"0.7092179",
"0.7092179",
"0.68099004",
"0.68099004",
"0.676128",
"0.676128",
"0.67377526",
"0.6724276",
"0.66819304",
"0.66785824",
"0.6556247",
"0.6520817",
"0.64952755",... | 0.7632908 | 42 |
Gets the file property value. File as a byte array | def file
return @file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def value\r\n @value ||= self.class.service_instance.get_blob(path)\r\n end",
"def fi... | [
"0.69566685",
"0.69566685",
"0.69566685",
"0.69566685",
"0.69239634",
"0.68635994",
"0.66263765",
"0.6536424",
"0.6511813",
"0.650664",
"0.6491183",
"0.6485573",
"0.6475529",
"0.64115965",
"0.64034015",
"0.6403276",
"0.63976175",
"0.6340234",
"0.63381916",
"0.63047594",
"0.63... | 0.7187043 | 1 |
Sets the file property value. File as a byte array | def file=(value)
@file = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file=(file)\n self.data = file\n dis_set :content_type, file.content_type\n dis_set :filename, file.original_filename\n end",
"def set(file)\n self.file = file\n end",
"def file=(file)\n self.fileRef = file.uuid\n end",
"def file=(v); @fil... | [
"0.6958593",
"0.693685",
"0.68934226",
"0.67325395",
"0.6716334",
"0.6711391",
"0.66310066",
"0.66050583",
"0.6572997",
"0.65395766",
"0.64590937",
"0.643266",
"0.643266",
"0.64165723",
"0.6347035",
"0.63398993",
"0.6284609",
"0.6278482",
"0.6217503",
"0.62059844",
"0.6204147... | 0.75777245 | 1 |
Gets the fileHash property value. SHA256 hash of the file | def file_hash
return @file_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_sha256\n Digest::SHA256.file(self).hexdigest\n end",
"def file_sha256_hash(file_path)\n file = File.read(file_path)\n Digest::SHA256.hexdigest(file) if file\n end",
"def hash\r\n # TODO what if file is empty?\r\n @hash ||= Digest::SHA1.file(File.join(@directory, @filename)).hexdig... | [
"0.791747",
"0.7664581",
"0.76560307",
"0.7439158",
"0.7335306",
"0.72340167",
"0.7178149",
"0.7174086",
"0.7022939",
"0.7017768",
"0.69841605",
"0.6943551",
"0.6942505",
"0.6647093",
"0.6604051",
"0.65755415",
"0.6566256",
"0.64974946",
"0.6491183",
"0.64547163",
"0.63662875... | 0.7474584 | 3 |
Sets the fileHash property value. SHA256 hash of the file | def file_hash=(value)
@file_hash = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_sha256\n Digest::SHA256.file(self).hexdigest\n end",
"def file_sha256_hash(file_path)\n file = File.read(file_path)\n Digest::SHA256.hexdigest(file) if file\n end",
"def hash\r\n # TODO what if file is empty?\r\n @hash ||= Digest::SHA1.file(File.join(@directory, @filename)).hexdig... | [
"0.6772999",
"0.66369",
"0.656553",
"0.61696494",
"0.6145309",
"0.6106103",
"0.60598093",
"0.60383195",
"0.5948737",
"0.5900063",
"0.5892718",
"0.58852744",
"0.5872986",
"0.5863941",
"0.5793927",
"0.5781963",
"0.5708866",
"0.5686436",
"0.5648362",
"0.55985224",
"0.5568164",
... | 0.8032693 | 0 |
The deserialization information for the current model | def get_field_deserializers()
return super.merge({
"displayName" => lambda {|n| @display_name = n.get_string_value() },
"file" => lambda {|n| @file = n.get_object_value(lambda {|pn| Base64url.create_from_discriminator_value(pn) }) },
"fileHash" => lambda {|n| @file_hash = n.get_string_value() },
"version" => lambda {|n| @version = n.get_string_value() },
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deserialized\n @deserialized ||= @serializer.deserialize @serialized_object\n end",
"def get_field_deserializers()\n return super.merge({\n \"detectionStatus\" => lambda {|n| @detection_status = n.get_enum_value(MicrosoftGraph::Models::SecurityDetectionStatus) },... | [
"0.6510734",
"0.63224316",
"0.6322254",
"0.62954384",
"0.6238735",
"0.6232461",
"0.62155676",
"0.6200175",
"0.6199403",
"0.6173917",
"0.61733985",
"0.61705345",
"0.61631054",
"0.61620396",
"0.6158031",
"0.6156071",
"0.6142402",
"0.613998",
"0.6138061",
"0.61200523",
"0.608901... | 0.63094735 | 3 |
Serializes information the current object | def serialize(writer)
raise StandardError, 'writer cannot be null' if writer.nil?
super
writer.write_string_value("displayName", @display_name)
writer.write_object_value("file", @file)
writer.write_string_value("fileHash", @file_hash)
writer.write_string_value("version", @version)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize\n end",
"def serialize(object) end",
"def serialize; end",
"def serialize; end",
"def serialize\n \n end",
"def serialize\n raise NotImplementedError\n end",
"def serialize\n raise NotImplementedError\n end",
"def dump\r\n super + to_s\r\n end",
... | [
"0.7951372",
"0.7645999",
"0.7579812",
"0.7579812",
"0.7440032",
"0.720861",
"0.720861",
"0.7207583",
"0.7016516",
"0.70007193",
"0.6992252",
"0.69838214",
"0.69723576",
"0.69666415",
"0.69666415",
"0.6942002",
"0.69417155",
"0.6933786",
"0.6913977",
"0.6891677",
"0.68810964"... | 0.0 | -1 |
Gets the version property value. Version of the entity. | def version
return @version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version\n attributes.fetch(:version)\n end",
"def version\n attributes.fetch(:version)\n end",
"def version\n attributes.fetch(:version)\n end",
"def version\n attributes.fetch(:version)\n end",
"def version\n attributes.fetch(:ve... | [
"0.75904036",
"0.75904036",
"0.75904036",
"0.75904036",
"0.75904036",
"0.7569684",
"0.75005096",
"0.75005096",
"0.74446875",
"0.73274076",
"0.73076767",
"0.7306772",
"0.7155831",
"0.7155831",
"0.7150681",
"0.71009225",
"0.70811284",
"0.70054656",
"0.69948876",
"0.6989028",
"0... | 0.71267724 | 22 |
Sets the version property value. Version of the entity. | def version=(value)
@version = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version=(v)\n @version = v\n end",
"def set(new_version)\n self.version = new_version\n end",
"def version=(version)\n @version = version\n end",
"def setVersion(version)\r\n\t\t\t\t\t@version = version\r\n\t\t\t\tend",
"def version_number=(value)\n @version_number = ... | [
"0.7894168",
"0.78093123",
"0.7764784",
"0.7703653",
"0.7361282",
"0.72826326",
"0.72480625",
"0.72480625",
"0.71721494",
"0.7145585",
"0.71347976",
"0.70081586",
"0.6971517",
"0.6937572",
"0.68501663",
"0.68265903",
"0.680043",
"0.66954046",
"0.6624683",
"0.6581281",
"0.6577... | 0.8079159 | 6 |
Validate params[ref_no] is a number and not some kind of attack. | def validate_load_param
return if params[:id].match?(/\d+/)
raise Error::AppError.new('Return Load', 'Invalid return number for loading')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_reference_nbr(test_data)\n verify_values_match(test_data[UseOfCollections::REFERENCE_NBR.name], element_value(reference_nbr_input))\n end",
"def verify_reference_nbr(test_data)\n verify_values_match(test_data[CoreUseOfCollectionsData::REFERENCE_NBR.name], element_value(reference_nbr_input))\n ... | [
"0.579201",
"0.5629228",
"0.5616987",
"0.5560069",
"0.54277825",
"0.5427736",
"0.5360769",
"0.5337348",
"0.53015727",
"0.5234927",
"0.5209641",
"0.51744694",
"0.51709825",
"0.51633203",
"0.5137455",
"0.51345634",
"0.51293504",
"0.5124157",
"0.50600576",
"0.50535697",
"0.50498... | 0.5187205 | 11 |
Extracted summary method Checks if draft button was pressed & redirects to the save draft action if validation passes. | def manage_draft(model)
return false unless params[:save_draft]
Rails.logger.debug('save_draft pressed')
if model.valid?(:draft)
Rails.logger.debug(' validation passed')
redirect_to(action: :save_draft)
else
render(status: :unprocessable_entity)
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_draft\n unless @submission.draft?\n redirect_to @problem\n end\n end",
"def save_draft\n frm.button(:value=>\"Save Draft\").click\n SubmissionConfirmation.new(@browser)\n end",
"def save_draft\n frm.button(:value=>\"Save Draft\").click\n SubmissionConfirmation.new(@browser)\n e... | [
"0.71348184",
"0.7017164",
"0.7017164",
"0.7017164",
"0.7017164",
"0.69914806",
"0.680377",
"0.66657597",
"0.6647909",
"0.6621452",
"0.6351758",
"0.6179058",
"0.6159553",
"0.6084184",
"0.60461986",
"0.6033071",
"0.60284007",
"0.5988193",
"0.5942611",
"0.5889227",
"0.5852865",... | 0.7350608 | 0 |
Extracted summary method Checks if calculate button was pressed & redirects to the calculate action if validation passes. | def manage_calculate(model)
return false unless params[:calculate_return]
Rails.logger.debug('calculate_return pressed - checking validation')
if model.valid?(:submit)
Rails.logger.debug(' validation passed')
redirect_to(action: :declaration_calculation)
else
render(status: :unprocessable_entity)
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate\n flash[:result] = calculation_param[:num1].to_i + calculation_param[:num2].to_i \n redirect_to calculator_result_path\n end",
"def declaration_calculation\n # do the submitted part first to get it out of the way\n if params[:continue]\n wizard_step_submitted(nil, next_step:... | [
"0.62693065",
"0.6163759",
"0.60113347",
"0.56353456",
"0.5631983",
"0.56272393",
"0.5619933",
"0.561991",
"0.5609216",
"0.5592172",
"0.55570745",
"0.5535041",
"0.5391578",
"0.5338835",
"0.53083104",
"0.52774155",
"0.5253272",
"0.52395165",
"0.52282846",
"0.5222621",
"0.52202... | 0.76938766 | 0 |
Does the account have a dd instruction | def account_has_dd_instruction?
return false if current_user.nil?
@account ||= Account.find(current_user)
@account.dd_instruction_available
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasdrm?\n @drm ? true : false\n end",
"def drmized?\n if @protections.any? {|p| p =~ /Drm/ }\n true\n else\n false\n end\n end",
"def drmized?\n @protections.any? { |p| p =~ /Drm/ }\n end",
"def is_dc?\n is_dc_srv = false\n serviceskey = 'HKLM\\\\SYSTEM\\... | [
"0.62792",
"0.6119336",
"0.6112508",
"0.60552096",
"0.60098994",
"0.60071915",
"0.5949517",
"0.5924369",
"0.5844952",
"0.5811704",
"0.57227224",
"0.571329",
"0.57049686",
"0.56433153",
"0.5594119",
"0.551767",
"0.54960996",
"0.5455629",
"0.54294115",
"0.54294115",
"0.54277164... | 0.75189644 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_risk_countning
@risk_countning = RiskCountning.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 trusted parameter "white list" through. | def risk_countning_params
params.fetch(:risk_countning, {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Only allow a trusted parameter "white list" through | def set_recipe
@recipe = Recipe.find_by(id: params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def param_whitelist\n [:role, :title]\n end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n ... | [
"0.71102256",
"0.7103063",
"0.7079237",
"0.70405525",
"0.696351",
"0.6808852",
"0.6794005",
"0.67904145",
"0.6729673",
"0.67058986",
"0.6666788",
"0.6662568",
"0.65984434",
"0.65984434",
"0.6595137",
"0.6594866",
"0.6583686",
"0.65497476",
"0.652406",
"0.65006906",
"0.6496638... | 0.0 | -1 |
returns the parsed JSON representation of an instance. If the current instance is a string we assume it's JSON | def reparsed_from_json
self.is_a?(String) ? JSON.parse(self) : JSON.parse(self.to_json)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_json\n JSON.parse self.to_json\n end",
"def to_json\n return self.class.to_json\n end",
"def from_json\n JSON.parse(self)\n end",
"def json\n raise StandardError, 'No JSON library initialized' unless URL.json_handler\n @json ||= URL.json_handler.new(self).parse\n end",
"def ... | [
"0.6881147",
"0.6540918",
"0.6514019",
"0.634179",
"0.6245756",
"0.62110484",
"0.61156094",
"0.6103765",
"0.607814",
"0.6077225",
"0.607252",
"0.6054357",
"0.6045088",
"0.6042151",
"0.6032539",
"0.60226625",
"0.600601",
"0.5998942",
"0.5982798",
"0.5948048",
"0.593183",
"0.... | 0.66972333 | 1 |
redirect after login to previous nonlogin page TODO figure out why it doesn't work for Polaris or Facebook logins | def store_location
# store last url - this is needed for post-login redirect to whatever the user last visited.
if (request.path != "/users/sign_in" &&
request.path != "/users/sign_up" &&
request.path != "/users/password/new" &&
request.path != "/users/password/edit" &&
request.path != "/users/confirmation" &&
request.path != "/users/sign_out" &&
!request.fullpath.match(/\/users\/auth\//) &&
!request.xhr?) # don't store ajax calls
session[:previous_url] = request.fullpath
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_checkpoint\n redirect to '/' if !logged_in?\n end",
"def redirect_to_login_page\n query_params = request.query_parameters\n query_params.merge!(return_to: request.path)\n\n target = cms_path(Homepage.default.login_page, query_params)\n\n redirect_to(target, alert: \"This page is protect... | [
"0.75332177",
"0.75077957",
"0.7406373",
"0.7382843",
"0.7344241",
"0.721329",
"0.71861494",
"0.717482",
"0.7134335",
"0.7131968",
"0.7123493",
"0.7099752",
"0.7087165",
"0.7077068",
"0.7055427",
"0.7026388",
"0.70072955",
"0.69954854",
"0.699116",
"0.698477",
"0.6978315",
... | 0.0 | -1 |
Returns the soap of the response as a Nokogiri document | def doc
@doc = @soap ? xml_doc(@soap) : xml_doc(@error)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result\n r = REXML::Document.new @response.body\n success? ? r.root.elements['SOAP-ENV:Body'].elements[\"#{@ns}:#{@action}Response\"].elements['return'].text : r.root.elements['SOAP-ENV:Body'].elements[\"SOAP-ENV:Fault\"].elements['faultstring'].text\n end",
"def to_s\n @document ||= @request.wsd... | [
"0.6919202",
"0.6846527",
"0.66538256",
"0.6642215",
"0.6412863",
"0.64015925",
"0.63859355",
"0.6372266",
"0.63682806",
"0.6328242",
"0.63208044",
"0.6244126",
"0.62185454",
"0.62087953",
"0.61477005",
"0.6141268",
"0.61292225",
"0.6082812",
"0.6080294",
"0.6066874",
"0.6039... | 0.73653084 | 0 |
Returns the error of the response as a Nokogiri document | def error_doc
@error_doc ||= xml_doc @error
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error\n doc['error']\n end",
"def output_response_error(response)\n # Parse response xml (see https://ocrsdk.com/documentation/specifications/status-codes)\n xml_data = REXML::Document.new(response)\n error_message = xml_data.elements[\"error/message\"]\n puts \"Error: #{error_message.tex... | [
"0.73315376",
"0.7245569",
"0.7227602",
"0.71949416",
"0.69308203",
"0.6585935",
"0.6521319",
"0.651475",
"0.6290436",
"0.6282774",
"0.62564164",
"0.6238579",
"0.6231927",
"0.6209801",
"0.61932874",
"0.6187858",
"0.61824894",
"0.6182422",
"0.6160254",
"0.6144251",
"0.6071539"... | 0.693053 | 5 |
Returns the file references in a download file list response | def file_references
return unless @command == :download_file_list
@file_references ||= begin
xml = xml_doc content
descriptors = xml.css('FileDescriptor')
descriptors.map { |descriptor| descriptor.at('FileReference').content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downloaded\n files_list = []\n files = session[:user].x_files.all(:downloads.gte => 1, uploaded: true)\n files.each { |file| files_list.push(file.description(session[:user])) }\n @result = { files: files_list, success: true }\n end",
"def file_list\n @file_list\n end",
"def files\n ... | [
"0.7119995",
"0.6858421",
"0.6845835",
"0.6732061",
"0.6717206",
"0.66601795",
"0.6476131",
"0.64256763",
"0.6415357",
"0.63854265",
"0.6383233",
"0.6353521",
"0.63046414",
"0.6286474",
"0.6282497",
"0.62758213",
"0.6263337",
"0.62503797",
"0.62393117",
"0.6201797",
"0.616320... | 0.79356444 | 0 |
Returns the raw soap as xml | def to_s
@soap
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @document ||= @request.wsdl.body\n end",
"def to_s\n @xml\n end",
"def to_xml\n http.body\n end",
"def soap(soap)\n @soap = soap\n http.endpoint @soap.endpoint.host, @soap.endpoint.port\n http.use_ssl = @soap.endpoint.ssl?\n\n log_request\n @res... | [
"0.6822619",
"0.65816706",
"0.6531415",
"0.6463704",
"0.6452073",
"0.63979566",
"0.63378865",
"0.6327901",
"0.6219599",
"0.61317945",
"0.61279416",
"0.6092952",
"0.60886437",
"0.60779136",
"0.60779136",
"0.60528356",
"0.6005525",
"0.6003827",
"0.5970745",
"0.59537625",
"0.592... | 0.7579338 | 0 |
Returns the response code of the response | def response_code(namespace: BXD, node_name: 'ResponseCode')
(node = doc.at("xmlns|#{node_name}", xmlns: namespace)) && node.content && node.content.rjust(2, '0')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_code\n @response.code\n end",
"def code\n @response.code\n end",
"def code\n @response.code.to_i\n end",
"def code\n @response.code.to_i\n end",
"def code\n @http_response.code.to_i\n end",
"def code\n @raw_response.code\n end",
"def status_c... | [
"0.91116387",
"0.88557464",
"0.8806127",
"0.8806127",
"0.8736797",
"0.8671937",
"0.8640215",
"0.8619008",
"0.85087764",
"0.8365747",
"0.8160464",
"0.8160464",
"0.8160464",
"0.8160464",
"0.80156624",
"0.79371893",
"0.78204954",
"0.77496105",
"0.77270114",
"0.7675103",
"0.76403... | 0.0 | -1 |
Returns the response text of the response | def response_text(namespace: BXD, node_name: 'ResponseText')
(node = doc.at("xmlns|#{node_name}", xmlns: namespace)) && node.content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reply_text\n return \"No response.\" if response.nil?\n return (not response.first.last.kind_of?(Hash) or response.first.last[\"reply_text\"].nil?) ? \"Unexpected response hash.\" : response.first.last[\"reply_text\"] if response.instance_of?(Hash)\n response_match = response.match(/... | [
"0.73231447",
"0.7137434",
"0.7075336",
"0.7036536",
"0.6980305",
"0.69420743",
"0.69064564",
"0.6859161",
"0.6838276",
"0.6807421",
"0.67521167",
"0.67503166",
"0.6742787",
"0.6737884",
"0.6735774",
"0.67060995",
"0.66821474",
"0.66821474",
"0.66821474",
"0.66821474",
"0.668... | 0.7106753 | 2 |
Finds all reference nodes with digest values in the document and returns a hash with uri as the key and digest as the value. | def find_digest_values
references = {}
reference_nodes = doc.css('xmlns|Reference', xmlns: DSIG)
reference_nodes.each do |node|
uri = node.attr('URI')
digest_value = node.at('xmlns|DigestValue', xmlns: DSIG).content
references[uri] = digest_value
end
references
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_nodes_to_verify(references)\n nodes = {}\n\n references.each do |uri, _digest_value|\n uri = uri.sub(/^#/, '')\n node = find_node_by_uri(uri)\n\n nodes[uri] = calculate_digest(node)\n end\n\n nodes\n end",
"def hash_by_uri\n @hash_by_uri... | [
"0.71525586",
"0.6359235",
"0.5827951",
"0.582562",
"0.56701225",
"0.56701225",
"0.5653979",
"0.5566303",
"0.5555408",
"0.55444485",
"0.5540631",
"0.5491038",
"0.547983",
"0.5430005",
"0.54097414",
"0.54044545",
"0.53715783",
"0.5369668",
"0.53551286",
"0.53388083",
"0.532881... | 0.8417258 | 0 |
Finds nodes to verify by comparing their id's to the uris' in the references hash. Then calculates the hashes of those nodes and returns them in a hash | def find_nodes_to_verify(references)
nodes = {}
references.each do |uri, _digest_value|
uri = uri.sub(/^#/, '')
node = find_node_by_uri(uri)
nodes[uri] = calculate_digest(node)
end
nodes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_hash(node_id)\n \n end",
"def hash_nodes(statements, nodes, grounded_hashes)\n hashes = grounded_hashes.dup\n ungrounded_hashes = {}\n hash_needed = true\n\n # We may have to go over the list multiple times. If a node is marked as\n # grounded, other nodes can then use it t... | [
"0.6218768",
"0.59814334",
"0.59220445",
"0.5813957",
"0.5735458",
"0.5683958",
"0.5552773",
"0.54998183",
"0.5463485",
"0.54141325",
"0.53758204",
"0.536647",
"0.536647",
"0.536647",
"0.53351533",
"0.53039163",
"0.52981234",
"0.5227945",
"0.52204657",
"0.52086574",
"0.519567... | 0.7812996 | 0 |
Extracts and returns application response from the response | def extract_application_response(namespace)
ar_node = doc.at('xmlns|ApplicationResponse', xmlns: namespace)
return unless ar_node
decode(ar_node.content)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response\n # Dump it to JSON\n MultiJson.dump({\n status: @app_response.status,\n headers: @app_response.headers,\n body: @app_response.body\n })\n end",
"def extract_appdata( response )\n appdata = response[NR_APPDATA_HEADER] or\n raise NewRelic::Agent:... | [
"0.68203694",
"0.6747703",
"0.67400885",
"0.6630652",
"0.6570765",
"0.6510482",
"0.6498255",
"0.64982045",
"0.6414196",
"0.63700587",
"0.63700587",
"0.63700587",
"0.63700587",
"0.63700587",
"0.63700587",
"0.63700587",
"0.63700587",
"0.63700587",
"0.63700587",
"0.63700587",
"0... | 0.7555321 | 0 |
Handles errors that have been passed from client | def client_errors
client_error = error.to_s
errors.add(:base, client_error) unless client_error.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client_error(e, client); end",
"def client_error?; end",
"def handle_error(client, e)\n code = case e\n when EOFError,Errno::ECONNRESET,Errno::EPIPE,Errno::ENOTCONN\n # client disconnected on us and there's nothing we can do\n when Unicorn::RequestURITooLongError\n 414\n when Unicorn:... | [
"0.7657344",
"0.75196713",
"0.71948284",
"0.70110404",
"0.69582707",
"0.6785923",
"0.67279536",
"0.67242974",
"0.67127025",
"0.66961366",
"0.6685393",
"0.6625318",
"0.6621475",
"0.6616286",
"0.6612185",
"0.65458816",
"0.6530594",
"0.65025735",
"0.64937943",
"0.6467766",
"0.64... | 0.601649 | 85 |
Find node by it's reference URI in soap header | def find_node_by_uri(uri)
doc.at("[xmlns|Id='#{uri}']", xmlns: OASIS_UTILITY)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def referenced_element\n ref = @xml.attributes['ref'].value\n @referenced_element ||= if ref =~ /:/\n prefix, element = ref.split(':')\n schema.find_element(element) || schema.find_attribute(\"@#{element}\") if schema = Schema.find(prefix)\n else\n self.schema.find_element(ref) ... | [
"0.62962455",
"0.60749346",
"0.58655995",
"0.57849884",
"0.5714609",
"0.5691276",
"0.56493264",
"0.56425107",
"0.56299937",
"0.5615698",
"0.5595392",
"0.5565955",
"0.55096835",
"0.54882383",
"0.5473108",
"0.5410008",
"0.54016066",
"0.54004484",
"0.5398782",
"0.5382894",
"0.53... | 0.6770897 | 0 |
Validates response code in response. "00" and "24" are currently considered valid. | def validate_response_code
return if %w(00 24).include? response_code
errors.add(:base, response_code: response_code, response_text: response_text)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_code_is_ok?\n return true if %w(00 24).include? response_code\n\n false\n end",
"def validate_response(response) # :nodoc:\n code = response.code.to_i\n raise HttpError, \"#{code} #{response.msg}\" if code < 200 || code > 299\n end",
"def ok?(http_code)\n http_... | [
"0.73591506",
"0.68359435",
"0.6654251",
"0.6563576",
"0.6497677",
"0.64170665",
"0.64136744",
"0.63978976",
"0.6337006",
"0.6333615",
"0.6317287",
"0.63100165",
"0.62551826",
"0.62441874",
"0.6235441",
"0.6213408",
"0.6172791",
"0.615127",
"0.612231",
"0.60977596",
"0.606838... | 0.8603419 | 0 |
Checks whether response code in the response is ok. Response code is considered ok if it is "00" or "24". | def response_code_is_ok?
return true if %w(00 24).include? response_code
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ok?(code)\n [200, 201, 202, 204, 206].include?(code)\n end",
"def ok?(http_code)\n http_code =~ /^20/ ||\n http_code =~ /^40/\n end",
"def response_codes_ok?\n response_codes.all? { |code| code == 200 || code == 201 || code == 302 || code == 304 || code == 401 }\n end",
"def vali... | [
"0.7958942",
"0.78650284",
"0.7811389",
"0.73684937",
"0.7309059",
"0.7276366",
"0.7234879",
"0.7225369",
"0.72155046",
"0.7201828",
"0.71383363",
"0.702264",
"0.69741106",
"0.6961814",
"0.6922667",
"0.6904916",
"0.6899167",
"0.6877346",
"0.68650156",
"0.68635345",
"0.6848739... | 0.8832933 | 0 |
POST /foods POST /foods.json | def create
@food = @fridge.foods.create(food_params)
respond_with @food, location: -> { kitchen_board_path }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end",
"def create\n @food = Food.new(food_params)\n respond_to do |format|\n if @food.save\n format.html { redirect_to @food, notice: 'Food was successfully created.' }\n ... | [
"0.6643145",
"0.64657855",
"0.6368647",
"0.6346859",
"0.633681",
"0.6319282",
"0.6282007",
"0.62472695",
"0.62304413",
"0.61407834",
"0.61186194",
"0.6108414",
"0.6086191",
"0.60048944",
"0.59922606",
"0.5987454",
"0.5985736",
"0.59629697",
"0.5961583",
"0.59610206",
"0.59393... | 0.685693 | 0 |
PATCH/PUT /foods/1 PATCH/PUT /foods/1.json | def update
@food.update(food_params)
respond_with @food, location: -> { kitchen_board_path }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n json_response(@food_item.update!(food_item_params))\n end",
"def update\n @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to foods_path(), notice: 'Food was successfully updated.' }\n ... | [
"0.6446689",
"0.6395018",
"0.6337557",
"0.6314569",
"0.62762415",
"0.62073964",
"0.62043935",
"0.6195201",
"0.616223",
"0.616193",
"0.61534315",
"0.61489725",
"0.6103136",
"0.6095035",
"0.60859686",
"0.6084084",
"0.6066294",
"0.60429436",
"0.6041146",
"0.60221934",
"0.6012773... | 0.62668836 | 5 |
DELETE /foods/1 DELETE /foods/1.json | def destroy
@food.destroy
respond_with @food, location: -> { kitchen_board_path }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @food = Food.find(params[:id])\n @food.des... | [
"0.72069806",
"0.7188432",
"0.7188432",
"0.6969845",
"0.6914444",
"0.69053894",
"0.68637383",
"0.68490005",
"0.6840715",
"0.68123996",
"0.6811297",
"0.68019694",
"0.68019694",
"0.68019694",
"0.6798543",
"0.6798085",
"0.67898506",
"0.6785572",
"0.67843544",
"0.6783531",
"0.677... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_food
@food = @fridge.foods.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 food_params
params.require(:food).permit(:name, :deadline)
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 |
Pods for SpaceOdyssey Testing | def test_pods
pod "Quick"
pod "Nimble"
pod "Nimble-Snapshots"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pods_test\n pod 'Quick'\n pod 'Nimble'\nend",
"def testing_pods\n # Pods for testing\n pod 'Quick'\n pod 'Nimble'\n end",
"def sharedPods\n\nend",
"def pods\n\tpod 'DateTools'\n\tpod 'HyUIActionEvent', :git => \"https://github.com/HyanCat/HyUIActionEvent.git\"\n\tpod 'HyFoundation', :path => \".... | [
"0.7161237",
"0.6933457",
"0.66963404",
"0.6663508",
"0.6596972",
"0.65876454",
"0.6551502",
"0.65176666",
"0.64997256",
"0.64951056",
"0.64813656",
"0.6455924",
"0.6442976",
"0.64067453",
"0.6402184",
"0.63940173",
"0.63880324",
"0.63675225",
"0.63464624",
"0.63210523",
"0.6... | 0.7039957 | 2 |
Yes, this method name is valid | def my_other_method😉(x)
# the 'yield' keyword executes a block passed to the method
yield_return = yield
puts "Yielded block returned #{yield_return}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def... | [
"0.7687798",
"0.7687798",
"0.7687798",
"0.7687798",
"0.7687798",
"0.7687798",
"0.7687798",
"0.7687798",
"0.7687798",
"0.7687798",
"0.7687798",
"0.7687798",
"0.75864923",
"0.75864923",
"0.75864923",
"0.73247826",
"0.70647407",
"0.70647407",
"0.7035379",
"0.7035379",
"0.7035379... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def get_chosen_answers
ChosenAnswer.order('created_at DESC')
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 |
Save newest snapshot on a day | def prune_daily(snapshot)
catch :found do
(0..rotation.daily - 1).each do |count|
day = in_days(count)
if day_key(snapshot.created_at) == day_key(day)
save_newest_snapshot(snapshot, day)
throw :found, true
end
end
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_snapshot\n return unless @current_snapshot\n current_state = @bitmap.to_json\n return if snapshots_match?(@current_snapshot, current_state)\n\n @snapshots << @current_snapshot\n end",
"def new_snapshot!(time = Time.now)\n snapshot_path = time.strftime(dir.path + '/%Y-%m-%dT%H:%M%z')\n ... | [
"0.6284039",
"0.62612426",
"0.6094328",
"0.6064722",
"0.59526473",
"0.58893585",
"0.5873106",
"0.5829736",
"0.5829736",
"0.5818014",
"0.5815142",
"0.580296",
"0.5795959",
"0.57800263",
"0.5762275",
"0.57585806",
"0.57542896",
"0.5699956",
"0.5678807",
"0.56773573",
"0.5657987... | 0.5666518 | 20 |
Save oldest snapshot on a week | def prune_weekly(snapshot)
catch :found do
(0..rotation.weekly - 1).each do |count|
week_beg = beginning_of_week(in_weeks(count))
week_end = end_of_week(in_weeks(count))
if snapshot.created_at >= week_beg && snapshot.created_at <= week_end
save_oldest_snapshot(snapshot, week_beg)
throw :found, true
end
end
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bucket_date\n self.created_at.beginning_of_week.beginning_of_day\n end",
"def oldest_snapshot\n `zfs list -r -H -t snapshot -o name -S creation #{@dataset}/share | tail -1`.chomp\n end",
"def quality_driven_software_export\n @from = Time.zone.now - 1.week\n @to = Time.zone.now\n end",
"def... | [
"0.59820557",
"0.5780318",
"0.5766718",
"0.5653355",
"0.5601915",
"0.55659986",
"0.5565949",
"0.5565949",
"0.55242866",
"0.5427993",
"0.5427993",
"0.54091036",
"0.5398009",
"0.5398009",
"0.5378387",
"0.5373672",
"0.534448",
"0.53354275",
"0.53354275",
"0.5324287",
"0.53224665... | 0.6609624 | 0 |
Save oldest snapshot of every 4 weeks | def prune_monthly(snapshot)
catch :found do
(0..rotation.monthly - 1).each do |count|
month_beg = beginning_of_week(in_months(count))
month_end = end_of_week(in_months(count))
if snapshot.created_at >= month_beg && snapshot.created_at <= month_end
save_oldest_snapshot(snapshot, month_beg)
throw :found, true
end
end
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune_weekly(snapshot)\n catch :found do\n (0..rotation.weekly - 1).each do |count|\n week_beg = beginning_of_week(in_weeks(count))\n week_end = end_of_week(in_weeks(count))\n if snapshot.created_at >= week_beg && snapshot.created_at <= week_end\n save_oldest_s... | [
"0.61927134",
"0.5632052",
"0.5566054",
"0.5491624",
"0.5460925",
"0.5423949",
"0.54086536",
"0.5355339",
"0.5355339",
"0.53230023",
"0.531859",
"0.53172874",
"0.5282492",
"0.5277918",
"0.5254318",
"0.5254318",
"0.5245757",
"0.5240686",
"0.52168465",
"0.5205184",
"0.51914734"... | 0.49214587 | 42 |
Returns the local git branches; current branch is always first | def local_branches
@local_branches ||= begin
branches = []
if not git.branches.local.empty?
branches << git.branches.local.select{ |b| b.current }[0].name
branches << git.branches.local.select{ |b| not b.current }.map{ |b| b.name }
end
branches.flatten
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_branches\n @branches ||= git_call('branch -a').split(\"\\n\").collect { |s| s.strip }\n end",
"def list\n Rugged::Branch.each_name(@git, :local).to_a\n end",
"def branch_list\n raw_branches = `cd #{project_repo_path} && git branch -r`\n branches = raw_branches.split(/\\n/)\n return... | [
"0.7899983",
"0.7846728",
"0.77958614",
"0.77468807",
"0.77436006",
"0.75390697",
"0.7472514",
"0.7442688",
"0.74028647",
"0.73678",
"0.7333239",
"0.72407275",
"0.72156686",
"0.7195415",
"0.7181203",
"0.7150347",
"0.70894146",
"0.69758475",
"0.6974953",
"0.69742197",
"0.69682... | 0.8867884 | 0 |
Protip: Don't cache these! The topic map needs to be reread every time we change branches. | def topic_map_file
# new stuff 1/Nov/2021
# allow users to break up the topic map into multiple topic maps
# load topic maps from a single folder called _topic_maps.
# we assume that all files in this folder are correctly formatted topic maps. If not, you will get normal asciibinder errors
topic_map_folder = TOPIC_MAP_FOLDER
topic_file = TOPIC_MAP_FILENAME
if !Dir.exist?(File.join(docs_root_dir, topic_map_folder))
# if the _topic_maps directory doesn't exist or is empty, see if we can find the topic map in the root folder to maintain backward compatibility
if !File.exist?(File.join(docs_root_dir, topic_file))
# fall back to looking for a _topic_map in the root directory
topic_file = BUILD_FILENAME # old folders use build_config.yml
if !File.exist?(File.join(docs_root_dir, topic_file))
# Critical error - no topic map file at all.
Trollop::die "Could not find a valid topic map file. There is no #{TOPIC_MAP_FOLDER} folder and the fall back files #{TOPIC_MAP_FILENAME} or #{BUILD_FILENAME} in branch '#{git.branch}' were also not found."
else
t = File.join(docs_root_dir, topic_file) # found build_config
end
else
t = File.join(docs_root_dir, topic_file) # found topic_map in root
end
else
# topic map files are in the _topic_maps folder
# create a combined temp file with all topic maps
tf = Tempfile.new("#{TOPIC_MAP_FILENAME}")
Dir.glob("#{topic_map_folder}/*.yml").sort.each do |filename|
lines = IO.read(filename)
tf << lines
tf.write "\n"
end
tf.rewind
t = tf.path
end
# returns the path to the final file
t
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_sidebard_topics\n # @sidebar_topics = Topic.with_published_blogs\n @sidebar_topics = Topic.with_blogs\n end",
"def define_topics\n @topics = {\n 'uk' => 'UK',\n 'world' => 'World',\n 'education' => 'Education',\n 'politics' => 'Politics',\n 'health' => 'Health',\n... | [
"0.62603617",
"0.6132856",
"0.6063058",
"0.60175115",
"0.59490293",
"0.59472275",
"0.5773808",
"0.5755653",
"0.5747146",
"0.5739873",
"0.57165545",
"0.57109475",
"0.5705959",
"0.5704744",
"0.5650812",
"0.5634079",
"0.56306314",
"0.56070024",
"0.5575257",
"0.5555308",
"0.55341... | 0.5997377 | 4 |
package_docs This method generates the docs and then organizes them the way they will be arranged for the production websites. | def package_docs(package_site)
site_map.sites.each do |site|
next if not package_site == '' and not package_site == site.id
site.distros.each do |distro_id,branches|
branches.each do |branch|
src_dir = File.join(preview_dir,distro_id,branch.dir)
tgt_tdir = branch.dir.split('/')
tgt_tdir.pop
tgt_dir = ''
if tgt_tdir.length > 0
tgt_dir = File.join(package_dir,site.id,tgt_tdir.join('/'))
else
tgt_dir = File.join(package_dir,site.id)
end
next if not File.directory?(src_dir)
FileUtils.mkdir_p(tgt_dir)
FileUtils.cp_r(src_dir,tgt_dir)
end
site_dir = File.join(package_dir,site.id)
if File.directory?(site_dir)
log_unknown("Packaging #{distro_id} for #{site.id} site.")
# Any files in the root of the docs repo with names ending in:
# *-#{site}.html
# will get copied into the root dir of the packaged site with
# the site name stripped out.
#
# Example: for site name 'commercial', the files:
# * index-commercial.html would end up as #{site_root}/index.html
# * search-commercial.html would end up as #{site_root}/search.html
# * index-community.html would be ignored
site_files = Dir.glob(File.join(docs_root_dir, '*-' + site.id + '.html'))
unless site_files.empty?
site_files.each do |fpath|
target_basename = File.basename(fpath).gsub(/-#{site.id}\.html$/, '.html')
FileUtils.cp(fpath,File.join(package_dir,site.id,target_basename))
end
else
FileUtils.cp(File.join(preview_dir,distro_id,'index.html'),File.join(package_dir,site.id,'index.html'))
end
['_images','_stylesheets'].each do |support_dir|
FileUtils.cp_r(File.join(docs_root_dir,support_dir),File.join(package_dir,site.id,support_dir))
end
# Now build a sitemap
site_dir_path = Pathname.new(site_dir)
SitemapGenerator::Sitemap.create(
:default_host => site.url,
:public_path => site_dir_path,
:compress => false,
:filename => File.join(site_dir,'sitemap')
) do
file_list = Find.find(site_dir).select{ |path| not path.nil? and path =~ /.*\.html$/ }.map{ |path| '/' + Pathname.new(path).relative_path_from(site_dir_path).to_s }
file_list.each do |file|
add(file, :changefreq => 'daily')
end
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_doc\n\n end",
"def build_docs\n object_map.each do |index, objects|\n objects.each do |object|\n template_context = {\n #:meta => Site\n index => object\n }\n content = converter.render(template_map[index], template_co... | [
"0.7025104",
"0.6895687",
"0.6891454",
"0.6817433",
"0.6712377",
"0.6559261",
"0.65110385",
"0.64511514",
"0.6383649",
"0.6374848",
"0.63063586",
"0.6283706",
"0.6277167",
"0.6265359",
"0.6249514",
"0.62232125",
"0.62202656",
"0.6216915",
"0.62112314",
"0.6206207",
"0.6176756... | 0.70263433 | 0 |
Load all application base classes and project classes | def boot(options={})
Jets::Booter.boot!(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_app_classes\n @@load_paths.each do |name, path|\n log.debug \"Loading #{name} classes...\"\n\n Dir[\"#{self.app_path}/#{path}\"].each do |f|\n log.debug \"Loading: #{f}\"\n load(f)\n end\n end\n end",
"def eager_load_app\n Dir.glob(\"#{Jets.root}app... | [
"0.7853603",
"0.69282746",
"0.6747031",
"0.6740964",
"0.6738334",
"0.6534763",
"0.64810175",
"0.64100415",
"0.64043343",
"0.6390381",
"0.6380251",
"0.6323744",
"0.63156295",
"0.62905055",
"0.6288159",
"0.6259414",
"0.62520427",
"0.6237102",
"0.62188053",
"0.62188053",
"0.6173... | 0.0 | -1 |
Ensures trailing slash Useful for appending a './' in front of a path or leaving it alone. Returns: '/path/with/trailing/slash/' or './' | def root
root = ENV['JETS_ROOT'].to_s
root = '.' if root == ''
root = "#{root}/" unless root.ends_with?('/')
Pathname.new(root)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force_trailing_slash\n force_slash :slash\n end",
"def force_no_trailing_slash\n force_slash :noslash\n end",
"def strip_trailing_separator(path)\n (path[-1..-1] == File::SEPARATOR) ? path[0..-2] : path\n end",
"def strip_trailing_separator(path)\n (path[-1..-1] == File::SEPARATOR)... | [
"0.7397646",
"0.7105064",
"0.6981155",
"0.6944703",
"0.69088477",
"0.6888051",
"0.6837106",
"0.6757932",
"0.6724696",
"0.6695518",
"0.666412",
"0.66009593",
"0.65854824",
"0.6578989",
"0.6545393",
"0.6497248",
"0.64931893",
"0.6459733",
"0.64541274",
"0.64204204",
"0.6372197"... | 0.0 | -1 |
Eager load jet's lib and classes | def eager_load_jets
lib_jets = File.expand_path(".", File.dirname(__FILE__))
Dir.glob("#{lib_jets}/**/*.rb").select do |path|
next if !File.file?(path)
next if skip_eager_load_paths?(path)
path = path.sub("#{lib_jets}/","jets/")
class_name = path
.sub(/\.rb$/,'') # remove .rb
.sub(/^\.\//,'') # remove ./
.sub(/app\/\w+\//,'') # remove app/controllers or app/jobs etc
.camelize
# special class mappings
class_name = class_mappings(class_name)
class_name.constantize # use constantize instead of require so dont have to worry about order.
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eager_load_jets\n lib_jets = File.expand_path(\".\", File.dirname(__FILE__))\n\n # Sort by path length because systems return Dir.glob in different order\n # Sometimes it returns longer paths first which messed up eager loading.\n paths = Dir.glob(\"#{lib_jets}/**/*.rb\")\n paths = pat... | [
"0.7801447",
"0.670352",
"0.6686485",
"0.66410136",
"0.65960246",
"0.6541563",
"0.65088314",
"0.65069",
"0.6469864",
"0.64313465",
"0.64313465",
"0.64313465",
"0.6428624",
"0.6405717",
"0.6405717",
"0.6405717",
"0.6405717",
"0.6400634",
"0.63666815",
"0.62933266",
"0.62933266... | 0.789342 | 0 |
Skip these paths because eager loading doesnt work for them. | def skip_eager_load_paths?(path)
path =~ %r{/cli} ||
path =~ %r{/core_ext} ||
path =~ %r{/default/application} ||
path =~ %r{/functions} ||
path =~ %r{/internal/app} ||
path =~ %r{/jets/stack} ||
path =~ %r{/rackup_wrappers} ||
path =~ %r{/overrides} ||
path =~ %r{/reconfigure_rails} ||
path =~ %r{/templates/} ||
path =~ %r{/version} ||
path =~ %r{/webpacker}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip_paths; end",
"def eager_load_paths=(_arg0); end",
"def eager_load; end",
"def eager_load; end",
"def eager_load; end",
"def eager_load!; end",
"def eager_load!; end",
"def eager_load!; end",
"def eager_load!; end",
"def skip_eager_load_paths?(path)\n path =~ %r{/jets/builders/rackup... | [
"0.67860746",
"0.6615084",
"0.6463913",
"0.6463913",
"0.6463913",
"0.64461124",
"0.64461124",
"0.64461124",
"0.64461124",
"0.60683894",
"0.60054874",
"0.5968472",
"0.5957786",
"0.5884706",
"0.58409077",
"0.5819634",
"0.5707765",
"0.5706317",
"0.5691209",
"0.56859845",
"0.5682... | 0.62628853 | 9 |
Eager load user's application | def eager_load_app
Dir.glob("#{Jets.root}app/**/*.rb").select do |path|
next if !File.file?(path) or path =~ %r{/javascript/} or path =~ %r{/views/}
next if path.include?('app/functions') || path.include?('app/shared/functions') || path.include?('app/internal/functions')
class_name = path
.sub(/\.rb$/,'') # remove .rb
.sub(%{^\./},'') # remove ./
.sub(Jets.root.to_s,'')
.sub(%r{app/shared/\w+/},'') # remove shared/resources or shared/extensions
.sub(%r{app/\w+/},'') # remove app/controllers or app/jobs etc
class_name = class_name.classify
class_name.constantize # use constantize instead of require so dont have to worry about order.
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_apps\n Application.with_user(session[:user_id])\n end",
"def get_applications\n\t\tApplication.where(\"api_user_id = ?\", id)\n\tend",
"def fetch_user_application\n @user_application = UserApplication.find(params[:id])\n end",
"def show\n @user ||= current_user\n @app = @user.apps.... | [
"0.75280976",
"0.7057005",
"0.6984113",
"0.66157454",
"0.65743166",
"0.64198476",
"0.63606554",
"0.63442826",
"0.6343478",
"0.6334509",
"0.6291019",
"0.62062424",
"0.61833",
"0.6149415",
"0.6127991",
"0.6121968",
"0.61203223",
"0.6109654",
"0.609885",
"0.6011563",
"0.59990615... | 0.62232244 | 11 |
If some of the pagination fields are present all of the required ones should be present | def all_pagination_is_present
if current.nil?
errors.add(
:current,
ErrorMessage["should be present if pagination is being used", "6.4"]
)
end
if per_page.nil?
errors.add(
:per_page,
ErrorMessage["should be present if pagination is being used", "6.4"]
)
end
if count.nil?
errors.add(
:count,
ErrorMessage["should be present if pagination is being used", "6.4"]
)
end
return unless pages.nil?
errors.add(
:pages,
ErrorMessage["should be present if pagination is being used", "6.4"]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_pagination_is_present\n return unless pagination && count.nil?\n\n errors.add(:count, ErrorMessage[\"should be present if pagination is being used\", \"6.4\"])\n end",
"def all_pagination_is_present\n errors.add(:current, ErrorMessage[\"should be present if pagination is being u... | [
"0.75490224",
"0.737551",
"0.6330928",
"0.62576425",
"0.6133295",
"0.6087282",
"0.60783076",
"0.6010496",
"0.5984411",
"0.59277725",
"0.59265846",
"0.5923338",
"0.5906319",
"0.589252",
"0.5852344",
"0.583852",
"0.58337116",
"0.5828805",
"0.58100224",
"0.58093613",
"0.5806842"... | 0.7680296 | 0 |
This should return the minimal set of attributes required to create a valid Task. As you add validations to Task, be sure to update the return value of this method accordingly. | def valid_attributes
{ name: 'do this' }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def required_attributes\n self.class::REQUIRED_ATTRIBUTES\n end",
"def required_attributes\n self.class.required_attributes\n end",
"def valid_attributes\n {\n completed: false,\n cancelled: false,\n transaction_id: nil,\n completed_date: Date.new(2012, 1, 30)\n }\n e... | [
"0.6688299",
"0.6407886",
"0.6247821",
"0.61087316",
"0.6105401",
"0.6089896",
"0.604625",
"0.60356784",
"0.60345066",
"0.60308415",
"0.6017821",
"0.59927446",
"0.5979198",
"0.59750974",
"0.59479237",
"0.594435",
"0.594435",
"0.5934403",
"0.59238446",
"0.5920182",
"0.5915918"... | 0.0 | -1 |
def randomize create_deck.shuffle! end | def split_deck
main_deck = create_deck
# randomize
@player1_deck, @player2_deck = main_deck.each_slice(main_deck.length / 2).to_a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shuffle\n @deck.sort_by{rand}\n end",
"def shuffle!\n @deck.shuffle!\n end",
"def shuffle!\n @deck.shuffle!\n end",
"def shuffle\n\t\t@deck.shuffle!\n\tend",
"def shuffle\r\n @deck_of_cards.shuffle!\r\n end",
"def shuffle\n @fulldeck.shuffle!\n end",
"def shuffle\n @deck.shuf... | [
"0.88316035",
"0.8735238",
"0.8735238",
"0.87057173",
"0.8684295",
"0.85356915",
"0.84439564",
"0.84037036",
"0.8392677",
"0.8372821",
"0.8344032",
"0.83392346",
"0.8307635",
"0.830099",
"0.8296694",
"0.82873446",
"0.82658386",
"0.8265112",
"0.8241511",
"0.82067704",
"0.81425... | 0.0 | -1 |
GET /services/1 GET /services/1.xml | def show
begin
@service = Service.find(params[:id])
rescue ActiveRecord::RecordNotFound
return render :xml => "<WARNING>there is not a company for that id</WARNING>"
end
@signature = params[:signature]
#@auth = false
#if params[:email] and params[:password]
# @user = User.find_by_email(params[:email])
# if @user.password == params[:password]
# @auth = true
# else
# @auth = false
# end
#end
params = request.query_parameters.reject {|key, value| key.to_s == "signature"}
params.sort_by {|key, value| key.to_s.underscore}.join('')
@parameters = params.to_s
@secret = ApplicationAccount.api_secret_field
@app_key = ApplicationAccount.api_key_field
respond_to do |format|
format.html # show.html.erb
if params[:app_key] == @app_key #and @auth
if @signature == Digest::MD5.hexdigest("#{@app_key}#{@parameters}#{@secret}").to_s
#format.xml { render :xml => Digest::MD5.hexdigest("#{@app_key}#{@parameters}#{@secret}").to_s }
if @service != nil
format.xml { render :xml => @service.to_xml(:only => [:id, :name, :description, :contact_name, :contact_title, :contact_email, :buy, :created_at, :updated_at]) }
else
format.xml { render :xml => "<WARNING>there is not a service for that if</WARNING>" }
end
else
@test = Digest::MD5.hexdigest("#{@app_key}#{@parameters}#{@secret}").to_s
format.xml { render :xml => "<WARNING>El signature debe ser: #{@test} </WARNING>" }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service(id)\n request :get, \"/services/#{id}\"\n end",
"def index\n endpoint(get(services_url).body)\n end",
"def show\n @service = Service.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service }\n end\n end",
"... | [
"0.723194",
"0.721514",
"0.6730267",
"0.67126286",
"0.6581411",
"0.6567619",
"0.6438637",
"0.64325076",
"0.6306425",
"0.6260527",
"0.6197347",
"0.61746657",
"0.61644286",
"0.6164009",
"0.6106485",
"0.6106036",
"0.6087944",
"0.6068472",
"0.6034685",
"0.6034039",
"0.6010789",
... | 0.0 | -1 |
GET /services.xml?search="" GET /services.xml?search="" | def apiSearch
if params[:search]
@service = Service.find(:all, :conditions => ['name LIKE ?', "%#{params[:search]}%"], :limit => "10")
end
if params[:buy] && params[:search]
@service = Service.find(:all, :conditions => ['buy LIKE ? AND name LIKE ?', "#{params[:buy]}", "%#{params[:search]}%"], :limit => "20")
end
if params[:sell] && params[:search]
@service = Service.find(:all, :conditions => ['sell LIKE ? AND name LIKE ?', "#{params[:sell]}", "%#{params[:search]}%" ], :limit => "20")
end
@signature = params[:signature]
params = request.query_parameters.reject {|key, value| key.to_s == "signature"}
params.sort_by {|key, value| key.to_s.underscore}.join('')
@parameters = params.to_s
@secret = ApplicationAccount.api_secret_field
@app_key = ApplicationAccount.api_key_field
respond_to do |format|
format.html # show.html.erb
if params[:app_key] == @app_key
if @signature == Digest::MD5.hexdigest("#{@app_key}#{@parameters}#{@secret}").to_s
#format.xml { render :xml => Digest::MD5.hexdigest("#{@app_key}#{@parameters}#{@secret}").to_s }
if @service != nil
format.xml { render :xml => @service.to_xml(:only => [:id, :name, :description, :contact_name, :contact_title, :contact_email, :buy, :sell, :created_at, :updated_at]) }
else
format.xml { render :xml => "<WARNING>there is not such a service</WARNING>" }
end
else
@test = Digest::MD5.hexdigest("#{@app_key}#{@parameters}#{@secret}").to_s
format.xml { render :xml => "<WARNING>El signature debe ser: #{@test} </WARNING>" }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service\n :search\n end",
"def search\n send_request\n parse_response\n end",
"def search(params={})\n rpc_call :search, params\n end",
"def search_request(params)\n result = @client.connection.get(PATH, params)\n Yelp::Fusion::Error.check_for_error(result)\n ... | [
"0.6910118",
"0.6731106",
"0.6635299",
"0.66053593",
"0.6568901",
"0.65091103",
"0.65081006",
"0.64274377",
"0.64011955",
"0.6363637",
"0.63398576",
"0.63257706",
"0.63123184",
"0.62603164",
"0.6257575",
"0.6253306",
"0.6240399",
"0.62098044",
"0.61488116",
"0.6141087",
"0.61... | 0.6156288 | 18 |
POST /homes POST /homes.xml | def create
@service = Service.new(params[:service])
respond_to do |format|
if @service.save
format.html { }
format.xml { render :xml => @service }
else
format.html { render :action => "new" }
format.xml { render :xml => @service }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n ... | [
"0.5734492",
"0.5658696",
"0.56528664",
"0.5593424",
"0.55568516",
"0.55568516",
"0.55568516",
"0.552443",
"0.5505072",
"0.5505072",
"0.5502801",
"0.55014515",
"0.53770363",
"0.53711814",
"0.5343086",
"0.5340235",
"0.5338582",
"0.53349483",
"0.5293549",
"0.525572",
"0.5238923... | 0.0 | -1 |
POST /homes POST /homes.xml | def create_feed
@service = Service.new(params[:service])
respond_to do |format|
if @service.save
Pusher['post'].trigger('thing-create', @service.attributes)
#@service.update_followers
format.html { }
format.xml { render :xml => @service }
else
format.html { render :action => "new" }
format.xml { render :xml => @service }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n ... | [
"0.5733403",
"0.5659698",
"0.5649899",
"0.5590986",
"0.55572283",
"0.55572283",
"0.55572283",
"0.55247027",
"0.5505353",
"0.5505353",
"0.5502494",
"0.5501772",
"0.5374022",
"0.53721666",
"0.53428656",
"0.53412926",
"0.5339787",
"0.53330094",
"0.52918",
"0.52547604",
"0.524152... | 0.0 | -1 |
We store the original request parameters in the session for use later on. This allows us to recreate a tool provider instance whenever we need. The TP instance could be used from any controller | def get_tool_provider
launch_params = session[:launch_params]
if launch_params
course = Course.find_by(consumer_key: launch_params[:oauth_consumer_key])
if !course
# TODO: render invalid, and display error.
return nil
end
IMS::LTI::ToolProvider.new(
course.consumer_key, course.consumer_secret, launch_params
)
else
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_product_params\n if params[:lti_version] == LTI_20\n #sets paramaters for lti 2.0 launches\n if params[:tool_consumer_info_product_family_code] == \"moodle\"\n session_cache(:user_id, params[:custom_user_id])\n end\n else\n # needs to be a better way to identi... | [
"0.60957396",
"0.5998806",
"0.5730903",
"0.56900305",
"0.56518656",
"0.5627486",
"0.5612248",
"0.5579439",
"0.5540892",
"0.5509596",
"0.5508074",
"0.5476767",
"0.5475657",
"0.5475094",
"0.5475094",
"0.5465534",
"0.5416397",
"0.540909",
"0.5398324",
"0.53966254",
"0.5396157",
... | 0.0 | -1 |
7digits max: 1+2+3+4+5+6+7+8+9 = 45 can be divided by 3, 5, 9 etc., 1+2+3+4+5+6+7+8 = 36 can be divided by 2, 3, 9, etc 1+2+3+4+5+6+7 = 29 prime | def max_pandigital
(10000..10000000).select {|x| is_pandigital?(x) and Prime.prime?(x) }.max
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prime_digit_replacement()\r\n\treturner = 1000000\r\n\t# Loop through not repeated digits\r\n\tfor digits in (11..999).step(2)\r\n\t\t# Sum of 3 repeated digits is divisable by 3\r\n\t\tnext if digits % 3 == 0\r\n\t\t# The last digit is 1, 3, 7 or 9\r\n\t\tnext if digits % 5 == 0\r\n\t\t\r\n\t\t\r\n\t\tthe_pat... | [
"0.73615974",
"0.7104181",
"0.68644893",
"0.68388104",
"0.67849374",
"0.6771177",
"0.6753806",
"0.6737072",
"0.672735",
"0.6704046",
"0.66969806",
"0.66829497",
"0.6657553",
"0.6650259",
"0.66500026",
"0.663895",
"0.6631205",
"0.66298544",
"0.6622312",
"0.6616317",
"0.6608829... | 0.64468116 | 45 |
Indicates whether its possible to capture the payment | def can_capture?(payment)
['pending'].include?(payment.state)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment... | [
"0.8574391",
"0.8574391",
"0.8574391",
"0.8574391",
"0.8574391",
"0.8421634",
"0.840692",
"0.8374448",
"0.83426374",
"0.83426374",
"0.83002377",
"0.83002377",
"0.8285566",
"0.82840663",
"0.8245142",
"0.76958513",
"0.72335327",
"0.71325046",
"0.71325046",
"0.71179265",
"0.7106... | 0.83986884 | 7 |
Indicates whether its possible to void the payment. | def can_void?(payment)
payment.state != 'void'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_void?(payment)\n payment.state != 'void'\n end",
"def can_void?(payment)\n payment.state != 'void'\n end",
"def can_void?(payment)\n payment.state != 'void'\n end",
"def can_void?(payment)\n payment.state != 'void'\n end",
"def can_void?(payment)\n payment.state... | [
"0.84356356",
"0.84356356",
"0.84356356",
"0.84356356",
"0.84356356",
"0.84356356",
"0.84356356",
"0.84150326",
"0.84150326",
"0.8361645",
"0.8361645",
"0.8343876",
"0.8314437",
"0.8242753",
"0.8242753",
"0.7034802",
"0.6779422",
"0.675492",
"0.66847706",
"0.6645454",
"0.6554... | 0.8338418 | 13 |
will perform a "deep" duplication of the interior arrays. | def deep_dup(arr)
arr.map{ |el| el.is_a?(Array) ? deep_dup(el) : el }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_dup(arr)\n\nend",
"def deep_dup(arr)\n\nend",
"def deep_dup(arr)\n\nend",
"def deep_dup; end",
"def deep_dup\n map(&:deep_dup)\n end",
"def deep_dup(arr)\n duper_arr = arr.dup.map { |item| item * 1 }\nend",
"def recursive_deep_dup(arr)\n # # does arr contain anymore arrays?\n # if !(arr... | [
"0.7400182",
"0.7400182",
"0.7400182",
"0.7339284",
"0.70522535",
"0.70110035",
"0.6860769",
"0.68314147",
"0.68062174",
"0.6804951",
"0.6743031",
"0.67375064",
"0.67276067",
"0.6662698",
"0.6659184",
"0.6658481",
"0.6651581",
"0.6651255",
"0.6626733",
"0.6615528",
"0.6611488... | 0.6366838 | 36 |
Write a method that finds the sum of the first n fibonacci numbers recursively. Assume n > 0. | def fibs_sum(n)
return 0 if n == 0
return 1 if n == 1
fibs_sum(n-1) + fibs_sum(n-2) + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n - 1) + fibs_sum(n - 2) + 1\nend",
"def fibs_sum(n)\n return 1 if n == 1 || n == 2\n sum = 0\n sum += (fibs_sum(n - 1) + fibs_sum(n - 2))\n \n \nend",
"def fib_sum(n)\n return n if ( 0..1 ).include? n\n ( fib_sum( n - 1 ) + fi... | [
"0.8982573",
"0.8749606",
"0.8707792",
"0.86844903",
"0.8639406",
"0.8585744",
"0.8540067",
"0.853989",
"0.8504086",
"0.85023195",
"0.84864634",
"0.8471163",
"0.8441136",
"0.8436838",
"0.84359986",
"0.8425502",
"0.84211195",
"0.84190655",
"0.8410988",
"0.84105897",
"0.8406268... | 0.8976148 | 3 |
method that takes two arrays as arguments, returns one array elements of return array should be product of elements of parameter arrays at each index Logic iterate through first array transforming it with index multiply each element by value at same index in other array return first array Methods arraymap arraywith_index Code | def multiply_list(array1, array2)
array1.map.with_index {|e, i| e * array2[i] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiply_list(array1, array2)\n array1.map.with_index { |_, i| array1[i] * array2[i] }\nend",
"def multiply_list(array1, array2)\n array1.map.with_index { |num, index| num * array2[index] }\nend",
"def multiply_list(arr1, arr2)\n results = []\n arr1.each_with_index do |item, index|\n results << item... | [
"0.7728425",
"0.7727996",
"0.76698124",
"0.76515895",
"0.7637969",
"0.7569053",
"0.75674796",
"0.75312203",
"0.75177026",
"0.7511302",
"0.7488516",
"0.74849",
"0.74528265",
"0.74501306",
"0.7442203",
"0.7432982",
"0.7394657",
"0.7330787",
"0.7327403",
"0.73248434",
"0.7290066... | 0.7879685 | 0 |
returns game state (not for players, but for polling to display board) | def state
if Game.exists?(params[:id])
game = Game.find(params[:id])
board = JSON.parse(game.board)
en_passant = JSON.parse(game.en_passant)
pieces_captured = game.pieces
pieces_captured_arr = Array.new
pieces_captured.each do |p|
pieces_captured_arr.push(p.representation)
end
data = {
:turn => game.player1_turn,
:board => board['board'],
:white_can_castle_king_side => game.white_can_castle_king_side,
:white_can_castle_queen_side => game.white_can_castle_queen_side,
:black_can_castle_king_side => game.black_can_castle_king_side,
:black_can_castle_queen_side => game.black_can_castle_queen_side,
:en_passant => en_passant,
:pieces_captured => pieces_captured_arr
}
render :json => data
else
render :json => {:error => "Could not find game"}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game_state\n end",
"def get_game_state\n @game_state\n end",
"def state\n @game.state\n end",
"def game_state\n if @game_state.nil?\n @game_state = GameState.new(@player_count,@mode, 6, 7)\n end\n @game_state\n end",
"def state\n @gameState.state\n end",
"def... | [
"0.8237769",
"0.8217817",
"0.8195645",
"0.81947523",
"0.8146123",
"0.7929523",
"0.78138363",
"0.7710613",
"0.74454623",
"0.7340677",
"0.73148394",
"0.72333723",
"0.7167558",
"0.70825785",
"0.69975245",
"0.69864947",
"0.6966575",
"0.69193554",
"0.68540514",
"0.6851216",
"0.680... | 0.6433654 | 45 |
generates a random player token (50 chars just letters caps and lowercase) | def generatePlayerToken
o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
string = (0...50).map { o[rand(o.length)] }.join
return string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_token\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n token = (0...50).map { o[rand(o.length)] }.join\n return token\n end",
"def random_token\n 32.times.map{ rand(36).to_s(36) }.join # 32 alphanumeric characters\n end",
"def rand_token\n\t\ttok = rand(36**8)... | [
"0.84731936",
"0.81199557",
"0.78732634",
"0.7790704",
"0.7673421",
"0.73845994",
"0.7340708",
"0.7291375",
"0.71521795",
"0.71499413",
"0.7121795",
"0.7066577",
"0.70367044",
"0.7001612",
"0.6949486",
"0.69285923",
"0.69217145",
"0.6871915",
"0.6863118",
"0.6846745",
"0.6781... | 0.9223349 | 0 |
returns a new board (array) with all pieces in starting positions | def newBoard
[['r', 'n', 'b', 'k', 'q', 'b', 'n', 'r'],
['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'],
['', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', ''],
['P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'],
['R', 'N', 'B', 'K', 'Q', 'B', 'N', 'R']]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_board\n @original_board\n @working_board.collect! { |row|\n row.collect! { |cell|\n cell = @original_board.shift\n }\n }\n @working_board\n end",
"def generate_board\n [0, 1, 2].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]... | [
"0.7584157",
"0.7479291",
"0.7416679",
"0.738813",
"0.7195384",
"0.7188797",
"0.70814353",
"0.70788825",
"0.70620906",
"0.70602447",
"0.69951916",
"0.6994833",
"0.6976464",
"0.6952814",
"0.6887158",
"0.6860719",
"0.6844133",
"0.6840718",
"0.682071",
"0.682042",
"0.68168247",
... | 0.68890923 | 14 |
returns true if color is white, false if color is black | def isWhite?(piece)
if upcase?(piece)
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def white?\n color == \"white\"\n end",
"def white?\n @color == \"White\" ? true : false\n end",
"def black?\n @color == :black\n end",
"def red?\n not black?\n end",
"def color?\n !@color.nil?\n end",
"def color?\n false\n end",
"def black_an... | [
"0.8746625",
"0.8522186",
"0.829725",
"0.80676377",
"0.77835536",
"0.7744547",
"0.77434546",
"0.76257485",
"0.7578321",
"0.7578321",
"0.75738895",
"0.7551545",
"0.7471563",
"0.74627274",
"0.7444936",
"0.74300086",
"0.7375997",
"0.73649967",
"0.73442477",
"0.731569",
"0.728559... | 0.0 | -1 |
this is a shifted array of arrays so that I can test line by line | def shifted_grid_at(t)
grid = grid_at(t)
shifted_grid = [[]]
(0...@height).each do |i|
shifted_grid[i] = grid.map {|n| n[i] }.flatten
end
shifted_grid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consecutive(arr)\r\n\r\nend",
"def using_shift(array)\n array.shift\nend",
"def using_shift(array)\n array = array.shift(1)\n array.shift\n \nend",
"def using_shift(array)\n array.shift\nend",
"def using_shift(array)\n array.shift\nend",
"def using_shift(array)\n array.shift\nend",
"def us... | [
"0.64835757",
"0.6476224",
"0.6463506",
"0.64583504",
"0.64583504",
"0.64583504",
"0.64583504",
"0.64583504",
"0.64583504",
"0.64583504",
"0.64583504",
"0.64583504",
"0.64583504",
"0.64583504",
"0.64583504",
"0.6441897",
"0.63873935",
"0.63505757",
"0.63351226",
"0.6317905",
... | 0.5809445 | 62 |
If we get here as an admin then we are trying to manage the SemiStatic Galleries and Photos. If not we are just trying to get a look at the public photo gallery which is constructed from various Galaries and Photos GET /galleries GET /galleries.json | def index
@galleries = Gallery.all
@photos_without_gallery = Photo.without_gallery
layout = 'semi_static_dashboards'
template = 'semi_static/galleries/index'
respond_to do |format|
format.html { render :template => template, :layout => layout }
format.json { render json: @galleries }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n # find the galleries in batches so we can render in groups\n @title = @title + \" : Galleries\"\n @meta_description = @meta_description +\" : Galleries\"\n @galleries = @galleries.collect {|x| x}\n if can? :create, Roxiware::Gallery\n @galleries << Roxiware::Gallery.new({:name=>\"Cr... | [
"0.7168475",
"0.71428955",
"0.7063804",
"0.697796",
"0.6959694",
"0.69245774",
"0.6920003",
"0.68982685",
"0.6859322",
"0.68564063",
"0.685437",
"0.68472064",
"0.6841392",
"0.680442",
"0.67803204",
"0.6759556",
"0.6733722",
"0.6733487",
"0.67034835",
"0.665043",
"0.66124034",... | 0.6669235 | 19 |
GET /galleries/1 GET /galleries/1.json | def show
@gallery = Gallery.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @gallery }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @galleries = Gallery.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @galleries }\n end\n end",
"def index\n @galleries = Gallery.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @... | [
"0.79173",
"0.79173",
"0.79173",
"0.78776866",
"0.7735861",
"0.77346313",
"0.75375456",
"0.7476225",
"0.74502295",
"0.7445945",
"0.7402685",
"0.7398114",
"0.7391437",
"0.73493505",
"0.7328296",
"0.7328296",
"0.7328296",
"0.7328296",
"0.7328296",
"0.7302482",
"0.7277169",
"0... | 0.7718372 | 6 |
GET /galleries/new GET /galleries/new.json | def new
@gallery = Gallery.new(:public => true)
respond_to do |format|
format.html # new.html.erb
format.json { render json: @gallery }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @gallery }\n end\n end",
"def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @gallery ... | [
"0.81738216",
"0.81738216",
"0.80150497",
"0.7966339",
"0.7876386",
"0.75959265",
"0.7558604",
"0.7450037",
"0.74395204",
"0.7438541",
"0.7356059",
"0.7313115",
"0.7305743",
"0.72933495",
"0.72933495",
"0.72838986",
"0.72754234",
"0.7234663",
"0.7234663",
"0.72301626",
"0.720... | 0.807698 | 2 |
POST /galleries POST /galleries.json | def create
@gallery = Gallery.new(gallery_params)
respond_to do |format|
if @gallery.save
format.html { redirect_to galleries_path, notice: 'Gallery was successfully created.' }
format.json { render json: @gallery, status: :created, location: @gallery }
else
format.html { render action: "new" }
format.json { render json: @gallery.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @gallery = Gallery.new(params[:gallery])\n\n respond_to do |format|\n if @gallery.save\n format.html { redirect_to admin_galleries_path, :notice => 'Gallery was successfully created.' }\n format.json { render :json => @gallery, :status => :created, :location => @gallery }\n ... | [
"0.7460015",
"0.7399197",
"0.7155343",
"0.7140505",
"0.7140505",
"0.7107336",
"0.70191944",
"0.70053196",
"0.6927762",
"0.6925792",
"0.689635",
"0.68943924",
"0.6844402",
"0.6811574",
"0.6800961",
"0.67973506",
"0.6780412",
"0.6727763",
"0.6727763",
"0.671913",
"0.671568",
... | 0.71515477 | 3 |
PUT /galleries/1 PUT /galleries/1.json | def update
@gallery = Gallery.find(params[:id])
respond_to do |format|
if @gallery.update_attributes(gallery_params)
format.html { redirect_to galleries_path, notice: 'Gallery was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @gallery.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @gallery = Gallery.find(params[:id])\n @gallery.update_attributes(params[:gallery])\n respond_with(@gallery, :status => :updated)\n end",
"def update\n @gallery = Gallery.find(params[:id])\n\n respond_to do |format|\n if @gallery.update_attributes(params[:gallery])\n form... | [
"0.7388382",
"0.72166747",
"0.7159979",
"0.7085863",
"0.70411646",
"0.70411646",
"0.702858",
"0.7015805",
"0.6851621",
"0.67789596",
"0.6777676",
"0.6770698",
"0.67641455",
"0.67641455",
"0.6762513",
"0.67592263",
"0.67378473",
"0.67259187",
"0.6723243",
"0.6695327",
"0.66936... | 0.7065188 | 4 |
DELETE /galleries/1 DELETE /galleries/1.json | def destroy
@gallery = Gallery.find(params[:id])
@gallery.destroy
respond_to do |format|
format.html { redirect_to galleries_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @gallery.destroy\n respond_to do |format|\n format.html { redirect_to galleries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gallery.destroy\n respond_to do |format|\n format.html { redirect_to galleries_url }\n format.json { head :no_co... | [
"0.78423643",
"0.78423643",
"0.77934647",
"0.7768313",
"0.7735156",
"0.76906264",
"0.76312304",
"0.76214737",
"0.76214737",
"0.76214737",
"0.7608021",
"0.76022667",
"0.76022667",
"0.76022667",
"0.7579993",
"0.7539818",
"0.75060815",
"0.7498214",
"0.7483219",
"0.7464486",
"0.7... | 0.779075 | 3 |
Never trust parameters from the scary internet, only allow the white list through. | def gallery_params
params.fetch(:gallery, {}).permit(:title, :sub_title, :description, :public, :locale, :position)
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 /closeinfs/1 GET /closeinfs/1.json | def show
require 'helpers/File'
if params[:id] == 'download'
download(params[:filename], 'close')
else
@closeinf = Closeinf.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @closeinf }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @closeinf = Closeinf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @closeinf }\n end\n end",
"def show\n @close_type = CloseType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { rend... | [
"0.61175",
"0.59090835",
"0.58362865",
"0.5429993",
"0.537607",
"0.5374845",
"0.5358071",
"0.5322939",
"0.5301502",
"0.52932185",
"0.5291671",
"0.5280974",
"0.5277272",
"0.5275349",
"0.52495235",
"0.5248874",
"0.52433366",
"0.5227849",
"0.5225267",
"0.52250814",
"0.5222347",
... | 0.61735934 | 0 |
GET /closeinfs/new GET /closeinfs/new.json | def new
@closeinf = Closeinf.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @closeinf }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @closing_day = ClosingDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @closing_day }\n end\n end",
"def new\n @closing_item = ClosingItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render j... | [
"0.7077849",
"0.6888925",
"0.68275845",
"0.67439336",
"0.65633",
"0.6550313",
"0.6537993",
"0.6537859",
"0.6513445",
"0.6480039",
"0.64735425",
"0.6470534",
"0.6468734",
"0.6464568",
"0.6463906",
"0.6463464",
"0.64624304",
"0.6458232",
"0.6445406",
"0.6445406",
"0.6445406",
... | 0.7423692 | 0 |
POST /closeinfs POST /closeinfs.json | def create
# 用于接受客户端参数,并且进行文件上传
require 'helpers/File'
params[:closeinf][:user_id] = params[:user][:username]
params[:closeinf][:project_id] = params[:project][:projname]
params[:closeinf][:closeinf_type_id] = params[:close_type][:closetypename]
file_temp = params[:img_file]
params[:closeinf][:closedtl], params[:closeinf][:file_path] = upload(file_temp, 'close')
@closeinf = Closeinf.new(params[:closeinf])
respond_to do |format|
if @closeinf.save
format.html { redirect_to @closeinf, notice: 'Closeinf was successfully created.' }
format.json { render json: @closeinf, status: :created, location: @closeinf }
else
format.html { render action: "new" }
format.json { render json: @closeinf.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(**params)\n resp = connection.post do |req|\n req.url close_version_path\n req.headers['Content-Type'] = 'application/json'\n req.body = params.to_json if params.any?\n end\n return resp.body if resp.success?\n\n raise_exception_based_o... | [
"0.56301755",
"0.5606542",
"0.5515276",
"0.54856414",
"0.54784036",
"0.5477798",
"0.5404403",
"0.5362803",
"0.5307257",
"0.51725245",
"0.5163815",
"0.5152656",
"0.5142727",
"0.51115125",
"0.5038443",
"0.500996",
"0.50016683",
"0.49828017",
"0.49638155",
"0.4938642",
"0.493452... | 0.4748692 | 56 |
PUT /closeinfs/1 PUT /closeinfs/1.json | def update
@closeinf = Closeinf.find(params[:id])
respond_to do |format|
# 更新客户端传入的交底参照信息,获得详细的更新信息
require 'helpers/File'
params[:closeinf][:user_id] = params[:user][:username]
params[:closeinf][:project_id] = params[:project][:projname]
params[:closeinf][:closeinf_type_id] = params[:close_type][:closetypename]
file_temp = params[:img_file]
#判定上传文件是否为空,为空,则不进行attribute_update,我们在程序模拟中必须注意到程序本身带来的不好的地方。
if file_temp != nil
params[:closeinf][:closedtl], params[:closeinf][:file_path] = upload(file_temp, 'close')
begin
File.delete('public/uploads/everydaycheck/' + @everyday_check.file_path)
rescue Exception => e
puts 'Error happened in everydaycheck'
else
#do nothing
end
end
if @closeinf.update_attributes(params[:closeinf])
format.html { redirect_to @closeinf, notice: 'Closeinf was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @closeinf.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_close\n respond_to do |format|\n if @ticket.update({status: Ticket::STATUS[:closed]})\n format.html { redirect_to @ticket, notice: 'Ticket was successfully marked as close.' }\n format.json { render json: {status: :ok}, status: :ok }\n else\n format.html { render :edit }\... | [
"0.5732741",
"0.57161546",
"0.5566008",
"0.55318993",
"0.54938513",
"0.54193807",
"0.5392865",
"0.531831",
"0.5307802",
"0.53030163",
"0.52888626",
"0.52763444",
"0.5260425",
"0.5260425",
"0.524919",
"0.52456635",
"0.5243543",
"0.52394587",
"0.52290696",
"0.52250195",
"0.5218... | 0.5971556 | 0 |
DELETE /closeinfs/1 DELETE /closeinfs/1.json | def destroy
@closeinf = Closeinf.find(params[:id])
begin
File.delete('public/uploads/close/'+@closeinf.file_path)
#删除文件有异常
rescue Exception => e
@closeinf.destroy
respond_to do |format|
format.html { redirect_to closeinfs_url }
format.json { head :no_content }
end
#删除文件无异常
else
@checkclose.destroy
respond_to do |format|
format.html { redirect_to closeinfs_url }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.... | [
"0.6944969",
"0.6866875",
"0.6783035",
"0.6702318",
"0.6677346",
"0.66628575",
"0.6590796",
"0.65872025",
"0.6575044",
"0.65679896",
"0.65679896",
"0.65679896",
"0.65679896",
"0.6540727",
"0.6539638",
"0.65268266",
"0.6513336",
"0.65058565",
"0.6500282",
"0.6479471",
"0.64583... | 0.6227316 | 67 |
Public: h_line Prints 50 dashes Returns: nil | def h_line
puts "-" * 50
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def h_line\n puts \"-\" * 80\n nil\nend",
"def line(length)\r\n puts '-'*length\r\n end",
"def hor_line\n\tfor i in 1..40\n\t\tprint \"-\"\n\tend\n\tputs ''\nend",
"def draw_line\n print H_SEP * columns\n end",
"def line\n\tputs \"-\" * 100\nend",
"def hline_top\n\tputs \"________________... | [
"0.86265355",
"0.77026343",
"0.7663781",
"0.7604804",
"0.7451925",
"0.736618",
"0.7355962",
"0.7141785",
"0.7083467",
"0.7041664",
"0.69648063",
"0.6958107",
"0.6832822",
"0.6783785",
"0.6701356",
"0.6693674",
"0.65621626",
"0.6554766",
"0.6550699",
"0.6524145",
"0.6482129",
... | 0.8742658 | 0 |
Public: check_input Prompts for input and checks it against an array of accepted answers. Parameters: valid_inputs Array: filled with strings of acceptable answers, in all caps Returns: String: one of the acceptable inputs. | def check_input(valid_inputs)
input = ""
loop do
input = gets.chomp.upcase
break if (valid_inputs).include?(input)
puts "Sorry. One more time:"
end
return input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(answers, input)\n until answers.include?(input)\n puts \"#Invalid input: #{input}\"\n input_answer\n end\n end",
"def get_user_input_and_check(acceptable_input)\n input = gets.chomp.downcase\n\n if acceptable_input.include? input\n return input\n\n else\n puts \"This is n... | [
"0.6287418",
"0.6169844",
"0.6125823",
"0.60314864",
"0.59804344",
"0.5928665",
"0.5885104",
"0.5880054",
"0.5820643",
"0.5804579",
"0.5698831",
"0.5687427",
"0.55930513",
"0.5560649",
"0.5529404",
"0.55199146",
"0.55174613",
"0.5516323",
"0.54859287",
"0.5477245",
"0.5428173... | 0.65750086 | 0 |
Public: create_player Creates a new Player objects using prompts. Parameters: num The player number. (IE: Player >1<) Returns: Player: a new player object. | def create_player(num, rules)
n =num.to_s
puts "Enter a name for Player " + n + ":"
name = gets.chomp
puts "Is Player" + n + " a HUMAN or a COMPUTER?"
valid = ["HUMAN","COMPUTER","COMP"]
control = check_input(valid)
p = Ai_Player.new(name,rules) if control == "COMPUTER" || control == "COMP"
p = Player.new(name,rules) if control == "HUMAN"
p
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_player(name, num)\n if name.downcase == \"computer\"\n player = ComputerPlayer.new(num)\n else\n player = HumanPlayer.new(name, num)\n end\n end",
"def make_player(player_num)\n choice = 0\n puts \"For Human Opponent type 1 \\nFor Computer Opponent type 2\"\n until choice ... | [
"0.7922465",
"0.73809904",
"0.71365845",
"0.7084906",
"0.7084208",
"0.6978517",
"0.6682843",
"0.66764545",
"0.65941584",
"0.658794",
"0.6586699",
"0.6546664",
"0.65409225",
"0.6536326",
"0.6445688",
"0.6437183",
"0.6434093",
"0.6402117",
"0.6396714",
"0.63859093",
"0.6384554"... | 0.6499815 | 14 |
Public: pause Prompts a key press before continuing. Returns: nil | def pause
puts "press ENTER to cotinue"
h_line
gets
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pause\n print \"Press Enter/Return to continue...\"\n gets\n end",
"def pause(msg=\"paused, press return key to continue\")\n puts msg\n STDIN.gets\n end",
"def pause\n $stderr.write('Press CTRL+j or ENTER to continue') && $stdin.gets\n end",
"def pause_program\n puts\n puts \"Press e... | [
"0.78134054",
"0.7607792",
"0.75839984",
"0.7480084",
"0.73513764",
"0.7316182",
"0.7269941",
"0.7252803",
"0.7221303",
"0.70161563",
"0.697211",
"0.68219423",
"0.6799451",
"0.6799451",
"0.67980736",
"0.67980736",
"0.6793515",
"0.6766887",
"0.6703891",
"0.6690236",
"0.6637468... | 0.6970771 | 11 |
Public: play_rps Launches a new RPS or RPSLS game Returns: Player: the winning player. | def play_game
puts "Would you like to play"
puts "Rock-Paper-Scissor (RPS)"
puts "OR"
puts "Rock-Paper-Scissor-Lizard-Spock? (RPSLS)"
h_line
rule_type = check_input(["RPS","RPSLS"])
rules = rule_type == "RPS" ? RPS_Rules.new : RPSLS_Rules.new
puts "Ok! Let's play " + rules.prompt + "!"
h_line
p1 = create_player(1,rules)
p2 = create_player(2,rules)
h_line
puts "Great. How many points are you playing to? (1-5)"
valid = ["1","2","3","4","5"]
length = check_input(valid).to_i
this_game = Game.new(p1,p2,length,rules)
h_line
puts "Ok!"
puts rules.prompt + ":"
puts this_game.p1.control + ":" +this_game.p1.name + " > VERSUS < " + this_game.p2.name + ":" + this_game.p2.control
puts "First to " + length.to_s + " points wins!"
pause
this_game.run_game
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n player1 = Player.new(\"You\")\n player2 = Player.new(\"Computer\")\n rps = RockPaperScissors.new\n\t\tbegin\n\t\t\tputs \"---------Play Rock Paper Scissors!----------------\"\n\n\t\t\tplayer1.choose_by_input\n\t\t\tplayer2.choose_by_rand\n\n\t\t\tputs \"#{player1.name} picked #{player1.ges... | [
"0.6371746",
"0.6187104",
"0.59339637",
"0.5784927",
"0.5780514",
"0.57542855",
"0.5749713",
"0.5703505",
"0.56976956",
"0.56902844",
"0.5633042",
"0.56262994",
"0.56201017",
"0.56114477",
"0.55578274",
"0.5523221",
"0.55062485",
"0.550315",
"0.5482069",
"0.5472737",
"0.54608... | 0.6009627 | 2 |
check if server exist in compute | def server_exist?(server_name)
compute = find_match(@compute.servers, server_name)
Puppet.debug "found server #{compute.name}" if compute != nil
Puppet.debug "server not found : #{server_name}" if compute == nil
return (compute != nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists_on_server?\n false\n end",
"def relevant?(server)\n server.exists?\n end",
"def checkServerExists(serverName)\n serverUrl = @appContext.getMasterURL() + \"/applications/\" + @appContext.getProject() + \"/assets/\" + serverName\n\n serverResult = @cloudmunchDataService.g... | [
"0.7758609",
"0.7445115",
"0.7226025",
"0.7120099",
"0.70724654",
"0.6991541",
"0.6716336",
"0.6710328",
"0.6610517",
"0.6608994",
"0.6608994",
"0.6608994",
"0.6545763",
"0.6497927",
"0.6497927",
"0.6470132",
"0.6450725",
"0.6447277",
"0.64317715",
"0.6431342",
"0.64159805",
... | 0.83819765 | 0 |
create a server TODO: Implement a fog provider mapping. Ex: flavor_ref(openstack) = flavor_id(hpcloud) | def server_create(server_name, template)
# calculate instance id
Puppet.debug "template keys => " + JSON.pretty_generate(template)
server_id, server_host = ::Pinas::Common.extract_instance_id_from(server_name)
# 1. setup the default options
options = {
:name => server_name,
:flavor_ref => get_flavor(template[:flavor_name]), # For Openstack provider
:image_ref => get_image(template[:image_name]), # For Openstack provider
:flavor_id => get_flavor(template[:flavor_name]), # For HPCloud provider
:image_id => get_image(template[:image_name]), # For HPCloud provider
:key_name => template[:key_name],
:security_groups => template[:security_groups],
}
Puppet.debug "setup default options = >" + JSON.pretty_generate(options)
# 2. setup the meta data/user data for the server, for boot hooks
begin
options[:metadata] = meta_to_hash(ERB.new(template[:meta_data]).result(binding)) if template.has_key?(:meta_data)
rescue Exception => e
Puppet.crit "servers.create in running erb for :metadata, Error: #{e}"
raise Puppet::Error, "Error : #{e}"
end
begin
options[:user_data] = ERB.new(File.read(template[:user_data])).result(binding) if template.has_key?(:user_data)
rescue Exception => e
Puppet.crit "servers.create in running erb for :user_data, Error: #{e}"
raise Puppet::Error, "Error : #{e}"
end
Puppet.debug "added metadata and user_data"
Puppet.debug "has network_name key ? #{template.has_key?(:network_name)}"
Puppet.debug "network class => #{network.class}"
Puppet.debug "template[:network_name] => #{template[:network_name]}"
Puppet.debug "template[:network_name] => #{template['network_name']}"
# 3. get the network uuid and name
if @network != nil and template.has_key?(:network_name) and template[:network_name] != ''
Puppet.debug "adding network #{template[:network_name]}"
networks = Array.new
nics = Array.new
nics << get_networkid(template[:network_name])
# nics << template[:network_name]
Puppet.debug "working on nics => #{nics}."
begin
nics.each do |net|
Puppet.debug "working on net => #{net}"
network = find_match(@network.networks, net)
networks.push('net_id' => network.id) if network
end
options[:nics] = networks
rescue Exception => e
raise Puppet::Error, "Problem assigning nics, #{e}"
end
Puppet.debug "after options, got = >" + JSON.pretty_generate(options)
end
# 4. create new server and wait for it to be ready.
# TODO: implement retryable and wait for code. need to confirm we have a timeout in fog.
# server = @compute.servers.create(options)
# retryable(on: Timeout::Error, tries: 200) do
# begin
# server.wait_for(30) { ready? }
# rescue RuntimeError, Fog::Errors::TimeoutError => e
# end
# end
Puppet.debug "attempting to create server #{server_name}"
new_server = nil
begin
new_server = @compute.servers.create(options)
new_server.wait_for { ready?}
new_server.wait_for { !addresses.nil? }
rescue Exception => e
Puppet.crit "servers.create Error: #{e}"
raise Puppet::Error, "Error : #{e}"
end
Puppet.notice "server created #{server_name} on net #{template[:network_name]} "
begin
newserver_ip_assign(new_server)
rescue Exception => e
Puppet.crit "server_ip_assign Error: #{e}"
raise Puppet::Error, "Error : #{e}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_server\n return nil if created? # only create a server if it does not already exist\n\n fog_description = fog_description_for_launch\n Chef::Log.debug(JSON.generate(fog_description)) # .dup.tap{|hsh| hsh[:user_data] = \"...\" }\n @fog_server = ClusterChef.connection.servers.create(fo... | [
"0.818937",
"0.75562346",
"0.7476839",
"0.73587906",
"0.7252064",
"0.72276723",
"0.72026455",
"0.71210223",
"0.69939023",
"0.6873014",
"0.681299",
"0.6665641",
"0.6600895",
"0.65933937",
"0.65772545",
"0.6442145",
"0.6347069",
"0.6263782",
"0.6257452",
"0.62562835",
"0.622254... | 0.6984542 | 9 |
get the public ip of the server | def server_get_public_ip(server_name)
public_ip = ''
if server_exist?(server_name)
server = find_match(@compute.servers, server_name)
network_name = server.addresses.keys.reduce
server.addresses.each do |address|
if (address.include? network_name and address.length == 2) #TODO: research why is this 'private' for a public ip?
if address[1].length >= 2
Puppet.debug "found floating ip = #{address[1][1].inspect}"
public_ip = address[1][1].addr
end
end
end
end
return public_ip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_public_ip()\n return open('http://ipinfo.io/ip').read.chomp\n end",
"def public_ip_of(server)\n server[:cloud][:public_ips].first rescue server[:ipaddress]\n end",
"def public_ip\n @public_ip ||= ssh.exec!(\"curl -s ip.appspot.com\").chomp\n end",
"def public_ip\n get('tools... | [
"0.8697886",
"0.86516935",
"0.86350006",
"0.8616807",
"0.83469546",
"0.8312011",
"0.8231474",
"0.8214037",
"0.8207131",
"0.8206954",
"0.77777594",
"0.7711924",
"0.7619694",
"0.75525326",
"0.750365",
"0.74890304",
"0.7476139",
"0.7475511",
"0.7473358",
"0.74596727",
"0.7459445... | 0.8082872 | 10 |
get the private ip of the server | def server_get_private_ip(server_name)
private_ip = ''
if server_exist?(server_name)
server = find_match(@compute.servers, server_name)
network_name = server.addresses.keys.reduce
server.addresses.each do |address|
if (address.include? network_name and address.length == 2)
if address[1].length >= 1
Puppet.debug "found private ip = #{address[1][0].inspect}"
private_ip = address[1][0].addr
end
end
end
end
return private_ip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private_ip_of(server)\n server[:cloud][:private_ips].first rescue server[:ipaddress]\n end",
"def private_ip_address\n data[:private_ip_address]\n end",
"def private_ip_address\n data[:private_ip_address]\n end",
"def private_ip_address\n private_ip_addresses.first\n ... | [
"0.87660265",
"0.83581096",
"0.83581096",
"0.8354842",
"0.76777065",
"0.7480041",
"0.7451758",
"0.7451004",
"0.7351276",
"0.7297032",
"0.7266264",
"0.7227498",
"0.7210426",
"0.71533185",
"0.7143917",
"0.7142919",
"0.7124676",
"0.70997345",
"0.70821524",
"0.70349985",
"0.70226... | 0.85386646 | 1 |
get the server id by private ip | def get_server_id_by_private_ip(private_ip)
@compute.servers.each do |server|
network_name = server.addresses.keys.reduce
server.addresses.each do |address|
if (address.include? network_name and address.length == 2)
if address[1].length >= 1
return server.id if address[1][0].addr == private_ip
end
end
end
end
return String.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private_ip_of(server)\n server[:cloud][:private_ips].first rescue server[:ipaddress]\n end",
"def server_get_private_ip(server_name)\n private_ip = ''\n if server_exist?(server_name)\n server = find_match(@compute.servers, server_name)\n network_name = server.addresses... | [
"0.7398203",
"0.7192604",
"0.70878214",
"0.7020143",
"0.67711514",
"0.67711514",
"0.671367",
"0.66729397",
"0.66370374",
"0.6528102",
"0.64893407",
"0.64458925",
"0.6414055",
"0.6407606",
"0.63592935",
"0.62540674",
"0.6189041",
"0.61716264",
"0.61472607",
"0.60932887",
"0.60... | 0.84600043 | 0 |
assign floating IP address to server by server hash TODO: consider moving to network class. only assign an ip if the server does not have two addresses yet. | def newserver_ip_assign(server)
if server != nil
addresses = server.addresses
if addresses != nil
network_name = server.addresses.keys.reduce
else
raise Puppet::Error, "Server has no network connections"
end
if addresses[network_name].count < 2
# check if already assigned
new_ip = nil
ip = get_free_floating_ip(server)
if ip != nil
begin
new_ip = @compute.associate_address(server.id, ip)
Puppet.notice "#{server.name} assigned ip => #{ip}"
rescue Exception => e
Puppet.err e
raise Puppet::Error, "associate_address Error : #{e}"
end
else
Puppet.warning "unable to assign server an ip : #{server.name}"
return nil
end
end
else
Puppet.warning "unable to find server to assign new ip #{server.name}"
return nil
end
return ip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_ip_assign(server_name)\n server = find_match(@compute.servers, server_name)\n if server != nil\n addresses = server.addresses\n if addresses != nil\n network_name = server.addresses.keys.reduce\n else\n Puppet.warning \"falling back to defau... | [
"0.6806789",
"0.6500675",
"0.63566226",
"0.6337944",
"0.62494177",
"0.60901153",
"0.60754216",
"0.6040648",
"0.6036684",
"0.59324336",
"0.58764076",
"0.58725256",
"0.58167773",
"0.57655394",
"0.5742207",
"0.57305163",
"0.57063264",
"0.566032",
"0.5587862",
"0.5573104",
"0.556... | 0.6999791 | 0 |
assign floating IP address to server by server name TODO: consider moving to network class. only assign an ip if the server does not have two addresses yet. | def server_ip_assign(server_name)
server = find_match(@compute.servers, server_name)
if server != nil
addresses = server.addresses
if addresses != nil
network_name = server.addresses.keys.reduce
else
Puppet.warning "falling back to default network"
network_name = 0 # HACK HACK HACK
end
if addresses[network_name].count < 2
# check if already assigned
new_ip = nil
ip = get_free_floating_ip(server)
if ip != nil
begin
new_ip = @compute.associate_address(server.id, ip)
Puppet.notice "#{server_name} assigned ip => #{ip}"
rescue Exception => e
Puppet.err e
raise Puppet::Error, "associate_address Error : #{e}"
end
else
Puppet.warning "unable to assign server an ip : #{server_name}"
return nil
end
end
else
Puppet.warning "unable to find server to assign new ip #{server_name}"
return nil
end
return ip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newserver_ip_assign(server)\n if server != nil\n addresses = server.addresses\n if addresses != nil\n network_name = server.addresses.keys.reduce\n else\n raise Puppet::Error, \"Server has no network connections\"\n end\n if addresses[ne... | [
"0.71509236",
"0.68237644",
"0.6613084",
"0.630855",
"0.62768096",
"0.6230427",
"0.6183832",
"0.61543864",
"0.6126896",
"0.61200947",
"0.59556305",
"0.5894039",
"0.58508474",
"0.5832372",
"0.5788153",
"0.57385373",
"0.57385373",
"0.57273495",
"0.5724624",
"0.5709159",
"0.5692... | 0.7707745 | 0 |
get an ip that is already allocated but unassigned to a server if one is not assigned, getting a new floating ip generated, and return that. | def get_free_floating_ip(server)
@compute.addresses.each do |address|
Puppet.debug "found a free address to assign #{address.ip}" if address.instance_id == nil
return address.ip if address.instance_id == nil
end
#if no free address generate new address
Puppet.debug "no free address available, create a new one."
ext_net = nil
begin
ext_net = get_first_external_network
rescue Exception => e
Puppet.err e
raise Puppet::Error, "get_first_external_network Error : #{e}"
end
response = nil
if ext_net != nil
Puppet.debug "using #{ext_net.name}"
ext_net_id = ext_net.id
#TODO: consider creating options for the hash below so we can
# provide more flexiblity in external network config.
hsh = {
#:tenant_id => server.tenant_id
#:floating_network_id => ext_net_id #,
#:port_id => @port,
#:fixed_ip_address => @fixed_ip,
#:floating_ip_address => @floating_ip
}
begin
Puppet.debug hsh
response = @network.create_floating_ip(ext_net_id, hsh)
Puppet.debug "got response = > #{response.status}"
rescue Exception => e
Puppet.err e
raise Puppet::Error, "create_floating_ip Error : #{e}"
end
else
Puppet.warning "unable to get a valid external network"
end
Puppet.debug "use new floating ip address: #{response}"
new_ip = nil
unless response.nil?
# this was failing : new_ip = response.body['floating_ip']['ip']
new_ip = response.body['floatingip']['floating_ip_address']
Puppet.debug "allocated a new address => #{new_ip}"
end
return new_ip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_ip_assign(server_name)\n server = find_match(@compute.servers, server_name)\n if server != nil\n addresses = server.addresses\n if addresses != nil\n network_name = server.addresses.keys.reduce\n else\n Puppet.warning \"falling back to defau... | [
"0.7469574",
"0.7457788",
"0.6577303",
"0.6576384",
"0.6510679",
"0.6300828",
"0.6244166",
"0.62412643",
"0.6211759",
"0.61293024",
"0.6083286",
"0.6059457",
"0.60062665",
"0.59955215",
"0.5916703",
"0.59026724",
"0.58915484",
"0.58907485",
"0.5890273",
"0.5865011",
"0.585092... | 0.7922082 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.