Serve event to RainbowAlga
761125
def srv_event(token, hits, url=RBA_URL):
    """"""

    if url is None:
        log.error("Please provide a valid RainbowAlga URL.")
        return

    ws_url = url + '/message'

    if isinstance(hits, pd.core.frame.DataFrame):
        pos = [tuple(x) for x in hits[['x', 'y', 'z']].values]
        time = list(hits['time'])
        tot = list(hits['tot'])
    elif isinstance(hits, Table):
        pos = list(zip(hits.pos_x, hits.pos_y, hits.pos_z))
        time = list(hits.time)
        tot = list(hits.tot)
    else:
        log.error(
            "No calibration information found in hits (type: {0})".format(
                type(hits)
            )
        )
        return

    event = {
        "hits": {
            'pos': pos,
            'time': time,
            'tot': tot,
        }
    }

    srv_data(ws_url, token, event, 'event')
620850
function prepareEvents(raddec) {
  let elements = [];

  raddec.events.forEach(function(event) {
    let i = document.createElement('i');
    let space = document.createTextNode(' ');
    i.setAttribute('class', EVENT_ICONS[event]);
    elements.push(i);
    elements.push(space);
  });

  return elements;
}
777894
function serve(req, res) {
  var responseIsArray = Array.isArray(res.entityResponse);
  util.invariant(responseIsArray, 'Response values are required.');

  res.json({ values: res.entityResponse });
}
1155544
function(event, data) {
				var i,
					node = data.node,
					$tdList = $(node.tr).find(">td"),
					cnList = node.data.vernacularNames
						? $.map(node.data.vernacularNames, function(o) {
								return o.vernacularName;
						  })
						: [];

				i = 0;
				function _setCell($cell, text) {
					$("<div class='truncate'>")
						.attr("title", text)
						.text(text)
						.appendTo($cell);
				}
				$tdList.eq(i++).text(node.key);
				$tdList.eq(i++).text(node.data.rank);
				i++; // #1: node.title = scientificName
				// $tdList.eq(i++).text(cnList.join(", "));
				_setCell($tdList.eq(i++), cnList.join(", "));
				$tdList.eq(i++).text(node.data.canonicalName);
				// $tdList.eq(i++).text(node.data.accordingTo);
				_setCell($tdList.eq(i++), node.data.accordingTo);
				$tdList.eq(i++).text(node.data.taxonomicStatus);
				$tdList.eq(i++).text(node.data.nameType);
				$tdList.eq(i++).text(node.data.numOccurrences);
				$tdList.eq(i++).text(node.data.numDescendants);
				// $tdList.eq(i++).text(node.data.authorship);
				_setCell($tdList.eq(i++), node.data.authorship);
				// $tdList.eq(i++).text(node.data.publishedIn);
				_setCell($tdList.eq(i++), node.data.publishedIn);
			}
528637
def put(self, event_type, event_data={}, **kwargs):
        
        event = dict(type=event_type, data=event_data)

        event["time"] = kwargs.get("time", datetime.utcnow().isoformat())

        if kwargs.get("id"):
            event["id"] = kwargs.get("id")

        data = json.dumps([event])

        r = requests.post(self.collector_url + 'event/put',
                          data=data,
                          headers={'content-type': 'application/json'})
        r.raise_for_status()

        return [event]
625674
def event_return(events):
    '''
    
    '''
    with _get_serv(events, commit=True) as cur:
        for event in events:
            tag = event.get('tag', '')
            data = event.get('data', '')
            sql = '''INSERT INTO `salt_events` (`tag`, `data`, `master_id`)
                     VALUES (%s, %s, %s)'''
            cur.execute(sql, (tag, salt.utils.json.dumps(data), __opts__['id']))
1102818
def post_event(id, event, options = {})
      data = options
      data['id'] = id
      data['event'] = event
      api_post(:event, data)
    end
