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
end utility methods private The methods below should not be private methods, as they will be called from outside of this file. Namely, it will be taken care of by the controller, with input coming from the statistics UI template. Statistic creation initially goes through a pipeline of operations which successively cleans the unstructured data and organizes it in such a way that analytics can be made possible. Currently Statistic creation is done during the destruction of a Scenario, whereby the bash data is brought down from an s3 bucket and parsed into a nested Hash, mapping users to timestamps to commands. The methods defined below are helper methods that allow the investigator to reveal certain aspects of the data.
def perform_analytics(data) # input -> data: a hash of the form { users -> list of strings of commands } # output -> results: a nested array of two-element arrays results = [] # [[ string, count ]] or {string => count}, chartkick can deal with either. frequencies = Hash.new(0) data.keys.each do | user | data[user].each do | cmd | if !frequencies.include?(cmd) frequencies[cmd] = 1 else frequencies[cmd] += 1 end end end return frequencies end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_stats(example)\n file_path = example.metadata[:file_path].gsub('./qa/specs/features', '')\n api_fabrication = ((example.metadata[:api_fabrication] || 0) * 1000).round\n ui_fabrication = ((example.metadata[:browser_ui_fabrication] || 0) * 1000).round\n\n {\n n...
[ "0.6137582", "0.5838895", "0.58100486", "0.57925653", "0.5538713", "0.5532725", "0.55223686", "0.55223686", "0.551081", "0.5502233", "0.5495581", "0.5489085", "0.5460216", "0.54348266", "0.54348266", "0.53910595", "0.5382593", "0.5376617", "0.5376617", "0.5376617", "0.5376617...
0.0
-1
accept any name except Bob
def check_sign(number) if number == 0 number elsif number > 0 "#{number} is positive" else "#{number} is negative" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allow?(name) \n return return_symbol if name_matchers.reject{|name_matcher| !name.match(name_matcher) } \n end", "def valid_name (name)\r\n /^\\w+$/.match (name)\r\n end", "def name_can_not_be_greg\n if self && self....
[ "0.6387961", "0.63849723", "0.62850595", "0.6264245", "0.6209132", "0.61507624", "0.6120526", "0.6076266", "0.60428", "0.60258096", "0.59472674", "0.5945586", "0.58928156", "0.5886686", "0.58759624", "0.5872772", "0.58523166", "0.5841868", "0.5835568", "0.5827848", "0.5822463...
0.0
-1
Ternary operator ? == "then" : == "else"
def check_sign(number) number > 0 ? "#{number} is positive" : "#{number} is negative" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ternary(statement, true_result, false_result)\n statement && true_result || false_result\nend", "def on_ifop(statement, true_val, false_val)\n return Node.new(\n :ternary,\n [statement, true_val, false_val],\n metadata\n )\n end", "def else?\n loc.else\n end",...
[ "0.7405856", "0.68724704", "0.67900676", "0.6786287", "0.65658075", "0.6467765", "0.64098865", "0.6359833", "0.6308969", "0.6269744", "0.62695235", "0.6257247", "0.62191004", "0.6208144", "0.6196348", "0.61727494", "0.6171337", "0.613032", "0.6084351", "0.6083681", "0.6041825...
0.0
-1
START Feed Action Tests
def test_get_feed get :feed assert_response :success end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_mp3_feed_works\n get \"/podcast_feed/all/mp3/rss.xml\"\n assert last_response.ok?\n end", "def fetch_test_feed\n logger.info 'FeedManager: env is test, fetching test data'\n data = Feedzirra::Feed.parse File.open(Rails.root.join('test', 'test_feeds', 'valid_feed.xml'), 'r').read\n return...
[ "0.6573332", "0.6347964", "0.6263043", "0.624825", "0.61992455", "0.6184532", "0.61655474", "0.6161431", "0.6106196", "0.60878974", "0.6031313", "0.5993742", "0.59935594", "0.5933913", "0.5873512", "0.5824045", "0.5824045", "0.5824045", "0.5824045", "0.57848823", "0.5769436",...
0.6938861
0
This is needed to stop test/unit from complaining that there is no test specified.
def test_hack assert(true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nothing\n end", "def test_nothing\n end", "def default_test\r\n end", "def default_test; end", "def default_test\n end", "def no_test\n flunk \"Test hasn't been written yet.\"\n end", "def default_test\n end", "def default_test\n end", "def __dummy_test__\n end",...
[ "0.76619726", "0.7476823", "0.74766475", "0.7436754", "0.74323094", "0.7390081", "0.73688567", "0.73688567", "0.7338989", "0.7278272", "0.72308105", "0.7103861", "0.6944664", "0.6903399", "0.67680943", "0.67680943", "0.6746586", "0.6746586", "0.67067266", "0.67013687", "0.664...
0.6091755
66
Defines the base unit of the class. ==== Example class Coolness true end
def base name, options = {} self.base_unit = name unit name, Rational(1), options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def superclass() end", "def base_class\n # create the base class file\n File.open(File.join(repo_name, 'lib', \"#{use_kata_name}.rb\"), 'w') {|f| f.write <<EOF}\nclass #{class_name}\nend\nEOF\n end", "def class Motorbike < Vehicle\r\n def wheelie\r\n end\r\nend", "def base_class; end...
[ "0.6647527", "0.6366933", "0.63147736", "0.63143635", "0.62903374", "0.6182327", "0.605098", "0.60183364", "0.6010736", "0.58870333", "0.58845043", "0.58530265", "0.58347595", "0.58311456", "0.5828461", "0.5828461", "0.5774724", "0.57660365", "0.57660365", "0.5753517", "0.571...
0.625815
5
Returns the hash of rules for the current class.
def rules Gorilla.units[name] ||= {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rules_as_hash\n\t\tunless @rules_as_hash\n\t\t\t@rules_as_hash = self.rules.each_with_object( {} ) do |rule, hash|\n\t\t\t\tpred, succ = self.parse_rule( rule )\n\t\t\t\thash[ pred ] = succ\n\t\t\tend\n\n\t\t\tself.alphabet.each do |char|\n\t\t\t\t@rules_as_hash[ char ] = char unless @rules_as_hash.key?( char ...
[ "0.6794187", "0.6490616", "0.64846677", "0.6477441", "0.64107436", "0.63832694", "0.63832694", "0.63832694", "0.6380443", "0.63434917", "0.6340206", "0.6268185", "0.6236619", "0.62218547", "0.6218318", "0.6203768", "0.620095", "0.6198281", "0.61724883", "0.61709374", "0.61691...
0.0
-1
Class method version of Gorilla::Unitnormalize, to handle, e.g., Enumerable, Numeric, and Range objects.
def normalize input, &block case input when Range normalize(input.min, &block)..normalize(input.max, &block) when Enumerable input.map { |unit| normalize unit, &block } when Numeric normalize Unit.new(input), &block else # Unit, etc. input.normalize(&block) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to(unit)\n unit = Unit.get(unit) if unit.is_a?(Symbol)\n self.normalize + unit.denormalize\n end", "def normalize\n divide(magnitude)\n end", "def normalized; end", "def normalize\n self / self.norm\n end", "def normalize; end", "def normalize!\n\t\t\tmagnitude = self...
[ "0.6815934", "0.67310166", "0.67151874", "0.6477827", "0.64341897", "0.64118713", "0.6294422", "0.6287442", "0.6274068", "0.62591845", "0.6256661", "0.6229033", "0.62161964", "0.60913044", "0.60724473", "0.60711014", "0.606446", "0.60351926", "0.60207754", "0.60141015", "0.60...
0.7427953
0
Instantiates a new unit for the class. Assumes the base unit if one is defined. ==== Example Gorilla::Unit.new 1 => (1) Gorilla::Time.new 1 => (1 second) Gorilla::Time.new 1, :minute => (1 minute)
def initialize amount, unit = self.class.base_unit if unit && self.class.rules[unit].nil? raise TypeError, "no such unit #{self.class}:#{unit}" elsif unit.nil? && !instance_of?(Unit) raise ArgumentError, "unit can't be nil for #{self.class}" end @amount, @unit = (amount.to_r if amount), unit end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unit(name)\n Unit.new(name, self)\n end", "def initialize(unit_type)\n \n @resolution_unit = unit_type\n \n # Create our hash.\n # The default value is an empty bucket with\n # a start point and resolution.\n @buckets = Hash.new do |hash, key|\n period = create_period( k...
[ "0.6812265", "0.6573167", "0.65611273", "0.64837223", "0.6322942", "0.6248117", "0.62442726", "0.6212339", "0.61753416", "0.61753416", "0.6065566", "0.6058368", "0.6049597", "0.60394", "0.6038262", "0.6000114", "0.5999554", "0.5980516", "0.59610397", "0.5919792", "0.586102", ...
0.64601064
4
Converts an instance to a new unit. ==== Example Gorilla::Weight.new(1, :pound).convert_to(:ounce) => (16 ounces)
def convert_to other_unit return dup if unit == other_unit unless self.class.rules.key? other_unit raise TypeError, "no such unit #{self.class}:#{other_unit}" end if self.class.rules[unit][:rules] amount = self.class.follow_rules normalized_amount, unit, other_unit return self.class.new amount, other_unit else amount = normalized_amount end new = self.class.new amount new.unit = other_unit new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to(unit)\n unit = Unit.get(unit) if unit.is_a?(Symbol)\n self.normalize + unit.denormalize\n end", "def as(unit)\n self.class.to(@amount, unit)\n end", "def as unit\n check_unit! unit\n dist = self.dup\n dist.number = convert_to_meters * meters_map[unit]\n dist.unit...
[ "0.64903563", "0.6374293", "0.62455237", "0.6194792", "0.6123529", "0.6098176", "0.60672337", "0.59975475", "0.5896459", "0.57980335", "0.57770336", "0.57436615", "0.5738317", "0.5738317", "0.571105", "0.5701904", "0.5684671", "0.5653204", "0.5627536", "0.5600549", "0.5592673...
0.56537807
17
Returns whether a unit was defined as metric. ==== Example class Coolness true end Coolness.new(1, :megaFonzie).metric? => true
def metric? unit and self.class.rules[unit][:metric] || false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metric?\n @metric\n end", "def metric_ton? = unit == 'metric-ton'", "def metrics?\n @metrics\n end", "def pixel_per_meter? = unit == 'pixel-per-meter'", "def metricModel? \n model = Sketchup.active_model\n\n # Get the length Units of the active model from the unitsOptions\n # 0=inche...
[ "0.8225088", "0.81232244", "0.73423445", "0.7090844", "0.6979925", "0.6822958", "0.6769892", "0.6758768", "0.6748588", "0.667046", "0.66321015", "0.66016424", "0.6527534", "0.6502581", "0.64179325", "0.63817996", "0.633297", "0.6319842", "0.6311718", "0.6305567", "0.62871915"...
0.89512295
0
Get status based on exception type
def status(exception) exception.is_a?(RSpec::Expectations::ExpectationNotMetError) ? Status::FAILED : Status::BROKEN end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n return 404 if NOT_FOUND_ERRORS.include? @exception.class.to_s\n @exception.respond_to?(:http_status) ? @exception.http_status : 500\n end", "def status_code_for_exception(exception)\n Egregious.status_code_for_exception(exception)\n end", "def octokit_error_as_status(type)\n ...
[ "0.7215961", "0.6946121", "0.68357164", "0.68093836", "0.680381", "0.65789205", "0.63794637", "0.62857175", "0.62823534", "0.6265933", "0.60673904", "0.60505986", "0.6028482", "0.600572", "0.59988004", "0.59925705", "0.59704626", "0.59657085", "0.59550506", "0.590416", "0.590...
0.63410676
7
Get exception status detail
def status_details(exception) StatusDetails.new(message: exception&.message, trace: exception&.backtrace&.join("\n")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n return 404 if NOT_FOUND_ERRORS.include? @exception.class.to_s\n @exception.respond_to?(:http_status) ? @exception.http_status : 500\n end", "def get_http_status exception\n http_status = nil\n if defined?(ActionDispatch::ExceptionWrapper) &&\n ActionDispatc...
[ "0.7047844", "0.6799808", "0.676369", "0.6662642", "0.66613734", "0.6559857", "0.6522813", "0.65098566", "0.6508267", "0.64736664", "0.64581007", "0.6454799", "0.6428949", "0.64248025", "0.64009047", "0.63842976", "0.634557", "0.63399905", "0.6338014", "0.63068277", "0.629083...
0.81669265
0
Check if value is full url
def url?(value) URI.parse(value.to_s).scheme end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_url?\n\t\t# http:// or not http://\n\t\tx = self.long_url.start_with?(\"http://\", \"https://\")\n\t\tif x == false\n\t\t\treturn \"http://\" + self.long_url\n\t\telse\n\t\t\treturn self.long_url\n\t\tend\n\tend", "def proper_url? \n\t\tif !(self.long_url.start_with?('http://') || self.long_url.start_...
[ "0.7798053", "0.76697046", "0.752585", "0.7499902", "0.74993503", "0.7461718", "0.7447176", "0.742179", "0.7375037", "0.73388517", "0.7315883", "0.73008", "0.7276913", "0.72729087", "0.7264941", "0.7253971", "0.7210881", "0.7199088", "0.71750695", "0.71686035", "0.7156956", ...
0.7381783
8
Construct url from pattern
def url(value, link_pattern) link_pattern.sub("{}", value) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_url url, text\n scheme, url, = parse_url url\n\n \"[#{text.sub(%r{^#{scheme}:/*}i, '')}](#{url})\"\n end", "def url(name, *params)\n params.map! do |param|\n if param.is_a?(Hash)\n param[:format] = param[:format].to_s if param.has_key?(:format)\n param.each { ...
[ "0.71301776", "0.680903", "0.67298335", "0.6648436", "0.6538054", "0.65193045", "0.6513451", "0.6513451", "0.6513451", "0.6491025", "0.6482116", "0.6476108", "0.6449089", "0.6430525", "0.6430313", "0.6419186", "0.6402814", "0.640198", "0.640198", "0.63851476", "0.63522124", ...
0.6524224
5
Retrieve all CPEs and their associated variants. The 'live' field in the output indicates whether any advisory has been shipped for that CPE and variant. This API does not require authentication. :apiurl: /api/v1/security/cpes :apimethod: GET :apiresponseexample: file:publican_docs/Developer_Guide/api_examples/cpes.json
def cpes @variants = Variant.all.group_by{|variant| variant.cpe || ''}.sort_by{|cpe,v| cpe} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @cps = Cp.all\n end", "def index\n @capexes = Capex.all\n end", "def index\n @pcs = Pc.all\n end", "def vpcs\n @vpcs ||= init_vpcs\n end", "def get_variants\n return [] if is_pdc?\n get_variants_by_package.values.flatten.uniq\n end", "def cpe\n\t\t\t\t\twhere(:r...
[ "0.5546804", "0.54726803", "0.53062415", "0.5253674", "0.5248795", "0.52337486", "0.510101", "0.4996687", "0.4957536", "0.49566272", "0.49063808", "0.48832402", "0.48682535", "0.4859834", "0.48554453", "0.48535448", "0.48460883", "0.48076898", "0.47946066", "0.47735325", "0.4...
0.5975741
0
Creates a SUBSCRIBE frame. Sets `ack` header to 'auto' unless it is already set to 'client' or 'clientindividual'.
def subscribe_frame d, h h[:ack] = 'auto' unless ['client', 'client-individual'].include?(h[:ack]) create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_client_ack_with_symbol_11\n if @conn.protocol != Stomp::SPL_11\n assert true\n return\n end\n sid = @conn.uuid()\n queue = make_destination()\n @conn.subscribe queue, :ack => :client, :id => sid\n @conn.publish queue, \"test_stomp#test_client_ack_with_symbol_11\"\n msg = @co...
[ "0.55870736", "0.55790424", "0.54074484", "0.5380273", "0.53647137", "0.5324904", "0.5308", "0.5260508", "0.5181441", "0.49778032", "0.49193686", "0.49107003", "0.48726657", "0.481885", "0.47889104", "0.4776266", "0.4776266", "0.47730666", "0.47506678", "0.47465703", "0.47461...
0.6750201
0
Creates an ACK frame
def ack_frame *args create_ack_or_nack 'ACK', args end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ack(opts={})\n\t\t\t# Set delivery tag\n\t\t\tdelivery_tag = opts.delete(:delivery_tag)\n\t\t\tdelivery_tag ||= self.delivery_tag\n\t\t\traise Bunny::AcknowledgementError, \"No delivery tag received\" unless delivery_tag\n\t\t\t\n client.send_frame(\n Qrack::Protocol09::Basic::Ack.new({:delivery_ta...
[ "0.65102285", "0.6487016", "0.6350764", "0.63146967", "0.62166655", "0.6072652", "0.6046227", "0.5995287", "0.58656776", "0.58335435", "0.5818466", "0.5782469", "0.5761721", "0.57331836", "0.5656255", "0.5650389", "0.56393814", "0.5625183", "0.55410886", "0.54408187", "0.5410...
0.780006
0
Creates an NACK frame
def nack_frame *args create_ack_or_nack 'NACK', args end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ack_frame *args\n create_ack_or_nack 'ACK', args\n end", "def gen_packet type, payload\n length = payload.size\n number = Thread.current[:number]\n Thread.current[:number] = number + 1\n \"@ABCD\" + [type,length,number].pack('CS>I>').force_encoding(ENCODING) + payload\nend", "def nacknowledge_frame...
[ "0.6508923", "0.5741221", "0.5615624", "0.561104", "0.5471409", "0.5460339", "0.5451302", "0.52467227", "0.520806", "0.51764727", "0.5139951", "0.5100133", "0.50859934", "0.5026159", "0.50260675", "0.5025573", "0.5017612", "0.5017612", "0.5017612", "0.5017612", "0.501504", ...
0.7034159
0
Creates a heartbeat frame (serialized as a single "\n" character)
def heartbeat_frame OnStomp::Components::Frame.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_heartbeat(sequence)\n send_packet(Opcodes::HEARTBEAT, sequence)\n end", "def save_heartbeat\n timestamp = Time.now.to_i\n store.zadd(\"hb:#{@client.uid}\", timestamp, [Time.now.to_s(:db), @payload].to_json)\n end", "def handle_heartbeat(_payload)\n send_packet(OPCODES[:HEARTBEAT]...
[ "0.599535", "0.5900252", "0.57715", "0.56977063", "0.5687411", "0.5641977", "0.5555416", "0.554638", "0.54458064", "0.54110134", "0.54101676", "0.5333949", "0.5303429", "0.52913487", "0.5267683", "0.5169766", "0.51461494", "0.5113312", "0.5075621", "0.50172395", "0.50087696",...
0.65995765
0
tyear, tmonth, tweek assigned where setting spent_on attributes these attributes make time aggregations easier
def spent_on=(date) super self.tyear = spent_on ? spent_on.year : nil self.tmonth = spent_on ? spent_on.month : nil self.tweek = spent_on ? spent_on.cweek : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spent_on=(date)\n super\n self.tyear = spent_on ? spent_on.year : nil\n self.tmonth = spent_on ? spent_on.month : nil\n self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil\n self.spent_from = date\n self.spent_to = self.spent_from.advance(:hours=>hours)...
[ "0.6525233", "0.6523704", "0.6403977", "0.6160838", "0.5894229", "0.5734933", "0.5646814", "0.56262475", "0.5550448", "0.552101", "0.54953843", "0.5461707", "0.54507524", "0.5431598", "0.5400899", "0.5361746", "0.53082275", "0.5303204", "0.53031826", "0.5294604", "0.52906287"...
0.66099507
0
say bay to everybody
def say_bye if @names.nil? puts "..." elsif @names.respond_to?("join") # join the list elements puts "Goodbye #{@names.join(", ")}. Come back soon!" else puts "Goodbye #{@names}. Come back soon!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shout\n 'Yay!'\n end", "def bark\n say('ouah ouah')\n nil\n end", "def bark\n puts \"woof!\"\n end", "def breathe\n \"i get oxygen from the water\"\n end", "def shout message, title = \"Battlecry\", priority = 0, sticky = false\n @allies.each do |ally|\n ally.notify...
[ "0.6785067", "0.6651768", "0.6388682", "0.63749725", "0.63710916", "0.6198532", "0.61901444", "0.6164843", "0.6145666", "0.61204815", "0.6118213", "0.6113019", "0.6091014", "0.60821676", "0.6056109", "0.6051375", "0.6014789", "0.6014313", "0.6009798", "0.6008327", "0.600365",...
0.0
-1
If Pro user passes validations (email, password, etc.), then call Stripe and tell it to set up a subscription upon charging the customer's card. Stripe responds back with customer data. Store customer.id as the customer token and save the user.
def save_with_subscription if valid? customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token) self.stripe_customer_token = customer.id save! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_with_subscription\n #If user data passes validations, then call Stripe with user information\n #to get a new subscription created upon charging their card\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\n self.stripe_customer_...
[ "0.8166746", "0.7665318", "0.7586758", "0.75683373", "0.75390834", "0.7518053", "0.74716955", "0.7392793", "0.7294338", "0.72191966", "0.72115946", "0.7128112", "0.712692", "0.70379615", "0.7009483", "0.69722223", "0.69667715", "0.69576347", "0.68969506", "0.6877924", "0.6873...
0.7624558
2
The default security delegates to ActiveRecordPermissions. You may override the method to customize.
def batch_create_authorized?(record = nil) authorized_for?(:crud_type => :create) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n if current_user.admin?\n # Role management\n # don't allow :destroy, :edit, :create\n # - destroy adds a 'delete' button that\...
[ "0.7124058", "0.70427585", "0.6954191", "0.69149697", "0.6909459", "0.6890503", "0.68741816", "0.6855458", "0.68015546", "0.6762293", "0.66815597", "0.66815597", "0.6657583", "0.6640195", "0.6627914", "0.66278124", "0.6593337", "0.64492166", "0.64396954", "0.64392996", "0.631...
0.0
-1
Checks given file against pattern. file File, Pathname or String
def matches?(path) return false if path.nil? send match_method, Pathname.new(path) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_match_in_file(pattern, file)\n File.file?(file) ? assert_match(pattern, File.read(file)) : assert_file_exists(file)\n end", "def pattern_match(file, pattern)\n case\n when pattern.is_a?(Regexp)\n return file.match(pattern)\n when pattern.is_a?(String)\n return File.fnm...
[ "0.79040873", "0.7767663", "0.76429737", "0.76429737", "0.7590968", "0.7568827", "0.7403286", "0.7375396", "0.73636085", "0.7363439", "0.7358617", "0.7326869", "0.7273945", "0.7269795", "0.7238025", "0.6862911", "0.68055886", "0.6743549", "0.6728241", "0.66884166", "0.6675093...
0.0
-1
GET /stay_times GET /stay_times.json
def index @stay_times = StayTime.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n end\n end", "def index\n @tea_times = TeaTime.all\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n fo...
[ "0.66211087", "0.63165516", "0.6313331", "0.6311019", "0.62858325", "0.6283367", "0.62432575", "0.6238713", "0.62150556", "0.6213193", "0.6212546", "0.6203579", "0.62031066", "0.616202", "0.61575663", "0.6142375", "0.61341816", "0.612905", "0.6113712", "0.6113712", "0.6102728...
0.75969326
0
GET /stay_times/1 GET /stay_times/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @stay_times = StayTime.all\n end", "def show\n @time_gap = TimeGap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_gap }\n end\n end", "def index\n @service_times = ServiceTime.all\n\n respond_to do |format|...
[ "0.7261846", "0.66732365", "0.6581946", "0.6489677", "0.64342993", "0.63616824", "0.6351887", "0.63425845", "0.6285759", "0.6273774", "0.62598795", "0.6255119", "0.6237478", "0.6222978", "0.6222819", "0.6222181", "0.6218224", "0.61824906", "0.617852", "0.61682594", "0.6140876...
0.0
-1
POST /stay_times POST /stay_times.json
def create @stay_time = StayTime.new(stay_time_params) respond_to do |format| if @stay_time.save format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' } format.json { render :show, status: :created, location: @stay_time } else format.html { render :new } format.json { render json: @stay_time.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stay_time_params\n params.require(:stay_time).permit(:arrive_date, :leave_date, :nationality, :country_stay, :day_stay)\n end", "def index\n @stay_times = StayTime.all\n end", "def create\n @timing = Timing.new(params[:timing].slice(:start, :stop, :days, :parent_class, :parent_id, :active))\...
[ "0.6601063", "0.6519595", "0.62858284", "0.6268728", "0.6266317", "0.62011385", "0.617307", "0.6168958", "0.6111555", "0.60858476", "0.60694796", "0.6050281", "0.6019576", "0.60107577", "0.5925939", "0.5908032", "0.5900547", "0.58972186", "0.5892104", "0.5891286", "0.5875553"...
0.7005587
0
PATCH/PUT /stay_times/1 PATCH/PUT /stay_times/1.json
def update respond_to do |format| if @stay_time.update(stay_time_params) format.html { redirect_to @stay_time, notice: 'Stay time was successfully updated.' } format.json { render :show, status: :ok, location: @stay_time } else format.html { render :edit } format.json { render json: @stay_time.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @patient = Patient.find(params[:patient_id])\n @schedule = @patient.schedules.find(params[:id])\n @pill_times = @schedule.pill_times\n\n # TODO can improve it to use nested attributes\n if params[:pill_time]\n params[:pill_time].each_with_index do |pill_time, idx|\n if @pill...
[ "0.6653054", "0.66524994", "0.6601323", "0.6582362", "0.6573549", "0.65660256", "0.6546499", "0.6529287", "0.6527774", "0.6489228", "0.6447293", "0.64378303", "0.6422342", "0.641576", "0.6414202", "0.6411619", "0.6408857", "0.6397323", "0.639375", "0.6386395", "0.6381744", ...
0.7227714
0
DELETE /stay_times/1 DELETE /stay_times/1.json
def destroy @stay_time.destroy respond_to do |format| format.html { redirect_to stay_times_url, notice: 'Stay time was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @time_gap = TimeGap.find(params[:id])\n @time_gap.destroy\n\n respond_to do |format|\n format.html { redirect_to time_gaps_url }\n format.json { head :ok }\n end\n end", "def destroy\n @meal_time = MealTime.find(params[:id])\n @meal_time.destroy\n\n respond_to do |fo...
[ "0.7226604", "0.69612134", "0.6939054", "0.6817791", "0.681168", "0.6803863", "0.67897755", "0.6786757", "0.6783543", "0.6771888", "0.6769168", "0.6741878", "0.67337954", "0.6730354", "0.66895", "0.6688952", "0.6681023", "0.66767806", "0.66705346", "0.6667793", "0.66658086", ...
0.74384403
0
Use callbacks to share common setup or constraints between actions.
def set_stay_time @stay_time = StayTime.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 stay_time_params params.require(:stay_time).permit(:arrive_date, :leave_date, :nationality, :country_stay, :day_stay) 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
rubocop:enable Metrics/MethodLength rubocop:disable Metrics/MethodLength
def deny_encryption_using_incorrect_key_statement( bucket_name, kms_key_arn ) { effect: 'Deny', principal: '*', action: 's3:PutObject', resource: "arn:aws:s3:::#{bucket_name}/*", condition: { 'StringNotEqualsIfExists' => { 's3:x-amz-server-side-encryption-aws-kms-key-id' => kms_key_arn } } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def schubert; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def refutal()\n end", "def custom; end", "def custom; end", "def offences_by; end", "def suivre...
[ "0.78097546", "0.6550692", "0.6393907", "0.6393907", "0.63413805", "0.6341239", "0.6341239", "0.6341239", "0.6341239", "0.63261473", "0.6132386", "0.6132386", "0.6035665", "0.60181385", "0.59858197", "0.597906", "0.59612405", "0.58933866", "0.58933866", "0.5888103", "0.588810...
0.0
-1
rubocop:enable Metrics/MethodLength rubocop:disable Metrics/MethodLength
def deny_un_encrypted_inflight_operations_statement( bucket_name ) { effect: 'Deny', principal: '*', action: 's3:*', resource: "arn:aws:s3:::#{bucket_name}/*", condition: { 'Bool' => { 'aws:SecureTransport' => 'false' } } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def refutal()\n end", "def custom; end", "def custom; end", "def offences_by; end", "def suivre...
[ "0.781014", "0.6551781", "0.63943195", "0.63943195", "0.63432074", "0.63432074", "0.63432074", "0.63432074", "0.6342304", "0.632547", "0.61320364", "0.61320364", "0.6036338", "0.601888", "0.5986253", "0.5978609", "0.5960824", "0.589437", "0.589437", "0.5888722", "0.5888722", ...
0.0
-1
Returns a list of open hours grouped by same days
def grouped_open_hours open_hours = [] start_day = nil end_day = nil current_period = nil standard_hours.sort.each_with_index do |o, i| if not o.open? period = "Stengt" else period = I18n.l(o.open_time, format: :time) + " - " + I18n.l(o.close_time, format: :time) end # Track day if start_day == nil start_day = o.day current_period = period end # Previous group ended, add it if period != current_period day = I18n.t("days.#{start_day}") if end_day != nil day += " - " + I18n.t("days.#{end_day}") end # Hverdager custom string if start_day == "monday" and end_day == "friday" day = "Hverdager" end open_hours.append([day, current_period]) current_period = period start_day = o.day end_day = nil end # Update period end if start_day != o.day end_day = o.day end # Last day closes period if i >= standard_hours.count - 1 day = I18n.t("days.#{start_day}") if end_day != nil day += " - " + I18n.t("days.#{o.day}") end open_hours.append([day, current_period]) end end open_hours end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grouped_office_hours\n merged_hours.map { |hash_list|\n days = if hash_list.length == 1\n hash_list.first[:day]\n elsif hash_list.length > 1\n \"#{hash_list.first[:day]} - #{hash_list.last[:day]}\"\n end\n {:hours => hash_list.first[:hours],\n :day => days }\n }....
[ "0.70517796", "0.69048524", "0.6768556", "0.6492265", "0.64917797", "0.63770425", "0.63338524", "0.6316042", "0.6208983", "0.61528325", "0.61422634", "0.6134684", "0.6125631", "0.60609424", "0.60586065", "0.60343283", "0.601223", "0.59675455", "0.5867969", "0.581537", "0.5812...
0.8231436
0
right now this only gets one user out of the params, but recipients can be modified to support multiple users conversation subject params are hardcoded in the view right now but this setup will take arbitrary input
def create recipients = User.where(id: params['recipients']) || [User.find_by_id(params[:uid].keys.first)] conversation = current_user.send_message(recipients, params[:message][:body], params[:message][:subject]).conversation flash[:success] = (I18n.locale == :sw ? "Ujumbe wako umetumwa" : "Your message has been sent") redirect_to conversation_path(conversation) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_other_recipients(user)\n self.users.find(:all)\n end", "def recipients_user_params\n params.require(:recipients_user).permit(:recipient_id, :user_id)\n end", "def set_recipient\n @recipient = User.find params[:user_id]\n end", "def recipients\n @recipients ||= User.where(id: s...
[ "0.67741156", "0.66519594", "0.6598331", "0.6495169", "0.6494603", "0.63888913", "0.6386048", "0.638197", "0.6355738", "0.63543403", "0.6350996", "0.6293286", "0.6263963", "0.6210231", "0.6169928", "0.6108885", "0.6103873", "0.60995907", "0.6096281", "0.6055742", "0.6049496",...
0.0
-1
subject is hardcoded in messages/new.html.erb but we can replace the hidden with a normal field if we want if someone really wants to modify the request they can set their own subject but whatever
def admin_message redirect_to root_path unless admin_user? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message_subject=(value)\n @message_subject = value\n end", "def subject\n self['subject'] || msg['subject']\n end", "def subject=(subject); @message_impl.setSubject subject; end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(...
[ "0.729674", "0.7173166", "0.71237373", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.7005791", "0.6833999", "0.6727346", "0.672659", "0.66890943", "0.66677266", "0.66677266", "0.66677266", "0.66677266", "0.66677266", "0.66677266...
0.0
-1
GET /graphium/cities GET /graphium/cities.json
def index @graphium_cities = Graphium::City.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n neo = Neography::Rest.new\n r = neo.execute_query(\"START n=node(*) RETURN n;\")\n r[\"data\"].shift # first node is wacky\n @cities = r[\"data\"].map { |node|\n OpenStruct.new(node[0][\"data\"].merge(id: node[0][\"self\"].match(/node\\/(\\d+)$/)[1].to_i))\n }\n end", "def cities...
[ "0.7350134", "0.7333397", "0.7067631", "0.7065568", "0.68672746", "0.68098557", "0.67984647", "0.6751429", "0.6747969", "0.6618983", "0.6499412", "0.6432094", "0.6423962", "0.6411681", "0.6357759", "0.634278", "0.62999105", "0.6293347", "0.6292854", "0.626926", "0.62361985", ...
0.7864492
0
GET /graphium/cities/1 GET /graphium/cities/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @graphium_cities = Graphium::City.all\n end", "def index\n neo = Neography::Rest.new\n r = neo.execute_query(\"START n=node(*) RETURN n;\")\n r[\"data\"].shift # first node is wacky\n @cities = r[\"data\"].map { |node|\n OpenStruct.new(node[0][\"data\"].merge(id: node[0][\"self\"...
[ "0.771884", "0.7206858", "0.68093234", "0.66432726", "0.6558376", "0.6531224", "0.64815676", "0.6453144", "0.6389224", "0.638217", "0.6376754", "0.6352371", "0.6347531", "0.63352", "0.6271009", "0.62321395", "0.6225589", "0.6203233", "0.6105522", "0.6102309", "0.607513", "0...
0.0
-1
POST /graphium/cities POST /graphium/cities.json
def create @graphium_city = Graphium::City.new(graphium_city_params) respond_to do |format| if @graphium_city.save format.html { redirect_to @graphium_city, notice: 'City was successfully created.' } format.json { render :show, status: :created, location: @graphium_city } else format.html { render :new } format.json { render json: @graphium_city.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n neo = Neography::Rest.new\n city = neo.create_node(params[:city])\n redirect_to cities_path\n end", "def graphium_city_params\n params.require(:graphium_city).permit(:name, :state, :state_code, :country, :country_code, :population, :osm_node_id)\n end", "def index\n @graphium_...
[ "0.72843736", "0.6981593", "0.66361165", "0.635568", "0.63230383", "0.6254943", "0.60747796", "0.60582554", "0.6043469", "0.599677", "0.5981062", "0.5971438", "0.5939756", "0.59395474", "0.5933267", "0.59171426", "0.5915548", "0.5906117", "0.5881162", "0.5881162", "0.5881162"...
0.7155015
1
PATCH/PUT /graphium/cities/1 PATCH/PUT /graphium/cities/1.json
def update respond_to do |format| if @graphium_city.update(graphium_city_params) format.html { redirect_to @graphium_city, notice: 'City was successfully updated.' } format.json { render :show, status: :ok, location: @graphium_city } else format.html { render :edit } format.json { render json: @graphium_city.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n if @city.update(city_params)\n render json: @city\n # 'city was successfully updated.'\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end", "def ...
[ "0.6442021", "0.61399406", "0.60396487", "0.6007295", "0.59603", "0.5939284", "0.59242314", "0.5900325", "0.5857155", "0.5848182", "0.58433634", "0.5836922", "0.58034754", "0.57885444", "0.578303", "0.57777816", "0.57711077", "0.5769961", "0.57688624", "0.57521904", "0.573857...
0.651353
0
DELETE /graphium/cities/1 DELETE /graphium/cities/1.json
def destroy @graphium_city.destroy respond_to do |format| format.html { redirect_to graphium_cities_url, notice: 'City was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def delete\n client.delete(\"/#{id}\")\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @city.destroy\n respond_to do |format|\n format.html {...
[ "0.6828938", "0.67404467", "0.6609387", "0.65831393", "0.6540373", "0.6499345", "0.6491838", "0.6472032", "0.6430665", "0.642744", "0.641377", "0.6393286", "0.6391623", "0.6378624", "0.63537174", "0.6353204", "0.6331599", "0.63308287", "0.6330156", "0.6270522", "0.62668324", ...
0.73883075
0
Use callbacks to share common setup or constraints between actions.
def set_graphium_city @graphium_city = Graphium::City.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 graphium_city_params params.require(:graphium_city).permit(:name, :state, :state_code, :country, :country_code, :population, :osm_node_id) 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
=begin This is a comment block multiple lines doctest: First doctest >> "hello!" => "hello!" doctest: I have another method here >> hello => "hello" doctest: I pass david to hello and get "Hello David!" >> hello "David" => "hello David!" doctest: If I forget to capitalize the name it will capitalize for me >> hello 'david' => "hello David!" doctest: I can even ask a question by add "?" >> hello "Victor", "?" => "hello Victor?" =end This is also
def hello name = "", punctuation = "!" "hello #{name.capitalize}#{punctuation}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method # test comment\n# ^^^ meta.function.method.without-arguments.ruby keyword.control.def.ruby\n# ^^^^^^ meta.function.method.without-arguments.ruby entity.name.function.ruby\n# ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby\n# ^^^^^^^^^^^^^ comment.line.numbe...
[ "0.67439234", "0.66269255", "0.66269255", "0.65377855", "0.63451767", "0.6331137", "0.62547994", "0.607349", "0.605264", "0.6012091", "0.6012091", "0.6012091", "0.6012091", "0.60044634", "0.59976315", "0.5962581", "0.5867539", "0.58513296", "0.58308834", "0.5824357", "0.58243...
0.55439585
70
Create a new container
def create response = post_request(URI.parse("http://"+Storage.find(cookies[:donabe_ip]).data+"/"+Storage.find(cookies[:current_tenant]).data+"/containers.json"), params[:container].to_json, Storage.find(cookies[:current_token]).data) json_respond response.body end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_container\n\t\t\t\t@command.container_class.new\n\t\t\tend", "def create_new_container\n puts 'Start creating a new container..'\n host = get_available_host\n if host.nil?\n puts 'Could not found a host with limit enough to create more containers'\n return\n end\n puts \"getti...
[ "0.8050959", "0.7759408", "0.75600547", "0.7483288", "0.7433373", "0.7287367", "0.7167117", "0.7157914", "0.69227374", "0.6864827", "0.6809483", "0.677375", "0.6754265", "0.65922725", "0.6511134", "0.6481132", "0.64740473", "0.6472005", "0.6435453", "0.6435349", "0.6430055", ...
0.65848744
14
Link to kata: Description: Fix the function I created this function to add five to any number that was passed in to it and return the new value. It doesn't throw any errors but it returns the wrong number. Can you help me fix the function? Answer:
def addFive(num) num + 5 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_five num\n num + 5\nend", "def add_ten(number)\n number += 10\nend", "def sum_3_5(number) \r\n\tsum3 = 0\r\n\tsum5 = 0\r\n\tsum15 = 0\r\n\t0.step(number-1,3) do |num|\r\n\t\tsum3 += num\r\n\tend\r\n\t0.step(number-1,5) do |num|\r\n\t\tsum5 += num\r\n\tend\r\n\t0.step(number-1,15) do |num|\r\n\t\tsum1...
[ "0.76271623", "0.70259476", "0.70219594", "0.6982283", "0.69683284", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6938488", "0.6888496", "0.68528074", "0.68372726", "0.68290305", "0.6823146", "0.681391...
0.76390034
0
GET /productors GET /productors.json
def index @productors = Productor.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if is_my_resource(params[:prossumer_id])\n @products = Product.where(prossumer_id: params[:prossumer_id]).as_json({\n cycle_id: params[:cycle_id],\n ...
[ "0.6741463", "0.67171097", "0.671549", "0.6692232", "0.6658295", "0.6645084", "0.6617059", "0.65588254", "0.65062225", "0.63921005", "0.6380967", "0.63795066", "0.63716406", "0.6369781", "0.63629127", "0.63590723", "0.6352903", "0.6352829", "0.63419574", "0.6332381", "0.63308...
0.724601
0
GET /productors/1 GET /productors/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @product }\n end\n end", "def product(name)\n get(\"/apiproducts/#{name}\")\n end", "def index\n @productors = Productor.all\n end", "def show\n @product ...
[ "0.7177513", "0.71620387", "0.69384587", "0.6872269", "0.6867054", "0.6861888", "0.68502027", "0.68350583", "0.6815497", "0.6780527", "0.67383075", "0.67305285", "0.67268795", "0.6717179", "0.6717163", "0.6713163", "0.67049307", "0.66973525", "0.6681537", "0.66773593", "0.662...
0.0
-1
POST /productors POST /productors.json
def create @productor = Productor.new(productor_params) respond_to do |format| if @productor.save format.html { redirect_to @productor, notice: 'Productor was successfully created.' } format.json { render :show, status: :created, location: @productor } else format.html { render :new } format.json { render json: @productor.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end", "def create\n if params[:products]\n params[:products].each do |product|\n @...
[ "0.6713027", "0.6615665", "0.65932584", "0.65732664", "0.6542138", "0.6514128", "0.6510743", "0.6489597", "0.64563674", "0.6453787", "0.64093566", "0.6408194", "0.637801", "0.63757545", "0.63692707", "0.6295044", "0.62853426", "0.6271232", "0.6265685", "0.62552404", "0.624977...
0.69069326
0
PATCH/PUT /productors/1 PATCH/PUT /productors/1.json
def update respond_to do |format| if @productor.update(productor_params) format.html { redirect_to @productor, notice: 'Productor was successfully updated.' } format.json { render :show, status: :ok, location: @productor } else format.html { render :edit } format.json { render json: @productor.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end", "def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @colle...
[ "0.6841503", "0.66668236", "0.6628461", "0.6572442", "0.6524781", "0.65049475", "0.6500295", "0.6495635", "0.6444946", "0.64427584", "0.6437838", "0.6423259", "0.6406662", "0.6405152", "0.63964087", "0.6387757", "0.637347", "0.6369127", "0.6369127", "0.63640547", "0.63625807"...
0.6493597
8
DELETE /productors/1 DELETE /productors/1.json
def destroy @productor.destroy respond_to do |format| format.html { redirect_to productors_url, notice: 'Productor was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @product = @person.products.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.json { render :json=>true }\n end\n end", "def destroy\n @onecompany_product = Onecompany::Product.find(params[:id])\n @onecompany_product.destroy\n\n respond_to do |form...
[ "0.7320538", "0.7290282", "0.72159845", "0.7169922", "0.71522564", "0.7148171", "0.71359265", "0.7120843", "0.6994942", "0.6965105", "0.6957253", "0.69516116", "0.69410175", "0.6939498", "0.69382334", "0.69382334", "0.69382334", "0.69269234", "0.68862873", "0.6878517", "0.687...
0.7276151
2
Use callbacks to share common setup or constraints between actions.
def set_productor @productor = Productor.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 productor_params params.require(:productor).permit(:name, :country_id) 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.6981537", "0.67835593", "0.6748275", "0.67436063", "0.6736311", "0.65937173", "0.6503359", "0.6498499", "0.6482832", "0.6478776", "0.645703", "0.6439998", "0.63802195", "0.6377008", "0.6366287", "0.632018", "0.63016284", "0.63011277", "0.62932974", "0.62919617", "0.6290564...
0.0
-1
Constructor Allows us to build out the class properly
def initialize current_user @vrn = current_user.vrn @access = current_user.access_token @query = { "from": "2020-01-01", "to": "2021-01-01" } @headers = { # Authenication # Required to communicate with oAuth 'Accept': 'application/vnd.hmrc.1.0+json', 'Authorization': 'Bearer ' + @access, # Fraud headers # https://developer.service.hmrc.gov.uk/guides/fraud-prevention/connection-method/web-app-via-server/#gov-vendor-product-name 'Gov-Client-Connection-Method': 'WEB_APP_VIA_SERVER', 'Gov-Client-User-IDs': "vat-mtd=#{current_user.id}", 'Gov-Client-Timezone': "UTC#{Time.now.strftime("%:z")}", 'Gov-Vendor-Version': "vat-mtd=1.0.0" } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def constructor; end", "def initialize\n \n end", "def initialize() end", "def initialize\r\n\r\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def...
[ "0.822296", "0.8161297", "0.77810293", "0.7763467", "0.7748298", "0.77391535", "0.77391535", "0.77391535", "0.77391535", "0.77391535", "0.77391535", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064", "0.7678064...
0.0
-1
Obligations This pulls down the submitted returns and gives us a periodKey (which we use to pull individual returns) The aim is to store all returns in a single table
def obligations self.class.get(url, { headers: @headers, query: @query }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def investment_return_from_ownership\n @initial_costs = {}\n @recuring_costs = {}\n @closing_costs = {}\n @home_appreciation = {}\n @costs_compare_sum = {}\n\n @rent_security_deposit = (@home_price/(12*@price_to_rent_ratio))*-1\n @costs_of_buying_house = {}\n @costs_of_buying_house[:rent] =...
[ "0.55788493", "0.5526659", "0.5364657", "0.5314379", "0.52564836", "0.52564836", "0.52300346", "0.51366454", "0.51056856", "0.5060219", "0.5029897", "0.5006404", "0.50056744", "0.4975693", "0.4962308", "0.4939352", "0.4932089", "0.49260435", "0.49239206", "0.49226317", "0.491...
0.0
-1
Returns Allows us to get individual returns from the API
def returns(periodKey) self.class.get(url("returns", periodKey), headers: @headers ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def returns\n parsed {\n @returns\n }\n end", "def find_returns\n\t\tbus = Bus.find(params[:bus_id])\n\t\t@return_buses = bus.find_returns(params[:dep_id] == '0' ? true : false).select{|rb| (!rb.maximum_seats || rb.available_tickets(params[:dep_id] == '0' ? 'to_waterloo' : 'from_waterloo') > ...
[ "0.69270486", "0.65126646", "0.6433455", "0.6315461", "0.6242207", "0.6183215", "0.61437607", "0.60923105", "0.6080625", "0.6005776", "0.5913505", "0.5892927", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.58929265", "0.5...
0.7180429
0
Liabilities Shows money owed to HMRC
def returns(periodKey) self.class.get(url("liabilities"), headers: @headers, query: @query ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attack_bonus(lv)\n (110 * 3 * lv.to_f + 250) / 100 + 5\n end", "def wealth\n @gold + inventory_worth\n end", "def view_liability\n @liabilities = Liability.find(:all, :conditions => 'is_deleted = 0')\n @currency_type = currency\n end", "def owes_amount\n loans=@loans\n net_wo...
[ "0.65483916", "0.6204804", "0.6156031", "0.6096375", "0.60831046", "0.6013273", "0.5999547", "0.5915415", "0.58615434", "0.5818462", "0.5772451", "0.5766779", "0.574856", "0.57436496", "0.57299966", "0.57145005", "0.57054454", "0.564986", "0.56490535", "0.5627159", "0.562418"...
0.5344736
64
def setup end def teardown end
def test_sequence dotest( ''' <process-definition name="n" revision="0"> <sequence> <print>a</print> <print>b</print> </sequence> </process-definition> '''.strip, "a\nb") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recycle; teardown; setup; end", "def teardown; end", "def teardown; end", "def teardown\r\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n...
[ "0.89268225", "0.88954216", "0.88954216", "0.87634265", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.87096465", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436", "0.86750436"...
0.0
-1
Log the given message +msg+ is the message to log Returns nothing
def log(msg) $logger << msg + "\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_log( msg )\n log( msg )\n end", "def log(msg)\n puts msg\n end", "def log(msg)\n STDERR.print \"** \", msg, \"\\n\"\n end", "def on_msg(msg)\n\n puts(fancy_print(msg, @noisy)) if @noisy\n\n return if msg['action'] == 'noop'\n\n @mutex.synchronize do\n\n @s...
[ "0.79773825", "0.7550129", "0.75215745", "0.74550974", "0.7428155", "0.7391896", "0.72911304", "0.72785366", "0.7248565", "0.72187406", "0.7210956", "0.7193646", "0.7190936", "0.7189346", "0.7142849", "0.7124976", "0.71004134", "0.70522743", "0.698523", "0.6977893", "0.695923...
0.6314112
89
Funciones y codigo personalizado
def url agencia_paquete_path(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def zuruecksetzen()\n end", "def mi_carrera\n\n\tend", "def functions\n\n end", "def probers; end", "def custom; end", "def custom; end", "def operations; end", "def operations; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end",...
[ "0.7378923", "0.7030819", "0.69482577", "0.6727263", "0.65133315", "0.6508423", "0.6508423", "0.65034413", "0.65034413", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64614797", "0.64255404", "0.6416642", "0.6373922", "0.63500303", "0....
0.0
-1
run a shell command and stream the output
def pipe(command) output = "" IO.popen(command) do |io| until io.eof? buffer = io.gets output << buffer puts buffer end end output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stream_output(command)\n puts command\n exit_status = nil\n Open3.popen3(command) do |stdin, stdout, stderr, wait_thread|\n stdout.each { |line| puts line }\n stderr.each { |line| puts line }\n exit_status = wait_thread.value.to_i\n end\n raise %Q(The command \"#{command}\" failed.) unless exit_s...
[ "0.73853344", "0.70910066", "0.6960645", "0.6930949", "0.6858384", "0.67822677", "0.67751426", "0.6771282", "0.67387", "0.6719041", "0.67178994", "0.6708008", "0.66929185", "0.6685716", "0.66768575", "0.66759187", "0.6675779", "0.6663482", "0.6657783", "0.6644214", "0.6625352...
0.6895726
4
Comparison operator for sorting, if the distance and num_dims_used accessor is set on both entities before calling this then it is sorted by rating else it is sorted alphabetically.
def <=>(ent) return self.name <=> ent.name unless num_dims_used and ent.num_dims_used return 1 if num_dims_used == 0 and ent.num_dims_used > 0 return -1 if num_dims_used > 0 and ent.num_dims_used == 0 return 0 if num_dims_used == 0 and ent.num_dims_used == 0 ent.percent <=> self.percent end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def <=>( other)\n @rating <=> other.rating\n end", "def sort_by_size(x,y)\n sizes = [\"Small\",\"Medium\",\"Large\",\"X-Large\",\"2X-Large\",\"3X-Large\"]\n cmp = sizes.index(x.tshirt) <=> sizes.index(y.tshirt)\n if cmp == 0\n x.name <=> y.name\n else\n cmp\n end\n end", "def space...
[ "0.61207867", "0.5983499", "0.579375", "0.5778915", "0.5769216", "0.5762753", "0.5692422", "0.5635052", "0.5560633", "0.5536304", "0.5535014", "0.5526959", "0.5509945", "0.55003774", "0.54993075", "0.5493392", "0.5473351", "0.5443815", "0.5368507", "0.53674096", "0.53658485",...
0.570391
6
returns in range [1,5]
def rating_for(dim) # If it's a boolean then this entity either has it or doesn't # Retirn 0|1 in the range of 1|5 if dim.bool? fv = FactValue.get_value(Fact.find_by_name(dim.name), self) return fv.value * 4 + 1 if fv else cr = CurrentRating.find_by_entity_id_and_opinion_id(self, dim.valuable) return cr.rating if cr end nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def range(arr)\n\nend", "def range; end", "def range; end", "def range; end", "def range(input); end", "def range1(min, max)\n # Base Case / Inductive Step\n return [] if max <= min\n\n range1(min, max - 1) << max - 1\nend", "def create_range(num)\n (1..num).to_a\nend", "def range(min, max)\n\t...
[ "0.72225076", "0.7116516", "0.7116516", "0.7116516", "0.703115", "0.69801944", "0.6970153", "0.68838", "0.6873761", "0.6869183", "0.6841101", "0.6811183", "0.68026847", "0.6796398", "0.6790431", "0.6786825", "0.6774616", "0.6771307", "0.6760523", "0.6760008", "0.674558", "0...
0.0
-1
def followed_by?(other_user) reverse_followships.find_by_follower_id(other_user.id) end def unfollowed!(other_user) reverse_followships.find_by_follower_id(other_user.id).destroy end
def has_role?(role) case role when :admin then admin? when :member then true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unfollowed(other_user)\n passive_relationships.find_by(follower_id: other_user.id).try(:destroy) \n end", "def unfollow(user)\n following = out_followings.find_by(to_id: user.id)\n if following\n following.destroy\n true\n else\n false\n end\n end", "def unfollow(other...
[ "0.84277236", "0.8358495", "0.82541686", "0.8202163", "0.8177405", "0.8177405", "0.8177405", "0.8177405", "0.8177405", "0.8143758", "0.80772305", "0.80772305", "0.80772305", "0.80667704", "0.80224836", "0.8001884", "0.7991048", "0.79881614", "0.7982519", "0.7974786", "0.79663...
0.0
-1
This method is to ascertain whether the value given is an integer and if not, continue down the array
def find_int(obj) if obj.respond_to?(:each) # This is an array, not the object type sought. obj.each do |x| find_int(x) end else # This is an integer or other object, return it. @holding_array << obj end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_a_number?(arr_value)\n\tarr_value.is_an_integer?\nend", "def is_int_array(arr)\n if arr == nil || arr == ''\n return false\n elsif arr.empty?\n return true\n end\n\narr.each do |i|\n if i.class == Integer || i.class == Float && i%1==0\n else\n return false\n end\n end\ntrue\nend"...
[ "0.74689525", "0.72572684", "0.6982113", "0.68708277", "0.66392297", "0.6637574", "0.6629268", "0.6601657", "0.6360849", "0.633293", "0.6281026", "0.62784475", "0.62735057", "0.6192196", "0.61749107", "0.6137958", "0.6136474", "0.6109165", "0.60758746", "0.60547787", "0.60470...
0.6332216
10
, :except => [:index, :show ]
def contact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n prevent_non_admin\n end", "def index # Only view\n end", "def index\n @unwanteds = Unwanted.all\n end", "def index\n super\n end", "def show\n skip_authorization\n end", "def index\n\t\trender :nothing => true\n\tend", "def index\n index_filter\n end", "def index\n ...
[ "0.7006304", "0.69962823", "0.6766851", "0.67623687", "0.6743255", "0.66927266", "0.66541106", "0.6613451", "0.6604464", "0.6580434", "0.6551282", "0.6543847", "0.6513401", "0.65105754", "0.6507022", "0.6447714", "0.6430164", "0.6430164", "0.6430164", "0.64212704", "0.6414382...
0.0
-1
return the location to read the stubContentMetadata.xml file from (could be in either the new or old location)
def stub_cm_file_name @stub_cm_file_name ||= path_finder.path_to_metadata_file(Settings.assembly.stub_cm_file_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metadata_full_path\n @metadata_full_path ||= \"#{File.dirname(@full_path)}/#{name}\"\n end", "def file() = pathname.relative_path_from(Cnfs.config.paths.definitions)", "def definition_root\n Rails.root.join('data', 'HCA_metadata', self.version)\n end", "def metadata_full_path\n @metadata_full_...
[ "0.60456425", "0.6014891", "0.5996093", "0.59916687", "0.5981252", "0.587458", "0.5837271", "0.58074325", "0.5786748", "0.57599765", "0.5732341", "0.57246023", "0.57190514", "0.57072794", "0.57066685", "0.57032806", "0.56712615", "0.56645745", "0.5661508", "0.56613666", "0.56...
0.56455034
20
this determines the reading order from the stub_object_type (default ltr unless the object type contains one of the possible "rtl" designations)
def book_reading_order return 'right-to-left' if stub_object_type.include?('rtl') || stub_object_type.include?('r-l') 'left-to-right' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line_order = locale_info(:layout, :orientation, :line_order)", "def text_direction\n I18n.translate(:'bidi.direction') == 'right-to-left' ? 'rtl' : 'ltr'\n # in ../locale/he.yml add\n # he:\n #bidi:\n #direction: right-to-left\n # then in ../locale/root.yml add\n # root:\n ...
[ "0.526763", "0.52128154", "0.52128154", "0.51135576", "0.50958973", "0.5048924", "0.49184984", "0.4907119", "0.48280075", "0.47610536", "0.47595844", "0.4753641", "0.47307527", "0.4727238", "0.4699162", "0.46970668", "0.46337548", "0.4633393", "0.46326482", "0.46310407", "0.4...
0.7757093
0
return a hash for any known file attributes defined in the stub content metadata file, these will override or add to the defaults
def stub_file_attributes(file) result = {} %w[preserve publish shelve role].each { |attribute| result[attribute.to_sym] = file.at_xpath("@#{attribute}").value unless file.at_xpath("@#{attribute}").blank? } result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_attributes\n {}\n end", "def file_attributes\n {}\n end", "def internal_file_attributes; end", "def file_attributes\n get_attributes_set(:FILE_ATT_LOOKUPS)\n end", "def file_attributes\n get_attributes_set(:FILE_ATT_LOOKUPS)\n end", ...
[ "0.7176146", "0.7176146", "0.71211416", "0.7079605", "0.7079605", "0.70232767", "0.6845598", "0.6459782", "0.64118034", "0.63867086", "0.63658184", "0.6360381", "0.6348694", "0.6313983", "0.6241228", "0.61640114", "0.6104902", "0.6094918", "0.60694766", "0.60694766", "0.60041...
0.7125154
2
Add 1 white space after def
def method1 # some proccesses end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def space1\n puts \"\"\nend", "def spaces; end", "def spaces; end", "def space; txt ' ','' end", "def indent1\n ' ' * 2\n end", "def space_out\n gsub(/(.)/, ' \\1')\n end", "def space_before()\n #This is a stub, used for indexing\n end", "def spec...
[ "0.6701916", "0.6420368", "0.6420368", "0.63849", "0.62949806", "0.6265731", "0.62510705", "0.62003106", "0.61522585", "0.6085364", "0.6058045", "0.6048515", "0.6022566", "0.59448016", "0.5941362", "0.5941183", "0.5928407", "0.5895583", "0.58608586", "0.5844196", "0.5841073",...
0.0
-1
Use () in method definition
def method1 # some proccesses end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def call; end", "def call; end", "def call; end", "def ca...
[ "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.76103616", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7301045", "0.7...
0.0
-1
Remove return if possible
def some_method(some_arr) some_arr.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discard; end", "def discard; end", "def discard_results; end", "def return!(&block); end", "def capture_return\n @returns = @code.split(/\\(/).first !~ /void/ \n end", "def returns; end", "def ignores; end", "def soft_return\n <<-CODE\n t1 = stack_pop();\n cpu_simple_return(state...
[ "0.67757374", "0.67757374", "0.64712447", "0.6356915", "0.6305391", "0.6261828", "0.62025833", "0.6158363", "0.61473", "0.6126667", "0.6102062", "0.6048262", "0.60336524", "0.60336524", "0.59802616", "0.5922496", "0.5864825", "0.58587396", "0.5824187", "0.5822716", "0.5768857...
0.0
-1
From the page 482 The full list of operating system errors on your particular platform is available as the constants of Errno. Any userdefined exception in this module (including subclasses of existing exceptions) must also define an Errno constant.
def test_Errno_Introduction2 assert_equal([:NOERROR, :EPERM, :ENOENT, :ESRCH, :EINTR], Errno.constants[0..4]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def errno\n SystemCallError.new(get_errno)\n end", "def errno; end", "def errno\n self.class::Errno\n end", "def shell_error_string ( e )\n if e > 32\n return nil\n else\n return case e\n when 0 then \"Out of memory or resources\"\n #define ERROR_FILE_NOT_FOUND 2L\n #define...
[ "0.6997116", "0.6874913", "0.6696123", "0.66079605", "0.63397455", "0.58944684", "0.58938855", "0.58938855", "0.5835156", "0.5780108", "0.5765723", "0.5751015", "0.569087", "0.56798285", "0.56031066", "0.55592716", "0.54955876", "0.54669195", "0.54658747", "0.5461876", "0.544...
0.68636173
2
scenarios if item is present: best: O(1), avg: O(N/2), worst: O(N) if item is NOT present best: O(1), avg: O(N/2), worst: O(N)
def sorted_sequential_search(array, value) i = 0 while i < array.length return i if array[i] == value return false if array[i] > value i += 1 end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def which_elements_missing? desired_elements\n database_elements = as_set\n desired_elements = Set.new(desired_elements)\n not_in_database = desired_elements - database_elements\n return not_in_database\n end", "def exists? item, list, lo, hi\n until lo >= hi\n mid = ((lo + hi) / 2).to_i\n if...
[ "0.56466204", "0.5602917", "0.55562454", "0.5533335", "0.5503255", "0.53874195", "0.53644425", "0.53553236", "0.5306399", "0.52539283", "0.5243651", "0.5224115", "0.52207965", "0.521725", "0.52033013", "0.51916766", "0.5186297", "0.5158719", "0.5156644", "0.5154102", "0.51536...
0.0
-1
binary search without recursion
def binary_search_with_while(array, value) from = 0 to = array.size - 1 while from <= to mid = (from + to) / 2 if array[mid] > value to = mid - 1 elsif array[mid] < value from = mid + 1 else return mid end end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_search(ary, value); end", "def bin_search(x, a, b)\r\n mid = (a + b) / 2\r\n sq = mid ** 2\r\n \r\n if a == b || sq == x\r\n mid\r\n elsif sq > x\r\n bin_search(x, a, mid - 1)\r\n else\r\n (mid + 1) ** 2 > x ? mid : bin_search(x, mid + 1, b)\r\n end\r\nend", ...
[ "0.8074286", "0.79244035", "0.7866262", "0.7840983", "0.78335905", "0.78310955", "0.78063136", "0.7773762", "0.77485484", "0.77258575", "0.7720127", "0.7709612", "0.77026045", "0.77022976", "0.769793", "0.7696042", "0.76854426", "0.76706547", "0.7667535", "0.76500267", "0.763...
0.0
-1
USER METHODS Follow a user by id
def follow(other_user_id) user_to_follow = User.find_by(id: other_user_id) followee_followerships.create(followee_id: user_to_follow.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follow\n who = User.find(params[:id])\n @current_user.follow(who)\n render :text => \"you are now following #{who.username}\"\n end", "def follow\n current_user.follow_user(@user)\n render json: {ok: 1}\n end", "def follow \n @user = User.find_by_id(params[:id])\n if @...
[ "0.7668381", "0.75081784", "0.7464432", "0.74639857", "0.7438839", "0.7399948", "0.7358199", "0.7355392", "0.73367906", "0.730492", "0.7291635", "0.7261809", "0.72572756", "0.72493", "0.7204702", "0.71847063", "0.71781725", "0.71346617", "0.7091446", "0.70668876", "0.7054419"...
0.727207
11
Unfollow a user by id
def unfollow(other_user_id) user_to_unfollow = User.find_by(id: other_user_id) active_relationships.find_by(followed_id: user_to_unfollow.id).destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unfollow\n current_user.unfollow_user(@user)\n render json: {ok: 1}\n end", "def unfollow(user)\n user.followers.delete(self)\n end", "def unfollow_user\n user = User.find(params[:user_id])\n current_user.unfollow(user)\n render_success_message(\"You are not anymore fo...
[ "0.8556826", "0.84737766", "0.84720457", "0.8419654", "0.83508956", "0.8334739", "0.83328897", "0.8319284", "0.8296302", "0.8239457", "0.81995213", "0.8193418", "0.81641597", "0.8146922", "0.8146922", "0.8146922", "0.8146922", "0.8146922", "0.8095", "0.80946875", "0.80946875"...
0.82586986
9
change password and encrypt
def password=(new_password) @password = Password.create(new_password) self.digest_password = @password end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt_password\n self.salt = make_salt if new_record?\n self.encrypted_password = encrypt(password)\n end", "def password=(new_password); end", "def password= password\n @password = password\n encrypt_password!\n end", "def encrypt_password\n self.salt = make_s...
[ "0.7974026", "0.7953494", "0.7913802", "0.7885503", "0.7868835", "0.78353184", "0.7827973", "0.781044", "0.7763111", "0.77279276", "0.7727391", "0.76988864", "0.7679751", "0.76769423", "0.76711094", "0.76619637", "0.76426196", "0.76342595", "0.7612288", "0.7606431", "0.75997"...
0.0
-1
POST /signup return authenticated token upon signup
def create extuser = User.find_by(username: user_params[:username]) if(extuser.nil?) @user = User.new(user_params) @user.high_score = 0 @user.save! auth_token = AuthenticateUser.new(user_params[:username], user_params[:password]).call response = { message: Message.account_created, auth_token: auth_token, high_score: 0 } json_response(response, :created) else response = { message: Message.dublicate_user } json_response(response, :bad_request) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end", "def sign_up\n user = User.new(signup_params)\n if user.save\n response = {success: true, result: user.id}\n render json: response, status: :created\n else\n response = {success: false}\n re...
[ "0.7063818", "0.68050104", "0.6739276", "0.6681925", "0.66760415", "0.66422856", "0.6563522", "0.655776", "0.65307575", "0.64594257", "0.64594257", "0.6419524", "0.6391598", "0.63508296", "0.6337406", "0.6335316", "0.62596434", "0.62461716", "0.62396497", "0.62369937", "0.623...
0.0
-1
POST /reviews POST /reviews.json
def create _params = review_init_params _params[:id] = SecurityManager.md5("#{@user.id}_#{@task.id}") _params[:score] = _params[:score].to_i _params[:author_id] = @user.id begin @review = @task.reviews.create(_params) rescue Mongo::Error::OperationFailure return bad_request("duplicated") end respond_to do |format| if @review.save format.html { redirect_to '/task' } else return unprocessable_entity end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @review = current_author.reviews.create(review_params)\n render json: @review, status: 201\n end", "def create\n review = course.reviews.new(review_params)\n \n if review.save\n render json: ReviewSerializer.new(review).serialized_json\n else\n render...
[ "0.7576602", "0.75637454", "0.7493771", "0.747111", "0.747111", "0.747111", "0.7300367", "0.72989565", "0.7201945", "0.7201945", "0.71795744", "0.717838", "0.71406734", "0.7120858", "0.7118763", "0.7002209", "0.6988962", "0.6979939", "0.69722533", "0.69606304", "0.6958055", ...
0.64110076
83
overridden Devise method that checks the soft delete timestamp on authentication
def active_for_authentication? super && !deactivated_at end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def active_for_authentication? \n super && !deleted_at \n end", "def active_for_authentication? \n super && !deleted_at \n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authenti...
[ "0.7789174", "0.7789174", "0.76794314", "0.7674369", "0.7647149", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", "0.75511885", ...
0.6381492
55
The AI serve multiple purpose, it can assume the role of both player (one at the time)
def initialize @possible = ["red", "red", "red", "red", "blue", "blue", "blue", "blue", "yellow", "yellow", "yellow", "yellow", "green", "green", "green", "green", "magenta", "magenta", "magenta", "magenta", "cyan", "cyan", "cyan", "cyan"] @possible_solution = Array.new @possible_score = {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def played_by?(username)\n @first_player.name == username || @second_player.name == username\n end", "def switch_players\n \n if @current_asker == @player1\n @current_asker = @player2\n @current_responder = @player1\n else\n @current_asker = @player1\n @current_resp...
[ "0.6530433", "0.6422845", "0.62878066", "0.62067527", "0.6203622", "0.6189053", "0.61464787", "0.6145142", "0.61423403", "0.61257845", "0.6099792", "0.6090982", "0.60865784", "0.60865784", "0.6071835", "0.60284823", "0.60090196", "0.6002437", "0.59999555", "0.59967315", "0.59...
0.0
-1
Serve the Ai playing the CodeMaker to choose a code.
def choose_code @code = [] 4.times do @code.push($possible_color[(rand(0..5))]) end @code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_code \n puts \"\\nYou have chosen to be the new CodeBreaker!\\nNow wait for me to create a code for you to crack \"\n @code = @role.random_code\n end", "def play_again\n begin\n _call = direction\n if _call.present?\n applet = \"{\\\"select\\\":\\\"#{_call.play_again(p...
[ "0.5867024", "0.5853624", "0.57858384", "0.5697716", "0.56517893", "0.56193143", "0.5558522", "0.55563265", "0.5545944", "0.5511267", "0.5459809", "0.54586744", "0.5450313", "0.54152787", "0.541295", "0.54060256", "0.5395365", "0.53819996", "0.53635365", "0.5346344", "0.53284...
0.0
-1
Will serve the Ai to take a guess. Will look at the feedback and take guess
def choose_guess(turn) @guess = [] if turn == 0 @best_available_guess = [] @guess = ["red", "red", "blue", "blue"] else @guess = @next_guess end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def guess(guess)\n \t@guess = guess\n\n \tguess_response\n end", "def game_guess\n if path == \"/game\" && verb == \"POST\"\n number = client.read\n game.guess(number)\n redirect(client)\n end\n end", "def make_guess\n guess = input_guess\n check_guess(guess)\n render_code(gue...
[ "0.753297", "0.71783257", "0.6946222", "0.681105", "0.6727323", "0.66807675", "0.66701126", "0.6514951", "0.6493853", "0.6463969", "0.6446141", "0.6434985", "0.6387544", "0.63712543", "0.6364618", "0.63473374", "0.63429815", "0.6339126", "0.63371587", "0.63173115", "0.6315965...
0.0
-1
GET /investments GET /investments.json
def index @investments = Investment.all respond_to do |format| format.html format.json end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @investments = Investment.all\n\n render json: {investments: @investments}, root: false\n end", "def show\n render json: @investment, root: false\n end", "def index\n @investables = Investable.all\n end", "def index\n @investigations = Investigation.where(:visible => true)\n\n ...
[ "0.7938945", "0.7190257", "0.71611875", "0.6985033", "0.69051164", "0.6877576", "0.68006974", "0.67372435", "0.66845745", "0.6632461", "0.6598962", "0.6554188", "0.6550055", "0.6512522", "0.6326754", "0.6315476", "0.6315378", "0.6278007", "0.62501585", "0.62358487", "0.623186...
0.8015847
0
GET /investments/1 GET /investments/1.json
def show @investment = Investment.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @investments = Investment.all\n\n respond_to do |format|\n format.html\n format.json\n end\n end", "def index\n @investments = Investment.all\n\n render json: {investments: @investments}, root: false\n end", "def show\n render json: @investment, root: false\n end", ...
[ "0.78003675", "0.7705234", "0.7289373", "0.71217364", "0.70874935", "0.6921958", "0.6823459", "0.6760489", "0.67382467", "0.6684904", "0.66459566", "0.65948385", "0.65658617", "0.65514493", "0.6546267", "0.64925194", "0.64925194", "0.64925194", "0.64925194", "0.64925194", "0....
0.7187704
3
PATCH/PUT /investments/1 PATCH/PUT /investments/1.json
def update respond_to do |format| if @investment.update(investment_params) format.html { redirect_to @investment, notice: 'Investment was successfully updated.' } format.json { render :show, status: :ok, location: @investment } else format.html { render :edit } format.json { render json: @investment.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @investment.update(investment_params)\n render json: @investment, status: :ok\n else\n render json: @investment.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @investment.update(investment_params)\n format.html { re...
[ "0.7436032", "0.7222304", "0.70660806", "0.69927675", "0.6985275", "0.6845567", "0.6717098", "0.66828084", "0.66499", "0.6646283", "0.65785193", "0.6573181", "0.65629935", "0.6558879", "0.6558879", "0.6555064", "0.65539455", "0.6488449", "0.64707756", "0.6405279", "0.63817567...
0.70902956
3
DELETE /investments/1 DELETE /investments/1.json
def destroy @investment.destroy respond_to do |format| format.html { redirect_to investments_url, notice: 'Investment was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @investment.destroy\n respond_to do |format|\n format.html { redirect_to investments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @investable.destroy\n respond_to do |format|\n format.html { redirect_to investables_url }\n format.json { h...
[ "0.79008186", "0.78626424", "0.7798032", "0.7760932", "0.75271136", "0.746929", "0.7452431", "0.74502695", "0.735179", "0.73415893", "0.7315725", "0.7307491", "0.73034465", "0.7295861", "0.7270416", "0.7250957", "0.7205344", "0.7169677", "0.71198225", "0.70978886", "0.7091487...
0.7656909
5
Use callbacks to share common setup or constraints between actions.
def set_investment @investment = Investment.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.6165094", "0.60450804", "0.5944413", "0.5915806", "0.58885634", "0.5835225", "0.5775847", "0.5700531", "0.5700531", "0.56543404", "0.56209993", "0.54238355", "0.5410386", "0.5410386", "0.5410386", "0.5394892", "0.5377769", "0.53559244", "0.5339896", "0.53388095", "0.533008...
0.0
-1
Fetch the two first characters (interpreted as AI) from the remaining data and try to find record class. If no record class was found, fetch a third character and try again, and then finally a forth, as no AI currently have more then 4 characters.
def record @record ||= process_ai_variants(2) || process_ai_variants(1) || process_ai_variants(1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preferred_264(fields)\n fields.select { |field| field.indicator1 == '3' && field.indicator2 == '1' }.last ||\n fields.select { |field| field.indicator2 == '1' }.last ||\n fields.select { |field| field.indicator1 == '3' && field.indicator2 =~ /[023]/ }.last ||\n fields.select...
[ "0.50342816", "0.5013062", "0.4884477", "0.47540987", "0.47352165", "0.47298652", "0.4716367", "0.47113243", "0.47038415", "0.4700437", "0.4647205", "0.4613086", "0.46043113", "0.45938137", "0.45789075", "0.45625678", "0.45625678", "0.45603186", "0.4560045", "0.45441553", "0....
0.0
-1
Record has a fixed barcode length
def shift_barcode_length return unless record.barcode_length shift_fixed_length(record.barcode_length) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def length\n barcode.two_dimensional? ? encoding.first.length : encoding.length\n end", "def length\n barcode.two_dimensional? ? encoding.first.length : encoding.length\n end", "def barcode\n str_order = order.id.to_s.rjust(5, '0')\n str_cardinality = 1.to_s.rjust(3, '0')\n str_order +...
[ "0.6568643", "0.6568643", "0.6193347", "0.6172301", "0.60400975", "0.60082644", "0.598168", "0.5893825", "0.5878259", "0.57244277", "0.5696949", "0.56375873", "0.56272346", "0.56210715", "0.5613167", "0.55780613", "0.5565064", "0.55514145", "0.55440646", "0.5540473", "0.55172...
0.7220451
0
Record has a variable barcode length
def shift_separator_length separator_index = data.find_index(separator) return unless separator_index && separator_index <= record.barcode_max_length shift_fixed_length(separator_index).tap do data.shift # Shift separator character end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shift_barcode_length\n return unless record.barcode_length\n\n shift_fixed_length(record.barcode_length)\n end", "def length\n barcode.two_dimensional? ? encoding.first.length : encoding.length\n end", "def length\n barcode.two_dimensional? ? encoding.first.length : encoding...
[ "0.6833759", "0.6680222", "0.6680222", "0.6470731", "0.6205599", "0.612365", "0.5866172", "0.585971", "0.5769487", "0.5719548", "0.57152337", "0.5704288", "0.569279", "0.56615734", "0.5647638", "0.5637222", "0.55916476", "0.5570419", "0.5544415", "0.55339706", "0.55224013", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.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.6165094", "0.60450804", "0.5944413", "0.5915806", "0.58885634", "0.5835225", "0.5775847", "0.5700531", "0.5700531", "0.56543404", "0.56209993", "0.54238355", "0.5410386", "0.5410386", "0.5410386", "0.5394892", "0.5377769", "0.53559244", "0.5339896", "0.53388095", "0.533008...
0.0
-1
Only allow a trusted parameter "white list" through.
def user_params params.permit(:name,:email,:password, :country) 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
attr_reader :name def name
def a_method self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name_reader\n @name\n end", "def name() return @name end", "def name() return @name end", "def name # getter method (or reader method)\n @name\n end", "def name #use and initlizer to set name as an instance variable\n @name\nend", "def getName; @name; end", "def ___name\n @name\n e...
[ "0.86338913", "0.8594176", "0.8594176", "0.8577292", "0.85306424", "0.84951365", "0.84216356", "0.83766085", "0.83570534", "0.8338035", "0.8338035", "0.8338035", "0.83332336", "0.8329312", "0.8329312", "0.8329312", "0.8329312", "0.8329312", "0.8329312", "0.8309918", "0.830038...
0.0
-1
used for querying a user's books in the search view mainly, when getting the book model when a search returns a book that a friend already has.
def index @books = [] if (params[:q]) @books = Book.where(params[:q]) end render :json => @books end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @books = Book.search(params[:search_term])\n @mybooks = current_user.books\n end", "def index\n \n @user = current_user\n @search = current_user.books.search(params[:q])\n @books = @search.result\n end", "def index\n books_to_consider=user_signed_in? ? (Book.where.not(owner_i...
[ "0.77267224", "0.7700092", "0.7314274", "0.7282825", "0.7265026", "0.7227536", "0.7141748", "0.7081032", "0.70346326", "0.7011905", "0.6955906", "0.6936213", "0.68576485", "0.68146014", "0.6802825", "0.6778951", "0.6761304", "0.67419374", "0.672906", "0.6715157", "0.67139125"...
0.6288276
65
Following method needs to be updated if multi environment params passed.
def environments=(env_params) env_params.each do |env_hash| next unless env_hash[:features] env_hash[:features].each do |feature_hash| self.features.build(feature_hash) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def env=(environment); end", "def env=(environment); end", "def environment(environment); end", "def configure_environment\n\n=begin\n :: Expected Params ::\n \n Constants::REQUEST_PARAM_TEST => Server Mode (Is Production or Staging?) \n\n=end \n\n if params[Constants::REQUEST_PARAM_TEST].present?\n...
[ "0.6749182", "0.6749182", "0.66758347", "0.6647997", "0.6559945", "0.6551102", "0.65333503", "0.63848424", "0.62014043", "0.6117982", "0.6091886", "0.60169446", "0.6010893", "0.6009778", "0.59973156", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344", "0.5982344...
0.6269189
8
Determines the public IP address of the running AWS instance
def determine_public_ip # 169.254.169.254 is the address of the AWS instance metadata service # See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html `curl --silent -XGET http://169.254.169.254/latest/meta-data/public-ipv4` end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_aws_ip(n)\n if node['analytics-cluster']['aws']['use_private_ip_for_ssh']\n n['ec2']['local_ipv4']\n else\n n['ec2']['public_ipv4']\n end\n end", "def get_aws_ip(n)\n if node['delivery-cluster']['aws']['use_private_ip_for_ssh']\n n['ec2']['local_ipv4']\n e...
[ "0.8188898", "0.80910486", "0.80247253", "0.80016977", "0.79642713", "0.7935058", "0.77813494", "0.77796614", "0.7759515", "0.7752921", "0.77118146", "0.7660461", "0.7611136", "0.7594755", "0.7531203", "0.7402093", "0.7347458", "0.72919375", "0.7099349", "0.70677626", "0.7060...
0.9010124
0
Determines the external port of the running Docker container that's associated with the port given
def determine_public_port(local_port) port = 0 count = 0 max_attempts = 30 # Give up after 30 seconds while port == 0 && count < max_attempts do hostname = ENV['HOSTNAME'] command = "curl --silent -XGET --unix-socket /var/run/docker.sock http://localhost/containers/#{hostname}/json" result = Maze::Runner.run_command(command) if result[1] == 0 begin json_string = result[0][0].strip json_result = JSON.parse(json_string) port = json_result['NetworkSettings']['Ports']["#{local_port}/tcp"][0]['HostPort'] rescue StandardError $logger.error "Unable to parse public port from: #{json_string}" return 0 end end count += 1 sleep 1 if port == 0 && count < max_attempts end $logger.error "Failed to determine public port within #{max_attempts} attempts" if port == 0 && count == max_attempts port end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def docker_port(internal_port, container_name = name)\n docker_runner = Fleetctl::Runner::SSH.new('docker', 'port', container_name, internal_port)\n docker_runner.run(host: ip)\n output = docker_runner.output\n if output\n output.rstrip!\n output.split(':').last\n end\n en...
[ "0.80071384", "0.78971666", "0.77233523", "0.7513421", "0.7195997", "0.71907336", "0.68278325", "0.67938745", "0.6681543", "0.66604924", "0.66603935", "0.66603935", "0.6647747", "0.66083825", "0.65949947", "0.65658265", "0.6517812", "0.6487592", "0.64644194", "0.6443003", "0....
0.67244875
8