Stores OHLC data received via wss in self.candles[chan_id]
        :param ts: timestamp, declares when data was received by the client
        :param chan_id: int, channel id
        :param data: list of data received via wss
        :return:
427442
def _handle_candles(self, ts, chan_id, data):
        
        pair = self.channel_labels[chan_id][1]['key'].split(':')[-1][1:]
        entry = data, ts
        self.data_q.put(('ohlc', pair, entry))
87458
function sendMsg(type, data) {
  if (
    typeof self !== 'undefined' &&
    (typeof WorkerGlobalScope === 'undefined' ||
      !(self instanceof WorkerGlobalScope))
  ) {
    self.postMessage(
      {
        type: `webpack${type}`,
        data,
      },
      '*'
    );
  }
}
424538
def data(ts = Time.now.floor)
      args = {
        enterprise_id: self.enterprise.id,
        funnel_slug: self.name_slug,
        ts: ts
      }
      res = Octo::FunnelData.where(args)
      if res.count > 0
        res.first
      elsif self.enterprise.fakedata?
        args.merge!({ value: fake_data(self.funnel.count) })
        Octo::FunnelData.new(args).save!
      end
    end
1060292
function (data) {
          //If a token is not configured, don't do anything.
          if (!token || !loggingEnabled) {
            return;
          }

          //TODO we're injecting this here to resolve circular dependency issues.  Is this safe?
          var $window = $injector.get( '$window' );
          var $location = $injector.get( '$location' );
		   //we're injecting $http
          var $http = $injector.get( '$http' );

          lastLog = new Date();

          var sentData = angular.extend({}, extra, data);

          if (includeCurrentUrl) {
            sentData.url = $location.absUrl();
          }

          if( includeTimestamp ) {
            sentData.timestamp = lastLog.toISOString();
          }

          if( includeUserAgent ) {
            sentData.userAgent = $window.navigator.userAgent;
          }

          //Loggly's API doesn't send us cross-domain headers, so we can't interact directly
           //Set header
          var config = {
            headers: {
             'Content-Type': 'text/plain'
            },
            withCredentials: false
          };

          if (deleteHeaders) {
            //Delete other headers - this tells browser it's no need to pre-flight OPTIONS request
            var headersToDelete = Object.keys($http.defaults.headers.common).concat(Object.keys($http.defaults.headers.post));
            headersToDelete = headersToDelete.filter(function(item) {
              return item !== 'Accept' && item !== 'Content-Type';
            });

            for (var index = 0; index < headersToDelete.length; index++) {
              var headerName = headersToDelete[index];
              config.headers[headerName] = undefined;
            }
          }

          // Apply labels
          for (var label in labels) {
            if (label in sentData) {
              sentData[labels[label]] = sentData[label];
              delete sentData[label];
            }
          }

          //Ajax call to send data to loggly
          $http.post(buildUrl(),sentData,config).catch(console.error);
        }
1340831
def received(self):
        
        if not hasattr(self, '_data'):
            # NB: units are reversed so that lowest numbered unit takes precedence
            self._data = JSONUnitDataView({key: value
                                           for unit in reversed(self)
                                           for key, value in unit.received_raw.items()})

        return self._data
266095
function prepareData(items, with_timestamps, with_ns) {
    var data = {
        request: 'sender data',
        data: items
    };

    if (with_timestamps) {
        var ts = Date.now() / 1000;
        data.clock = ts | 0;

        if (with_ns) {
            data.ns = (ts % 1) * 1000 * 1000000 | 0;
        }
    }

    var payload = new Buffer(JSON.stringify(data), 'utf8'),
        header  = new Buffer(5 + 4); // ZBXD\1 + packed payload.length

    header.write('ZBXD\x01');
    header.writeInt32LE(payload.length, 5);
    return Buffer.concat([header, new Buffer('\x00\x00\x00\x00'), payload]);
}
1260293
def write(self, data: bytes) -> int:
        
        if self._sock is None:
            raise IOError('Internal socket set to None; cannot perform handshake.')
        if not self._is_handshake_completed:
            raise IOError('SSL Handshake was not completed; cannot send data.')

        # Pass the cleartext data to the SSL engine
        self._ssl.write(data)

        # Recover the corresponding encrypted data
        final_length = self._flush_ssl_engine()

        return final_length