125873
function run() {
		$fw=\Base::instance();
		// Assign signal handlers
		declare(ticks=1);
		pcntl_signal(SIGINT,[$this,'kill']);
		pcntl_signal(SIGTERM,[$this,'kill']);
		gc_enable();
		// Activate WebSocket listener
		$listen=stream_socket_server(
			$this->addr,$errno,$errstr,
			STREAM_SERVER_BIND|STREAM_SERVER_LISTEN,
			$this->ctx
		);
		$socket=socket_import_stream($listen);
		register_shutdown_function(function() use($listen) {
			foreach ($this->sockets as $socket)
				if ($socket!=$listen)
					$this->close($socket);
			$this->close($listen);
			if (isset($this->events['stop']) &&
				is_callable($func=$this->events['stop']))
				$func($this);
		});
		if ($errstr)
			user_error($errstr,E_USER_ERROR);
		if (isset($this->events['start']) &&
			is_callable($func=$this->events['start']))
			$func($this);
		$this->sockets=[(int)$listen=>$listen];
		$empty=[];
		$wait=$this->wait;
		while (TRUE) {
			$active=$this->sockets;
			$mark=microtime(TRUE);
			$count=@stream_select(
				$active,$empty,$empty,(int)$wait,round(1e6*($wait-(int)$wait))
			);
			if (is_bool($count) && $wait) {
				if (isset($this->events['error']) &&
					is_callable($func=$this->events['error']))
					$func($this);
				die;
			}
			if ($count) {
				// Process active connections
				foreach ($active as $socket) {
					if (!is_resource($socket))
						continue;
					if ($socket==$listen) {
						if ($socket=@stream_socket_accept($listen,0))
							$this->alloc($socket);
						else
						if (isset($this->events['error']) &&
							is_callable($func=$this->events['error']))
							$func($this);
					}
					else {
						$id=(int)$socket;
						if (isset($this->agents[$id]))
							$this->agents[$id]->fetch();
					}
				}
				$wait-=microtime(TRUE)-$mark;
				while ($wait<1e-6) {
					$wait+=$this->wait;
					$count=0;
				}
			}
			if (!$count) {
				$mark=microtime(TRUE);
				foreach ($this->sockets as $id=>$socket) {
					if (!is_resource($socket))
						continue;
					if ($socket!=$listen &&
						isset($this->agents[$id]) &&
						isset($this->events['idle']) &&
						is_callable($func=$this->events['idle']))
						$func($this->agents[$id]);
				}
				$wait=$this->wait-microtime(TRUE)+$mark;
			}
			gc_collect_cycles();
		}
	}
323381
function subscribeToEvents() {
    const socket = _socket.get(this);

    function onEventApiError(error) {
        dbg('Event API connection error: ' + JSON.stringify(error));
    }

    socket.on('pong', (latency) => {
        dbg(`Event API latency: ${latency} ms`);
    });
    socket.on('connect_error', onEventApiError);
    socket.on('error', onEventApiError);
    socket.on('disconnect', onEventApiError);
    socket.on('reconnect_error', onEventApiError);
    socket.on('reconnect_failed', () => {
        onEventApiError('Reconnecting to the Event API failed');
    });

    socket.on('new_receipt', receiptJSON => {
        const receipt = Receipt.from(receiptJSON, _provider.get(this));
        _eventEmitter.get(this).emit(EventNames.newReceipt, receipt);
    });
}
1232325
def _nodedev_event_update_cb(conn, dev, opaque):
    '''
    
    '''
    _salt_send_event(opaque, conn, {
        'nodedev': {
            'name': dev.name()
        },
        'event': opaque['event']
    })
520157
function(eventStr, callback) {
    if (!this.events[eventStr]) {
      this.events[eventStr] = [];
    }

    this.events[eventStr].push(callback);
  }
