Register embed handler for web
177831
public function registerEmbedHandlerForWeb() {
		wp_embed_register_handler(
			self::EMBED_ID,
			self::EMBED_URL_REGEX,
			function ( $matches, $attr, $url, $rawattr ) {
				$embed = sprintf(
					'<iframe src="https://phet.colorado.edu/sims/html/%1$s" width="800" height="600" scrolling="no" allowfullscreen></iframe>',
					esc_attr( $matches[1] )
				);
				return apply_filters( 'embed_' . self::EMBED_ID, $embed, $matches, $attr, $url, $rawattr );
			}
		);
	}
579412
protected function registerMakeCommand()
    {
        $this->app->singleton('pluggables.make', function ($app) {
            $handler = new Handlers\PluggableMakeHandler($app['pluggables'], $app['files']);

            return new Console\PluggableMakeCommand($handler);
        });
    }
655160
def _register_webhook(self, webhook_url, events):
        """"""
        response = self._request(
            MINUT_WEBHOOKS_URL,
            request_type='POST',
            json={
                'url': webhook_url,
                'events': events,
            },
        )
        return response
1140833
function embed(sourcePath, relativePaths, name, done) {
  var items = '';
  each(relativePaths, function(relativePath, next) {
    var fullPath = path.join(sourcePath, relativePath);
    fs.readFile(fullPath, 'utf8', function(err, text) {
      if (err) return next(err);
      items += '  $templateCache.put(\'' +
        inline(relativePath) + '\', \'' +
        inline(text.trim()) + '\');\n';
      next();
    });
  }, function(err) {
    if (err) return done(err);
    console.log(
      'angular.module(\'' + inline(name) + '\', []).run([\'$templateCache\', function($templateCache) {\n' +
      items +
      '}]);');
    done();
  });
}
17540
def register_vcs_handler(vcs, method):  # tyoe: (str, str) -> typing.Callable  # decorator
    """"""
    def decorate(f):
        """Store f in HANDLERS[vcs][method]."""
        if vcs not in HANDLERS:
            HANDLERS[vcs] = {}
        HANDLERS[vcs][method] = f
        return f
    return decorate
637072
function htmlParserImpl(html, handler) {
    if (html === null || html === undefined) {
      html = '';
    } else if (typeof html !== 'string') {
      html = '' + html;
    }
    inertBodyElement.innerHTML = html;

    //mXSS protection
    var mXSSAttempts = 5;
    do {
      if (mXSSAttempts === 0) {
        throw $sanitizeMinErr('uinput', 'Failed to sanitize html because the input is unstable');
      }
      mXSSAttempts--;

      // strip custom-namespaced attributes on IE<=11
      if (window.document.documentMode) {
        stripCustomNsAttrs(inertBodyElement);
      }
      html = inertBodyElement.innerHTML; //trigger mXSS
      inertBodyElement.innerHTML = html;
    } while (html !== inertBodyElement.innerHTML);

    var node = inertBodyElement.firstChild;
    while (node) {
      switch (node.nodeType) {
        case 1: // ELEMENT_NODE
          handler.start(node.nodeName.toLowerCase(), attrToMap(node.attributes));
          break;
        case 3: // TEXT NODE
          handler.chars(node.textContent);
          break;
      }

      var nextNode;
      if (!(nextNode = node.firstChild)) {
        if (node.nodeType === 1) {
          handler.end(node.nodeName.toLowerCase());
        }
        nextNode = node.nextSibling;
        if (!nextNode) {
          while (nextNode == null) {
            node = node.parentNode;
            if (node === inertBodyElement) break;
            nextNode = node.nextSibling;
            if (node.nodeType === 1) {
              handler.end(node.nodeName.toLowerCase());
            }
          }
        }
      }
      node = nextNode;
    }

    while ((node = inertBodyElement.firstChild)) {
      inertBodyElement.removeChild(node);
    }
  }
651852
def register_console_logging_handler(cls, lgr, level=logging.INFO):
        """"""
        console_handler = logger.DevassistantClHandler(sys.stdout)
        if console_handler.stream.isatty():
            console_handler.setFormatter(logger.DevassistantClColorFormatter())
        else:
            console_handler.setFormatter(logger.DevassistantClFormatter())
        console_handler.setLevel(level)
        cls.cur_handler = console_handler
        lgr.addHandler(console_handler)