71076
def _handle_websocket_headers(self, handler: WebSocketHandler) -> None:
        
        fields = ("Host", "Sec-Websocket-Key", "Sec-Websocket-Version")
        if not all(map(lambda f: handler.request.headers.get(f), fields)):
            raise ValueError("Missing/Invalid WebSocket headers")
629137
function Client(transport) {
	MCS.call(this, transport, DomainMCSPDU.SEND_DATA_INDICATION, DomainMCSPDU.SEND_DATA_REQUEST);
	
	// channel context automata
	this.channelsConnected = 0;
	
	// init gcc information
	this.clientCoreData = gcc.clientCoreData();
	this.clientNetworkData = gcc.clientNetworkData(new type.Component([]));
	this.clientSecurityData = gcc.clientSecurityData();
	
	// must be readed from protocol
	this.serverCoreData = null;
	this.serverSecurityData = null;
	this.serverNetworkData = null;
	
	var self = this;
	this.transport.on('connect', function(s) {
		self.connect(s);
	});
}
601231
def savepysyn(self,wave,flux,fname,units=None):
        
        if units is None:
            ytype='throughput'
            units=' '
        else:
            ytype='flux'
        col1=pyfits.Column(name='wavelength',format='D',array=wave)
        col2=pyfits.Column(name=ytype,format='D',array=flux)
        tbhdu=pyfits.BinTableHDU.from_columns(pyfits.ColDefs([col1,col2]))
        tbhdu.header.update('tunit1','angstrom')
        tbhdu.header.update('tunit2',units)
        tbhdu.writeto(fname.replace('.fits','_pysyn.fits'))
136965
function onmessage(data) {
          if (!handshaked) {
            handshaked = true;
            // The handshake output is in the form of URI.
            var result = url.parse(data, true).query;
            // A newly issued id for HTTP transport. It is used to identify which HTTP transport
            // is associated with which HTTP exchange. Don't confuse it with an id for socket,
            // `cettia-id`.
            self.id = result["cettia-transport-id"];
            // And then fire `open` event.
            self.emit("open");
          } else {
            // `code` is a first character of a message and used to recognize that delivered
            // message is text message or binary message.
            var code = data.substring(0, 1);
            data = data.substring(1);
            switch (code) {
              // If the `code` is `1`, the remainder of message is a plain text message. Fires
              // `text` event.
              case "1":
                self.emit("text", data);
                break;
              // If the `code` is `2`, the remainder of message is a Base64-encoded binary
              // message. Decodes it in Base64 and fires `binary` event.
              case "2":
                self.emit("binary", new Buffer(data, "base64"));
                break;
              // Otherwise, it is invalid. Fires an error and closes the connection.
              default:
                self.emit("error", new Error("protocol"));
                self.close();
                break;
            }
          }
        }