631808
function renderEvents(events, modifiedEventId) {
		var i, len=events.length,
			dayEvents=[],
			slotEvents=[];
		for (i=0; i<len; i++) {
			if (events[i].allDay) {
				dayEvents.push(events[i]);
			}else{
				slotEvents.push(events[i]);
			}
		}

		if (opt('allDaySlot')) {
			renderDayEvents(dayEvents, modifiedEventId);
			setHeight(); // no params means set to viewHeight
		}

		renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId);
	}
1315725
function serve(done) {
  gulp.watch(['src/**/*.css'], () => {
    reset();
    gulp.series('build-css', 'generate-preview', outputDevServerInfo);
  });

  gulp.watch(['previewer-src/**', 'patterns.yaml'], () => {
    reset();
    gulp.series('generate-preview-force', outputDevServerInfo)
  });

  browserSync.emitter.on('init', outputDevServerInfo);

  browserSync.init({
    logLevel: 'silent',
    ui: false,
    port: 4321,
    notify: false,
    server: {
      baseDir: __dirname + '/build',
      middleware: [historyApiFallback()],
    },
    startPath: '/',
    open: false
  });
}
487425
def event_stream(self, filters=None):
        
        if filters is None:
            filters = {}
        return self._docker.events(decode=True, filters=filters)
144155
def publish_and_get_event(self, resource):
        """"""
        l_subscribed = False
        this_event = None

        if not self.__subscribed:
            self._get_event_stream()
            self._subscribe_myself()
            l_subscribed = True

        status = self.publish(
            action='get',
            resource=resource,
            mode=None,
            publish_response=False)

        if status == 'success':
            i = 0
            while not this_event and i < 2:
                self.__event_handle.wait(5.0)
                self.__event_handle.clear()
                _LOGGER.debug("Instance %s resource: %s", str(i), resource)
                for event in self.__events:
                    if event['resource'] == resource:
                        this_event = event
                        self.__events.remove(event)
                        break
                i = i + 1

        if l_subscribed:
            self._unsubscribe_myself()
            self._close_event_stream()
            l_subscribed = False

        return this_event
350217
function eventHover ( event ) {

            var proposal = calcPointToPercentage(event.calcPoint);

            var to = scope_Spectrum.getStep(proposal);
            var value = scope_Spectrum.fromStepping(to);

            Object.keys(scope_Events).forEach(function( targetEvent ) {
                if ( 'hover' === targetEvent.split('.')[0] ) {
                    scope_Events[targetEvent].forEach(function( callback ) {
                        callback.call( scope_Self, value );
                    });
                }
            });
        }
1168516
protected function __bindEvents()
    {
        $server = $this->swoolePort ?? $this->swooleServer;

        $server->on('connect', function(\swoole_server $server, $fd, $reactorID){
            try{
                $this->trigger('connect', [
                    'server'    => $this,
                    'fd'        => $fd,
                    'reactorID' => $reactorID,
                ], $this, ConnectEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });
        
        $server->on('receive', function(\swoole_server $server, $fd, $reactorID, $data){
            try{
                $this->trigger('receive', [
                    'server'    => $this,
                    'fd'        => $fd,
                    'reactorID' => $reactorID,
                    'data'      => $data,
                ], $this, ReceiveEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });
        
        $server->on('close', function(\swoole_server $server, $fd, $reactorID){
            try{
                $this->trigger('close', [
                    'server'    => $this,
                    'fd'        => $fd,
                    'reactorID' => $reactorID,
                ], $this, CloseEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });

        $server->on('BufferFull', function(\swoole_server $server, $fd){
            try{
                $this->trigger('bufferFull', [
                    'server'    => $this,
                    'fd'        => $fd,
                ], $this, BufferEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });

        $server->on('BufferEmpty', function(\swoole_server $server, $fd){
            try{
                $this->trigger('bufferEmpty', [
                    'server'    => $this,
                    'fd'        => $fd,
                ], $this, BufferEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });
    }