373566
function registerBoxViewPageEventHandlers() {
        // event names depend on whether we support svg or not
        if (scope.getUtility('support').svg) {
            realtime.on('pageavailable.svg', handlePageAvailableEvent);
            realtime.on('finished.svg', handleFinishedEvent);
            realtime.on('failed.svg', handleFailedEvent);
        } else {
            realtime.on('pageavailable.png', handlePageAvailableEvent);
            realtime.on('finished.png', handleFinishedEvent);
            realtime.on('failed.png', handleFailedEvent);
        }

        realtime.on('error', handleErrorEvent);
    }
579192
def registerStatsHandler(app, serverName, prefix='/status/'):
  """"""
  if prefix[-1] != '/':
    prefix += '/'
  handler = functools.partial(statsHandler, serverName)
  app.add_url_rule(prefix, 'statsHandler', handler, methods=['GET'])
  app.add_url_rule(prefix + '<path:path>', 'statsHandler', handler, methods=['GET'])
368395
def embed(self, width=600, height=650):
        
        from IPython.display import IFrame
        return IFrame(self.url, width, height)
1232294
async function _process(args, { fetch }) {
  const url = args[0]
  try {
    const res = await fetch(`https://noembed.com/embed?url=${url}`)
    return await res.json()
  } catch (e) {
    return {
      html: url
    }
  }
}
274474
protected function configureHandler()
    {
        if ($this->config('_handlerConfigured') !== true) {
            $app = $this;

            if ($this->config('bono.cli') !== true) {
                $this->whoops = new Run();

                $handler = new PrettyPageHandler();
                $path = explode(DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__);
                $path = $path[0].'/templates/_whoops';
                $handler->setResourcesPath($path);

                $jsonResponseHandler = new JsonResponseHandler();
                $jsonResponseHandler->onlyForAjaxRequests(true);

                $appHandler = function ($err) use ($app, $handler) {
                    if (!isset($app->request)) {
                        return;
                    }

                    $template = 'error.php';
                    if ($err->getMessage() === '404 Resource not found') {
                        $template = 'notFound.php';
                    }

                    $request = $app->request;

                    // Add some custom tables with relevant info about your application,
                    // that could prove useful in the error page:
                    $handler->addDataTable('Bono Application', array(
                        'Template'         => 'Modify this page on templates/'.$template,
                        'Application Class'=> get_class($app),
                        'Charset'          => $request->headers('ACCEPT_CHARSET') ?: '<none>',
                        'Locale'           => $request->getContentCharset() ?: '<none>',
                    ));

                    $handler->addDataTable('Bono Request', array(
                        'URI'         => $request->getRootUri(),
                        'Request URI' => $request->getResourceUri(),
                        'Path'        => $request->getPath(),
                        'Query String'=> $request->params() ?: '<none>',
                        'HTTP Method' => $request->getMethod(),
                        'Script Name' => $request->getScriptName(),
                        'Base URL'    => $request->getUrl(),
                        'Scheme'      => $request->getScheme(),
                        'Port'        => $request->getPort(),
                        'Host'        => $request->getHost(),
                    ));

                    // Set the title of the error page:
                    $handler->setPageTitle("Bono got whoops! There was a problem.");
                };

                $this->whoops->pushHandler($handler);

                // Add a special handler to deal with AJAX requests with an
                // equally-informative JSON response. Since this handler is
                // first in the stack, it will be executed before the error
                // page handler, and will have a chance to decide if anything
                // needs to be done.
                $this->whoops->pushHandler($jsonResponseHandler);
                $this->whoops->pushHandler($appHandler);

                $this->notFound(array(new NotFoundHandler($this), 'handle'));
                $this->error(array(new ErrorHandler($this), 'handle'));
            }

            $this->config('_handlerConfigured', true);
        }

        return $this;
    }
