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
TODO: move to common
def meta_to_hash(str) key_pairs = str.split(',') h_kp = {} key_pairs.each do | kp | a_kp = kp.split('=') key = a_kp[0] val = a_kp[1] h_kp[key] = val if val != nil end return h_kp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def common\n \n end", "def probers; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def custom; end", "def custom; end", "def schubert; end", "def implementation; end", "def implementation; end", "def wrapper; end", "def weber; en...
[ "0.7360308", "0.6987226", "0.64408237", "0.6388894", "0.6388894", "0.6388894", "0.6388894", "0.62039113", "0.62039113", "0.61605805", "0.6157613", "0.6157613", "0.60257155", "0.5992918", "0.5963068", "0.5963068", "0.595802", "0.5940188", "0.5909174", "0.58172524", "0.5791979"...
0.0
-1
TODO: move to common
def meta_to_json(str) key_pairs = str.split(',') h_kp = {} key_pairs.each do | kp | a_kp = kp.split('=') key = a_kp[0] val = a_kp[1] h_kp[key] = val end return h_kp.to_json end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def common\n \n end", "def probers; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def custom; end", "def custom; end", "def schubert; end", "def implementation; end", "def implementation; end", "def wrapper; end", "def weber; en...
[ "0.7360308", "0.6987226", "0.64408237", "0.6388894", "0.6388894", "0.6388894", "0.6388894", "0.62039113", "0.62039113", "0.61605805", "0.6157613", "0.6157613", "0.60257155", "0.5992918", "0.5963068", "0.5963068", "0.595802", "0.5940188", "0.5909174", "0.58172524", "0.5791979"...
0.0
-1
get server_id from name DEPRICATE: Use find_match in common.rb
def server_id(server_name) Puppet.warning "[DEPRICATED]: Use find_match in common.rb" @compute.servers.each do |server| return server.id if server.name == server_name end return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_server_id(name:, dc_id:, account_alias:)\n regex = /#{dc_id}#{account_alias}#{name}\\d{2}/i\n servers.select { |id| id.match regex }.first\n end", "def find_server(id: nil, name: nil)\n if id\n $bot.servers[id]\n elsif name\n $bot.servers.values.find{ |s| s.name.downcase.include?(na...
[ "0.8000758", "0.70216817", "0.6816041", "0.6692368", "0.6662957", "0.6607139", "0.6529527", "0.6177668", "0.6149084", "0.614167", "0.6047667", "0.60330665", "0.602258", "0.59929657", "0.59557796", "0.59437585", "0.5941719", "0.5941719", "0.5941719", "0.5941719", "0.5941719", ...
0.82626563
0
return the flavor_id from the server_template[:flavor_name]
def get_flavor(flavor_name) flavor_res = find_match(@compute.flavors, flavor_name) flavor_to_use = (flavor_res != nil) ? flavor_res.id.to_s : nil if flavor_to_use.nil? Puppet.crit "The flavor is not found on cloud account!, flavor_name => #{flavor_name}" raise Puppet::Error, "The flavor is not found on cloud account!, flavor_name => #{flavor_name}" else Puppet.notice "Flavor '#{flavor_name}' found : '#{flavor_to_use}'" end return flavor_to_use end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def server_flavor_id(s)\n s.respond_to?('flavor_id') ? s.flavor_id : nil\n end", "def default_flavor_id\n flavor_id = images['default_flavor_id']\n\n if flavor_id.nil?\n error(\"Could not determine default flavor_id for platform #{instance.platform.name} via #{config[:compute_p...
[ "0.79389834", "0.68942744", "0.6458656", "0.6312948", "0.6302071", "0.62181777", "0.6190336", "0.60988367", "0.6019002", "0.60024446", "0.5999297", "0.5998658", "0.5953316", "0.5953316", "0.5953316", "0.5953316", "0.5953316", "0.5953316", "0.5953316", "0.59120417", "0.5911216...
0.6751637
2
return the network_id from the server_template[:network_name] network.networks[2].name but with Fog::Network
def get_networkid(network_name) network_res = find_match(@network.networks, network_name) network_to_use = (network_res != nil) ? network_res.id.to_s : nil if network_to_use.nil? Puppet.crit "The network is not found on cloud account!, network_name => #{network_name}" raise Puppet::Error, "The network is not found on cloud account!, network_name => #{network_name}" else Puppet.notice "Network '#{network_name}' found : '#{network_to_use}'" end return network_to_use end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def network\n n = @head.fetch[0]\n raise \"Invalid network name '#{n}'\" unless n =~ /^[a-z]{4,16}$/\n n\n end", "def get_network(network_id)\n get(\"cloud-instances/#{guid}/networks/#{network_id}\")\n end", "def network_name\n return self.class.generate_network_name(@confi...
[ "0.71146756", "0.682341", "0.67654085", "0.6624237", "0.65540045", "0.6347503", "0.61948895", "0.61458087", "0.6143096", "0.61202854", "0.60989565", "0.6066974", "0.6030295", "0.60157204", "0.5963515", "0.5963423", "0.5963423", "0.5929058", "0.575644", "0.5735022", "0.5728842...
0.72388935
0
return the image_id from the server_template[:image_name]
def get_image(image_name) image_res = find_match(@compute.images, image_name) image_to_use = (image_res != nil) ? image_res.id : nil if image_to_use.nil? Puppet.crit "The image is not found on cloud account!, image_name => #{image_name}" raise Puppet::Error, "The image is not found on cloud account!, image_name => #{image_name}" else Puppet.notice "Image '#{image_name}' found : '#{image_to_use}'" end return image_to_use end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def server_image_id(s)\n s.respond_to?('image_id') ? s.image_id : 'no_image'\n end", "def image_id\n data[:image_id]\n end", "def retrieve_image_id\n name = config['image_name']\n\n img_data = connection.image_list.body[\"DATA\"].find { |i| i[\"LABEL\"] == name }\n if img_dat...
[ "0.7975704", "0.7457247", "0.7385065", "0.68246263", "0.65923303", "0.65323424", "0.6511669", "0.6464305", "0.64495325", "0.6427296", "0.6404439", "0.63860554", "0.63518167", "0.635054", "0.6314881", "0.6243206", "0.6235278", "0.62215453", "0.6204256", "0.6200756", "0.6175244...
0.6213237
18
Used to load and initialize data for databinding
def details @vouch_list = VouchList.find(params[:id]) render json: { title: @vouch_list.title, items: @vouch_list.items_formatted } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_data\n end", "def initialize\n super()\n init_data()\n end", "def initialize_data\n end", "def initialize\n load_data\n end", "def initialize_data_source(data)\n @data_source = data\n end", "def bound_data(data, initial)\n data\n end", "def get_data()\n...
[ "0.6786686", "0.6770922", "0.6740001", "0.65534455", "0.64351255", "0.63925916", "0.6180623", "0.6157378", "0.59286225", "0.5904533", "0.58781177", "0.5803188", "0.5800511", "0.5792056", "0.5756006", "0.5745233", "0.57042664", "0.5689179", "0.5664176", "0.56462246", "0.561608...
0.0
-1
TODO: [multiservice] will be removed The single plan the account has contracted
def bought_plan bought_cinstance.plan rescue ActiveRecord::RecordNotFound => error System::ErrorReporting.report_error(error) ApplicationPlan.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def business_plan\n end", "def provider_account\n plan.try! :provider_account\n end", "def payment_plan\n bank_account_terms > 1 ? BANK_FINANCED : NOT_FINANCED\n end", "def plan_object\n Plan.new plan\n end", "def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan...
[ "0.6861554", "0.6616433", "0.65549517", "0.654903", "0.6526066", "0.6526066", "0.6482235", "0.64037883", "0.64037883", "0.63989097", "0.63561904", "0.63561904", "0.6348567", "0.6337605", "0.63184655", "0.6299389", "0.6272916", "0.6238688", "0.6224147", "0.6214329", "0.6207775...
0.62066096
21
DEPRECATED: legacy method replace by plan.create_contract_with
def buy( plan, additional_cinstance_params = nil) # ActiveSupport::Deprecation.warn(BUY_DEPRECATED_WARNING, caller) plan.create_contract_with(self, additional_cinstance_params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buy!( plan, additional_cinstance_params = nil)\n # ActiveSupport::Deprecation.warn(BUY_DEPRECATED_WARNING, caller)\n plan.create_contract_with!(self, additional_cinstance_params)\n end", "def create_contract(name, abi, code, options = {})\n gas_price = options[:gas_price] ? options[:gas_price] : 0\...
[ "0.7752855", "0.62416524", "0.62123656", "0.61901647", "0.58335024", "0.5809863", "0.5794304", "0.5736747", "0.5725436", "0.56667763", "0.56445336", "0.5622271", "0.5622271", "0.5604003", "0.5598735", "0.5598735", "0.5598735", "0.5598735", "0.5598735", "0.5598735", "0.5578236...
0.76790226
1
DEPRECATED: legacy method replace by plan.create_contract_with
def buy!( plan, additional_cinstance_params = nil) # ActiveSupport::Deprecation.warn(BUY_DEPRECATED_WARNING, caller) plan.create_contract_with!(self, additional_cinstance_params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buy( plan, additional_cinstance_params = nil)\n # ActiveSupport::Deprecation.warn(BUY_DEPRECATED_WARNING, caller)\n plan.create_contract_with(self, additional_cinstance_params)\n end", "def create_contract(name, abi, code, options = {})\n gas_price = options[:gas_price] ? options[:gas_price] : 0\n ...
[ "0.76790226", "0.62416524", "0.62123656", "0.61901647", "0.58335024", "0.5809863", "0.5794304", "0.5736747", "0.5725436", "0.56667763", "0.56445336", "0.5622271", "0.5622271", "0.5604003", "0.5598735", "0.5598735", "0.5598735", "0.5598735", "0.5598735", "0.5598735", "0.557823...
0.7752855
0
TODO: [multiservice] will be removed beware that this method relies on only one application_contract The single cinstance the account has contracted REFACTOR: it is a convenience method that only works on master for "normal" accounts
def bought_cinstance bought_cinstances.first or fail(ApplicationNotFound, "Cinstance of #{org_name} not found") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure_contracts\n # configure accounts for eosdactokens\n\nend", "def contract; Contract.get(self.contract_id); end", "def service_contract_of(buyer)\n service_contracts.find_by(user_account_id: buyer.id)\n end", "def contract; end", "def contract; end", "def get_contract_current()\n self...
[ "0.66533005", "0.63222295", "0.62976044", "0.59677476", "0.59677476", "0.5942448", "0.56770116", "0.5651488", "0.5607454", "0.55999416", "0.55695254", "0.5545219", "0.54985964", "0.5482392", "0.5476282", "0.5462713", "0.54507095", "0.5431307", "0.53863996", "0.5378635", "0.53...
0.4963148
84
Checks if path is an executable script. This verifier is "smart" because if the path contains a forward slash '/' then it assumes you're checking an absolute path to an executable. If no '/' is in the path, it assumes you're checking for a global executable that would be available anywhere on the command line.
def has_executable(path) # Be smart: If the path includes a forward slash, we're checking # an absolute path. Otherwise, we're checking a global executable if path.include?('/') @commands << "test -x #{path}" else @commands << "[ -n \"`echo \\`which #{path}\\``\" ]" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_script(path)\n binary=path.split(' ')[0]\n raise \"#{path} does not exist\" unless File.exist? binary\n raise \"#{path} is not executable\" unless File.executable? binary\n path\n end", "def has_executable(path)\n # Be smart: If the path includes a forward slash, we're check...
[ "0.8197871", "0.7746706", "0.7687165", "0.7662539", "0.7520701", "0.73018384", "0.7207629", "0.7170073", "0.69066447", "0.6871082", "0.672169", "0.6720992", "0.6709207", "0.6694692", "0.667605", "0.66097844", "0.65530545", "0.65507936", "0.6462388", "0.6461731", "0.6457861", ...
0.77679056
1
Creates a streaming request.
def initialize(parent, name, options = {}) logger.debug "Creating stream '#{name}' with options: #{options.inspect}" @parent = parent @name = name @path = options.delete(:path) || name @metadata = options.delete(:metadata) || {} @options = options @failure_delay = nil @failure_count = 0 @failure_reason = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stream\n add_headers\n add_body_type_headers\n send_request\n end", "def create_stream request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_cr...
[ "0.77519894", "0.7141972", "0.7141972", "0.7070942", "0.6912417", "0.68954897", "0.6794193", "0.6706234", "0.66477585", "0.6593982", "0.65572584", "0.6478995", "0.63994795", "0.63935596", "0.6362893", "0.6264695", "0.6224265", "0.6152618", "0.6107271", "0.6107271", "0.6045604...
0.0
-1
Starts the streaming connection
def perform logger.debug "Preparing to start stream" @stream_processor = nil type = request_method http = EventMachine::HttpRequest.new(full_url).send(type, http_options(type)) authorization_method.add_header_to(http) # Handle failures correctly so we can back off @current_request = http http.errback { fail!(:network)} http.callback { http.response_header.status > 299 ? fail!(:http) : perform } http.stream { |c| receive_chunk(c) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start\n logger.info('StreamController starting')\n @stream_parser.begin_read\n self\n end", "def start\n unless @running\n @connections.each { |conn| conn.start(@start_bytes) }\n @running = true\n end\n end", "def stream\n @stream ||=\n connect!\n ...
[ "0.7470051", "0.7355571", "0.6968667", "0.69090027", "0.69033366", "0.6881494", "0.6804549", "0.6721759", "0.67151856", "0.6694601", "0.66885334", "0.6678001", "0.66052216", "0.6540061", "0.6473392", "0.64665914", "0.6461057", "0.64494205", "0.64139014", "0.63888174", "0.6382...
0.63331187
27
Process a failure and responds accordingly.
def fail!(type) suffix = type == :http ? " (Error Code #{@current_request.response_header.status})" : "" logger.debug "Streaming failed with #{type}#{suffix}" if @failure_count == 0 || @failure_reason != type logger.debug "Instantly restarting (#{@failure_count == 0 ? "First failure" : "Different type of failure"})" EM.next_tick { perform } else @failure_delay ||= INITIAL_DELAYS[type] logger.debug "Restarting stream in #{@failure_delay} seconds" logger.debug "Adding timer to restart in #{@failure_delay} seconds" EM.add_timer(@failure_delay) { perform } potential_new_delay = DELAY_CALCULATOR[type].call(@failure_delay) @failure_delay = [potential_new_delay, MAX_DELAYS[type]].min logger.debug "Next delay is #{@failure_delay}" end @failure_count += 1 @failure_reason = type logger.debug "Failed #{@failure_count} times with #{@failure_reason}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_failure(result) #:nodoc:\n if @failure_callback\n @failure_callback.call(message, result)\n else\n failure(result)\n end\n rescue Exception\n Beetle::reraise_expectation_errors!\n end", "def error(output)\n respond_with(Response::Failure, output)\n end"...
[ "0.72323805", "0.7139119", "0.7139119", "0.7085683", "0.69272065", "0.67695206", "0.66957724", "0.66697806", "0.66423696", "0.66231036", "0.65743643", "0.65612257", "0.6539236", "0.65050405", "0.64698076", "0.6448897", "0.6444752", "0.6432373", "0.6417504", "0.63999635", "0.6...
0.0
-1
Returns the current stream processor, creating a new one if it hasn't been initialized yet.
def stream_processor @stream_processor ||= StreamProcessor.new(@parent, @name, @metadata) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def processor\n @processor ||= Processor.new(options)\n end", "def get_instance(payload)\n MediaProcessorInstance.new(@version, payload)\n end", "def get_processor; end", "def processor\n return @options[:processor]\n end", "def get_schematron_proce...
[ "0.66099524", "0.62458915", "0.6094145", "0.5995532", "0.5920153", "0.57780415", "0.5650081", "0.55716914", "0.5525056", "0.5501505", "0.5476307", "0.5405511", "0.5298895", "0.5286617", "0.52424496", "0.52199334", "0.51493436", "0.5084866", "0.50571555", "0.5024548", "0.49819...
0.7699759
0
Processes a chunk of the incoming request, parsing it with the stream processor as well as resetting anything that is used to track failure (as a chunk implies that it's successful)
def receive_chunk(c) return unless @current_request.response_header.status == 200 if !@failure_reason.nil? @failure_reason = nil @failure_delay = nil @failure_count = 0 end stream_processor.receive_chunk(c) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process(chunk, &block)\n @buffer.concat(chunk)\n @buffer.gsub!(MESSAGE_PATTERN) do |match|\n yield($1.to_s) if block_given?\n # erase the message\n ''\n end\n end", "def process(request_buffer=nil)\n raise NotImplementedError\n end", "def write( ch...
[ "0.61212975", "0.6089221", "0.60315955", "0.6010431", "0.5957202", "0.593735", "0.5910008", "0.5891816", "0.586956", "0.58647394", "0.58636194", "0.5861642", "0.58535504", "0.5834415", "0.5834415", "0.582902", "0.58067375", "0.57605654", "0.5733627", "0.57129335", "0.5697502"...
0.72862214
0
Returns a set of options that apply to the request no matter what method is used to send the request. It's important that this is used for credentials as well as making sure there is no timeout on the connection
def default_request_options {:timeout => 0, :head => {}} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_options\n {\n open_timeout:,\n timeout: read_timeout\n }\n end", "def request_options(opts = {})\n opts\n end", "def options\n # figure out our options for this request\n add_ssl_options(\n # for GETs, we pass the params ...
[ "0.7815587", "0.75952685", "0.7523668", "0.7258784", "0.7143106", "0.70799685", "0.7026949", "0.6949496", "0.6860085", "0.6838298", "0.6826108", "0.68010384", "0.68010384", "0.67921144", "0.6782817", "0.6782817", "0.6764992", "0.673263", "0.67261803", "0.67261803", "0.6718369...
0.7052142
6
Returns normalized http options for the current request, built on top of default_request_options and a few other details.
def http_options(type) base = self.default_request_options if @options.present? if type == :get base[:query] = @options else base[:head]['Content-Type'] = "application/x-www-form-urlencoded" base[:body] = body = {} @options.each_pair { |k,v| body[CGI.escape(k.to_s)] = CGI.escape(v) } end end base end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def http_request_options(env)\n opts = {}\n if [:put, :post].include? @request[:method]\n opts[:body] = @request[:body] || extract_request_body(env)\n end\n opts\n end", "def get_request_options(options) # :nodoc:\n options = @options.merge(options)\n \n options[:outpu...
[ "0.73530185", "0.66336995", "0.66333336", "0.6576598", "0.65737724", "0.6512726", "0.6511805", "0.65115184", "0.64955235", "0.64673185", "0.63934094", "0.63277656", "0.63141894", "0.62934023", "0.6243169", "0.6216117", "0.62047404", "0.6200586", "0.6141522", "0.6082607", "0.6...
0.7632941
0
Returns the correct http method to be used for the current path.
def request_method {:filter => :post, :sample => :get, :firehose => :get, :retweet => :get }.fetch(@path, :get) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def http_method\n\t\t\t\treturn @http_method if defined?(@http_method)\n\n\t\t\t\tmethod_from_method =\n\t\t\t\t\tbegin\n\t\t\t\t\t\tparams['_method']\n\t\t\t\t\trescue ArgumentError => e\n\t\t\t\t\t\t## https://github.com/rack/rack/issues/337#issuecomment-48555831\n\t\t\t\t\t\traise unless e.message.include?('inv...
[ "0.7512981", "0.73632115", "0.72694933", "0.7245075", "0.71789014", "0.71775186", "0.71504325", "0.71115524", "0.7106041", "0.70587766", "0.7008083", "0.7008083", "0.70014274", "0.69811755", "0.6867827", "0.68185043", "0.6735041", "0.6730702", "0.6723296", "0.6719958", "0.669...
0.6432277
33
Returns the full streaming api associated with this url.
def full_url @full_url ||= (Streaming.streaming_base_url / Streaming.api_version.to_s / "statuses" / "#{@path}.json") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def streaming_endpoint\n encoded_url = URI.encode(\"#{SITE_URL}#{STREAM_URL}\".strip)\n URI.parse(encoded_url)\n end", "def url\n api_url\n end", "def stream_uri\n @stream_uri\n end", "def stream_url\n\t\t\"http://www.google.com\"\n\tend", "def current_stream_url\n @...
[ "0.75988233", "0.68559694", "0.66728866", "0.66061825", "0.63932484", "0.638971", "0.6359763", "0.6267841", "0.62631446", "0.625069", "0.62436295", "0.61924195", "0.6176798", "0.6176798", "0.6140369", "0.61321056", "0.61138624", "0.611103", "0.61017245", "0.60765296", "0.6056...
0.6941342
1
Note: execute method executes ruby code by dumping ruby code in a file in /tmp/ directory with filename id.rb Ensure that a docker instance running with ruby 2.7.1. container's name must be ruby231 and /tmp/ is mounted in docker container's /tmp/
def execute return "Docker container not running" unless ensure_container_running create_ruby_file output = execute_rubybin_file lint_errors = check_lint rubocop_errors = check_rubocop self.flog_score = check_flog_score self.reek_output = JSON.parse(check_reek) run_tests delete_ruby_file self.output = output self.lint_errors = lint_errors self.rubocop_errors = rubocop_errors end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_and_run_container(code,test_code,user_id)\n puts \"Building and running docker container\"\n formatted_code = format_code(code,test_code)\n p formatted_code\n command = [\"#{DOCKER_DIR}/build.sh\",%Q[\\\"#{formatted_code}\\\"],user_id].join(\" \").chomp\n %x[#{command}]\n end", "def doc...
[ "0.67380863", "0.66739446", "0.66739446", "0.6574789", "0.6153071", "0.58914196", "0.588928", "0.5868365", "0.5836099", "0.5833469", "0.5756109", "0.5630261", "0.5630261", "0.56213397", "0.56190425", "0.5604183", "0.56019676", "0.5600769", "0.5545518", "0.5537837", "0.5506803...
0.73496634
0
check data is valid or not
def check() result = true result = false if @data[:firstname].to_s.empty? || @data[:lastname].to_s.empty? || @data[:birthday] !~ /^\d\d\d\d-\d\d?-\d\d?$/ return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid?\n data\n end", "def valid?\n data\n end", "def valid?\n @data && @errors.empty?\n end", "def valid(data)\n return data && data[0] && data[1]\n end", "def emma_data_valid?\n if emma_data.blank?\n error(:emma_data, :missing)\n else\n check_required(database_...
[ "0.8241595", "0.8241595", "0.7676588", "0.76147866", "0.72997916", "0.7257549", "0.71413624", "0.70661783", "0.7043332", "0.704049", "0.70137763", "0.7007754", "0.6972259", "0.6972259", "0.6961424", "0.6939572", "0.6939572", "0.69215596", "0.68906677", "0.68906677", "0.687659...
0.68812466
20
Decide if 'a' or 'an'
def generate_identifier(sample) # Here, I will include every 'location adjective' and 'discovery' beginning with a vowel. These must all be preceeded by 'an'. if ["alternative-timeline", "alternate-history", "ancient", "anachronistic", "arcane prophecy", "alien artifact", "enchanted sword", "otherworldly portal", "encrypted data feed", "exiled angel"].include?(sample) "an" else "a" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def a_or_an(word)\n %w(a e i o u).include?(word[0].downcase) ? \"an\" : \"a\"\n end", "def a_or_an(word)\n word = word.strip\n if %w{a e i o u A E I O U}.include? word[0..0].to_s\n \"an #{word}\"\n else\n \"a #{word}\"\n end\n end", "def a_or_an(word)\n word = word.strip\n...
[ "0.82925504", "0.79418945", "0.79231673", "0.68788755", "0.6686627", "0.662114", "0.6617054", "0.6437742", "0.6348916", "0.62921894", "0.62863517", "0.6256444", "0.623605", "0.61930513", "0.618318", "0.6154438", "0.6143306", "0.61304283", "0.6123219", "0.6116263", "0.6111315"...
0.0
-1
Generate a random date for the story
def random_date(from = 0.0, to = Time.now) Time.at(from+rand * (to.to_f - from.to_f)).strftime("%d/%m/%y") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rand_date\n rand_date = Date.today-rand(200)\n return rand_date\nend", "def creation_date\n time_frames = []\n (MULTIPLIER**2).times do |x|\n time_frames << midnight_tonight - ((x*3) + 1).month\n end\n date_range = (time_frames.sample..midnight_tonight)\n rand(date_range)\nend", "def random_...
[ "0.8065038", "0.78754705", "0.78452384", "0.7786213", "0.77069324", "0.76527274", "0.7246396", "0.72414356", "0.7127557", "0.7105681", "0.7093782", "0.703214", "0.6966912", "0.69548845", "0.6953929", "0.69330084", "0.67861944", "0.67853034", "0.675992", "0.67468643", "0.6687"...
0.77828467
4
Arguments: :url is a String, it is url of the web document :doc is a String, it contains the web document or IMAGE constant Returns: nil if the document isn't image file or html page String, which is: file name if the document is an image file or contents of element if the document is a html page
def scraper( args ) url = args[:url] document = args[:doc] # Return file name for urls marked with IMAGE if document == IMAGE return url[( url.rindex('/') + 1 ) .. -1] end # if the document doesn't have a <title> element inside <head> element # then return nil # else return title of this document Hpricot.buffer_size = 262144 #for html pages with very long attributes doc = Hpricot( document ) arr = doc.search( "head/title" ) if arr.empty? return nil #This isn't image file or html document else title = arr[0].inner_html.strip return title end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_webpage(doc)\n return if doc.uri =~ /\\.(pdf|ps|eps|doc|ppt|xls|mov|avi|jpg|png|jpeg|gif|tif)$/i\n begin\n timeout(TIMEOUT) do\n info \"[read_webpage] Downloading #{doc.uri}\"\n open(doc.uri) do |f|\n #puts \"Content : #{f.read}\"\n doc.write_attribute(:content,c...
[ "0.67496884", "0.65439063", "0.6468391", "0.64041835", "0.6164635", "0.6092481", "0.60624963", "0.6024855", "0.6023356", "0.59959584", "0.5986967", "0.59325886", "0.58731127", "0.5825556", "0.5807949", "0.5770662", "0.57594794", "0.5742497", "0.57413185", "0.57368106", "0.568...
0.708948
0
Functions for loading/writing CSV files
def from_csv path, opts={} daru_options, opts = from_csv_prepare_opts opts # Preprocess headers for detecting and correcting repetition in # case the :headers option is not specified. hsh = if opts[:headers] from_csv_hash_with_headers(path, opts) else from_csv_hash(path, opts) .tap { |hash| daru_options[:order] = hash.keys } end Daru::DataFrame.new(hsh,daru_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_csv_full\n \n end", "def import_csv_smart\n \n end", "def prepare_data\n data = CSV.read('input.csv', { col_sep: SEPARATOR })\n\n CSV.open('output.csv','wb') do |csv|\n data.each do |row|\n csv << prepare_row(row)\n end\n end\n\n rescue Errno::ENOENT\n puts 'No va...
[ "0.7050215", "0.68889505", "0.688836", "0.6514686", "0.6511784", "0.6479401", "0.646633", "0.6443908", "0.6434646", "0.639479", "0.6356089", "0.6308452", "0.62703604", "0.62681586", "0.62556434", "0.62249607", "0.62208897", "0.62031215", "0.620002", "0.6198013", "0.6176061", ...
0.0
-1
Execute a query and create a data frame from the result
def from_sql(db, query) require 'daru/io/sql_data_source' SqlDataSource.make_dataframe(db, query) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(query)\n @query = query\n @conn, @adapter = choose_adapter(@dbh, @query)\n df_hash = result_hash\n Daru::DataFrame.new(df_hash).tap(&:update)\n end", "def execute_query\n the_query = create_query\n\n #to do: start and end offsets\n res...
[ "0.7155133", "0.668187", "0.65245724", "0.64619875", "0.6428561", "0.64222574", "0.6419511", "0.64045465", "0.63543665", "0.63390696", "0.63262814", "0.6315325", "0.6311962", "0.6310839", "0.6299909", "0.62983733", "0.6240305", "0.62366605", "0.6219141", "0.6210278", "0.61859...
0.6906371
2
Load dataframe from AR::Relation
def from_activerecord(relation, *fields) fields = relation.klass.column_names if fields.empty? fields = fields.map(&:to_sym) result = relation.pluck(*fields).transpose Daru::DataFrame.new(result, order: fields).tap(&:update) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_activerecord(relation, *fields)\n if fields.empty?\n records = relation.map do |record|\n record.attributes.symbolize_keys\n end\n return Daru::DataFrame.new(records)\n else\n fields = fields.map(&:to_sym)\n end\n\n vectors = field...
[ "0.6936078", "0.5885378", "0.5885378", "0.5681491", "0.5633544", "0.5607167", "0.5296113", "0.5291698", "0.5078717", "0.5078102", "0.5066383", "0.5064495", "0.50395834", "0.50111485", "0.49696183", "0.4960796", "0.49511477", "0.49497566", "0.48886317", "0.4886219", "0.4866307...
0.6899915
1
Loading data from plain text files
def from_plaintext filename, fields ds = Daru::DataFrame.new({}, order: fields) fp = File.open(filename,'r') fp.each_line do |line| row = Daru::IOHelpers.process_row(line.strip.split(/\s+/),['']) next if row == ["\x1A"] ds.add_row(row) end ds.update fields.each { |f| ds[f].rename f } ds end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_text(filename); end", "def parse_file\n @file ||= File.open(@file_name) unless @file_name.nil?\n @text = @file.readlines\n @file.close unless @file.nil?\n parse_text\n end", "def fromFile( filename ) \n lines = IO.readlines( filename )\n loa...
[ "0.7460712", "0.6832215", "0.6684912", "0.6676647", "0.6633156", "0.66077965", "0.6553301", "0.65314525", "0.65314525", "0.65171176", "0.6473957", "0.6458051", "0.6458051", "0.64159524", "0.6412087", "0.63579327", "0.63023347", "0.62768567", "0.6240431", "0.6225768", "0.61964...
0.60467064
33
Loading and writing Marshalled DataFrame/Vector
def save klass, filename fp = File.open(filename, 'w') Marshal.dump(klass, fp) fp.close end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def marshal_load(serialised); end", "def marshal_load(x)\n @table = x\n end", "def marshal\n @data\n end", "def marshal_load(array)\n\t\t@lines, @columns, @stack = array\n\t\treturn self\n\tend", "def marshal_dump\n data\n end", "def marshal_dump\n [@@col_map, @@location_column...
[ "0.5776233", "0.572338", "0.55685425", "0.55542415", "0.5515811", "0.5461559", "0.5433875", "0.5373549", "0.5354462", "0.5353278", "0.5284058", "0.5257547", "0.52436876", "0.52300185", "0.52300185", "0.52300185", "0.52300185", "0.52300185", "0.52300185", "0.52270734", "0.5205...
0.0
-1
Splits headers (all th tags) into order and index. Wherein, Order : All tags on first proper row of HTML table index : All tags on first proper column of HTML table
def html_parse_hash(headers, size, headers_size) headers_index = headers.find_index { |x| x.count == headers_size } order = headers[headers_index] order_index = order.count - size order = order[order_index..-1] indice = headers[headers_index+1..-1].flatten indice = nil if indice.to_a.empty? [order, indice] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def semanticize_table_headers!\n @document.tree.search('table tr:first td').each { |node| node.node_name = 'th' }\n end", "def ar_index_table_headers \n label_header= content_tag(:th, controller.ardata.labels[:label])\n \n # This will be used when adding the table rows.\n # it will...
[ "0.6782144", "0.67185336", "0.6697444", "0.6581722", "0.65597653", "0.63773453", "0.6357133", "0.63094854", "0.6214358", "0.61771023", "0.61159104", "0.60242057", "0.59455556", "0.59066826", "0.5903324", "0.584573", "0.5833022", "0.58243954", "0.58064586", "0.5770985", "0.577...
0.5776998
19
Allows user to override the scraped order / index / data
def html_decide_values(scraped_val={}, user_val={}) %I[data index name order].each do |key| user_val[key] ||= scraped_val[key] end user_val end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n set_orders()\n set_product_expiration()\n set_product_targets()\n @next_order = @product_targets.length + 1\n end", "def order\n @order || index\n end", "def edit_existing(order)\n @data.order = order\n @data.user = User.with_id(order.order_user_id)\n\n order_common(fa...
[ "0.5659694", "0.5482468", "0.5482359", "0.539954", "0.5333652", "0.5328841", "0.531788", "0.53087276", "0.5308208", "0.5308208", "0.52803326", "0.52637595", "0.5257111", "0.5224904", "0.51982754", "0.5194393", "0.5189531", "0.5184226", "0.5179095", "0.5177246", "0.51677954", ...
0.57674026
0
Look for pages in directories
def scan_pages0( index, directory ) unless index index = Page.new( File.join( directory, "index.src" ) ) @root = index end @subdir_pages = get_nondir_pages( directory ) @nondir_pages = get_subdir_pages( directory ) @nondir_pages.each do |page_src| Page.new( page_src, index ) end @subdir_pages.each do |page_src| page = Page.new( page_src, index ) scan_pages( config, page, File.dirname( page_src ) ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find\n list = Dir.glob(File.join(@pages_folder, '**/*'))\n list.map! { |name| name.gsub(@pages_folder + '/', '')}\n list.map { |name| name.force_html_extension }\n end", "def sub_pages(dir)\n sitemap.resources.select do |r|\n r.url.start_with? \"/#{dir}\"\n end\n end", "def fi...
[ "0.72145456", "0.7186482", "0.7024486", "0.6937392", "0.68647456", "0.6814052", "0.6675991", "0.6667176", "0.6631105", "0.65949184", "0.6579314", "0.6525735", "0.648459", "0.64569664", "0.64465576", "0.63054186", "0.6297525", "0.6252817", "0.6229611", "0.6189924", "0.6166294"...
0.6888374
4
:nodoc: to make it more mockable
def get_nondir_pages( directory ) Dir[ File.join( directory, "*/index.src" ) ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def spec; end", "def spec; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def wrapper; end", "def implementation; end", "def implementation; end", "def weber; end", "def internal; end", "def custom; end", "def custom; end", "def pr...
[ "0.7772672", "0.6852146", "0.6852146", "0.6834221", "0.6834221", "0.6834221", "0.6834221", "0.67364806", "0.6568494", "0.6568494", "0.6513016", "0.6420706", "0.6317515", "0.6317515", "0.6219273", "0.62146294", "0.6190825", "0.6190825", "0.6190825", "0.6190825", "0.6190825", ...
0.0
-1
:nodoc: to make it more mockable
def get_subdir_pages( directory ) Dir[ File.join( directory, "*.src" ) ] - Dir[ File.join( directory, "index.src" ) ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def spec; end", "def spec; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def wrapper; end", "def implementation; end", "def implementation; end", "def weber; end", "def internal; end", "def custom; end", "def custom; end", "def pr...
[ "0.7770701", "0.68534493", "0.68534493", "0.683399", "0.683399", "0.683399", "0.683399", "0.6734552", "0.6566761", "0.6566761", "0.6512738", "0.64186233", "0.63150173", "0.63150173", "0.6218651", "0.62135726", "0.61904085", "0.61904085", "0.61904085", "0.61904085", "0.6190408...
0.0
-1
addr The IP address or hostname of the Hue bridge. serial The serial number of the bridge, if available (parsed from the USN header in a UPnP response)
def initialize addr, serial = nil @addr = addr @verified = false @username = nil @name = nil @config = nil @registered = false @lights = {} @groups = {} @scenes = {} @whitelist = {} @lightscan = {'lastscan' => 'none'} if serial && serial =~ /^[0-9A-Fa-f]{12}$/ @serial = serial.downcase else @serial = nil end @request_queue = NLHue::RequestQueue.new addr, 2 @update_timer = nil @update_callbacks = [] @rate_timer = nil @rate_targets = {} @rate_proc = proc do if @rate_targets.empty? log "No targets, canceling rate timer." # XXX @rate_timer.cancel if @rate_timer @rate_timer = nil else log "Sending targets from rate timer." # XXX send_targets do @rate_timer = EM::Timer.new(RATE_LIMIT, @rate_proc) end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hwaddr\n begin\n exists? && IO.read(\"/sys/class/net/#{name}/address\").strip\n rescue Errno::ENOENT\n end.tap do |address|\n raise Errors::UnknownInterface, \"Interface #{name} not found on this machine\" unless address\n end\n end", "def hiqnet_address\r\n...
[ "0.558092", "0.54393435", "0.5357486", "0.5275969", "0.5270679", "0.5261901", "0.51633495", "0.5157383", "0.5157383", "0.5156827", "0.51076233", "0.5096908", "0.5075681", "0.5036458", "0.5030236", "0.5020802", "0.5017987", "0.5011339", "0.5000452", "0.50001717", "0.49889433",...
0.49018717
30
Calls the given block with true or false if verification by description.xml succeeds or fails. If verification has already been performed, the block will be called immediately with true.
def verify &block if @verified yield true return true end @request_queue.get '/description.xml', :info, 4 do |result| puts "Description result: #{result.inspect}" # XXX if result.is_a?(Hash) && result[:status] == 200 @desc = REXML::Document.new result[:content] @desc.write($stdout, 4, true) # XXX @desc.elements.each('friendlyName') do |el| puts "Friendly name: #{@name}" # XXX set_name el.text end @desc.elements.each('serialNumber') do |el| puts "Serial number: #{@serial}" # XXX @serial = el.text.downcase end @desc.elements.each('modelName') do |el| puts "modelName: #{el.text}" # XXX if el.text.include? 'Philips hue' @verified = true end end # FIXME: Delete this line when converted to em-http-request; this # works around the empty :content returned by EM::HttpClient # # See commits: # 34110773fc45bfdd56c32972650f9d947d8fac78 # 6d8d7a0566e3c51c3ab15eb2358dde3e518594d3 @verified = true end begin yield @verified rescue => e log_e e, "Error notifying block after verification" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def executeAssertionBlock(block)\n !!block.call(object)\n end", "def verify_block(&blk)\n begin\n return true if yield\n rescue\n false\n end\n end", "def with_checking(description)\n puts \"Checking #{description}\"\n result = yield\n if result\n puts \"OK\"\n else\n puts \"F...
[ "0.65840983", "0.6473263", "0.62401044", "0.6233254", "0.6220238", "0.6219511", "0.59731245", "0.5967244", "0.5967244", "0.59525335", "0.58734745", "0.58713204", "0.5827957", "0.5813138", "0.5810332", "0.5782185", "0.57201874", "0.5712374", "0.570024", "0.5699299", "0.5698088...
0.75283694
0
Attempts to register with the Bridge. The block will be called with true and the result array if registration succeeds, false and an Exception if not. If registration succeeds, the Bridge object's current username will be set to the username returned by the bridge. If the Bridge is already registered it will not be reregistered, and the block will be called with true and the current username. Call update after registration succeeds. registered? will not return true until update has succeeded.
def register devicetype, &block raise NotVerifiedError.new unless @verified if @username && @registered yield true, @username return end msg = %Q{{"devicetype":#{devicetype.to_json}}} @request_queue.post '/api', msg, :registration, nil, 6 do |response| status, result = check_json response if status @username = result.first['success']['username'] end yield status, result end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def registered?\n begin\n self.get_registration\n true\n rescue => e\n # any error should be treated as the user not being registered\n false\n end\n end", "def register\n @is_registered = true\n self\n end", "def register\n show_dialog_waiting(Vocab.registration_p...
[ "0.62199533", "0.6007073", "0.5883042", "0.5859944", "0.5857364", "0.58492035", "0.5764487", "0.5762062", "0.5736482", "0.5705183", "0.5700994", "0.56192017", "0.55733997", "0.54774666", "0.54496026", "0.5405383", "0.5389993", "0.53895724", "0.53800815", "0.5354542", "0.53299...
0.6138822
1
Deletes the given +username+ (or this Bridge object's current username if +username+ is nil) from the Bridge's whitelist, sets this Bridge's username to nil, and sets its registered state to false.
def unregister username = nil, &block raise NotVerifiedError.new unless @verified username ||= @username @request_queue.delete "/api/#{username}/config/whitelist/#{username}", :registration, 6 do |response| status, result = check_json response if @username == username && status @registered = false @username = nil Bridge.notify_bridge_callbacks self, false end yield status, result end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deauth(username)\n Huey::Request.delete(\"config/whitelist/#{username}\")\n self.reload\n end", "def delete_user(username)\n\t\t\t\t@session['datastore'][username] = nil\n\t\t\tend", "def remove_user(username)\n if self[SYSTEM_USER_COLLECTION].find_one({:user => username})\n self[S...
[ "0.69554055", "0.6568369", "0.6200747", "0.6008256", "0.60070443", "0.60070443", "0.59742314", "0.58221394", "0.5801536", "0.566706", "0.5665698", "0.55921537", "0.55850226", "0.55784607", "0.55639356", "0.55238116", "0.5450828", "0.54430914", "0.54430914", "0.53972775", "0.5...
0.6637034
1
Starts a timer that retrieves the current state of the bridge every interval seconds. Does nothing if this Bridge is already subscribed.
def subscribe interval=1 return if @update_timer update_proc = proc { update do |status, result| @update_timer = EM::Timer.new(interval, update_proc) if @update_timer end } @update_timer = EM::Timer.new(interval, update_proc) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start\n raise \"the interval has been aborted\" if aborted?\n return unless stopped?\n\n @stopped = false\n\n @id = `#@window.setInterval(#@block, #@every * 1000)`\n end", "def start\n @timer = every(1) { tick }\n super\n end", "def on_timer(value=1000)\n Thread...
[ "0.6312342", "0.61189157", "0.60254246", "0.59954417", "0.5986461", "0.5986461", "0.59518826", "0.5920519", "0.5920519", "0.58591133", "0.58031946", "0.5788709", "0.57642204", "0.572136", "0.5702048", "0.5692792", "0.5679188", "0.56693244", "0.5645475", "0.56327254", "0.56237...
0.69687414
0
Stops the timer started by subscribe(), if one is running.
def unsubscribe @update_timer.cancel if @update_timer @update_timer = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop\n @timer.cancel\n end", "def stop\n @timer.cancel\n end", "def stop_listening\n @subscriber.stop! if @subscriber\n end", "def stop\n @timers.each do |timer|\n timer.cancel\n end\n @timers.clear\n end", "def stop_timer\n view.stop_timer self...
[ "0.7208738", "0.7208738", "0.69116664", "0.6818474", "0.6656549", "0.6605912", "0.65774155", "0.6568183", "0.6470193", "0.64692885", "0.6469141", "0.6349849", "0.63468593", "0.6345411", "0.63434935", "0.6334285", "0.63316935", "0.63245964", "0.62875366", "0.6272684", "0.62596...
0.6665006
4
Adds a callback to be notified when a subscription update is received, or when a subscription update fails. The return value may be passed to remove_update_callback. Callback parameters: Update successful: true, [lights or groups changed: true/false] Update failed: false, [exception]
def add_update_callback &cb @update_callbacks << cb cb end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_update(&update_callback)\n @update_callbacks << update_callback\n end", "def on_update=(callback)\n @update_callback = callback\n end", "def subscribe_to_updates\n if @subscription = @requestor.find_or_create_subscriptions(@target.id)\n @subscription.update_attributes(blocked: fa...
[ "0.7075663", "0.6224534", "0.59255123", "0.584003", "0.58216286", "0.57713974", "0.5715874", "0.5674524", "0.5639649", "0.56100214", "0.5542756", "0.5537184", "0.5499962", "0.54837537", "0.54030734", "0.5394803", "0.52811897", "0.5265721", "0.5264511", "0.5257668", "0.5203185...
0.7102745
0
Removes the given callback (returned by add_update_callback) from the list of callbacks notified with subscription events.
def remove_update_callback cb @update_callbacks.delete cb end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_callback(callback_name)\n callbacks.delete(callback_name)\n callbacks_queue.delete(callback_name)\n end", "def callback_handler_remove\n rl_callback_handler_remove\n @rl_callback_handler = nil\n end", "def clear_callbacks\r\n @callbacks = []\r\n end", "def remove_...
[ "0.6481506", "0.6411273", "0.62749004", "0.6236037", "0.61117584", "0.6084223", "0.5931582", "0.5915377", "0.5877672", "0.5862584", "0.58331406", "0.58084935", "0.58058757", "0.5774096", "0.57272804", "0.5706519", "0.5663278", "0.5621206", "0.55927604", "0.5571331", "0.555196...
0.8007734
0
Updates the Bridge object with the lights, groups, and config of the Hue bridge. Also updates the current light scan status on the first update or if the Bridge thinks a scan is currently active. On success the given block will be called with true and whether the lights/groups were changed, false and an exception on error.
def update &block @request_queue.get "/api/#{api_key}", :info do |response| status, result = check_json response changed = false begin if status first_update = !@registered # TODO: Extract a helper method for adding new # members to and removing old members from a list @config = result @config['lights'].each do |id, info| id = id.to_i if @lights[id].is_a? Light @lights[id].handle_json info else @lights[id] = Light.new(self, id, info) changed = true end end @lights.select! do |id, light| incl = @config['lights'].include? id.to_s changed ||= !incl incl end set_name @config['config']['name'] unless @name @serial ||= @config['config']['mac'].gsub(':', '').downcase @registered = true unless @groups[0].is_a? Group @groups[0] = Group.new(self, 0) get_api '/groups/0', :info do |response| status, result = check_json response if status && @groups[0] @groups[0].handle_json result end end end @config['groups'].each do |id, info| if @groups[id.to_i].is_a? Group @groups[id.to_i].handle_json info else @groups[id.to_i] = Group.new(self, id.to_i, info) changed = true end end @groups.select! do |id, light| incl = @config['groups'].include?(id.to_s) || id == 0 changed ||= !incl incl end @config['scenes'].each do |id, info| if @scenes[id].is_a? Scene @scenes[id].handle_json info else @scenes[id] = Scene.new(self, id, info) changed = true end end @scenes.select! do |id, scene| incl = @config['scenes'].include?(id.to_s) changed ||= !incl incl end wl = @config['config']['whitelist'] if wl != @whitelist @whitelist = wl changed = true end if changed @scenes = Hash[@scenes.sort_by{|id, s| s.name}] end # TODO: schedules, rules, sensors, etc. scan_status true if first_update || @lightscan['lastscan'] == 'active' Bridge.notify_bridge_callbacks self, true if first_update || changed end rescue => e log_e e, "Bridge #{@serial} update raised an exception" status = false result = e end result = changed if status notify_update_callbacks status, result yield status, result end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_controller_connection\n if @connected != Input.controller_connected?\n @connected = Input.controller_connected?\n @old_battery_state = Input.battery_level\n @option_window.refresh\n end\n if Input.battery_level != @old_battery_state\n @option_window.refresh\n @old_batte...
[ "0.5408596", "0.5275027", "0.50654453", "0.5060324", "0.4936463", "0.4872355", "0.48646826", "0.48621616", "0.48409176", "0.4779506", "0.47053787", "0.46791893", "0.46555665", "0.46322113", "0.4554132", "0.45399958", "0.45234722", "0.4453902", "0.44519606", "0.4446497", "0.44...
0.5878848
0
Initiates a scan for new lights. If a block is given, yields true if the scan was started, an exception if there was an error.
def scan_lights &block post_api '/lights', nil do |response| begin status, result = check_json response @lightscan['lastscan'] = 'active' if status yield status if block_given? rescue => e yield e end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def with_java_scan &block\n raise ArgumentError, \"Block not given\" if block.nil?\n raise ArgumentError, \"Invalid arity: should be 1\" unless block.arity == 1\n spawn :@scan_cbs, @scan_cbs + [block]\n end", "def scan_cells(&block)\n scan_all(cells_criteria, &block)\n end", "def scan_tags(&b...
[ "0.5867022", "0.53808326", "0.53256786", "0.531078", "0.5285557", "0.52118206", "0.5183046", "0.51772565", "0.5169412", "0.51397717", "0.5119272", "0.51182896", "0.50922704", "0.5063125", "0.5051086", "0.50462866", "0.50422245", "0.5031705", "0.5027632", "0.50235724", "0.5023...
0.7099511
0
Returns true if a scan for lights is active (as of the last call to update), false otherwise.
def scan_active? @lightscan['lastscan'] == 'active' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lights_on?\n @lights\n end", "def lightsOn?\n return @lightsOn\n end", "def lights?\n @lights\n end", "def lights_on?\n return [true,false].sample\n end", "def lights\n\n @lights = !@lights\n if @lights\n \"The lights are on\"\n else\n \"The lights are off\"\n end...
[ "0.7674892", "0.7360575", "0.7233731", "0.64849", "0.63123477", "0.6294762", "0.62514067", "0.6181043", "0.6163711", "0.61606634", "0.61383146", "0.6092119", "0.6012332", "0.59911", "0.5990424", "0.59901106", "0.59860796", "0.59768814", "0.5968709", "0.5968709", "0.59664726",...
0.79253644
0
Returns whether the Bridge object has had at least one successful update from update.
def updated? @config.is_a? Hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def any_updates?\n change_history.size > 1\n end", "def any_updates?\n change_history.size > 1\n end", "def updated?\n self.connected && self.updated\n end", "def has_updates?\n !@update_map.empty?\n end", "def has_updates?\n self['newUpdatesFlag']\n end", "def update_result_ok...
[ "0.7464678", "0.7464678", "0.7304033", "0.7252543", "0.7220776", "0.7119375", "0.7090966", "0.705", "0.6995716", "0.6968168", "0.69564897", "0.69346863", "0.6868893", "0.68510073", "0.67830276", "0.67241764", "0.66650885", "0.6573852", "0.6554077", "0.6549482", "0.6534345", ...
0.0
-1
Indicates whether verification succeeded. A Hue bridge has been verified to exist at the address given to the constructor or to addr= if this returns true. Use verify to perform verification if this returns false.
def verified? @verified end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid?\n verify\n end", "def valid?\n verify\n end", "def valid?\n verify\n end", "def valid?\n verify\n end", "def valid?\n verify\n end", "def valid?\n verify\n end", "def valid?\n verify\n end", "def valid?\n verify\n end", "def...
[ "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965", "0.63408965"...
0.5991329
39
Returns true if this bridge is subscribed (i.e. periodically polling the Hue bridge for updates).
def subscribed? !!@update_timer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribed?\n self.subscription == :subscribed\n end", "def subscribed?\n !ended? && !unsubscribed?\n end", "def subscribed?\n self.type == :subscribed\n end", "def suscription_on?\n is_subscribed == true\n end", "def subscribe?\n self.type == :subscribe\n end", "d...
[ "0.7946308", "0.7938493", "0.7915705", "0.7895659", "0.77532387", "0.7379593", "0.7349836", "0.7328108", "0.7158644", "0.7158644", "0.7147259", "0.7107745", "0.7053006", "0.70139307", "0.7007126", "0.69957983", "0.6934671", "0.6891518", "0.6891518", "0.68670607", "0.6849866",...
0.78307253
4
Returns a Hash mapping light IDs to Light objects, representing the lights known to the Hue bridge.
def lights @lights.clone end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def light_ids\n @attributes.fetch('lights', [])\n end", "def lights\n @lights ||= add_all_lights\n end", "def lights\n @lights ||= add_all_lights\n end", "def lights_hash(n, lamps)\n hash = Hash.new { |h, k| h[k] = [] }\n \n lamps.each do |lamp|\n\n end\n\n hash\nend", ...
[ "0.7500638", "0.6380999", "0.6380999", "0.6303617", "0.6026148", "0.6001825", "0.6001825", "0.5920344", "0.5908299", "0.58829224", "0.5859584", "0.5802445", "0.5802445", "0.5802445", "0.5788266", "0.5788266", "0.57625306", "0.57625306", "0.5758434", "0.57246894", "0.56967103"...
0.61170554
4
The number of lights known to this bridge.
def num_lights @lights.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def countLights(matrix)\n\tlitLights = 0\n\n\tfor i in 0..999\n\t\tfor j in 0..999\n\t\t\tlitLights += matrix[i,j]\n\t\tend\n\tend\n\n\treturn litLights\nend", "def num_neighbors\r\n @neighbors.count\r\n end", "def light_ids\n @attributes.fetch('lights', [])\n end", "def lights\n @li...
[ "0.6731543", "0.66263807", "0.66185164", "0.64785963", "0.64785963", "0.62717646", "0.62717646", "0.6202634", "0.6202634", "0.6195516", "0.605526", "0.6027725", "0.5943172", "0.5787732", "0.5782506", "0.57694006", "0.5761925", "0.57609403", "0.5755349", "0.5740372", "0.571812...
0.8139214
0
Returns a Hash mapping group IDs to Group objects representing the groups known to this bridge, including the default group 0 that contains all lights from this bridge.
def groups @groups.clone end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def groups\n @groups ||= {}\n end", "def groups\n @@groups = Group.groups if @@groups.nil? or @@groups.empty?\n @@groups\n end", "def all_group_hash\n hash = {}\n for group in @all_groups\n hash[group] = {}\n end\n return hash\n end", "def groups\n groups = []\...
[ "0.7278022", "0.71933854", "0.7082268", "0.6907562", "0.6885421", "0.68583345", "0.6845495", "0.68207264", "0.6795948", "0.6760277", "0.67308164", "0.67166287", "0.6667879", "0.65284264", "0.6511587", "0.6510065", "0.6437705", "0.6413965", "0.64084774", "0.6392975", "0.636734...
0.61751
39
The number of groups known to this bridge, including the default group that contains all lights known to the bridge.
def num_groups @groups.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_groups\n empty? ? 0 : boundaries.size\n end", "def size\n\t\t\t@groups.size\n\t\tend", "def length\n group.length\n end", "def num_gears\n num = 0\n group_instances.each { |g| num += g.gears.count}\n num\n end", "def instance_count\n @group.instances.lengt...
[ "0.7295261", "0.68643695", "0.669064", "0.66473454", "0.65847224", "0.6582812", "0.64593595", "0.64540553", "0.62126845", "0.61896724", "0.6147205", "0.61127913", "0.6087059", "0.6075933", "0.5985837", "0.5976869", "0.5951094", "0.5909777", "0.59059256", "0.5905163", "0.57761...
0.7944338
0
Returns a Hash mapping scene IDs to Scene objects. Unlike lights and groups, scenes have String IDs.
def scenes @scenes.clone end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scenes\n @scenes ||= []\n end", "def scenes\n Scene.find( \n :all,\n :select => 's.*',\n :from => 'scenes s, episodes e, locations l',\n :conditions => [\"s.episode_id = e.id and s.id = l.scene_id and l.place_id = ?\", self],\n :order => 'e.tx_date, e.position, s.segme...
[ "0.63348407", "0.63146913", "0.6125771", "0.58619994", "0.5754684", "0.5574227", "0.55558133", "0.54979885", "0.54979885", "0.53951746", "0.53202236", "0.5291148", "0.52688235", "0.52551806", "0.5214817", "0.52137315", "0.5205684", "0.5205684", "0.520322", "0.514856", "0.5141...
0.6034291
3
The number of scenes found on the bridge.
def num_scenes @scenes.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game_objects_count\n @game_objects.count\n end", "def count\n @atlas.count\n end", "def nr_of_regions\n ConnectedComponents.new(in_use_graph).count\n end", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def get_total_games_played\n return gam...
[ "0.699612", "0.6709337", "0.65870094", "0.6524701", "0.6524701", "0.6524291", "0.6471586", "0.64668804", "0.6406284", "0.63415366", "0.6329088", "0.63251376", "0.6322875", "0.6322875", "0.6301791", "0.6296861", "0.6294337", "0.6240688", "0.62379754", "0.62244105", "0.62189984...
0.8389755
0
Returns the scene with an exactly matching ID, the most recently created Scene with a name starting with +prefix+ (that is, the scene occurring last in an alphanumeric sort), or nil if no match was found.
def find_scene(prefix) return @scenes[prefix] if @scenes.include? prefix prefix = prefix.downcase @scenes.select{|id, scene| scene.name.downcase.start_with?(prefix) }.values.max_by{|s| s.name } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_by_prefix(prefix)\n @machines.each do |uuid, data|\n return data.merge(\"id\" => uuid) if uuid.start_with?(prefix)\n end\n\n nil\n end", "def find(edition_name_prefix)\n @db[:editions].\n where(Sequel.like(:edition_name, \"#{edition_name_prefix}%\")).\n ...
[ "0.5568467", "0.4794541", "0.47670853", "0.46915835", "0.4662409", "0.4654239", "0.46374613", "0.46324417", "0.4592734", "0.45366785", "0.45264465", "0.45187235", "0.44537246", "0.44519886", "0.4439375", "0.44199073", "0.44198763", "0.4404438", "0.44042554", "0.44016227", "0....
0.78451127
0
Creates a new group with the given name and list of lights. The given block will be called with true and a NLHue::Group object on success, false and an error on failure. If group creation succeeds, all bridge callbacks added with Bridge.add_bridge_callback will be notified after the new group is yielded to the block (if a block is given). Note that the group's name may be changed by the bridge.
def create_group name, lights, &block raise "No group name was given" unless name.is_a?(String) && name.length > 0 raise "No lights were given" unless lights.is_a?(Array) && lights.length > 0 light_ids = [] lights.each do |l| raise "All given lights must be NLHue::Light objects" unless l.is_a?(Light) raise "Light #{l.id} (#{l.name}) is not from this bridge." if l.bridge != self light_ids << l.id.to_s end group_data = { :lights => light_ids, :name => name }.to_json post_api '/groups', group_data, :lights do |response| status, result = check_json response begin result = result.first if result.is_a? Array if status && result['success'] id = result['success']['id'].split('/').last.to_i raise "Invalid ID received for new group: '#{result['success']['id']}'" unless id > 0 group = Group.new(self, id, { 'name' => name, 'lights' => light_ids, 'action' => {} }) group.update do |upstatus, upresult| if upstatus @groups[id] = group Bridge.notify_bridge_callbacks self, true yield true, group if block_given? else yield upstatus, upresult if block_given? end end else raise result end rescue => e yield false, e if block_given? end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group(name, &blk)\n add_child(:groups, Hubcap::Group.new(self, name, &blk))\n end", "def group(name = nil, &block)\n make_child(name, nil, &block)\n end", "def group(name, &block)\n # Get group\n group = name if name.kind_of? Salticid::Group \n name = name.to_s\n group ||= @grou...
[ "0.713949", "0.69096524", "0.6700818", "0.652287", "0.6443264", "0.6329301", "0.63061875", "0.62899846", "0.62898123", "0.62295014", "0.61937153", "0.61933017", "0.615046", "0.61314267", "0.61112154", "0.6093368", "0.6081424", "0.60778207", "0.6066129", "0.60226285", "0.60031...
0.885701
0
Deletes the given NLHue::Scene on this bridge. Calls the given block with true and a message on success, or false and an error on failure. Bridge notification callbacks will be called after the result is yielded.
def delete_scene scene, &block raise "No scene was given to delete" if scene.nil? raise "Scene must be a NLHue::Scene object" unless scene.is_a?(Scene) raise "Scene is not from this bridge" unless scene.bridge == self delete_api "/scenes/#{CGI.escape(scene.id)}", :lights do |response| status, result = check_json response if status @scenes.delete scene.id end yield status, result if block_given? if status Bridge.notify_bridge_callbacks self, true end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @scene.destroy\n respond_to do |format|\n format.html { redirect_to scenes_url, notice: 'Scene was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @scene.destroy\n respond_to do |format|\n format.html { redirect_to scenes_url...
[ "0.62353075", "0.62213796", "0.6189894", "0.6169564", "0.5996744", "0.58624065", "0.5775065", "0.5727144", "0.5574374", "0.55107546", "0.54708886", "0.5466487", "0.54575986", "0.542815", "0.54231954", "0.540305", "0.5373792", "0.53393084", "0.5320553", "0.5293575", "0.5291562...
0.8098972
0
Deletes the given NLHue::Group on this bridge. Raises an exception if the group is group 0. Calls the given block with true and a message on success, or false and an error on failure. Bridge notification callbacks will be called after the result is yielded.
def delete_group group, &block raise "No group was given to delete" if group.nil? raise "Group must be a NLHue::Group object" unless group.is_a?(Group) raise "Group is not from this bridge" unless group.bridge == self raise "Cannot delete group 0" if group.id == 0 delete_api "/groups/#{group.id}", :lights do |response| status, result = check_json response if status @groups.delete group.id end yield status, result if block_given? if status Bridge.notify_bridge_callbacks self, true end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_group(group)\n\t\t\tend", "def delete_group(group)\n\t\t\tend", "def remove_group(group)\r\n\t\tsend('RMG', group.info[:guid])\r\n\t\t## XXX save changes locally?\r\n\t\treturn 1\r\n\tend", "def destroy #:nodoc:\n @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format...
[ "0.6957819", "0.6957819", "0.69299835", "0.6764173", "0.673809", "0.6646134", "0.6613386", "0.65503854", "0.6545508", "0.6538161", "0.65330887", "0.65230376", "0.6515907", "0.65155786", "0.64921975", "0.6478566", "0.64706117", "0.646887", "0.64661044", "0.6452676", "0.6449062...
0.84115726
0
Sets the +username+ used to interact with the bridge. This should be a username obtained from a previously registered Bridge.
def username= username check_username username @username = username end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def username=(new_username)\n @username = new_username\n end", "def username=(username)\n validate_options(username: username)\n @username = username\n end", "def set_Username(value)\n set_input(\"Username\", value)\n end", "def set_Username(value)\n set_input(\"User...
[ "0.7117537", "0.7105212", "0.69336903", "0.69336903", "0.69336903", "0.69336903", "0.69336903", "0.69336903", "0.69336903", "0.69336903", "0.69336903", "0.69336903", "0.69021094", "0.6894568", "0.6749603", "0.6749603", "0.6749093", "0.6749093", "0.6749093", "0.6749093", "0.67...
0.69940656
2
Sets the IP address or hostname of the Hue bridge. The Bridge object will be marked as unverified, so verify should be called afterward.
def addr= addr @addr = addr @verified = false @request_queue.addr = addr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def host=(h)\n @host = h\n end", "def set_host(v)\n @host = v\n end", "def host(s) self.host_value = s ; self end", "def host=(h)\n attributes['host'] = h\n end", "def host=(value)\n @host = value\n end", "def host=(value)\n @host = val...
[ "0.6380319", "0.6334601", "0.6303093", "0.6301946", "0.62004274", "0.62004274", "0.6164405", "0.6028193", "0.5987225", "0.5979246", "0.5967275", "0.59298855", "0.57918686", "0.5777998", "0.57229793", "0.5717808", "0.5643524", "0.562138", "0.56064236", "0.5605323", "0.5604846"...
0.0
-1
Unsubscribes from bridge updates, marks this bridge as unregistered, notifies global bridge callbacks added with add_bridge_callback, then removes references to configuration, lights, groups, and update callbacks.
def clean was_updated = updated? unsubscribe @registered = false Bridge.notify_bridge_callbacks self, false if was_updated @verified = false @config = nil @lights.clear @groups.clear @update_callbacks.clear end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unbridge bridge_id\n post \"bridges/#{bridge_id}\", {callIds: []}\n\n nil\n end", "def unsubscribe\n unregister\n end", "def unbind\n puts \"connection #{@connection.id.to_s} unbound\"\n begin\n unless !@registered\n self.unregister(@user.uuid)\n $ws_...
[ "0.64779556", "0.62827724", "0.6187084", "0.61358994", "0.61358994", "0.6133465", "0.6091101", "0.6070104", "0.6027533", "0.5975473", "0.5939539", "0.5817324", "0.5756803", "0.5756803", "0.57393116", "0.5716143", "0.57077163", "0.57043755", "0.56702536", "0.5663346", "0.56591...
0.6522796
0
Throws errors if the given username is invalid (may not catch all invalid names).
def check_username username raise 'Username must be a String' unless username.is_a?(String) raise 'Username must be >= 10 characters.' unless username.to_s.length >= 10 raise 'Spaces are not permitted in usernames.' if username =~ /[[:space:]]/ end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_username_format\n return if valid_username_format?\n\n errors.add(:username, :invalid_characters)\n end", "def check_username_format\n errors.add(:username, \"is not a valid username\") unless username =~ Handle.validation_regex\n end", "def username_is_acceptable\n errors.add(:use...
[ "0.8121343", "0.80832106", "0.79336566", "0.779494", "0.7690804", "0.76739776", "0.76739776", "0.745263", "0.734605", "0.73372793", "0.7207874", "0.7161121", "0.71379685", "0.7101783", "0.70514107", "0.70094556", "0.68575674", "0.68204826", "0.6819529", "0.6787927", "0.676678...
0.82596356
0
"Hue Bridge: [IP]: [Friendly Name] ([serial]) N lights"
def to_s str = "Hue Bridge: #{@addr}: #{@name} (#{@serial}) - #{@lights.length} lights" str << " (#{registered? ? '' : 'un'}registered)" str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n if @bridge_port == true\n \"Bridge: [#{@port_name}, #{@remote_switch_name}, #{@remote_port_name}, #{@remote_port_number}]\"\n else\n \"Std Port: [#{@port_name}, [ #{@port_arp.join(',')} ] ]\"\n end\n end", "def use_headlights(brightness = \"low-beam\")\r\n puts \"Turning on #{brig...
[ "0.58824545", "0.5774781", "0.565755", "0.5490819", "0.54569775", "0.5453243", "0.5396668", "0.53842795", "0.5329678", "0.53196526", "0.52631485", "0.52585334", "0.52534646", "0.52339596", "0.52266794", "0.52082783", "0.51929694", "0.518862", "0.51843894", "0.51839954", "0.51...
0.7570752
0
Return value of to_h converted to a JSON string. Options: :include_config => true include raw config returned by the bridge
def to_json *args to_h(args[0].is_a?(Hash) && args[0][:include_config]).to_json(*args) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_h\n config\n end", "def to_h\n @config\n end", "def to_h\n @config\n end", "def to_h\n @configuration\n end", "def to_hash\n self.config.to_hash\n end", "def to_rb\n configuration.map { |k,v| \"#{k}(#{v.inspect})\" }.join(\"\\n\")\n e...
[ "0.7526183", "0.7377948", "0.7377948", "0.6968851", "0.6853835", "0.6814267", "0.67512256", "0.66779435", "0.66559136", "0.66040635", "0.64707404", "0.646304", "0.64608413", "0.6382475", "0.63694143", "0.6348724", "0.6348724", "0.6310124", "0.62416214", "0.624012", "0.6194497...
0.7424467
1
Makes a GET request under the API using this Bridge's stored username.
def get_api subpath, category=nil, &block @request_queue.get "/api/#{api_key}#{subpath}", &block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url\n @client.url + self.class.path + @username\n end", "def get_user(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'GetUser'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise Arg...
[ "0.65347844", "0.6530842", "0.65195173", "0.6404768", "0.6393467", "0.6339473", "0.6338923", "0.6318688", "0.6292428", "0.6263483", "0.6208974", "0.6152653", "0.6132869", "0.6095127", "0.6095127", "0.60607016", "0.60607016", "0.605765", "0.60516113", "0.6047426", "0.60464454"...
0.0
-1
Makes a POST request under the API using this Bridge's stored username.
def post_api subpath, data, category=nil, content_type=nil, &block @request_queue.post "/api/#{api_key}#{subpath}", data, category, content_type, &block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post\n resource.post(request, response)\n end", "def postUser( email, user_id, first_name, last_name, active, trust, creation_date, user_type, social_network, social_network_id, reseller_admin_masheryid, group_id, admin_upgrader)\n params = Hash.new\n params['email'] = email\n params['user_i...
[ "0.63094956", "0.6232658", "0.62154585", "0.61414486", "0.61348444", "0.6126493", "0.61174226", "0.60588765", "0.603084", "0.6027679", "0.6003043", "0.5986998", "0.59762055", "0.5972042", "0.59598887", "0.5952303", "0.5951627", "0.5947094", "0.594116", "0.59280324", "0.592731...
0.0
-1
Makes a PUT request under the API using this Bridge's stored username.
def put_api subpath, data, category=nil, content_type=nil, &block @request_queue.put "/api/#{api_key}#{subpath}", data, category, content_type, &block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_username(username)\n @username = username\n end", "def put(url, vars={})\n send_request url, vars, 'PUT'\n end", "def put!\n request! :put\n end", "def put user_id, options={}, headers={}\n @connection.put \"users/#{user_id}.json\", options, headers\n end", "d...
[ "0.6580767", "0.63734984", "0.63221985", "0.6319628", "0.6306846", "0.6274774", "0.625426", "0.6244505", "0.617221", "0.6163654", "0.61635196", "0.61456454", "0.61456454", "0.61456454", "0.6052811", "0.60244024", "0.59840506", "0.5968456", "0.5959332", "0.5956222", "0.5924222...
0.0
-1
Makes a DELETE request under the API using this Bridge's stored username.
def delete_api subpath, category=nil, &block @request_queue.delete "/api/#{api_key}#{subpath}", category, &block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(username)\n perform_request({:action => \"client-delete\", :username => username})\n end", "def delete\n params = self.class.prepare_params_for(:delete, \"userName\" => user_name)\n response = self.class.perform(params)\n self.class.check_response(response)\n end", "def del...
[ "0.8233824", "0.77127844", "0.7507735", "0.7406935", "0.73858654", "0.73858654", "0.73858654", "0.73858654", "0.7270392", "0.72385144", "0.71852297", "0.70921016", "0.7054678", "0.70243645", "0.70084894", "0.6951433", "0.69220746", "0.69220746", "0.69208175", "0.69208175", "0...
0.0
-1
Schedules a Light, Scene, or Group to have its deferred values sent the next time the rate limiting timer fires, or immediately if the rate limiting timer has expired. Starts the rate limiting timer if it is not running.
def add_target t, &block raise 'Target must respond to :send_changes' unless t.respond_to?(:send_changes) raise "Target is from #{t.bridge.serial} not this bridge (#{@serial})" unless t.bridge == self log "Adding deferred target #{t}" # XXX @rate_targets[t] ||= [] @rate_targets[t] << block if block_given? # TODO: Use different timers for different request types unless @rate_timer log "No rate timer -- sending targets on next tick" # XXX # Waiting until the next tick allows multiple # updates to be queued in the current tick that # will all go out at the same time. EM.next_tick do log "It's next tick -- sending targets now" # XXX send_targets end log "Setting rate timer" @rate_timer = EM::Timer.new(RATE_LIMIT, @rate_proc) else log "Rate timer is set -- not sending targets now" # XXX end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_rate_limits\n sleep 1 / REQUST_LIMIT_PER_MINUTE.to_f\n end", "def start_throttling\n @processed = false\n @timer = EventMachine::PeriodicTimer.new(1.0 / @qps) do\n @processed = false\n end\n end", "def schedule(&blk)\n @reactor.next_tick(blk)\n end", ...
[ "0.6170829", "0.6112097", "0.59202856", "0.5861176", "0.57119775", "0.56063473", "0.55017847", "0.5383989", "0.53765607", "0.53765607", "0.534488", "0.5332213", "0.5312418", "0.52822256", "0.5281144", "0.5264953", "0.52590024", "0.524953", "0.523969", "0.52377707", "0.5160814...
0.0
-1
Returns the string to use in API URLs as the API key (the bridge username if registered, or an obviously invalid string otherwise).
def api_key @username || 'unknown' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_key\n @api_key ||= config_value.split('-')[1].chomp\n end", "def api_name\n return @api_name if @api_name\n sanitized = @username.gsub(/[\\W_]+/, '_')\n @api_name ||= sanitized[0..15]\n end", "def api_key\n api_key_div.text.gsub(/API Key:/,'').gsub(/\\(create\\)/,'').gsub...
[ "0.73183495", "0.7194041", "0.71003586", "0.7046885", "0.69170696", "0.69170696", "0.6888311", "0.669796", "0.6627433", "0.6606757", "0.65865153", "0.6538079", "0.64959794", "0.64959794", "0.6493146", "0.64861137", "0.648286", "0.6471229", "0.6460389", "0.6460389", "0.6460389...
0.78458375
0
Sets this bridge's name (call after getting UPnP XML or bridge config JSON), removing the IP address if present.
def set_name name @name = name.gsub " (#{@addr})", '' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_name\n self.name = domain.name if name.blank?\n self.name = \"#{name}.#{domain.name}\" if not name.end_with?(domain.name)\n end", "def fix_name\n\t if not self.name\n\t self.name = self.url\n end\n\tend", "def set_name\n @appname = \"Bike London\"\n end", "def set_node_name!(n)\...
[ "0.5888477", "0.58467346", "0.58049816", "0.5720786", "0.56210506", "0.55881375", "0.55249375", "0.551268", "0.5471337", "0.5450694", "0.54475623", "0.54157025", "0.5401262", "0.5391361", "0.53826094", "0.5367998", "0.5355333", "0.53459483", "0.533655", "0.53334826", "0.53303...
0.6766947
0
Calls send_changes on all targets in the ratelimiting queue, passing the result to each callback that was scheduled by a call to submit on the Light or Group. Clears the ratelimiting queue. Calls the block (if given) with no arguments once all changes scheduled at the time of the initial call to send_targets have been sent.
def send_targets &block targets = @rate_targets.to_a @rate_targets.clear return if targets.empty? target, cbs = targets.shift target_cb = proc {|status, result| cbs.each do |cb| begin cb.call status, result if cb rescue => e log_e e, "Error notifying rate limited target #{t} callback #{cb.inspect}" end end target, cbs = targets.shift if target log "Sending subsequent target #{target}" # XXX target.send_changes &target_cb else yield if block_given? end } log "Sending first target #{target}" # XXX target.send_changes &target_cb end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flush\n send_batch( Traject::Util.drain_queue(@batched_queue) )\n end", "def flush_jobs\n queued_jobs&.each(&:call)&.clear\n end", "def flush_filters(options = {}, &block)\n flushers = options[:final] ? @shutdown_flushers : @periodic_flushers\n\n flushers.each do |flusher|\n flus...
[ "0.5405749", "0.53730637", "0.53371835", "0.5284666", "0.5230514", "0.5188284", "0.5150451", "0.5104808", "0.50986713", "0.50941503", "0.50728005", "0.50513655", "0.5048827", "0.50429076", "0.5029701", "0.4993517", "0.49702623", "0.49443182", "0.49137878", "0.4904867", "0.489...
0.71456033
0
Calls all callbacks added using add_update_callback with the given update status and result.
def notify_update_callbacks status, result @update_callbacks.each do |cb| begin cb.call status, result rescue => e log_e e, "Error calling an update callback" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_update_callback &cb\n\t\t\t@update_callbacks << cb\n\t\t\tcb\n\t\tend", "def on_update(&update_callback)\n @update_callbacks << update_callback\n end", "def update &block\n receive_update_callbacks << block\n end", "def update_status\n begin\n if self.service_test.status_c...
[ "0.6666957", "0.6558847", "0.6192256", "0.60164154", "0.6016233", "0.58437735", "0.57424825", "0.5714062", "0.5487436", "0.54584926", "0.543268", "0.5432672", "0.5425748", "0.5418609", "0.5379018", "0.53442824", "0.53269625", "0.53009045", "0.5249911", "0.5200492", "0.5197573...
0.8535055
0
The only public interface in ActionCable for defining periodic timers is exposed at the class level. Looking at the source though, it is easy to see that new timers can be setup with `start_periodic_timer`. To ensure that we do not leak any timers, it is important to store these instances in `active_periodic_timers` so that ActionCable cleans them up for us when the channel shuts down. Also, periodic timers are not supported by the testing adapter, so we have to skip all of this in unit tests (it _will_ be covered in systems tests though). See `ActionCable::Channel::PeriodicTimers` for details.
def _setup_declarative_notifcation_timer(notification, interval) return if _stubbed_connection? || @_declarative_notifications_timers.include?(notification) callback = proc do synchronize_entrypoint! do _handle_declarative_notifcation(notification) end end timer = start_periodic_timer(callback, every: interval) @_declarative_notifications_timers[notification] = timer active_periodic_timers << timer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_periodic_timers; end", "def start_periodic_timers; end", "def create_periodic_timer(interval, &block)\n Timer.new(self, interval, :periodic => true, &block)\n end", "def stop_periodic_timers; end", "def add_periodic_timer(interval, callback=nil, &blk)\n @timers ||= {}\n timer = ...
[ "0.7656444", "0.7656444", "0.67096126", "0.66658", "0.6544925", "0.6363874", "0.6223419", "0.6223419", "0.6113376", "0.6106477", "0.5994491", "0.5985076", "0.59351444", "0.59077746", "0.58995426", "0.5815916", "0.57789004", "0.5771966", "0.57404673", "0.5712682", "0.5676491",...
0.5431712
32
this needed to be changed from attr_reader to attr_accessor to allow the setter method to work
def initialize(protein, base, toppings) @protein = protein @base = base @toppings = toppings end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_accessor(*args)\n attr_reader(*args)\n attr_writer(*args)\n end", "def attr_accessor(*fields)\n attr_reader *fields\n attr_writer *fields\n end", "def _setter_method\n :\"_#{self[:name]}=\"\n end", "def setter\r\n @setter ||= Field.setter(@name)\r\n end"...
[ "0.71179175", "0.68417317", "0.6794544", "0.67938864", "0.677677", "0.6751756", "0.67012244", "0.6689501", "0.66449744", "0.6636697", "0.663424", "0.6595739", "0.65752286", "0.6552692", "0.6472537", "0.64697415", "0.64697415", "0.64697415", "0.64001906", "0.6400113", "0.63834...
0.0
-1
if not blank, expect a float
def expect_float(value, field, subfield) return true if value.blank? return true if value.is_a?(Float) errors.add(field, "#{subfield} must be a float if present") false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def numeric?; float?; end", "def match_float( val )\n\t\treturn Float( val ) rescue nil\n\tend", "def convert_float( text_value )\r\n (!text_value.empty?) ? text_value.to_f : 0.0\r\nend", "def is_float(answer)\n float_answer = answer.to_f\n if float_answer == 0.0\n float_answer = nil\n end\n [float_a...
[ "0.790926", "0.75695205", "0.7517961", "0.74388254", "0.7384512", "0.7265466", "0.7221904", "0.720018", "0.7178305", "0.7166165", "0.71486765", "0.71090084", "0.70938885", "0.706803", "0.70650584", "0.7052679", "0.7047198", "0.70388335", "0.7031522", "0.7028021", "0.6986538",...
0.80276895
0
if not blank, expect an integer or float
def expect_integer_or_float(value, field, subfield) return true if value.blank? return true if value.is_a?(Integer) || value.is_a?(Float) errors.add(field, "#{subfield} must be an integer or float if present") false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def numeric?; float?; end", "def valid_number?(num)\n integer?(num) || float?(num)\nend", "def numeric_check(first_num)\n Float(first_num) != nil rescue false\nend", "def valid_num?(input)\n integer?(input) || float?(input)\nend", "def is_numeric?(val)\n Float val rescue false\n end", "def expect_...
[ "0.7323875", "0.7188554", "0.7169224", "0.7132365", "0.7099458", "0.70648926", "0.69519264", "0.68677175", "0.68374294", "0.6822195", "0.6806846", "0.6794792", "0.67836946", "0.67503303", "0.6740267", "0.6740267", "0.66957724", "0.66825014", "0.6664428", "0.6651231", "0.66375...
0.7783422
0
if not blank, expect an array
def expect_array(value, field, subfield) return true if value.blank? return true if value.is_a?(Array) errors.add(field, "#{subfield} must be an array") false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_nil_or_array_of_values(value, label)\n msg = \"#{label} must be a NULL or an array of strings or numbers.\"\n if !value.is_a?(Array) && !value.nil?\n CloudyCrud::InvalidRequest.new(msg)\n end\n \n if value.is_a?(Array)\n value.each do |v|\n if !v.is_a?(Num...
[ "0.71572083", "0.7050505", "0.68758124", "0.6707297", "0.6622902", "0.65551275", "0.6513702", "0.6492044", "0.6492044", "0.6427246", "0.6423743", "0.64149284", "0.6391352", "0.63831747", "0.63776064", "0.63641554", "0.63641554", "0.6351237", "0.6310188", "0.63008064", "0.6297...
0.7216775
0
if not blank, expect an array of integers
def expect_array_of_integers(value, field, subfield) return false unless expect_array(value, field, subfield) error_count = 0 value.each_with_index do |v, i| error_count += 1 unless expect_integer(v, field, "#{subfield}[#{i}]") end error_count == 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def int_array_check(arr)\n arr.each do |element|\n Integer(element) != nil rescue return false\n end\n return true\n end", "def ensure_nil_or_array_of_values(value, label)\n msg = \"#{label} must be a NULL or an array of strings or numbers.\"\n if !value.is_a?(Array) && !value.nil?\n ...
[ "0.6666064", "0.6467739", "0.63995194", "0.6375523", "0.6326545", "0.6130898", "0.6046748", "0.5972084", "0.5926946", "0.5921156", "0.58225864", "0.5802283", "0.5798244", "0.57748795", "0.57748795", "0.57526755", "0.57479525", "0.5731831", "0.572155", "0.57019013", "0.5697303...
0.6788924
0
if not blank, expect a Kronos hash
def expect_kronos_hash(value, field) return true if value.blank? if (value.keys - %w(year month day)).length > 0 errors.add(field, "only 'year', 'month', and 'day' keys are allowed") return false end year, month, day = value['year'], value['month'], value['day'] error_count = 0 error_count += 1 unless expect_integer(year, field, :year) error_count += 1 unless expect_integer(month, field, :month) error_count += 1 unless expect_integer(day, field, :day) return false unless error_count == 0 kronos = new_kronos(year, month, day) kronos_errors = kronos.errors kronos_errors.each { |e| errors.add(field, e) } kronos_errors.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_hash_empty_string\n knot = KnotHash.new\n assert_equal \"a2582a3a0e66e6e86e3812dcb672a272\", knot.hash('')\n end", "def validate_hash(info)\r\n\t\t# passes in the parsed info\r\n\t\tstring_to_hash = get_string_to_hash(info)\r\n\t\tcorrect_hash = get_hash(string_to_hash)\r\n\t\t#puts string_to_has...
[ "0.6772369", "0.6324056", "0.6310255", "0.62402475", "0.61013603", "0.60619116", "0.60619116", "0.602757", "0.5939394", "0.59071565", "0.5893877", "0.589202", "0.5877765", "0.5877765", "0.5858099", "0.5813908", "0.5783015", "0.5769241", "0.5765105", "0.57645154", "0.5752574",...
0.5411967
76
if not blank, expect a ratings hash
def expect_ratings_hash(value, field) return true if value.blank? if (value.keys - %w(avg min max bins n)).length > 0 errors.add(field, "only 'min', 'max', 'avg', 'bins', and 'n' keys are allowed") return false end min, max, avg, bins, n = value['min'], value['max'], value['avg'], value['bins'], value['n'] error_count = 0 error_count += 1 unless expect_integer(min, field, :min) error_count += 1 unless expect_integer(max, field, :max) error_count += 1 unless expect_integer_or_float(avg, field, :avg) error_count += 1 unless expect_array_of_integers(bins, field, :bins) error_count += 1 unless expect_integer(n, field, :n) error_count == 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_reviews_hash\n\t\t[{title: \"Pretty decent, could have been better\", stars: 4, summary: \"This chair arrived well-packaged and protected with a lot of foam insulation around the wheels and metal components. Assembly was quick and simple, as I didn't even need the instructions. All you have to do is put...
[ "0.6193544", "0.6170705", "0.6077841", "0.5977752", "0.59250176", "0.5807057", "0.57502466", "0.5629469", "0.5608204", "0.55922484", "0.55729353", "0.55428743", "0.5512205", "0.548633", "0.5484338", "0.5468345", "0.5451925", "0.54482514", "0.5396275", "0.5394986", "0.53863436...
0.5972832
4
Marks all the receipts from the relation as unread
def mark_as_unread(options={}) update_receipts({:is_read => false}, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_as_unread\n update_attributes(is_read: false)\n end", "def mark_as_unread()\n update_attribute('read', false)\n end", "def mark_as_unread(options = {})\n update_receipts({ is_read: false }, options)\n end", "def mark_unread!\n update_is_read_status false\n end", "def mark_a...
[ "0.78058374", "0.77973753", "0.7703921", "0.7648808", "0.7543684", "0.7543684", "0.74502486", "0.730283", "0.7253037", "0.7248103", "0.7245441", "0.7240881", "0.7175328", "0.7005042", "0.699146", "0.6945779", "0.69456506", "0.69120806", "0.68855524", "0.68277246", "0.6790923"...
0.7702514
4
Marks all the receipts from the relation as trashed
def move_to_trash(options={}) update_receipts({:trashed => true}, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def untrash\n update_attributes(trashed: false)\n end", "def untrash\n update_attributes(:trashed => false)\n end", "def trash!\n self.update_column(self.class.trashed_at_attribute_name, Time.now)\n end", "def untrash(options = {})\n update_receipts({ trashed: false }, options)\n ...
[ "0.65835357", "0.65598935", "0.6489531", "0.647539", "0.6419946", "0.6419946", "0.62808454", "0.6257433", "0.6229513", "0.62206876", "0.6132078", "0.611559", "0.6004777", "0.58164495", "0.5726632", "0.570261", "0.5621111", "0.5611692", "0.5611692", "0.5609933", "0.55916923", ...
0.5919988
13
Marks all the receipts from the relation as not trashed
def untrash(options={}) update_receipts({:trashed => false}, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def soft_restore!\n update_attribute(:mark_as_deleted, false)\n end", "def untrash\n update_attributes(trashed: false)\n end", "def untrash\n update_attributes(:trashed => false)\n end", "def is_trashed?\n trashed\n end", "def is_trashed?\n trashed\n end", "def mark_as_not_deleted...
[ "0.64194554", "0.6357363", "0.63108295", "0.63078237", "0.63078237", "0.6227842", "0.61284506", "0.61284506", "0.6123075", "0.6101573", "0.6101573", "0.60873854", "0.6079668", "0.60584587", "0.6001685", "0.59941113", "0.58727115", "0.5802029", "0.578999", "0.57544273", "0.568...
0.58552414
17
Marks the receipt as deleted
def mark_as_deleted(options={}) update_receipts({:deleted => true}, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_as_deleted(options = {})\n update_receipts({ deleted: true }, options)\n end", "def mark_as_deleted(participant)\n return if participant.nil?\n return receipt_for(participant).mark_as_deleted\n end", "def mark_as_not_deleted(options = {})\n update_receipts({ deleted: false }, optio...
[ "0.78310746", "0.7163043", "0.7065122", "0.70333284", "0.7002711", "0.7002711", "0.6994164", "0.69806486", "0.6960063", "0.6956435", "0.68856287", "0.6815642", "0.6744133", "0.67261976", "0.67261976", "0.66927785", "0.66836315", "0.6607872", "0.6604654", "0.6570757", "0.65593...
0.77319705
2
Marks the receipt as not deleted
def mark_as_not_deleted(options={}) update_receipts({:deleted => false}, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_as_not_deleted(options = {})\n update_receipts({ deleted: false }, options)\n end", "def markToDelete\n #N Without this it won't be marked for deletion\n @toBeDeleted = true\n end", "def mark_as_deleted(options = {})\n update_receipts({ deleted: true }, options)\n end", ...
[ "0.7962008", "0.7333951", "0.72914743", "0.72495705", "0.72495705", "0.7212722", "0.7212722", "0.7196142", "0.7108303", "0.70384866", "0.7021048", "0.6912656", "0.6691948", "0.6617215", "0.6599504", "0.6558748", "0.6537653", "0.65372896", "0.65372896", "0.6488924", "0.6467783...
0.7905363
2
Moves all the receipts from the relation to inbox
def move_to_inbox(options={}) update_receipts({:mailbox_type => :inbox, :trashed => false}, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_inbox(options = {})\n update_receipts({ mailbox_type: :inbox, trashed: false }, options)\n end", "def move_to_inbox\n update_attributes(mailbox_type: :inbox, trashed: false)\n end", "def move_to_inbox\n update_attributes(:mailbox_type => :inbox, :trashed => false)\n end", "def tra...
[ "0.6903409", "0.68214685", "0.6783832", "0.6261648", "0.62301004", "0.62273306", "0.59882736", "0.5973973", "0.5951482", "0.5931505", "0.5872843", "0.5854581", "0.5817995", "0.5780997", "0.5776568", "0.57480943", "0.5689026", "0.56243956", "0.55887383", "0.5579526", "0.557882...
0.69446534
0
Moves all the receipts from the relation to sentbox
def move_to_sentbox(options={}) update_receipts({:mailbox_type => :sentbox, :trashed => false}, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_sentbox(options = {})\n update_receipts({ mailbox_type: :sentbox, trashed: false }, options)\n end", "def move_to_sentbox\n update_attributes(:mailbox_type => :sentbox, :trashed => false)\n end", "def move_to_sentbox\n update_attributes(mailbox_type: :sentbox, trashed: false)\n end"...
[ "0.709845", "0.6927832", "0.68966913", "0.643739", "0.632694", "0.6268902", "0.6230505", "0.6187396", "0.6122531", "0.60698205", "0.59661883", "0.58835673", "0.581402", "0.57397383", "0.56649935", "0.5644321", "0.55803204", "0.55726445", "0.5530438", "0.55276215", "0.55217713...
0.71585536
0
Marks the receipt as deleted
def mark_as_deleted update_attributes(:deleted => true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_as_deleted(options = {})\n update_receipts({ deleted: true }, options)\n end", "def mark_as_deleted(options={})\n update_receipts({:deleted => true}, options)\n end", "def mark_as_deleted(options={})\n update_receipts({:deleted => true}, options)\n end", "def mark_as_deleted(...
[ "0.78310746", "0.77319705", "0.77319705", "0.7163043", "0.7065122", "0.70333284", "0.7002711", "0.7002711", "0.6994164", "0.69806486", "0.6960063", "0.6956435", "0.68856287", "0.6815642", "0.6744133", "0.66927785", "0.66836315", "0.6607872", "0.6604654", "0.6570757", "0.65593...
0.67261976
16
Marks the receipt as not deleted
def mark_as_not_deleted update_attributes(:deleted => false) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_as_not_deleted(options = {})\n update_receipts({ deleted: false }, options)\n end", "def mark_as_not_deleted(options={})\n update_receipts({:deleted => false}, options)\n end", "def mark_as_not_deleted(options={})\n update_receipts({:deleted => false}, options)\n end", "def m...
[ "0.7962008", "0.7905363", "0.7905363", "0.7333951", "0.72914743", "0.72495705", "0.72495705", "0.7196142", "0.7108303", "0.70384866", "0.7021048", "0.6912656", "0.6691948", "0.6617215", "0.6599504", "0.6558748", "0.6537653", "0.65372896", "0.65372896", "0.6488924", "0.6467783...
0.7212722
8
Marks the receipt as read
def mark_as_read update_attributes(:is_read => true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_read_receipt=(value)\n @is_read_receipt = value\n end", "def mark_read!\n update_is_read_status true\n end", "def mark_as_read(participant)\n return if participant.nil?\n receipt_for(participant).mark_as_read\n end", "def mark_as_read(participant)\n return u...
[ "0.7552296", "0.7498822", "0.74588305", "0.73571444", "0.7345046", "0.72771454", "0.7134009", "0.71117777", "0.70811677", "0.70498735", "0.70498335", "0.70339084", "0.70301104", "0.70238996", "0.7012125", "0.69184047", "0.68969786", "0.6884461", "0.68068343", "0.6774346", "0....
0.638305
34
Marks the receipt as unread
def mark_as_unread update_attributes(:is_read => false) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_unread!\n update_is_read_status false\n end", "def mark_as_unread()\n update_attribute('read', false)\n end", "def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end", "def mark_as_unread(options={})\n update_receipts({:is_read => false}, option...
[ "0.8334026", "0.816925", "0.80689204", "0.80689204", "0.8016737", "0.79229987", "0.767009", "0.76440966", "0.7595514", "0.75792134", "0.75527245", "0.7538944", "0.74712104", "0.73848987", "0.7295448", "0.7291855", "0.72349524", "0.7210682", "0.72082144", "0.720497", "0.711393...
0.7755203
7
Marks the receipt as trashed
def move_to_trash update_attributes(:trashed => true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def untrash(options = {})\n update_receipts({ trashed: false }, options)\n end", "def move_to_trash(options = {})\n update_receipts({ trashed: true }, options)\n end", "def trash!\n self.update_column(self.class.trashed_at_attribute_name, Time.now)\n end", "def untrash\n update...
[ "0.69219124", "0.67171866", "0.67137825", "0.6652731", "0.6605463", "0.6521941", "0.650799", "0.650799", "0.6392251", "0.60774404", "0.6036706", "0.5981778", "0.597217", "0.5937765", "0.59080106", "0.568447", "0.5683478", "0.56734157", "0.56527406", "0.5624777", "0.5623851", ...
0.62432826
9
Marks the receipt as not trashed
def untrash update_attributes(:trashed => false) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_trashed?\n trashed\n end", "def is_trashed?\n trashed\n end", "def untrash(options = {})\n update_receipts({ trashed: false }, options)\n end", "def untrash\n update_attributes(trashed: false)\n end", "def untrash(options={})\n update_receipts({:trashed => false}, options)\n...
[ "0.6697808", "0.6697808", "0.6573803", "0.6352519", "0.63296217", "0.6290867", "0.6284387", "0.61686015", "0.6134588", "0.6078834", "0.6078834", "0.60372204", "0.5971123", "0.59027916", "0.5822483", "0.57965857", "0.5788384", "0.5770317", "0.5720212", "0.5710139", "0.56475806...
0.64406717
3
Moves the receipt to inbox
def move_to_inbox update_attributes(:mailbox_type => :inbox, :trashed => false) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_inbox(options={})\n update_receipts({:mailbox_type => :inbox, :trashed => false}, options)\n end", "def move_to_inbox(options = {})\n update_receipts({ mailbox_type: :inbox, trashed: false }, options)\n end", "def move_to_inbox\n update_attributes(mailbox_type: :inbox, trashed: f...
[ "0.816639", "0.80753946", "0.7646465", "0.68694544", "0.669493", "0.66706556", "0.6565059", "0.6452016", "0.6390382", "0.62213904", "0.6152697", "0.60150284", "0.5985406", "0.58441675", "0.58000255", "0.56987786", "0.5676851", "0.5676178", "0.5666402", "0.5627923", "0.5537429...
0.7618634
3
Moves the receipt to sentbox
def move_to_sentbox update_attributes(:mailbox_type => :sentbox, :trashed => false) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_sentbox(options={})\n update_receipts({:mailbox_type => :sentbox, :trashed => false}, options)\n end", "def move_to_sentbox(options = {})\n update_receipts({ mailbox_type: :sentbox, trashed: false }, options)\n end", "def move_to_sentbox\n update_attributes(mailbox_type: :sentbox...
[ "0.80425024", "0.7959969", "0.727761", "0.6857767", "0.6788295", "0.63775176", "0.6344544", "0.61171114", "0.61171114", "0.5989076", "0.5914472", "0.58116394", "0.570135", "0.567278", "0.56533146", "0.56383014", "0.5606686", "0.55847335", "0.5569224", "0.55460316", "0.55322",...
0.73351306
2
Returns the conversation associated to the receipt if the notification is a Message
def conversation message.conversation if message.is_a? Mailboxer::Message end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n\t\t@conversation = current_user.mailbox.conversations.find(params[:id]).receipts_for(current_user)\n\tend", "def conversation\n @conversation ||= mailbox.conversations.find(params[:id])\n end", "def conversation\n @conversation ||= mailbox.conversations.find(params[:id])\n end", "def fetch...
[ "0.6350189", "0.6332858", "0.6332858", "0.6320066", "0.6226794", "0.62215024", "0.61476874", "0.611586", "0.6071903", "0.60659176", "0.6058745", "0.6015387", "0.6011112", "0.5794935", "0.5714565", "0.5713625", "0.56873703", "0.56852686", "0.56492454", "0.5635355", "0.5610224"...
0.69913954
1
Returns if the participant have read the Notification
def is_unread? !is_read end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_unread?(participant)\n return false if participant.nil?\n !receipt_for(participant).first.is_read\n end", "def read?\n !recipient_read_at.nil?\n end", "def is_unread?(participant)\n return false unless participant\n receipts_for(participant).not_trash.is_unread.count != 0\n end", "de...
[ "0.77494866", "0.75095993", "0.7376746", "0.7304574", "0.72450143", "0.72403264", "0.70782804", "0.70645475", "0.70561475", "0.7054909", "0.7043266", "0.70395154", "0.7030828", "0.70300716", "0.69458485", "0.6945682", "0.69395685", "0.6933228", "0.69307315", "0.68218017", "0....
0.718954
8