345457
def _loadData(self, data):
        
        self._data = data
        self._token = logfilter.add_secret(data.attrib.get('authenticationToken'))
        self._webhooks = []
        self.authenticationToken = self._token
        self.certificateVersion = data.attrib.get('certificateVersion')
        self.cloudSyncDevice = data.attrib.get('cloudSyncDevice')
        self.email = data.attrib.get('email')
        self.guest = utils.cast(bool, data.attrib.get('guest'))
        self.home = utils.cast(bool, data.attrib.get('home'))
        self.homeSize = utils.cast(int, data.attrib.get('homeSize'))
        self.id = data.attrib.get('id')
        self.locale = data.attrib.get('locale')
        self.mailing_list_status = data.attrib.get('mailing_list_status')
        self.maxHomeSize = utils.cast(int, data.attrib.get('maxHomeSize'))
        self.queueEmail = data.attrib.get('queueEmail')
        self.queueUid = data.attrib.get('queueUid')
        self.restricted = utils.cast(bool, data.attrib.get('restricted'))
        self.scrobbleTypes = data.attrib.get('scrobbleTypes')
        self.secure = utils.cast(bool, data.attrib.get('secure'))
        self.thumb = data.attrib.get('thumb')
        self.title = data.attrib.get('title')
        self.username = data.attrib.get('username')
        self.uuid = data.attrib.get('uuid')
        subscription = data.find('subscription')

        self.subscriptionActive = utils.cast(bool, subscription.attrib.get('active'))
        self.subscriptionStatus = subscription.attrib.get('status')
        self.subscriptionPlan = subscription.attrib.get('plan')

        self.subscriptionFeatures = []
        for feature in subscription.iter('feature'):
            self.subscriptionFeatures.append(feature.attrib.get('id'))

        roles = data.find('roles')
        self.roles = []
        if roles:
            for role in roles.iter('role'):
                self.roles.append(role.attrib.get('id'))

        entitlements = data.find('entitlements')
        self.entitlements = []
        for entitlement in entitlements.iter('entitlement'):
            self.entitlements.append(entitlement.attrib.get('id'))

        # TODO: Fetch missing MyPlexAccount attributes
        self.profile_settings = None
        self.services = None
        self.joined_at = None
1285839
function( data ){

            var bodies = this.getTargets()
                ,dt = data.dt
                ,bodyA
                ,bodyB
                ,collisions = []
                ,ret
                ,prevContacts = this.prevContacts || {}
                ,contactList = {}
                ,pairHash = Physics.util.pairHash
                ,hash
                ;

            for ( var j = 0, l = bodies.length; j < l; j++ ){

                bodyA = bodies[ j ];

                for ( var i = j + 1; i < l; i++ ){

                    bodyB = bodies[ i ];

                    ret = checkPair( bodyA, bodyB );

                    if ( ret instanceof Array ){

                        for ( var k = 0, r, ll = ret.length; k < ll; k++ ){
                            r = ret[k];
                            if ( r ){
                                hash = pairHash( bodyA.uid, bodyB.uid );
                                contactList[ hash ] = true;
                                r.collidedPreviously = prevContacts[ hash ];
                                collisions.push( r );
                            }
                        }

                    } else if ( ret ){
                        hash = pairHash( bodyA.uid, bodyB.uid );
                        contactList[ hash ] = true;
                        ret.collidedPreviously = prevContacts[ hash ];

                        collisions.push( ret );
                    }
                }
            }

            this.prevContacts = contactList;

            if ( collisions.length ){

                this._world.emit( this.options.channel, {
                    collisions: collisions
                });
            }
        }
811199
def send(self, data, opcode=websocket.ABNF.OPCODE_TEXT):
        
        self.ws_client.send(data, opcode)
358448
def data(self, data):
        
        self.unpacker.feed(data)
        for msg in self.unpacker:
            self.handlers[msg[0]](*msg)
29375
def store_chart_stream # :nodoc:
    store_chart(*@config[:chart])
    store_begin

    # Store the chart SCL record.
    store_plotgrowth

    if @chartarea[:visible] != 0
      store_chartarea_frame_stream
    end

    # Store SERIES stream for each series.
    index = 0
    @series.each do |series|
      store_series_stream(
          :index            => index,
          :value_formula    => series[:values][0],
          :value_count      => series[:values][1],
          :category_count   => series[:categories][1],
          :category_formula => series[:categories][0],
          :name             => series[:name],
          :name_encoding    => series[:name_encoding],
          :name_formula     => series[:name_formula]
        )
        index += 1
    end

    store_shtprops

    # Write the TEXT streams.
    (5..6).each do |font_index|
      store_defaulttext
      store_series_text_stream(font_index)
    end

    store_axesused(1)
    store_axisparent_stream

    if !@title_name.nil? || !@title_formula.nil?
      store_title_text_stream
    end

    store_end
  end
393906
def send_to_websocket(self, data):
        """"""
        data = json.dumps(data)
        self.websocket.send(data)