110454
def register(self, *paths, methods=None, name=None):
        """"""
        if isinstance(methods, str):
            methods = [methods]

        def wrapper(handler):

            if isinstance(handler, (FunctionType, MethodType)):
                handler = RESTHandler.from_view(handler, *(methods or ['GET']))

            if handler.name in self.handlers:
                raise muffin.MuffinException('Handler is already registered: %s' % handler.name)

            self.handlers[tuple(paths or ["/{0}/{{{0}}}".format(handler.name)])] = handler

            handler.bind(self.app, *paths, methods=methods, name=name or handler.name)
            return handler

        # Support for @app.register(func)
        if len(paths) == 1 and callable(paths[0]):
            view = paths[0]
            paths = []
            return wrapper(view)

        return wrapper
893555
function handler(req,res){  
    try{
      res.writeHead(200, {'Content-Type': 'text/html'});
      var start = new Date().getTime();
      //console.log(start);

      //read css, wait.for syntax:
      var css = wait.for(fs.readFile,'style.css','utf8');

      //read post, fancy syntax:
      var content = wait.for(fs.readFile,'blogPost.txt','utf8');

      //compose  template, fancy syntax, as parameter:
      var template = composeTemplate ( css, wait.for(fs.readFile,'blogTemplate.html','utf8') );

      console.log('about to call hardToGetData...');

      //call async, wait.for syntax, in a expression
      var hardToGetData = "\n" + start.toString().substr(-5) +"<br>" + ( wait.for(longAsyncFn,'some data') );

      console.log('hardToGetData=',hardToGetData);
      
      var end = new Date().getTime();

      hardToGetData += ', after '+(end-start)+' ms<br>';
      hardToGetData += end.toString().substr(-5);

      res.end( applyTemplate(template, formatPost ( content + hardToGetData) ) );

    }
    catch(err){
      res.end('ERROR: '+err.message);
    }
  }
426937
protected function registerClientScript()
    {
        $id = $this->options['id'];
        $view = $this->getView();
        $option = !empty($this->pluginOptions['option']) ? Json::encode($this->pluginOptions['option']) : '{}';

        if ($this->theme) {
            $js = "var {$this->clientId} = echarts.init(document.getElementById('{$id}'), " . $this->quote($this->theme) . ");";
        } else {
            $js = "var {$this->clientId} = echarts.init(document.getElementById('{$id}'));";
        }
        $js .= "{$this->clientId}.setOption({$option});";
        if (isset($this->pluginOptions['group'])) {
            $js .= "{$this->clientId}.group = " . $this->quote($this->pluginOptions['group']) . ";";
        }
        if ($this->responsive) {
            $js .= "$(window).resize(function () {{$this->clientId}.resize()});";
        }
        foreach ($this->pluginEvents as $name => $handlers) {
            $handlers = (array) $handlers;
            foreach ($handlers as $handler) {
                $js .= "{$this->clientId}.on(" . $this->quote($name) . ", $handler);";
            }
        }

        EChartsAsset::register($view);
        $view->registerJs($js);
    }
689316
def _register_handler(event, fun, external=False):
    """"""
    registry = core.HANDLER_REGISTRY
    if external:
        registry = core.EXTERNAL_HANDLER_REGISTRY

    if not isinstance(event, basestring):
        # If not basestring, it is a BaseEvent subclass.
        # This occurs when class methods are registered as handlers
        event = core.parse_event_to_name(event)

    if event in registry:
        registry[event].append(fun)
    else:
        registry[event] = [fun]
    return fun
213348
public function registerHandlersFromConfig()
    {
        $config = $this->container->getConfigInstance();
        foreach ($config->getAJAXTypeHandlers() as $handlerArray) {

            if (isset($handlerArray['path'])) {
                $path = $handlerArray['path'];
                if (!file_exists($path)) {
                    throw new FileNotFoundException($path, "AJAXTypeHandler class file");
                }
                /** @noinspection PhpIncludeInspection */
                require_once $path;
            }

            $className = $handlerArray['class_name'];

            if (!class_exists($className)) {
                throw new ClassNotDefinedException($className);
            }

            $handler = new $className($this->container);

            if($handler instanceof TypeHandlerGenerator){
                $handler = $handler->generateTypeHandler();
            }

            if (!($handler instanceof TypeHandler)) {
                throw new ClassNotInstanceOfException($handler == null ? 'null' : get_class($handler), 'AJAXTypeHandler');
            }

            $this->registerHandler($handler);
        }
    }